better CQnetDB error msgs && okay for a few bytes before a GPS $

pull/14/head
Tom Early 6 years ago
parent 2a6141383d
commit af0d399cd4

@ -36,11 +36,13 @@ bool CLocation::Parse(const char *instr)
std::string s(instr); std::string s(instr);
std::cmatch cm; std::cmatch cm;
trim(s); trim(s);
if (s.size() < 20)
return false;
bool success; bool success;
if (0 == s.find("$$CRC")) { if (3 > s.find("$$CRC")) {
success = std::regex_search(s.c_str(), cm, crc, std::regex_constants::match_default); success = std::regex_search(s.c_str(), cm, crc, std::regex_constants::match_default);
} else if ((0 == s.find("$GPGGA")) || (0 == s.find("$GPRMC"))) { } else if ((3 > s.find("$GPGGA")) || (3 > s.find("$GPRMC"))) {
success = std::regex_search(s.c_str(), cm, rmc, std::regex_constants::match_default); success = std::regex_search(s.c_str(), cm, rmc, std::regex_constants::match_default);
} else { } else {
std::cerr << "Unrecognized GPS string: " << s << std::endl; std::cerr << "Unrecognized GPS string: " << s << std::endl;

@ -48,7 +48,7 @@ bool CQnetDB::Init()
") WITHOUT ROWID;"); ") WITHOUT ROWID;");
if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) { if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) {
fprintf(stderr, "CQnetDB::Open create table LHEARD error: %s\n", eMsg); fprintf(stderr, "CQnetDB::Init [%s] error: %s\n", sql.c_str(), eMsg);
sqlite3_free(eMsg); sqlite3_free(eMsg);
return true; return true;
} }
@ -62,7 +62,7 @@ bool CQnetDB::Init()
") WITHOUT ROWID;"); ") WITHOUT ROWID;");
if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) { if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) {
fprintf(stderr, "CQnetDB::Open create table LINKSTATUS error: %s\n", eMsg); fprintf(stderr, "CQnetDB::Init [%s] error: %s\n", sql.c_str(), eMsg);
sqlite3_free(eMsg); sqlite3_free(eMsg);
return true; return true;
} }
@ -74,7 +74,7 @@ bool CQnetDB::Init()
") WITHOUT ROWID;"); ") WITHOUT ROWID;");
if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) { if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) {
fprintf(stderr, "CQnetDB::Open create table GATEWAYS error: %s\n", eMsg); fprintf(stderr, "CQnetDB::Init [%s] error: %s\n", sql.c_str(), eMsg);
sqlite3_free(eMsg); sqlite3_free(eMsg);
return true; return true;
} }
@ -99,7 +99,7 @@ bool CQnetDB::UpdateLH(const char *callsign, const char *sfx, const char module,
char *eMsg; char *eMsg;
if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), countcallback, &count, &eMsg)) { if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), countcallback, &count, &eMsg)) {
fprintf(stderr, "CQnetDB::Count error: %s\n", eMsg); fprintf(stderr, "CQnetDB::UpdateLH [%s] error: %s\n", sql.c_str(), eMsg);
sqlite3_free(eMsg); sqlite3_free(eMsg);
return true; return true;
} }
@ -129,7 +129,7 @@ bool CQnetDB::UpdateLH(const char *callsign, const char *sfx, const char module,
} }
if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) { if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) {
fprintf(stderr, "CQnetDB::UpdateLH error: %s\n", eMsg); fprintf(stderr, "CQnetDB::UpdateLH [%s] error: %s\n", sql.c_str(), eMsg);
sqlite3_free(eMsg); sqlite3_free(eMsg);
return true; return true;
} }
@ -154,7 +154,7 @@ bool CQnetDB::UpdatePosition(const char *callsign, const char *maidenhead, doubl
char *eMsg; char *eMsg;
if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) { if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) {
fprintf(stderr, "CQnetDB::UpdatePosition error: %s\n", eMsg); fprintf(stderr, "CQnetDB::UpdatePosition [%s] error: %s\n", sql.c_str(), eMsg);
sqlite3_free(eMsg); sqlite3_free(eMsg);
return true; return true;
} }
@ -175,7 +175,7 @@ bool CQnetDB::UpdateMessage(const char *callsign, const char *message)
char *eMsg; char *eMsg;
if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) { if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) {
fprintf(stderr, "CQnetDB::UpdateMessage error: %s\n", eMsg); fprintf(stderr, "CQnetDB::UpdateMessage [%s] error: %s\n", sql.c_str(), eMsg);
sqlite3_free(eMsg); sqlite3_free(eMsg);
return true; return true;
} }
@ -201,7 +201,7 @@ bool CQnetDB::UpdateLS(const char *address, const char from_mod, const char *to_
char *eMsg; char *eMsg;
if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) { if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) {
fprintf(stderr, "CQnetDB::UpdateLS error: %s\n", eMsg); fprintf(stderr, "CQnetDB::UpdateLS [%s] error: %s\n", sql.c_str(), eMsg);
sqlite3_free(eMsg); sqlite3_free(eMsg);
return true; return true;
} }
@ -225,7 +225,7 @@ bool CQnetDB::UpdateGW(const char *name, const char *address, unsigned short por
char *eMsg; char *eMsg;
if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) { if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) {
fprintf(stderr, "CQnetDB::UpdateGW error: %s\n", eMsg); fprintf(stderr, "CQnetDB::UpdateGW [%s] error: %s\n", sql.c_str(), eMsg);
sqlite3_free(eMsg); sqlite3_free(eMsg);
return true; return true;
} }
@ -268,7 +268,7 @@ bool CQnetDB::DeleteLS(const char *address)
char *eMsg; char *eMsg;
if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) { if (SQLITE_OK != sqlite3_exec(db, sql.c_str(), NULL, 0, &eMsg)) {
fprintf(stderr, "CQnetDB::DeleteLS error: %s\n", eMsg); fprintf(stderr, "CQnetDB::DeleteLS [%s] error: %s\n", sql.c_str(), eMsg);
sqlite3_free(eMsg); sqlite3_free(eMsg);
return true; return true;
} }
@ -287,7 +287,7 @@ bool CQnetDB::FindLS(const char mod, std::list<CLink> &linklist)
sqlite3_stmt *stmt; sqlite3_stmt *stmt;
int rval = sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, 0); int rval = sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, 0);
if (SQLITE_OK != rval) { if (SQLITE_OK != rval) {
fprintf(stderr, "CQnetDB::FindLS prepare_v2 error\n"); fprintf(stderr, "CQnetDB::FindLS [%s] error\n", sql.c_str());
return true; return true;
} }

@ -54,7 +54,7 @@
#define CFG_DIR "/usr/local/etc" #define CFG_DIR "/usr/local/etc"
#endif #endif
const std::string GW_VERSION("QnetGateway-614"); const std::string GW_VERSION("QnetGateway-615");
int CQnetGateway::FindIndex(const int i) const int CQnetGateway::FindIndex(const int i) const
{ {

Loading…
Cancel
Save

Powered by TurnKey Linux.