acw: airtime-scale jitter caps, companion surroundings awareness

- flood retransmit jitter now capped at min(2000ms, 6·airtime) instead of
  fixed 2000ms — spreads tighter at SF7, unchanged at SF8
- reactive per-dupe backoff cap now min(2000ms, 12·airtime), keeps
  semantic of "push past ~12 relay slots"
- contention ring 16 → 24 for 50-neighbor hilltops
- companions passively track heard floods (warms EMA without forwarding)
  and spread their own TX by up to min(1000ms, 3·airtime), hopefully
  fixing repeaters missing companion's first transmission

config cleanup:
- move BLE TX buffer bumps (ACL_TX=12 etc.) from zephcore_common.conf to
  esp32_common.conf — the Espressif blob needs them, nRF doesn't, and
  the bumps were overflowing nRF52840 RAM
- remove CONFIG_ZEPHCORE_MAX_CONTACTS=510 overrides from 5 nRF52840
  companion boards; Kconfig default of 350 fits with comfortable margin
  (wio prod: 91% → 79% RAM)
This commit is contained in:
liquidraver
2026-04-17 10:24:12 +02:00
parent cba81af196
commit ba4b86752d
17 changed files with 1909 additions and 1864 deletions
+22 -4
View File
@@ -1173,10 +1173,13 @@ void CompanionMesh::onRawDataRecv(mesh::Packet *packet)
uint32_t CompanionMesh::getRetransmitDelay(const mesh::Packet *packet)
{
float factor = getContentionTracker().getFloodDelayFactor();
uint32_t t = (uint32_t)(_radio->getEstAirtimeFor(
packet->getPathByteLen() + packet->payload_len + 2) * factor);
uint32_t max_jitter = 5 * t;
/* Cap jitter to 2000ms to avoid excessive latency in very dense areas.
uint32_t airtime = _radio->getEstAirtimeFor(
packet->getPathByteLen() + packet->payload_len + 2);
uint32_t max_jitter = (uint32_t)(5 * airtime * factor);
/* Airtime-scaled ceiling: never exceed ~6 airtimes of spread. */
uint32_t airtime_cap = 6 * airtime;
if (max_jitter > airtime_cap) max_jitter = airtime_cap;
/* Absolute cap: avoid excessive latency in very dense areas.
* Reactive backoff will fine-tune further if needed. */
if (max_jitter > 2000) max_jitter = 2000;
/* Floor: give downstream nodes time to finish RX processing
@@ -1193,6 +1196,21 @@ uint32_t CompanionMesh::getDirectRetransmitDelay(const mesh::Packet *packet)
return 20 + getRNG()->nextInt(0, t / 10 + 1);
}
uint32_t CompanionMesh::getInitialFloodJitter(const mesh::Packet *packet)
{
float factor = getContentionTracker().getFloodDelayFactor();
uint32_t airtime = _radio->getEstAirtimeFor(
packet->getPathByteLen() + packet->payload_len + 2);
uint32_t max_jitter = (uint32_t)(5 * airtime * factor);
/* Companion spreads less aggressively than a repeater: half the
* airtime ceiling, and a tighter absolute cap (1000ms vs 2000ms). */
uint32_t airtime_cap = 3 * airtime;
if (max_jitter > airtime_cap) max_jitter = airtime_cap;
if (max_jitter > 1000) max_jitter = 1000;
if (max_jitter == 0) return 0;
return getRNG()->nextInt(0, max_jitter + 1);
}
uint8_t CompanionMesh::getDutyCyclePercent() const
{
return (uint8_t)prefs.airtime_factor;