}
#endif
+ #if MCU_VARIANT == MCU_ESP32 || MCU_VARIANT == MCU_NRF52
+ #if MODEM == SX1280
+ avoid_interference = false;
+ #else
+ if (EEPROM.read(eeprom_addr(ADDR_CONF_DIA)) == 0x01) { avoid_interference = false; }
+ else { avoid_interference = true; }
+ #endif
+ #endif
+
// Validate board health, EEPROM and config
validate_status();
display_unblank();
}
#endif
+ } else if (command == CMD_DIS_IA) {
+ if (sbyte == FESC) {
+ ESCAPE = true;
+ } else {
+ if (ESCAPE) {
+ if (sbyte == TFEND) sbyte = FEND;
+ if (sbyte == TFESC) sbyte = FESC;
+ ESCAPE = false;
+ }
+ dia_conf_save(sbyte);
+ }
} else if (command == CMD_DISP_RCND) {
#if HAS_DISPLAY
if (sbyte == FESC) {
portMUX_TYPE update_lock = portMUX_INITIALIZER_UNLOCKED;
#endif
-bool medium_free() { update_modem_status(); return !dcd; }
+bool medium_free() {
+ update_modem_status();
+ if (avoid_interference && interference_detected) { return false; }
+ return !dcd;
+}
bool noise_floor_sampled = false;
int noise_floor_sample = 0;
#endif
}
+#define LED_ID_TRIG 16
+uint8_t led_id_filter = 0;
void update_modem_status() {
#if MCU_VARIANT == MCU_ESP32
portENTER_CRITICAL(&update_lock);
portEXIT_CRITICAL();
#endif
- if (carrier_detected) { dcd = true; }
- else { dcd = false; }
+ interference_detected = current_rssi > (noise_floor+CSMA_INFR_THRESHOLD_DB);
+ if (interference_detected) { if (led_id_filter < LED_ID_TRIG) { led_id_filter += 1; } }
+ else { if (led_id_filter > 0) {led_id_filter -= 1; } }
+
+ if (carrier_detected) { dcd = true; } else { dcd = false; }
dcd_led = dcd;
if (dcd_led) { led_rx_on(); }
- else { if (airtime_lock) { led_indicate_airtime_lock(); }
- else { led_rx_off(); } }
+ else {
+ if (interference_detected) {
+ if (led_id_filter >= LED_ID_TRIG && noise_floor_sampled) { led_id_on(); }
+ } else {
+ if (airtime_lock) { led_indicate_airtime_lock(); }
+ else { led_rx_off(); led_id_off(); }
+ }
+ }
}
void check_modem_status() {
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#elif MCU_VARIANT == MCU_ESP32
#if HAS_NP == true
void led_rx_on() { npset(0, 0, 0xFF); }
void led_rx_off() { npset(0, 0, 0); }
void led_tx_on() { npset(0xFF, 0x50, 0x00); }
void led_tx_off() { npset(0, 0, 0); }
+ void led_id_on() { npset(0x90, 0, 0x70); }
+ void led_id_off() { npset(0, 0, 0); }
#elif BOARD_MODEL == BOARD_RNODE_NG_20
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#elif BOARD_MODEL == BOARD_RNODE_NG_21
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#elif BOARD_MODEL == BOARD_RNODE_NG_22
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#elif BOARD_MODEL == BOARD_TBEAM
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, LOW); }
void led_tx_off() { digitalWrite(pin_led_tx, HIGH); }
+ void led_id_on() { }
+ void led_id_off() { }
#elif BOARD_MODEL == BOARD_TDECK
void led_rx_on() { }
void led_rx_off() { }
void led_tx_on() { }
void led_tx_off() { }
+ void led_id_on() { }
+ void led_id_off() { }
#elif BOARD_MODEL == BOARD_TBEAM_S_V1
void led_rx_on() { }
void led_rx_off() { }
void led_tx_on() { }
void led_tx_off() { }
+ void led_id_on() { }
+ void led_id_off() { }
#elif BOARD_MODEL == BOARD_LORA32_V1_0
#if defined(EXTERNAL_LEDS)
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#else
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#endif
#elif BOARD_MODEL == BOARD_LORA32_V2_0
#if defined(EXTERNAL_LEDS)
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#else
void led_rx_on() { digitalWrite(pin_led_rx, LOW); }
void led_rx_off() { digitalWrite(pin_led_rx, HIGH); }
void led_tx_on() { digitalWrite(pin_led_tx, LOW); }
void led_tx_off() { digitalWrite(pin_led_tx, HIGH); }
+ void led_id_on() { }
+ void led_id_off() { }
#endif
#elif BOARD_MODEL == BOARD_HELTEC32_V2
#if defined(EXTERNAL_LEDS)
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#else
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#endif
#elif BOARD_MODEL == BOARD_HELTEC32_V3
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#elif BOARD_MODEL == BOARD_LORA32_V2_1
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#elif BOARD_MODEL == BOARD_HUZZAH32
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#elif BOARD_MODEL == BOARD_GENERIC_ESP32
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#endif
#elif MCU_VARIANT == MCU_NRF52
#if HAS_NP == true
- void led_rx_on() { npset(0, 0, 0xFF); }
- void led_rx_off() { npset(0, 0, 0); }
- void led_tx_on() { npset(0xFF, 0x50, 0x00); }
- void led_tx_off() { npset(0, 0, 0); }
+ void led_rx_on() { npset(0, 0, 0xFF); }
+ void led_rx_off() { npset(0, 0, 0); }
+ void led_tx_on() { npset(0xFF, 0x50, 0x00); }
+ void led_tx_off() { npset(0, 0, 0); }
+ void led_id_on() { npset(0x90, 0, 0x70); }
+ void led_id_off() { npset(0, 0, 0); }
#elif BOARD_MODEL == BOARD_RAK4631
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
+ void led_id_on() { }
+ void led_id_off() { }
#elif BOARD_MODEL == BOARD_HELTEC_T114
- // Heltec T114 pulls pins LOW to turn on
- void led_rx_on() { digitalWrite(pin_led_rx, LOW); }
- void led_rx_off() { digitalWrite(pin_led_rx, HIGH); }
- void led_tx_on() { digitalWrite(pin_led_tx, LOW); }
- void led_tx_off() { digitalWrite(pin_led_tx, HIGH); }
+ // Heltec T114 pulls pins LOW to turn on
+ void led_rx_on() { digitalWrite(pin_led_rx, LOW); }
+ void led_rx_off() { digitalWrite(pin_led_rx, HIGH); }
+ void led_tx_on() { digitalWrite(pin_led_tx, LOW); }
+ void led_tx_off() { digitalWrite(pin_led_tx, HIGH); }
+ void led_id_on() { }
+ void led_id_off() { }
#endif
#endif
#endif
}
+void dia_conf_save(uint8_t val) {
+ if (val > 0x00) { eeprom_update(eeprom_addr(ADDR_CONF_DIA), 0x01); }
+ else { eeprom_update(eeprom_addr(ADDR_CONF_DIA), 0x00); }
+ hard_reset();
+}
+
void np_int_conf_save(uint8_t p_int) {
eeprom_update(eeprom_addr(ADDR_CONF_PSET), CONF_OK_BYTE);
eeprom_update(eeprom_addr(ADDR_CONF_PINT), p_int);