feat(companion): on-device scope + repeater scope filtering; fix CAD, UTF-8 truncation, Public channel, Nodes list, keyboard cursor

- Settings > Radio > Scope: type a community/region name on-device (derives
  the shared key the same "#name" -> SHA256 way as DEFAULT_FLOOD_SCOPE_NAME),
  previously only settable from a connected app.
- Tools > Repeater > Scope only + Extra scopes: only relay flood traffic
  matching the device's own scope or a comma-separated list of additional
  scopes, without changing what scope the device's own messages send under.
  No-op while unconfigured.
- getCADEnabled()/getInterferenceThreshold() were hardcoded off on
  companion_radio; CAD now auto-enables whenever RX power-save (duty-cycle)
  is active, since the noise floor isn't kept fresh during duty-cycle sleep.
- Message truncation to fit the send frame could split a multi-byte UTF-8
  character in half; now stops at the last complete character.
- The default "Public" channel was unconditionally re-added at every boot
  before the saved channel list was loaded, so deleting it never stuck.
  Only seeded now on a genuinely fresh device (no channel file yet).
- Tools > Nodes read contacts from the wrong starting offset, landing on
  internally-reserved bookkeeping slots instead of real contacts -- showed
  as blank "Unknown" rows and silently dropped that many real contacts off
  the end of the list.
- resetContacts() only cleared the first few reserved slots, not the whole
  contact table, contrary to its own comment; only reachable today via
  private-key import, fixed to match stated intent regardless.
- Keyboard's multi-line text preview could render the cursor on an empty
  line below short typed text instead of right after it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-08-21 10:40:50 +02:00
co-authored by Claude Sonnet 5
parent 7e10e0359c
commit f589b9b2d1
13 changed files with 283 additions and 27 deletions
+23 -2
View File
@@ -12,7 +12,7 @@ class UITask;
#define FIRMWARE_VER_CODE 13
#ifndef FIRMWARE_BUILD_DATE
#define FIRMWARE_BUILD_DATE "14 Aug 2026"
#define FIRMWARE_BUILD_DATE "19 Aug 2026"
#endif
// Fallback only -- every real build (local or CI) goes through build.sh, which
@@ -20,7 +20,7 @@ class UITask;
// "dev-<commit>" otherwise; see build-solo-firmwares.yml). This default only
// shows up for a `pio run` invoked directly, bypassing build.sh entirely.
#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION "v1.25-dev"
#define FIRMWARE_VERSION "v1.26-dev"
#endif
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
@@ -301,6 +301,19 @@ public:
// the repeater toggle / network / profile changes.
void applyRepeaterRadio();
// Sets this device's own scope (Settings > Radio > Scope) from a single
// typed region name, deriving default_scope_key the same "#name" -> SHA256
// way as DEFAULT_FLOOD_SCOPE_NAME (see begin()). Empty name clears the
// scope. Governs what scope the companion's own messages send under, and
// (as scope[0]) what repeat_scope_only accepts. Calls rebuildRepeatScopes().
void setPrimaryScope(const char* name);
// Rebuilds repeat_scopes[]/repeat_scope_count from default_scope_key (slot 0,
// if configured) plus the comma-separated repeat_extra_scopes (Tools >
// Repeater > Extra scopes). Call after loading prefs at boot and whenever
// either scope setting is edited.
void rebuildRepeatScopes();
bool isAckPending(uint32_t expected_ack) const {
if (expected_ack == 0) return false; // 0 marks an empty/cleared slot, not a real ACK
for (int i = 0; i < EXPECTED_ACK_TABLE_SIZE; i++)
@@ -498,6 +511,14 @@ private:
TransportKey send_scope;
// Runtime-only (not persisted) cache of scopes accepted by repeat_scope_only:
// slot 0 is default_scope_key (if configured), the rest are derived from the
// comma-separated repeat_extra_scopes. Rebuilt by rebuildRepeatScopes() (see
// the public section below) whenever either scope setting changes.
static const uint8_t MAX_REPEAT_SCOPES = 4;
TransportKey repeat_scopes[MAX_REPEAT_SCOPES];
uint8_t repeat_scope_count;
uint8_t cmd_frame[MAX_FRAME_SIZE + 1];
uint8_t out_frame[MAX_FRAME_SIZE + 1];
CayenneLPP telemetry;