mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-12-06 05:14:19 +00:00
observer: log prefix and RAW line
This commit is contained in:
1 parent
42aeae4c3e
commit
2fcf78e045
2 files changed
+26
No files matched your search
@@ -159,6 +159,30 @@ void ObserverMesh::logRxRaw(float snr, float rssi, const uint8_t raw[], int len)
|
||||
_last_rssi = rssi;
|
||||
_last_raw_len = (len <= (int)sizeof(_last_raw)) ? len : (int)sizeof(_last_raw);
|
||||
memcpy(_last_raw, raw, _last_raw_len);
|
||||
#if IS_ENABLED(CONFIG_ZEPHCORE_PACKET_LOGGING)
|
||||
/* Same RAW line as the repeater (app/RepeaterMesh.cpp) */
|
||||
static char hex_buf[MAX_TRANS_UNIT * 2 + 1];
|
||||
|
||||
Utils::toHex(hex_buf, raw, len);
|
||||
zc_console_line_start();
|
||||
printk("%s RAW: %s\n", getLogDateTime(), hex_buf);
|
||||
#endif
|
||||
(void)snr;
|
||||
}
|
||||
|
||||
const char *ObserverMesh::getLogDateTime()
|
||||
{
|
||||
static char tmp[48];
|
||||
time_t t = (time_t)_rtc->getCurrentTime();
|
||||
struct tm *tm = gmtime(&t);
|
||||
|
||||
if (tm) {
|
||||
snprintf(tmp, sizeof(tmp), "%02d:%02d:%02d - %d/%d/%d U", tm->tm_hour, tm->tm_min,
|
||||
tm->tm_sec, tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900);
|
||||
} else {
|
||||
snprintf(tmp, sizeof(tmp), "%u U", (unsigned)t);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void ObserverMesh::logRx(Packet *packet, int len, float score)
|
||||
|
||||
@@ -68,6 +68,8 @@ protected:
|
||||
/* Capture score (called between logRxRaw and onRecvPacket) */
|
||||
void logRx(Packet *packet, int len, float score) override;
|
||||
void logTx(Packet *packet, int len) override;
|
||||
/* "HH:MM:SS - D/M/YYYY U", the repeater's packet-line prefix */
|
||||
const char *getLogDateTime() override;
|
||||
/* Build JSON and enqueue to MQTT publisher */
|
||||
DispatcherAction onRecvPacket(Packet *pkt) override;
|
||||
|
||||
|
||||
Reference in new issue
Block a user