diff --git a/zephcore/app/ObserverMesh.cpp b/zephcore/app/ObserverMesh.cpp index c2ed570..e0760ea 100644 --- a/zephcore/app/ObserverMesh.cpp +++ b/zephcore/app/ObserverMesh.cpp @@ -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) diff --git a/zephcore/app/ObserverMesh.h b/zephcore/app/ObserverMesh.h index d18fcb6..5c753fc 100644 --- a/zephcore/app/ObserverMesh.h +++ b/zephcore/app/ObserverMesh.h @@ -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;