Note tested, added 750ms delay to overcome possible race condition

This commit is contained in:
John Poole 2026-05-29 17:46:56 -07:00
commit ce56e876bd
2 changed files with 21 additions and 11 deletions

View file

@ -53,6 +53,7 @@ build_flags =
-D SIM_PHY_ENVELOPE=1
-D SIM_PHY_BLOCK_BOB_CY=1
-D MR_TRANSPORT_PROBE=1
-D MR_LINKFWD_DELAY_MS=750
; Live announces are enough for this single-hop field exercise. Do not define
; RNS_PERSIST_PATHS here: the LittleFS-backed path_store compactor can leave an
; active segment FD open while unlinking /path_store_*.dat on ESP32.

View file

@ -46,6 +46,9 @@
#ifndef EX204_RNS_TRACE
#define EX204_RNS_TRACE 0
#endif
#ifndef MR_LINKFWD_DELAY_MS
#define MR_LINKFWD_DELAY_MS 0
#endif
static constexpr const char* APP_NAME = "microreticulum";
static constexpr const char* APP_ASPECT = "linkping";
@ -114,6 +117,7 @@ struct PeerState {
uint32_t tx_iter = 0;
uint8_t tx_since_link_open = 0;
uint8_t last_tx_second = 255;
uint8_t last_skip_second = 255;
};
static PeerState peers[MAX_PEERS];
@ -662,6 +666,7 @@ static void clear_peer_slot(uint8_t index) {
peers[index].tx_iter = 0;
peers[index].tx_since_link_open = 0;
peers[index].last_tx_second = 255;
peers[index].last_skip_second = 255;
}
static int ensure_peer_for_label(const String& label) {
@ -909,11 +914,12 @@ static void print_config() {
Serial.printf("LoRa: freq=%.1f BW=%.1f SF=%d CR=%d sync=0x%02x txp=%d\r\n",
(double)LORA_FREQ_MHZ, (double)LORA_BW_KHZ, (int)LORA_SF,
(int)LORA_CR, (int)LORA_SYNC_WORD, (int)LORA_TX_POWER_DBM);
Serial.printf("Sim: phy_envelope=%d phy_block_bob_cy=%d node_slot=%d rns_trace=%d\r\n",
Serial.printf("Sim: phy_envelope=%d phy_block_bob_cy=%d node_slot=%d rns_trace=%d linkfwd_delay_ms=%u\r\n",
(int)SIM_PHY_ENVELOPE,
(int)SIM_PHY_BLOCK_BOB_CY,
(int)NODE_SLOT_INDEX,
(int)EX204_RNS_TRACE);
(int)EX204_RNS_TRACE,
(unsigned)MR_LINKFWD_DELAY_MS);
}
static void send_announce() {
@ -1140,6 +1146,8 @@ void loop() {
link = &peer.inbound_link;
}
if (!link) {
if (peer.last_skip_second != rtc_now.second) {
peer.last_skip_second = rtc_now.second;
Serial.printf("TX LINK SKIP: peer=%s outbound=%u outbound_status=%u inbound=%u inbound_status=%u attempted=%u active_out=%u active_in=%u\r\n",
peer.label.c_str(),
peer.outbound_link ? 1U : 0U,
@ -1149,6 +1157,7 @@ void loop() {
peer.outbound_attempted ? 1U : 0U,
peer.outbound_active ? 1U : 0U,
peer.inbound_active ? 1U : 0U);
}
continue;
}