diff --git a/esp32/uwb_anchor/src/main.cpp b/esp32/uwb_anchor/src/main.cpp index e423b6e..c9ae1ed 100644 --- a/esp32/uwb_anchor/src/main.cpp +++ b/esp32/uwb_anchor/src/main.cpp @@ -195,8 +195,21 @@ void setup(void) { /* ── Loop ───────────────────────────────────────────────────────── */ +/* + * Time-division multiplexing: 2 anchors share the same channel. + * Each anchor only responds during its time slot to avoid RF collisions. + * Slot duration = 50ms → each anchor gets 10 Hz effective rate. + * Anchor 0 responds during even slots, anchor 1 during odd slots. + */ +#define SLOT_MS 50 +#define NUM_ANCHORS_TOTAL 2 + void loop(void) { serial_poll(); espnow_process(); - DW1000Ranging.loop(); + + uint32_t slot = (millis() / SLOT_MS) % NUM_ANCHORS_TOTAL; + if (slot == ANCHOR_ID) { + DW1000Ranging.loop(); + } }