better dashboard

pull/14/head
Tom Early 6 years ago
parent 15a1df32e1
commit 4e6c36ff62

@ -40,9 +40,10 @@ bool CQnetDB::Init()
} }
sql.assign("CREATE TABLE LHEARD(" sql.assign("CREATE TABLE LHEARD("
"mycall TEXT PRIMARY KEY, " "callsign TEXT PRIMARY KEY, "
"sfx TEXT, " "sfx TEXT, "
"urcall TEXT, " "module TEXT, "
"reflector TEXT, "
"lasttime INT NOT NULL" "lasttime INT NOT NULL"
") WITHOUT ROWID;"); ") WITHOUT ROWID;");
@ -77,16 +78,18 @@ bool CQnetDB::Init()
return false; return false;
} }
bool CQnetDB::UpdateLH(const char *mycall, const char *sfx, const char *urcall) bool CQnetDB::UpdateLH(const char *callsign, const char *sfx, const char module, const char *reflector)
{ {
if (NULL == db) if (NULL == db)
return false; return false;
std::string sql("REPLACE INTO LHEARD (mycall,sfx,urcall,lasttime) VALUES ('"); std::string sql("REPLACE INTO LHEARD (callsign,sfx,module,reflector,lasttime) VALUES ('");
sql.append(mycall); sql.append(callsign);
sql.append("','"); sql.append("','");
sql.append(sfx); sql.append(sfx);
sql.append("','"); sql.append("','");
sql.append(urcall); sql.append(1, module);
sql.append("','");
sql.append(reflector);
sql.append("',"); sql.append("',");
sql.append("strftime('%s','now'));"); sql.append("strftime('%s','now'));");

@ -53,7 +53,7 @@ public:
~CQnetDB() { if (db) sqlite3_close(db); } ~CQnetDB() { if (db) sqlite3_close(db); }
bool Open(const char *name); bool Open(const char *name);
bool Init(); bool Init();
bool UpdateLH(const char *mycall, const char *sfx, const char *urcall); bool UpdateLH(const char *callsign, const char *sfx, const char module, const char *reflector);
bool UpdateLS(const char *address, const char from_mod, const char *to_callsign, const char to_mod, time_t connect_time); bool UpdateLS(const char *address, const char from_mod, const char *to_callsign, const char to_mod, time_t connect_time);
bool DeleteLS(const char *address); bool DeleteLS(const char *address);
bool FindLS(const char mod, std::list<CLink> &linklist); bool FindLS(const char mod, std::list<CLink> &linklist);

@ -635,7 +635,7 @@ void CQnetGateway::ProcessTimeouts()
} }
} }
void CQnetGateway::ProcessG2Msg(const unsigned char *data, const int mod) bool CQnetGateway::ProcessG2Msg(const unsigned char *data, const int mod, std::string &smrtgrp)
{ {
static unsigned int part[3] = { 0 }; static unsigned int part[3] = { 0 };
static char txt[3][21]; static char txt[3][21];
@ -652,8 +652,10 @@ void CQnetGateway::ProcessG2Msg(const unsigned char *data, const int mod)
memcpy(txt[mod]+(5u*(part[mod]/2u)+2u), c, 3); memcpy(txt[mod]+(5u*(part[mod]/2u)+2u), c, 3);
if (++part[mod] > 7) { if (++part[mod] > 7) {
// we've got everything! // we've got everything!
printf("Msg = '%s'\n", txt[mod]); if (0 == strncmp(txt[mod], "VIA SMARTGP ", 12))
smrtgrp.assign(txt[mod]+12);
part[mod] = 0; // now we can start over part[mod] = 0; // now we can start over
return true;
} }
} else { // we'll get here when part[mod] = 2, 4 or 6 } else { // we'll get here when part[mod] = 2, 4 or 6
unsigned int sequence = part[mod]++ / 2; // this is the sequency we are expecting, 1, 2 or 3 unsigned int sequence = part[mod]++ / 2; // this is the sequency we are expecting, 1, 2 or 3
@ -672,6 +674,7 @@ void CQnetGateway::ProcessG2Msg(const unsigned char *data, const int mod)
} else { } else {
part[mod] = 0; // messages will never be spread across a superframe part[mod] = 0; // messages will never be spread across a superframe
} }
return false;
} }
// new_group is true if we are processing the first voice packet of a 2-voice packet pair. The high order nibble of the first byte of // new_group is true if we are processing the first voice packet of a 2-voice packet pair. The high order nibble of the first byte of
@ -971,6 +974,7 @@ void CQnetGateway::ProcessSlowData(unsigned char *data, const unsigned short sid
void CQnetGateway::ProcessG2(const ssize_t g2buflen, const SDSVT &g2buf, const int source_sock) void CQnetGateway::ProcessG2(const ssize_t g2buflen, const SDSVT &g2buf, const int source_sock)
// source_sock is the socket number of the incoming data, or -1 if it's a unix socket // source_sock is the socket number of the incoming data, or -1 if it's a unix socket
{ {
static std::string lhcallsign, lhsfx;
static unsigned char lastctrl = 20U; static unsigned char lastctrl = 20U;
static std::string superframe[3]; static std::string superframe[3];
if ( (g2buflen==56 || g2buflen==27) && 0==memcmp(g2buf.title, "DSVT", 4) && (g2buf.config==0x10 || g2buf.config==0x20) && g2buf.id==0x20) { if ( (g2buflen==56 || g2buflen==27) && 0==memcmp(g2buf.title, "DSVT", 4) && (g2buf.config==0x10 || g2buf.config==0x20) && g2buf.id==0x20) {
@ -990,14 +994,13 @@ void CQnetGateway::ProcessG2(const ssize_t g2buflen, const SDSVT &g2buf, const i
else else
printf("UnixSock=%s\n", link2gate.c_str()); printf("UnixSock=%s\n", link2gate.c_str());
} }
lhcallsign.assign((const char *)g2buf.hdr.mycall, 8);
std::string mycall((const char *)g2buf.hdr.mycall, 8); if (showLastHeard && memcmp(g2buf.hdr.sfx, "RPTR", 4) && std::regex_match(lhcallsign.c_str(), preg)) {
if (showLastHeard && memcmp(g2buf.hdr.sfx, "RPTR", 4) && std::regex_match(mycall.c_str(), preg)) { lhsfx.assign((const char *)g2buf.hdr.sfx, 4);
std::string sfx((const char *)g2buf.hdr.sfx, 4); std::string reflector((const char *)g2buf.hdr.urcall, 8);
std::string urcall((const char *)g2buf.hdr.urcall, 8); if (0 == reflector.compare("CQCQCQ "))
rtrim(mycall); set_dest_rptr('A'+i, reflector);
rtrim(sfx); qnDB.UpdateLH(lhcallsign.c_str(), lhsfx.c_str(), 'A'+i, reflector.c_str());
qnDB.UpdateLH(mycall.c_str(), sfx.c_str(), urcall.c_str());
} }
Gate2Modem[i].Write(g2buf.title, 56); Gate2Modem[i].Write(g2buf.title, 56);
@ -1079,8 +1082,12 @@ void CQnetGateway::ProcessG2(const ssize_t g2buflen, const SDSVT &g2buf, const i
// no matter what, we will send this on if it is the closing frame // no matter what, we will send this on if it is the closing frame
lastctrl = (0x3FU & g2buf.ctrl); lastctrl = (0x3FU & g2buf.ctrl);
Gate2Modem[i].Write(g2buf.title, 27); Gate2Modem[i].Write(g2buf.title, 27);
if (source_sock >= 0) if (source_sock >= 0) {
ProcessG2Msg(g2buf.vasd.text, i); std::string smartgroup;
if(ProcessG2Msg(g2buf.vasd.text, i, smartgroup)) {
qnDB.UpdateLH(lhcallsign.c_str(), lhsfx.c_str(), 'A'+i, smartgroup.c_str());
}
}
} else { } else {
if (LOG_DEBUG) if (LOG_DEBUG)
fprintf(stderr, "Warning: Ignoring packet because its ctrl=0x%02xU and lastctrl=0x%02xU\n", g2buf.ctrl, lastctrl); fprintf(stderr, "Warning: Ignoring packet because its ctrl=0x%02xU and lastctrl=0x%02xU\n", g2buf.ctrl, lastctrl);

@ -174,7 +174,7 @@ private:
void APRSBeaconThread(); void APRSBeaconThread();
void ProcessTimeouts(); void ProcessTimeouts();
void ProcessSlowData(unsigned char *data, const unsigned short sid); void ProcessSlowData(unsigned char *data, const unsigned short sid);
void ProcessG2Msg(const unsigned char *data, const int mod); bool ProcessG2Msg(const unsigned char *data, const int mod, std::string &smrtgrp);
void ProcessG2(const ssize_t g2buflen, const SDSVT &g2buf, const int sock_source); void ProcessG2(const ssize_t g2buflen, const SDSVT &g2buf, const int sock_source);
void ProcessModem(); void ProcessModem();
bool Flag_is_ok(unsigned char flag); bool Flag_is_ok(unsigned char flag);

@ -149,16 +149,15 @@ foreach($showlist as $section) {
break; break;
case 'LH': case 'LH':
echo 'Last Heard:<br><code>', "\n"; echo 'Last Heard:<br><code>', "\n";
$rstr = 'MyCall/Sfx Source Last Time<br>'; $rstr = 'MyCall/Sfx Mod From Last Time<br>';
echo str_replace(' ', '&nbsp;', $rstr), "\n"; echo str_replace(' ', '&nbsp;', $rstr), "\n";
$dbname = $cfgdir.'/'.GetCFGValue('dash_sql_filename'); $dbname = $cfgdir.'/'.GetCFGValue('dash_sql_filename');
$db = new SQLite3($dbname, SQLITE3_OPEN_READONLY); $db = new SQLite3($dbname, SQLITE3_OPEN_READONLY);
$ss = 'SELECT mycall,sfx,urcall,strftime("%s","now")-lasttime FROM LHEARD ORDER BY 4 LIMIT '.GetCFGValue('dash_lastheard_count').' '; $ss = 'SELECT callsign,sfx,module,reflector,strftime("%s","now")-lasttime FROM LHEARD ORDER BY 4 LIMIT '.GetCFGValue('dash_lastheard_count').' ';
if ($stmnt = $db->prepare($ss)) { if ($stmnt = $db->prepare($ss)) {
if ($result = $stmnt->execute()) { if ($result = $stmnt->execute()) {
while ($row = $result->FetchArray(SQLITE3_NUM)) { while ($row = $result->FetchArray(SQLITE3_NUM)) {
$source = ("CQCQCQ " == $row[2]) ? "Linking" : "Routing"; $rstr = MyAndSfxToQrz($row[0], $row[1]).' '.$row[2].' '.$row[3].' '.SecToString(intval($row[4])).'<br>';
$rstr = MyAndSfxToQrz($row[0], $row[1]).' '.$source.' '.SecToString(intval($row[3])).'<br>';
echo str_replace('*', ' ', str_replace(' ', '&nbsp;', $rstr)), "\n"; echo str_replace('*', ' ', str_replace(' ', '&nbsp;', $rstr)), "\n";
} }
$result->finalize(); $result->finalize();

Loading…
Cancel
Save

Powered by TurnKey Linux.