aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/smartresponse_public/PublicApp.cpp10
-rw-r--r--examples/smartresponse_public/UITask.cpp238
2 files changed, 158 insertions, 90 deletions
diff --git a/examples/smartresponse_public/PublicApp.cpp b/examples/smartresponse_public/PublicApp.cpp
index 5073f324..1b711b61 100644
--- a/examples/smartresponse_public/PublicApp.cpp
+++ b/examples/smartresponse_public/PublicApp.cpp
@@ -176,17 +176,17 @@ bool PublicApp::validateRadioSettings(const RadioSettings& settings) {
const char* PublicApp::getResetCauseText() const {
#ifdef WDRF
if (_reset_cause & _BV(WDRF)) {
- return "WDT";
+ return "watchdog";
}
#endif
#ifdef BORF
if (_reset_cause & _BV(BORF)) {
- return "BOR";
+ return "brownout";
}
#endif
#ifdef EXTRF
if (_reset_cause & _BV(EXTRF)) {
- return "EXT";
+ return "external pin";
}
#endif
#ifdef JTRF
@@ -196,10 +196,10 @@ const char* PublicApp::getResetCauseText() const {
#endif
#ifdef PORF
if (_reset_cause & _BV(PORF)) {
- return "PWR";
+ return "power-on";
}
#endif
- return "---";
+ return "unknown";
}
char PublicApp::getWatchdogStage() const {
diff --git a/examples/smartresponse_public/UITask.cpp b/examples/smartresponse_public/UITask.cpp
index 567e67bd..bb3a4e80 100644
--- a/examples/smartresponse_public/UITask.cpp
+++ b/examples/smartresponse_public/UITask.cpp
@@ -175,6 +175,68 @@ void renderSettingsSoftkeyLabels(SmartResponseXEBoard* board) {
renderRightSoftkeyLabel(board, 1, "Cancel");
}
+void renderDebugSoftkeyLabels(SmartResponseXEBoard* board) {
+ renderRightSoftkeyLabel(board, 0, "Back");
+}
+
+const char* packetResultText(char code) {
+ switch (code) {
+ case 'O': return "accepted";
+ case '+': return "outbound rebroadcast heard";
+ case 'T': return "unsupported packet type";
+ case 'L': return "invalid packet length";
+ case 'H': return "different public channel";
+ case 'D': return "duplicate packet";
+ case 'M': return "authentication failed";
+ case 'Y': return "unsupported message flags";
+ case 'W': return "flash write failed";
+ case 'E': return "empty message";
+ default: return "none yet";
+ }
+}
+
+const char* watchdogStageText(char code) {
+ switch (code) {
+ case 'I': return "idle loop";
+ case 'S': return "startup";
+ case 'A': return "application loop";
+ case 'U': return "UI update";
+ case 'F': return "flash access";
+ case 'P': return "power transition";
+ case 'D': return "dispatcher loop";
+ case 'C': return "public packet handler";
+ case 'c': return "message authentication";
+ case 'p': return "message decryption";
+ case 'v': return "message validation";
+ case 'x': return "message text decoding";
+ case 'm': return "message storage";
+ case 'w': return "message flash write";
+ case 'o': return "message completion";
+ case 'R': return "radio service";
+ case 'X': return "radio receive start";
+ case 'L': return "radio packet length";
+ case 'r': return "radio packet read";
+ case 'T': return "airtime calculation";
+ case 't': return "radio transmit start";
+ case 'f': return "radio transmit finish";
+ case 'B': return "radio channel check";
+ case 'i': return "packet RSSI read";
+ case 'n': return "packet SNR read";
+ case 'k': return "decrypt key setup";
+ case 'd': return "decrypt completion";
+ case 'K': return "encrypt key setup";
+ case 'E': return "message encryption";
+ case 'e': return "final encryption block";
+ case 'h': return "authentication check";
+ case 'a': return "authenticated decrypt";
+ default:
+ if (code >= '0' && code <= '9') {
+ return "message decrypt block";
+ }
+ return "internal operation";
+ }
+}
+
char markerFor(const PublicMessage& msg, bool first_segment) {
if (!first_segment) {
return ' ';
@@ -677,147 +739,150 @@ void UITask::renderSettings() {
}
void UITask::renderDebug() {
- char line[48];
+ char line[kDisplayCols + 1];
- drawLine(0, "Radio Debug");
+ drawLine(0, "System Diagnostics");
- copyText(line, sizeof(line), "RF raw:");
+ copyText(line, sizeof(line), "RX packets: radio ");
appendUnsigned(line, sizeof(line), _app->getRawRxCount());
- appendText(line, sizeof(line), " pkt:");
+ appendText(line, sizeof(line), " parsed ");
appendUnsigned(line, sizeof(line), _app->getParsedRxCount());
- appendText(line, sizeof(line), " rej:");
+ appendText(line, sizeof(line), " rejected ");
appendUnsigned(line, sizeof(line), _app->getRejectCount());
- appendText(line, sizeof(line), " ");
- {
- size_t len = strlen(line);
- if (len + 1 < sizeof(line)) {
- line[len] = _app->getLastRejectCode();
- line[len + 1] = 0;
- }
- }
- drawLine(2, line);
+ drawLine(1, line);
- copyText(line, sizeof(line), "Last len:");
+ copyText(line, sizeof(line), "Last RX: ");
appendUnsigned(line, sizeof(line), _app->getLastRawLen());
- appendText(line, sizeof(line), " type:");
+ appendText(line, sizeof(line), " bytes type ");
appendUnsigned(line, sizeof(line), _app->getLastRxType());
- appendText(line, sizeof(line), " snr:");
- appendSigned(line, sizeof(line), _app->getLastSNR());
- appendText(line, sizeof(line), " rssi:");
+ appendText(line, sizeof(line), " RSSI ");
appendSigned(line, sizeof(line), _app->getLastRSSI());
- drawLine(3, line);
+ appendText(line, sizeof(line), " dBm SNR ");
+ appendSigned(line, sizeof(line), _app->getLastSNR());
+ appendText(line, sizeof(line), " dB");
+ drawLine(2, line);
- copyText(line, sizeof(line), "TX ok:");
+ copyText(line, sizeof(line), "TX packets: completed ");
appendUnsigned(line, sizeof(line), _app->getTxDoneCount());
- appendText(line, sizeof(line), " fail:");
+ appendText(line, sizeof(line), " failed ");
appendUnsigned(line, sizeof(line), _app->getTxFailCount());
+ drawLine(3, line);
+
+ copyText(line, sizeof(line), "Rejected by type ");
+ appendUnsigned(line, sizeof(line), _app->getRejectTypeCount());
+ appendText(line, sizeof(line), " wrong channel ");
+ appendUnsigned(line, sizeof(line), _app->getRejectHashCount());
drawLine(4, line);
+ copyText(line, sizeof(line), "Rejected as duplicate ");
+ appendUnsigned(line, sizeof(line), _app->getRejectDupCount());
+ appendText(line, sizeof(line), " authentication ");
+ appendUnsigned(line, sizeof(line), _app->getRejectMacCount());
+ drawLine(5, line);
+
+ copyText(line, sizeof(line), "Last packet result: ");
+ appendText(line, sizeof(line), packetResultText(_app->getLastRejectCode()));
+ drawLine(6, line);
+
#if defined(USE_SX1262)
- copyText(line, sizeof(line), "SX st:");
+ copyText(line, sizeof(line), "SX1262: status 0x");
appendHexByte(line, sizeof(line), radio_get_status());
- appendText(line, sizeof(line), " irq:");
+ appendText(line, sizeof(line), " IRQ flags 0x");
appendHexWord(line, sizeof(line), (uint16_t)radio_get_irq_flags());
- appendText(line, sizeof(line), " b:");
+ drawLine(7, line);
+
+ copyText(line, sizeof(line), "Radio pins: BUSY ");
appendUnsigned(line, sizeof(line), radio_get_busy_level());
- appendText(line, sizeof(line), " i:");
+ appendText(line, sizeof(line), " DIO1/IRQ ");
appendUnsigned(line, sizeof(line), radio_get_irq_level());
- drawLine(5, line);
-
- copyText(line, sizeof(line), "RSSI now:");
+ appendText(line, sizeof(line), " live RSSI ");
appendSigned(line, sizeof(line), radio_get_current_rssi());
- drawLine(6, line);
+ appendText(line, sizeof(line), " dBm");
+ drawLine(8, line);
#else
- copyText(line, sizeof(line), "SX v:");
+ copyText(line, sizeof(line), "SX127x: version 0x");
appendHexByte(line, sizeof(line), radio_read_reg(RADIOLIB_SX127X_REG_VERSION));
- appendText(line, sizeof(line), " op:");
+ appendText(line, sizeof(line), " mode 0x");
appendHexByte(line, sizeof(line), radio_read_reg(RADIOLIB_SX127X_REG_OP_MODE));
- appendText(line, sizeof(line), " irq:");
+ appendText(line, sizeof(line), " IRQ 0x");
appendHexByte(line, sizeof(line), (uint8_t)radio_get_irq_flags());
- appendText(line, sizeof(line), " ms:");
+ drawLine(7, line);
+
+ copyText(line, sizeof(line), "Modem status 0x");
appendHexByte(line, sizeof(line), radio_get_modem_status());
- appendText(line, sizeof(line), " d:");
+ appendText(line, sizeof(line), " DIO0/IRQ ");
appendUnsigned(line, sizeof(line), radio_get_dio0_level());
- drawLine(5, line);
-
- copyText(line, sizeof(line), "RSSI now:");
+ appendText(line, sizeof(line), " live RSSI ");
appendSigned(line, sizeof(line), radio_get_current_rssi());
- appendText(line, sizeof(line), " pa:");
+ appendText(line, sizeof(line), " dBm");
+ drawLine(8, line);
+
+ copyText(line, sizeof(line), "PA config 0x");
appendHexByte(line, sizeof(line), radio_read_reg(RADIOLIB_SX127X_REG_PA_CONFIG));
- appendText(line, sizeof(line), " dac:");
+ appendText(line, sizeof(line), " PA DAC 0x");
appendHexByte(line, sizeof(line), radio_read_reg(kRegPaDac));
- drawLine(6, line);
-#endif
-
- copyText(line, sizeof(line), "rej T:");
- appendUnsigned(line, sizeof(line), _app->getRejectTypeCount());
- appendText(line, sizeof(line), " H:");
- appendUnsigned(line, sizeof(line), _app->getRejectHashCount());
- appendText(line, sizeof(line), " D:");
- appendUnsigned(line, sizeof(line), _app->getRejectDupCount());
- appendText(line, sizeof(line), " M:");
- appendUnsigned(line, sizeof(line), _app->getRejectMacCount());
- drawLine(7, line);
-
-#if defined(USE_SX1262)
- copyText(line, sizeof(line), "Wired SX1262 irq");
-#else
- copyText(line, sizeof(line), "ocp:");
+ appendText(line, sizeof(line), " OCP 0x");
appendHexByte(line, sizeof(line), radio_read_reg(RADIOLIB_SX127X_REG_OCP));
- appendText(line, sizeof(line), " map:");
- appendHexByte(line, sizeof(line), radio_read_reg(RADIOLIB_SX127X_REG_DIO_MAPPING_1));
- appendText(line, sizeof(line), " sw:");
- appendHexByte(line, sizeof(line), radio_read_reg(RADIOLIB_SX127X_REG_SYNC_WORD));
+ drawLine(9, line);
#endif
- drawLine(8, line);
const PublicApp::RadioSettings& settings = _app->getRadioSettings();
- copyText(line, sizeof(line), "RF ");
+ copyText(line, sizeof(line), "Frequency: ");
appendFreqMHz(line, sizeof(line), settings.freq_khz);
- appendText(line, sizeof(line), " BW ");
+ appendText(line, sizeof(line), " MHz bandwidth ");
appendFixed1(line, sizeof(line), settings.bw_x10);
- drawLine(9, line);
+ appendText(line, sizeof(line), " kHz");
+ drawLine(10, line);
- copyText(line, sizeof(line), "SF:");
+ copyText(line, sizeof(line), "LoRa: spreading factor ");
appendUnsigned(line, sizeof(line), settings.sf);
- appendText(line, sizeof(line), " CR:");
+ appendText(line, sizeof(line), " coding rate 4/");
appendUnsigned(line, sizeof(line), settings.cr);
- appendText(line, sizeof(line), " TX:");
+ appendText(line, sizeof(line), " TX ");
appendSigned(line, sizeof(line), settings.tx_power);
- drawLine(10, line);
+ appendText(line, sizeof(line), " dBm");
+ drawLine(11, line);
- copyText(line, sizeof(line), "Reset:");
+ copyText(line, sizeof(line), "Last reset: ");
appendText(line, sizeof(line), _app->getResetCauseText());
- appendText(line, sizeof(line), "/");
- {
+ char watchdog_stage = _app->getWatchdogStage();
+ if (watchdog_stage != '-') {
+ appendText(line, sizeof(line), " at ");
+ appendText(line, sizeof(line), watchdogStageText(watchdog_stage));
+ appendText(line, sizeof(line), " (");
size_t len = strlen(line);
if (len + 1 < sizeof(line)) {
- line[len] = _app->getWatchdogStage();
+ line[len] = watchdog_stage;
line[len + 1] = 0;
}
+ appendText(line, sizeof(line), ")");
}
- drawLine(11, line);
+ drawLine(12, line);
- copyText(line, sizeof(line), "Stack now:");
+ copyText(line, sizeof(line), "Stack free: now ");
appendUnsigned(line, sizeof(line), MeshCoreStackFreeNow());
- appendText(line, sizeof(line), " min:");
+ appendText(line, sizeof(line), " bytes minimum ");
appendUnsigned(line, sizeof(line), MeshCoreStackFreeMin());
- drawLine(12, line);
+ appendText(line, sizeof(line), " bytes");
+ drawLine(13, line);
- copyText(line, sizeof(line), "FS v:");
+ copyText(line, sizeof(line), "Message flash: ");
appendUnsigned(line, sizeof(line), _app->getMessageCount());
- appendText(line, sizeof(line), " b:");
+ appendText(line, sizeof(line), " records next page ");
+ appendUnsigned(line, sizeof(line), _app->getFlashNextPage());
+ drawLine(14, line);
+
+ copyText(line, sizeof(line), "Flash pages: ");
appendUnsigned(line, sizeof(line), _app->getFlashBlankPageCount());
- appendText(line, sizeof(line), " bad:");
+ appendText(line, sizeof(line), " blank ");
appendUnsigned(line, sizeof(line), _app->getFlashInvalidPageCount());
- appendText(line, sizeof(line), " br:");
+ appendText(line, sizeof(line), " invalid ");
appendUnsigned(line, sizeof(line), _app->getFlashPhysicalBreakCount());
- appendText(line, sizeof(line), " next:");
- appendUnsigned(line, sizeof(line), _app->getFlashNextPage());
- drawLine(13, line);
+ appendText(line, sizeof(line), " layout gaps");
+ drawLine(15, line);
copyText(line, sizeof(line), _notice);
- drawLine(15, line);
+ drawLine(16, line);
}
void UITask::renderPublicHeader() {
@@ -932,6 +997,9 @@ void UITask::render(bool force) {
renderDebug();
_last_diag_refresh = millis();
}
+ if (force) {
+ renderDebugSoftkeyLabels(_board);
+ }
return;
}