radiolib: RADIO_DIAG -- radiostat/radiokick for a receiver that went deaf

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-10-31 19:51:11 +01:00
1 parent 439d40ac04
commit 65ff32a10a
5 files changed
+106

No files matched your search

@@ -62,4 +62,27 @@ public:
}
void doResetAGC() override { sx126xResetAGC((SX126x *)_radio, getRxBoostedGainMode()); }
#ifdef RADIO_DIAG
protected:
// CUSTOM (TeTeHacko): `radiostat`, chip side. mode: 2 STBY_RC, 3 STBY_XOSC,
// 4 FS, 5 RX, 6 TX; cmd: 2 data available, 3 timeout, 4 processing error,
// 5 exec failure. Pin levels are read back, so -1 = not wired.
int diagChip(char* out, int sz) override {
CustomSX1262* r = (CustomSX1262 *)_radio;
uint8_t s = r->diagStatus();
int dio1 = -1, rxen = -1;
#ifdef P_LORA_DIO_1
if ((uint32_t) P_LORA_DIO_1 != (uint32_t) RADIOLIB_NC) dio1 = digitalRead(P_LORA_DIO_1);
#endif
#ifdef SX126X_RXEN
if ((uint32_t) SX126X_RXEN != (uint32_t) RADIOLIB_NC) rxen = digitalRead(SX126X_RXEN);
#endif
return snprintf(out, sz, " mode=%u cmd=%u irq=0x%04lx deverr=0x%04x rssi=%d dio1=%d rxen=%d boost=%d",
(unsigned) ((s >> 4) & 7), (unsigned) ((s >> 1) & 7),
(unsigned long) r->getIrqFlags(), (unsigned) r->diagDeviceErrors(),
(int) r->getRSSI(false), dio1, rxen, (int) r->getRxBoostedGainMode());
}
public:
#endif
};