From ce56e876bd1d703e5168433a969dfbe8bb17e334 Mon Sep 17 00:00:00 2001 From: John Poole Date: Fri, 29 May 2026 17:46:56 -0700 Subject: [PATCH] Note tested, added 750ms delay to overcome possible race condition --- .../204_established_identities/platformio.ini | 1 + .../204_established_identities/src/main.cpp | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/exercises/204_established_identities/platformio.ini b/exercises/204_established_identities/platformio.ini index 598d9e9..f4936d0 100644 --- a/exercises/204_established_identities/platformio.ini +++ b/exercises/204_established_identities/platformio.ini @@ -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. diff --git a/exercises/204_established_identities/src/main.cpp b/exercises/204_established_identities/src/main.cpp index dab683d..c6c4de1 100644 --- a/exercises/204_established_identities/src/main.cpp +++ b/exercises/204_established_identities/src/main.cpp @@ -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,15 +1146,18 @@ void loop() { link = &peer.inbound_link; } if (!link) { - 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, - peer.outbound_link ? (unsigned)peer.outbound_link.status() : 255U, - peer.inbound_link ? 1U : 0U, - peer.inbound_link ? (unsigned)peer.inbound_link.status() : 255U, - peer.outbound_attempted ? 1U : 0U, - peer.outbound_active ? 1U : 0U, - peer.inbound_active ? 1U : 0U); + 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, + peer.outbound_link ? (unsigned)peer.outbound_link.status() : 255U, + peer.inbound_link ? 1U : 0U, + peer.inbound_link ? (unsigned)peer.inbound_link.status() : 255U, + peer.outbound_attempted ? 1U : 0U, + peer.outbound_active ? 1U : 0U, + peer.inbound_active ? 1U : 0U); + } continue; }