Share high-contact RAK offline queue with held one-key DMs

This commit is contained in:
mikecarper committed 2026-09-28 12:47:12 -07:00
1 parent eaf19c3638
commit 898cadae2c
7 files changed
+466 -15

No files matched your search

+7 -4
View File
@@ -1,6 +1,7 @@
# Full Companion contact caches
# Companion contact caches
Full Companions on ESP32 and nRF52 without PSRAM now keep 16 outgoing paths
Full Companions on ESP32 and nRF52 without PSRAM, plus the high-contact RAK4631
USB/BLE profiles, keep 16 outgoing paths
and 16 shared secrets in RAM. Every contact remains in the contact table;
selecting a different contact loads its saved path as needed. This recovers
about 25.4 KiB of internal RAM in the 350-contact ESP32 qualification builds.
@@ -9,8 +10,10 @@ See the [qualification results](companion_contact_cache_results.md) for the
six-board RAM comparison, physical tests, and shared-secret timings.
PSRAM boards retain their existing complete contact table in external RAM.
Legacy USB/BLE/WiFi Companion profiles also retain their inline paths and
secrets. The build flag `MESH_CONTACT_CACHE=0` or `1` overrides this policy for
Most legacy USB/BLE/WiFi Companion profiles retain inline paths and secrets.
The high-contact RAK4631 USB/BLE profiles also enable the same cache,
keeping all 350 contacts while making room for the shared 256-frame offline/DM
pool. The build flag `MESH_CONTACT_CACHE=0` or `1` overrides this policy for
qualification; it is not a runtime feature switch.
## Paths and persistence
+11 -4
View File
@@ -12,7 +12,8 @@ A reboot clears it.
| ESP32 with configured PSRAM | 512 |
| ESP32 without PSRAM | 256 |
| nRF52840 with at most 300 contact slots | 256 |
| nRF52840 with more than 300 contact slots (non-shared queue) | 208 |
| nRF52840 with more than 300 contacts and the contact cache (non-mOTA-shared queue) | 256 total: up to 15 held DMs use slots until accepted |
| nRF52840 with more than 300 contacts but no contact cache | 208 ordinary frames plus a separate 15-DM queue |
| nRF52 Full Companion with the memory correction | 256 normally; 128 while mOTA owns shared storage |
| RP2040 | 256 |
| STM32 | 16 |
@@ -45,9 +46,15 @@ Full profiles require at least 72 KiB of heap space at link time; OLED and
headless profiles use their own [memory budgets](firmware_memory_budget.md).
Standard, logging, MQTT, and Cascade build overlays retain the selected target
capacity. The high-contact nRF52 default above is the exception: it reserves
RAM for the separate 15-entry consent-pending DM queue. A target's explicit
`OFFLINE_QUEUE_SIZE` still takes precedence.
capacity. On cache-enabled high-contact nRF52 Companions, including the RAK4631
USB and BLE profiles, ordinary messages and consent-pending DMs share one
256-frame RAM pool. With no held DMs, all 256 slots are available to ordinary
messages; with 15 held DMs, up to 241 are. The app sees only ordinary messages
until a sender is accepted. The oldest held DM rolls off when a sixteenth
decryptable DM arrives. The shared pool is still volatile and clears on reboot.
Uncached high-contact profiles keep the conservative 208-frame default and
separate held queue. An explicit target `OFFLINE_QUEUE_SIZE` still takes
precedence.
Each queue slot currently costs 177 bytes. A 256-frame queue reserves 45,312
bytes, while a 512-frame queue reserves 90,624 bytes. There is no 256-frame
+6 -3
View File
@@ -260,9 +260,12 @@ The receiving Companion verifies the introduction signature. By default,
`PUSH_CODE_NEW_ADVERT` (`0x8A`) but is not added as a contact. The app/user
accepts through the normal add-contact command. Up to 15 verified, decryptable
plain DMs are held in RAM and delivered after acceptance; the oldest rolls
off first. The queue is lost on reboot. On high-contact nRF52 builds, the
ordinary offline queue is 208 frames (previously 256) to retain the runtime
heap margin for this separate 15-DM queue. The device sends a signed `DMR1`
off first. The queue is lost on reboot. Cache-enabled high-contact nRF52
Companions share a 256-frame pool between ordinary offline messages and up to
15 held DMs, so ordinary capacity is 256 when none are held and 241 when all
15 are held. The held frames are not exposed by ordinary message sync before
acceptance. Uncached high-contact nRF52 builds retain 208 ordinary frames and
a separate held queue. The device sends a signed `DMR1`
refusal, and the sender pushes `0x91` plus the full rejecting key to a
connected app, then stops further introductions for that peer until reboot.
Directly attached clients may use `get dm.one_key` or `set dm.one_key on|off`;