diff --git a/docs/kiss_modem_protocol.md b/docs/kiss_modem_protocol.md index 067e1539..00b0bf90 100644 --- a/docs/kiss_modem_protocol.md +++ b/docs/kiss_modem_protocol.md @@ -28,8 +28,6 @@ Maximum unescaped frame size: 512 bytes. ## Commands -Command and response codes below are taken from `examples/kiss_modem/KissModem.h` and the switch in `KissModem::processFrame()`. - ### Request Commands (Host → Modem) | Command | Value | Data | @@ -129,7 +127,7 @@ Response to `CMD_GET_NOISE_FLOOR` (0x13). Little-endian. |--------------|------|--------------------------------| | Noise floor | 2 | int16_t, dBm (signed), e.g. -120 | -The modem recalibrates the noise floor periodically (every 2 s) from RX samples when idle. The receiver AGC is also reset periodically (every 30 s) so RSSI and noise floor do not drift to the minimum (-120). Typical range after calibration is about -120 to -90 dBm. Values may be 0 or briefly stale until the radio has been in receive mode long enough to collect 64 samples. +The modem recalibrates the noise floor every two seconds with an AGC reset every 30 seconds. ### Stats (RESP_STATS) diff --git a/examples/kiss_modem/main.cpp b/examples/kiss_modem/main.cpp index 13855309..3a610460 100644 --- a/examples/kiss_modem/main.cpp +++ b/examples/kiss_modem/main.cpp @@ -12,8 +12,8 @@ #include #endif -#define NOISE_FLOOR_CALIB_INTERVAL_MS 2000 // match Dispatcher default -#define AGC_RESET_INTERVAL_MS 30000 // periodic RX restart so AGC doesn't drift (repeater uses same via prefs) +#define NOISE_FLOOR_CALIB_INTERVAL_MS 2000 +#define AGC_RESET_INTERVAL_MS 30000 StdRNG rng; mesh::LocalIdentity identity; @@ -100,11 +100,9 @@ void loop() { uint8_t packet[KISS_MAX_PACKET_SIZE]; uint16_t len; - // Match Dispatcher order: noise floor calib + loop() first, so we never sample RSSI in the same - // iteration as startReceive() (AGC reset -> recvRaw below). Sampling right after startReceive() - // can yield settling/cold RSSI and drive the floor toward -120. + // trigger noise floor calibration if ((uint32_t)(millis() - next_noise_floor_calib_ms) >= NOISE_FLOOR_CALIB_INTERVAL_MS) { - radio_driver.triggerNoiseFloorCalibrate(0); // 0 = no interference threshold (KISS has no prefs) + radio_driver.triggerNoiseFloorCalibrate(0); next_noise_floor_calib_ms = millis(); } radio_driver.loop(); @@ -119,7 +117,7 @@ void loop() { } if ((uint32_t)(millis() - next_agc_reset_ms) >= AGC_RESET_INTERVAL_MS) { - radio_driver.resetAGC(); // next recvRaw() will startReceive() and reset AGC so RSSI/noise floor don't stick at -120 + radio_driver.resetAGC(); next_agc_reset_ms = millis(); } uint8_t rx_buf[256];