Merge pull request #1350 from OffbandMesh/docs/545-notify-plan-dev

docs(#545): radio channel notify plan of record
pull/1356/head
Strycher 2 days ago committed by GitHub
commit 82acc1666a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,193 @@
# Feature PLAN: radio channel notifications, independent of app notifications
| | |
|---|---|
| **Feature** | [#544](https://github.com/OffbandMesh/meshcore-client/issues/544) · Citadel `meshcore-open-pmu` |
| **Serves** | Standalone. Closes research child [#545](https://github.com/OffbandMesh/meshcore-client/issues/545). Firmware half: [meshcore-firmware#606](https://github.com/OffbandMesh/meshcore-firmware/issues/606). |
| **Status** | Draft. Approved when this PR merges. |
| **Owner** | @Strycher |
| **Last updated** | 2026-11-03 |
## At a glance
- **What:** a second, independent per-channel notification control that sets the **radio's** buzzer, beside the existing per-channel control that sets the **phone's** notifications.
- **Why now:** the app's per-channel setting never reached the radio, and the shipped T1000-E guide documents that gap as a limitation. Firmware now stores a per-channel mode and answers `0xC5 0x18/0x19`.
- **How:** Epic A reproduces the gap as failing tests, Epic B the wire and sync, Epic C the two separate controls, Epic D the owner's paired hardware check.
- **Done when:** a channel's **radio** setting changes what the buzzer does with the phone disconnected, a channel's **app** setting changes what the phone does, and neither one moves the other.
## The directive this is built to
Owner, 2026-11-03:
> "Rewrite, separate app notifications from radio notifications, so that they are separate controls and separate notifications. radio notifications set the channel setting in the radio and app notifications in the app. They are independent settings."
Earlier, on why one merged value was wrong:
> "I'm wondering if this should be separated between in-app/on-phone notifications (we have this already) and a separate setting for radio notifications (addition to the menu)."
**Consequence: there is no bridging.** No Inherit option in the app's phone setting, no resolution function that reads one to answer the other, no precedence rule between them. Two stores, two controls, two outputs.
## 1. Diagnosis
| # | Finding | Evidence | Effect |
|---|---|---|---|
| 1 | The app's per-channel setting is **phone-only** and always was. | `ChannelNotifyMode { all, mentionsOnly, off }`, `lib/models/app_settings.dart:31`. Stored per radio then per PSK in `channelNotifyModesByRadio`, resolved at `lib/services/app_settings_service.dart:249-259`, written at `:265-299`. Rendered by `lib/widgets/channel_notify_mode.dart:14-34` from the Channels list and the channel chat menu. | It needs no change in behaviour. It becomes the **app** half of a labelled pair, nothing more. |
| 2 | Nothing in the client reaches the radio's per-channel notify. | No `0x18`/`0x19` sub-code exists in `lib/connector/`. Allocated sub-codes stop at `0x17` (`offband_screen_settings.dart:13-17`). | The radio half is entirely new client code. |
| 3 | Firmware has built it and the contract is settled. | FuchsiaCreek, Agent Mail 1406: `[0xC5][0x18][chan_idx]` GET, `[0xC5][0x19][chan_idx][mode]` SET replying with a re-read; `mode` 0 not set / 1 all / 2 mentions / 3 off; keyed by channel **slot index**; `OFFBAND_CAP2_CHAN_NOTIFY = 0x80` gated on `PIN_BUZZER`; built green on branch `epic/606-channel-notify`. | Build to this. It is not mine to redesign, and it is unpushed, so Epic D waits on the owner's firmware gate. |
| 4 | The encoding mirrors a surface that already ships. | `ChannelTune`: stored byte 0 means "no choice", any other value is `id + 1`, keyed by slot index, SET answered by a re-read, local state follows the reply and never the request. `lib/connector/offband_device_ui.dart:292-330`; send path `lib/connector/meshcore_connector.dart:1113-1145`; tests `test/connector/channel_tune_connector_test.dart`. | The radio half is a copy of a tested surface, not a new mechanism. |
| 5 | The client stores by **PSK**; the wire is keyed by **slot**. | #839 made the app store PSK-keyed deliberately, with no bare-index fallback, because slot indices differ between radios (`app_settings_service.dart:246-258`). `Channel` carries both `index` and `pskHex` (`lib/models/channel.dart:12-24`). | The radio half keys by slot and needs no PSK bridge for its own store, but it must map a channel row to a slot to address it. A channel whose slot the radio has not reported cannot be addressed. |
| 6 | `caps2 0x80` fills caps byte 2, so **caps byte 3** arrives with it, at offset **87**. | FuchsiaCreek 1406, and firmware's own frame builder: `offband_caps2` is written at 84, then `ui_led_enabled` at 85 and `ui_display_mode` at 86 (`examples/companion_radio/MyMesh.cpp:3032-3036`). Read it length-gated, never version-gated. | A `parseOffbandCaps3` mirroring `parseOffbandCaps2` (`meshcore_connector.dart:7862-7863`). Reading byte 3 at 85 would parse the LED state as a capability mask. |
| 7 | The radio's **own** fallback is not the client's business, but the client must render the truth. | Per 1406: a channel with a mode set decides for itself; a channel with no mode falls back to the radio's device-wide scope; a device scope of `None` overrides even a set channel. The device-wide default is now `Self`. | The radio control cannot display the stored byte as if it were the effective behaviour. See §6 and decision 1. |
| 8 | The device-wide scope control already ships in the client. | Section header "Device notification scope" with All / Self / None rows, `lib/screens/settings/device_ui_view.dart:129` and `:195-210`; enum at `lib/connector/offband_device_ui.dart:194-210`. On the badge the same byte is the Setup row labelled "Sound" (`ui-new/BadgeScreens.cpp:1622`, cycled at `:1675-1689`). | The owner has said this control **may be deprecated** by per-channel settings. Firmware still ships it and still falls back to it, so this plan leaves it in place and does not design its removal. Flagged in §10. |
| 9 | DMs are not a channel, so nothing per-channel covers them. | The device-wide scope is what distinguishes DM-and-mention beeping from all-message beeping (`offband_device_ui.dart:195-197`). | Another reason this plan does not touch the device-wide control. Raised with firmware; not resolved here. |
| 10 | The shipped user guide documents the gap this closes. | firmware PR #1967's T1000-E guide: "The client's per-channel setting does not reach the radio… 'beep only when mentioned' is a whole-radio setting." | That text needs correcting when the firmware half merges. Firmware's to make, named here so it is not lost. |
## 2. Scope
**In:**
- A **new** per-channel radio control, writing `[0xC5][0x19][chan_idx][mode]` and reading `0x18`, gated on `caps2 0x80`.
- `parseOffbandCaps3` at device-info offset 87, length-gated.
- Per-radio client state for the radio modes, cleared on radio change like every other `0xC5` surface, written only from a device reply.
- Labelling both controls so it is obvious which output each one governs.
- New strings English-only, with the regenerated `untranslated.json` committed.
**Out:**
- **Any change to the app's per-channel notify behaviour.** It keeps its store, its resolution and its three values. Only its label and placement change.
- **Any bridging between the two.** No Inherit in the app control, no shared resolution, no precedence.
- **The device-wide scope control**, including its possible deprecation (row 8) and the DM question (row 9).
- **Any bit in caps byte 3.** This establishes the byte and its parser only.
- The firmware half, and the guide correction in firmware PR #1967.
- **Killed by the owner's rulings, recorded so they are not re-proposed:** `NOTIFY_SCOPE_INHERIT = 3` (there is no firmware Inherit; "how would firmware inherit from firmware?"), the 4-byte `sha256(psk)` key, the width byte, collision escalation, CLEAR-then-repush, and a separate global gate byte.
## 3. Epics
Tasks are 3-4 points. Each Epic ends with a verification task and gets one PR. Epic A reproduces the diagnosis as failing tests before anything is built.
### Epic A: the gap, as failing tests
| Task | Pts |
|---|---|
| **A1 · The radio modes do not exist:** a `0x18` reply for slot 1 with mode 2 resolves to Mentions for slot 1; mode 0 resolves to "not set"; a reply for a slot with no channel is dropped, not applied to a guessed channel. Red today: no parser. New `test/connector/channel_notify_connector_test.dart`, shaped on `channel_tune_connector_test.dart`. | 3 |
| **A2 · Independence, asserted:** setting the app mode for a channel emits **no** `0x18`/`0x19` traffic, and a `0x19` reply does **not** change `channelNotifyModesByRadio`. This is the test that keeps the two from being re-merged later. | 3 |
| **A3 · Capability and byte 3:** the radio control is absent without `caps2 0x80`; caps byte 3 reads offset 87 and is null on a frame of 87 bytes or fewer, with 85 and 86 proven not to be mistaken for it. | 3 |
| **A4 · Epic verification** | 1 |
### Epic B: the wire and the sync
| Task | Pts |
|---|---|
| **B1 · The contract:** `offbandUiChannelNotifyGet = 0x18`, `offbandUiChannelNotifySet = 0x19`, a `RadioChannelNotify` value type with the 1-based encoding and an explicit unset, frame builders reusing `_channelByte`, `DeviceUiSurface.channelNotify`, `offbandCap2ChannelNotify = 0x80`, `parseOffbandCaps3`. | 4 |
| **B2 · Connector state:** a per-radio slot-to-mode map cleared in `_clearDeviceUiState`, `_handleDeviceUiReply` extended, suppression logged through `_deviceUiGateOpen`, request and set methods shaped on `requestChannelTune` / `setChannelTune` so state follows the reply and never the request. | 4 |
| **B3 · Read on connect:** once the channel table is known and the bit is set, GET each populated slot. A channel with no known slot is not addressed and is reported, not silently skipped. | 3 |
| **B4 · Epic verification** | 1 |
### Epic C: two controls, clearly separate
| Task | Pts |
|---|---|
| **C1 · The radio control:** a new per-channel affordance that writes the radio mode, gated on `caps2 0x80`, with the shipped "not saved until the radio replies" behaviour and a refusal shown with `persist: true`. Offers All / Mentions / Off / Not set. | 4 |
| **C2 · Labelling, so neither is mistaken for the other:** the existing control reads as the phone's notifications, the new one as the radio's sound. Both reachable from the same places the app control already is (`channels_screen.dart:534`, `channel_chat_screen.dart:476`), never merged into one row. | 3 |
| **C3 · Effective state, not the raw byte:** where the radio control shows what a channel will actually do, it composes the radio's rules from row 7 rather than displaying the stored mode. A channel set to All under a device scope of None is not shown as All. | 3 |
| **C4 · The #475 contract note, rewritten:** the two vocabularies stay distinct and are now two independent settings over two outputs. Plus the new English strings and the regenerated `untranslated.json`. | 3 |
| **C5 · Epic verification** | 1 |
### Epic D: Integration Testing (owner, paired)
| Task | Pts |
|---|---|
| **D1 · Independence on hardware:** set a channel's radio mode to Off and its app mode to All; the buzzer stays silent with the phone disconnected and the phone still notifies. Then the reverse. Needs a firmware image answering `0x18`/`0x19`. | 3 |
| **D2 · The negative test:** a radio without `caps2 0x80` shows no radio control and sends no `0x18`/`0x19`; the app control behaves exactly as it does today. | 3 |
| **D3 · Epic verification** | 1 |
## 4. Order and dependencies
A, then B, then C, then D. A is the red baseline; B owns the state C renders.
**Same files, so these do not run in parallel:** B1 and C1 both touch `lib/connector/offband_device_ui.dart`; B2 and B3 both touch `lib/connector/meshcore_connector.dart`. C2 touches `channels_screen.dart`, `channel_chat_screen.dart` and `channel_notify_mode.dart`, which nothing else here touches.
**Only Epic D depends on firmware.** A to C land on their own tests with no firmware change. D is a paired hardware test the owner runs; the firmware branch is unpushed and its PR is his gate.
## 5. Grants and authorization
| Term | Proposed | Why |
|---|---|---|
| **What merging this plan authorizes** | Building Epics A, B and C unattended, in order. | Each lands on tests needing no radio and no firmware change. |
| **Merges** | 3, one per Epic (A, B, C). Epic D has no code and no PR. | Tasks are commits on the Epic branch. |
| **Epic verification** | Owner. | §7's command is the evidence each PR shows. |
| **Owner steps during the run** | None until Epic C merges. Then a paired image, a flash, and Epic D. | Nothing in A to C needs hardware. |
| **Stops** | Anything in §6. Also any sign the `0x18` contract does not match what a flashed image answers: that stops and goes to the owner. | |
| **Flash** | Not authorized by this plan. The owner flashes; I name the image. | Client session. |
```grant-terms
{
"epic_chain": [],
"chain": true,
"verification": { "mode": "owner" },
"merge": { "budget": 3, "basis": "one merge per code Epic: A the failing tests, B the wire and sync, C the two controls. Epic D is the owner's paired hardware test and has no PR. Tasks are commits on the Epic branch, so there is no per-task merge." },
"flash": null,
"reset": null,
"expires_after_hours": 168
}
```
**`epic_chain` is empty on purpose.** The Epic issues do not exist yet; canon creates them when this plan merges, and the numbers are filled in here then.
## 6. Can't-tell branches
| Where | Can't tell what | Does |
|---|---|---|
| `caps2 0x80` clear, or caps byte 2 absent | nothing: that is a definite answer | not a can't-tell branch. No radio control, no `0x18` traffic, app control unchanged. Listed so it is not mistaken for one. |
| `caps2 0x80` set, `0x18` GET sent, nothing back | what the radio holds for this channel | **stop**: loading row, no value shown, no write offered. The scope surface already behaves this way (`device_ui_view.dart:180-190`). |
| A `0x18` reply names a slot with no matching channel | which channel it means | **stop**: drop it and log it. Never apply a mode to a guessed channel. |
| A channel row whose slot the radio has not reported | which slot to address | **stop**: do not write; surface it on the row. Silent non-delivery is the failure #839 was fixed to end. |
| `caps2 0x80` set but the radio refuses `0x19` with `0x7F` | why the bit and the behaviour disagree | **stop**: keep the previous value, show the refusal persistently, drop the control for this radio for the session. A bit that lies is a firmware bug and must surface as one. |
| Device-info frame is exactly 85, 86 or 87 bytes | whether byte 3 is present | **stop**: `parseOffbandCaps3` returns null, as byte 2 does on a short frame. Reading 85 or 86 would parse the LED or display state as a capability mask (row 6). |
| Radio connected, `0x18` answered, but the device-wide scope is unknown | what a channel with mode 0 will actually do | **stop**: show the channel as "not set" and do not claim an effective behaviour. The composition in row 7 needs both values; with one missing there is nothing truthful to display. |
| No radio connected, and the **app** control is read | nothing: the app store is local and complete | not a can't-tell branch. The app setting is independent and answers from its own store, exactly as it does today. |
No fail-open branch is proposed. If one proves necessary it comes to the owner for a fail-open grant before the merge, not after.
## 7. Verification
- **Named command:**
```
C:\Dev\flutter-meshcore\bin\flutter.bat test test/connector/channel_notify_connector_test.dart test/connector/offband_device_ui_test.dart test/connector/offband_caps2_test.dart test/connector/channel_tune_connector_test.dart test/services/app_settings_service_test.dart
```
Plus `flutter analyze` on the touched files, `dart format` before every commit, and the full `flutter test` suite on each Epic's PR, because §3 changes strings and string changes have broken asserts that `analyze` passed.
`channel_tune_connector_test.dart` is in the list deliberately: it is the shipped surface the radio half is copied from, and a regression there means the copy was wrong.
- **Independence assertion, non-negotiable:** A2 must fail if the two settings are ever wired together. Prove it fails before trusting it.
- **Acceptance bar:** A1 to A3 fail before Epic B and pass after. D1 shows the two settings moving independently on real hardware with the phone disconnected for the radio half. Green tests alone do not meet the bar: the point is that two controls drive two outputs without touching each other.
## 8. Done when
- A channel's **radio** setting changes what the buzzer does, with the phone disconnected.
- A channel's **app** setting changes what the phone does, exactly as it does today.
- Changing either one leaves the other untouched, asserted by a test.
- The radio control appears only on radios advertising `caps2 0x80`, and such a radio behaves exactly as today without it.
- Caps byte 3 reads from offset 87, is null on a shorter frame, and holds no allocated bits.
- No gate this plan adds reads `FIRMWARE_VER_CODE` (#1065).
## 9. Your choices
| # | Question | Option A | Option B | Rec. | Your choice |
|---|---|---|---|---|---|
| 1 | What the radio control shows for a channel whose radio mode is **Not set**. | **Show the composed result** ("Follows the radio: mentions only"), computed from the device-wide scope per row 7. Truthful, and makes None-overrides-everything visible. Costs reading the scope on connect. | **Show "Not set"** and nothing more. Simpler, but a user with the radio muted sees "Not set" on a channel they explicitly set to All and cannot tell why it is silent. | ⭐ A | |
**Settled, not re-asked:** the two settings are separate and independent (owner, 2026-11-03). The capability signal is `caps2 0x80` with caps byte 3 at offset 87. Nothing rides on `FIRMWARE_VER_CODE`. There is no firmware Inherit.
## 10. Carried-in work
| Item | Goes to |
|---|---|
| The firmware half: per-channel storage on the non-GUI variants and the `0x18`/`0x19` handler. Built green on `epic/606-channel-notify`, unpushed. | [meshcore-firmware#606](https://github.com/OffbandMesh/meshcore-firmware/issues/606). Epic D cannot run without it; Epics A to C do not wait on it. |
| Whether the device-wide notification scope is deprecated now that channels carry their own modes (row 8), and what then governs DM beeping (row 9). | Firmware's surface and the owner's call. This plan deliberately leaves the control in place and designs no removal. |
| The T1000-E guide text that documents the old gap (row 10). | firmware PR #1967's guide, corrected when the firmware half merges. |
| Retiring the GUI variants' own per-channel array. | Firmware, after #606; ChartreuseOtter layers the GUI onto the same byte. The client must not design around that array either way. |
| #545's deliverables are discharged here: the wire contract (§2), the decision matrix (§6 and row 7), the #475 note update (task C4), and settling with firmware (row 3). | Close #545 when this merges. |
When this plan merges, each Epic and Task gets a GitHub issue and a Citadel task, per canon.
Loading…
Cancel
Save

Powered by TurnKey Linux.