Current announce cycle was: once per minute, at 2 + NODE_SLOT_INDEX * 4 seconds. So BOB at :06, CY at :10, DAN at :14, etc.

I changed it to:

first announce: immediately after startup once microReticulum is ready
second announce: after ANNOUNCEMENT_2 seconds
later announces: every ANNOUNCEMENT_REPEAT seconds
This commit is contained in:
John Poole 2026-06-02 11:22:27 -07:00
commit db57359abd
3 changed files with 68 additions and 10 deletions

View file

@ -55,6 +55,8 @@ build_flags =
-D MR_TRANSPORT_PROBE=1
-D MR_LINKFWD_DELAY_MS=750
-D MR_LRPROOF_DELAY_MS=750
-D ANNOUNCEMENT_2=300
-D ANNOUNCEMENT_REPEAT=3600
; 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

@ -0,0 +1,25 @@
#!/bin/bash
# $Header$
# $HeadURL$
set -e
EXERCISE="/usr/local/src/microreticulum/microReticulumTbeam/exercises/204_established_identities"
for env in amy bob cy dan ed flo guy
do
ENV="$(echo "$env" | tr '[:lower:]' '[:upper:]')"
echo "===== copy artifact $env from ryzdesk ====="
rsync -a \
"ryzdesk:${EXERCISE}/.pio/build/${env}/" \
"${EXERCISE}/.pio/build/${env}/"
echo "===== upload $env / $ENV ====="
pio run \
-d "$EXERCISE" \
-e "$env" \
-t nobuild \
-t upload \
--upload-port "/dev/ttyt${ENV}"
done

View file

@ -49,6 +49,12 @@
#ifndef MR_LINKFWD_DELAY_MS
#define MR_LINKFWD_DELAY_MS 0
#endif
#ifndef ANNOUNCEMENT_2
#define ANNOUNCEMENT_2 300
#endif
#ifndef ANNOUNCEMENT_REPEAT
#define ANNOUNCEMENT_REPEAT 3600
#endif
static constexpr const char* APP_NAME = "microreticulum";
static constexpr const char* APP_ASPECT = "linkping";
@ -62,6 +68,8 @@ static constexpr uint32_t LINK_RETRY_MS = 90000;
static constexpr uint32_t LINK_RX_STALE_MS = 75000;
static constexpr uint32_t LINK_REOPEN_DELAY_MS = 5000;
static constexpr uint8_t LINK_MESSAGES_PER_CYCLE = 5;
static constexpr uint32_t ANNOUNCEMENT_2_MS = (uint32_t)ANNOUNCEMENT_2 * 1000UL;
static constexpr uint32_t ANNOUNCEMENT_REPEAT_MS = (uint32_t)ANNOUNCEMENT_REPEAT * 1000UL;
struct DateTime {
uint16_t year = 0;
@ -614,10 +622,6 @@ static uint8_t node_send_slot_second() {
return (uint8_t)(4U + ((uint8_t)NODE_SLOT_INDEX * 4U));
}
static uint8_t node_announce_slot_second() {
return (uint8_t)(2U + ((uint8_t)NODE_SLOT_INDEX * 4U));
}
static int find_peer_by_label(const String& label) {
for (uint8_t i = 0; i < MAX_PEERS; ++i) {
if (peers[i].label == label) {
@ -920,6 +924,9 @@ static void print_config() {
(int)NODE_SLOT_INDEX,
(int)EX204_RNS_TRACE,
(unsigned)MR_LINKFWD_DELAY_MS);
Serial.printf("Announce: startup=1 second=%lu repeat=%lu seconds\r\n",
(unsigned long)ANNOUNCEMENT_2,
(unsigned long)ANNOUNCEMENT_REPEAT);
}
static void send_announce() {
@ -931,6 +938,35 @@ static void send_announce() {
inbound_destination.announce(RNS::bytesFromString(NODE_LABEL));
}
static void maybe_send_scheduled_announce() {
if (!clock_ready || !inbound_destination) {
return;
}
static bool startup_announce_sent = false;
static uint8_t announce_count = 0;
static uint32_t next_announce_ms = 0;
const uint32_t now = millis();
if (!startup_announce_sent) {
startup_announce_sent = true;
announce_count = 1;
next_announce_ms = now + ANNOUNCEMENT_2_MS;
send_announce();
return;
}
if ((int32_t)(now - next_announce_ms) < 0) {
return;
}
send_announce();
if (announce_count < 2) {
announce_count = 2;
}
next_announce_ms = now + ANNOUNCEMENT_REPEAT_MS;
}
static void maybe_open_link(const DateTime& rtc_now, bool have_rtc_now) {
const uint32_t now = millis();
static uint32_t last_open_ms = 0;
@ -1114,7 +1150,6 @@ void loop() {
static uint32_t last_rtc_poll_ms = 0;
static DateTime rtc_now{};
static bool have_rtc_now = false;
static uint8_t last_announce_minute = 255;
uint32_t now = millis();
if ((uint32_t)(now - last_rtc_poll_ms) >= 200U) {
@ -1123,11 +1158,7 @@ void loop() {
}
maybe_open_link(rtc_now, have_rtc_now);
if (have_rtc_now && rtc_now.second == node_announce_slot_second() &&
last_announce_minute != rtc_now.minute) {
last_announce_minute = rtc_now.minute;
send_announce();
}
maybe_send_scheduled_announce();
const uint8_t send_slot = node_send_slot_second();
const uint8_t second_slot = (uint8_t)((send_slot + 30U) % 60U);
if (have_rtc_now && (rtc_now.second == send_slot || rtc_now.second == second_slot)) {