Repository navigation
feat(firmware+app): rename Omi device with onboard persistent storage & cross-phone sync (#2824) - #14558
feat(firmware+app): rename Omi device with onboard persistent storage & cross-phone sync (#2824)#14558shuoYun114 wants to merge 11 commits into
Conversation
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the thorough end-to-end implementation — the firmware persistence layer is exactly what #2824 asked for, and I verified all 8 tests in app/test/unit/device_onboard_rename_test.dart executed and passed in the Dart Analyze & Tests CI job. The overall structure is clean, and the read-path sync in bt_device.dart (onboard name wins, original name kept as fallback) plus the forced-refresh split in device_provider.dart (preserving the cached getDeviceInfo() signature) are the right shape. Two firmware issues block this as-is, though.
Blocking: scan response can exceed the 31-byte legacy limit (omi/firmware/omi/src/lib/core/transport.c)
bt_sd now contains the DIS UUID16 element (4 bytes: len + type + 2 data bytes) plus BT_DATA_NAME_COMPLETE (2-byte header + name). The write handler accepts names up to 31 bytes and app_settings_save_device_name persists them, so any name over 25 bytes produces a scan response of up to 37 bytes. Consequences:
- At rename time,
bt_le_adv_update_data()fails (onlyLOG_WRN). - After reboot,
transport_start()restores the saved name intobt_sdand callsbt_le_adv_start(), which rejects the oversized scan response — the code logs "continuing without BLE", so the device never advertises again. The user cannot connect to fix the name; recovery requires a reflash/factory reset.
Note the handler saves to NVS before calling update_advertising_name(), so a rejected update does not roll the name back. Possible fixes (any one): clamp the persisted name to the actual budget (25 bytes given the UUID16 element), drop the UUID16 element from bt_sd, or reject writes where 4 + 2 + len > 31 inside settings_device_name_write_handler.
Blocking: bt_set_name() path is compiled out and name fields conflict (transport.c)
CONFIG_BT_DEVICE_NAME_DYNAMIC is not enabled in omi/firmware/omi/omi.conf (only CONFIG_BT_GATT_DYNAMIC_DB is set), so both #if defined(CONFIG_BT_DEVICE_NAME_DYNAMIC) blocks are dead code — the bt_set_name() behavior described in the PR summary does not exist in this build. Also, bt_ad still carries BT_DATA_NAME_COMPLETE CONFIG_BT_DEVICE_NAME ("Omi") while bt_sd carries the custom name, so scanners see two conflicting name fields. Either enable the Kconfig (and remove the static name from bt_ad), or drop the guarded blocks and update the description to match the actual behavior.
Smaller notes (non-blocking):
app/lib/pages/settings/device_settings.dart: whenensureConnection()returnsnull, no rename happens, but the dialog still closes and shows the "Device name: X" success snackbar — please show a failure message on that path. (The controller disposal viawhenCompleteand the cachedScaffoldMessengerare handled well.)app/lib/services/devices/connectors/omi_connection.dart:bytes.sublist(0, 31)can split a multi-byte UTF-8 sequence (the dialog'smaxLength: 31counts characters, not bytes). Clamping on a codepoint boundary would avoid writing invalid UTF-8 to the device.device_onboard_rename_test.dart: "keeps original name whengetDeviceNamethrows" does not actually exercise a throw — the mock returns empty, making it identical to the preceding absence test.device_connection.dart: the base-class no-opperformSetDeviceName/performGetDeviceNamedefaults follow the existing mic-gain pattern — fine.settings.h/settings.c: thesettings_setbounds checks and null-termination are sound, and boot ordering (app_settings_init()beforetransport_start()) correctly applies the saved name before advertising starts; part of thesettings.cdiff is clang-format churn on unrelated lines.- There is no firmware build in CI, so none of the firmware above was compiled or exercised there — could you share how the firmware side was validated on hardware, in particular a rename with a name longer than 25 bytes followed by a reboot?
The new GATT characteristic (19b10014-…), the final advertising-payload layout, and the #2824 bounty settlement are product/firmware-maintainer decisions, so leaving those for maintainer sign-off alongside the fixes.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
Hi @Git-on-my-level, |
47e0de8 to
88e50ad
Compare
woahwhattheheck
left a comment
There was a problem hiding this comment.
Exact-head follow-up on 88e50adac2d7ce65a2678567042cc20d2eefab1c: the Sep 18 firmware blockers are repaired on this head. The scan-response budget is now 25 bytes, CONFIG_BT_DEVICE_NAME_DYNAMIC=y, the static advertising-name conflict is removed, the null-connection success path is fixed, and the throwing mock is real. The current PR-triggered workflows are all green.
One acceptance mismatch remains for non-ASCII names: the UI limits characters (maxLength: 25), while the firmware/scan-response contract limits UTF-8 bytes (MAX_DEVICE_NAME_PAYLOAD_LEN = 25). performSetDeviceName() silently truncates by codepoint to that byte budget. For example, the new test intentionally turns 一二三四五六七八九十 into 一二三四五六七八. But _showRenameDeviceDialog then caches the untruncated newName into both pairedDevice and connectedDevice, persists that full value once, calls refreshDeviceInfo() (which corrects pairedDevice from the GATT readback but does not replace connectedDevice), and shows a success snackbar built from the original untruncated name. The device/second phone therefore owns one name while at least the live connectedDevice and success UI can claim another.
That cuts directly across #2824's cross-phone/onboard-persistence acceptance target. I would make truncation explicit rather than silent: validate UTF-8 byte length in the dialog and reject >25-byte input with a localized error, or have setDeviceName return/read back the canonical device value and update every provider field + success message from that confirmed value. Please add a production-facing multibyte regression proving the displayed/cached name equals the onboard value after rename.
Separate proof gap: this head still changes Zephyr firmware while the normal PR workflows do not run the manual-only CV1 firmware build. Eight hosted workflows are green, but they are not firmware compile/hardware evidence. A real CV1 build plus rename → reboot → second-phone discovery remains the strongest acceptance proof.
88e50ad to
afcc374
Compare
|
Hi @woahwhattheheck @Git-on-my-level, Thank you for the pinpoint feedback on the non-ASCII character vs UTF-8 byte mismatch! We have addressed the acceptance gap in the latest commit:
The branch has also been cleanly rebased onto the latest |
cf1af55 to
af68a93
Compare
|
Friendly ping @woahwhattheheck @Git-on-my-level: |
af68a93 to
3c4e20c
Compare
e4ffa0e to
7137cd6
Compare
|
Follow-up on 7137cd6: the byte-vs-character truncation gap from the last review round is closed, and the app-side acceptance path now holds together end to end. Verified in this diff:
Two small non-blocking notes:
Still open from earlier rounds: no firmware build runs in CI, so the Zephyr side remains compile-unverified here. A CV1 build plus a rename → reboot → second-phone discovery walkthrough is the acceptance proof for #2824 before this leaves draft. The firmware GATT contract, advertising layout, and #2824 bounty settlement are maintainer calls — leaving for maintainer sign-off. by AI on behalf of David |
Dismissed as stale: both firmware blockers from this review (scan-response 31-byte overflow via >25-byte names; CONFIG_BT_DEVICE_NAME_DYNAMIC compiled out plus conflicting name fields in bt_ad/bt_sd) are resolved on the current head 7137cd6 — the write handler now rejects >25-byte payloads and non-zero offsets, the Kconfig is enabled, and the static name was removed from bt_ad.
|
Quick addendum beyond the earlier round of feedback on this head (which still stands):
Still with the maintainer queue for on-hardware validation (GATT write → NVS persist → advertising update → reboot → second-phone discovery) and the #2824 bounty call. by AI on behalf of David |
7137cd6 to
f3a5f21
Compare
|
Thanks @shuoYun114 — this addresses exactly what was missing from the earlier attempts at #2824: maintainer feedback on #3111 explicitly asked for onboard firmware persistence, and this delivers it end to end. I went through the full diff; the overall shape looks solid and cohesive (firmware + the app half of the same feature), so I'm reviewing it as one unit. Firmware side:
App side:
Non-blocking things to consider before marking ready:
Nice work on a bounty that several earlier PRs couldn't close. Since this changes firmware GATT/NVS behavior and BLE advertising, it needs on-device validation and a maintainer sign-off before merge — leaving for human maintainer review, no urgency beyond that. 🤖 This was an AI-generated review on behalf of the maintainers. The author of this PR is entitled to the bounty reward associated with issue #2824, if this PR is accepted by the maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
f3a5f21 to
53cff54
Compare
There was a problem hiding this comment.
1 issue found across 12 files
Confidence score: 3/5
- In
omi_connection.dart, a rename can be reported as successful when the device is missing the required characteristic. Make unavailable writes observable so callers can report the failure.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/lib/services/devices/connectors/omi_connection.dart">
<violation number="1" location="app/lib/services/devices/connectors/omi_connection.dart:1267">
P2: This reports a successful rename when the device lacks the characteristic: `NativeBleTransport.writeCharacteristic` logs and returns normally for missing characteristics. Make unavailable writes observable so callers can report failure.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| Future<void> performSetDeviceName(String name) async { | ||
| try { | ||
| final clampedBytes = truncateUtf8ToBytes(name.trim(), maxDeviceNameBytes); | ||
| await transport.writeCharacteristic( |
There was a problem hiding this comment.
P2: This reports a successful rename when the device lacks the characteristic: NativeBleTransport.writeCharacteristic logs and returns normally for missing characteristics. Make unavailable writes observable so callers can report failure.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/services/devices/connectors/omi_connection.dart, line 1267:
<comment>This reports a successful rename when the device lacks the characteristic: `NativeBleTransport.writeCharacteristic` logs and returns normally for missing characteristics. Make unavailable writes observable so callers can report failure.</comment>
<file context>
@@ -1243,6 +1245,57 @@ class OmiDeviceConnection extends DeviceConnection {
+ Future<void> performSetDeviceName(String name) async {
+ try {
+ final clampedBytes = truncateUtf8ToBytes(name.trim(), maxDeviceNameBytes);
+ await transport.writeCharacteristic(
+ settingsServiceUuid,
+ settingsDeviceNameCharacteristicUuid,
</file context>
|
Follow-up on the two commits pushed after the last review round — the empty-name/unset semantics and the dialog localization now hold together cleanly:
Still pending maintainer on-hardware validation (GATT write → NVS persist → advertising update → reboot → second-phone discovery) and the #2824 bounty ruling; leaving for human maintainer review. by AI on behalf of David |
|
Addressed all feedback items from @cubic-dev-ai and @Git-on-my-level in commit 418fa5a: |
@shuoYun114 Good progress — checked commit 418fa5a against the open review items, and most of them are genuinely closed in this diff:
One item from the Oct 5 review is still open: the over-budget error So "all feedback" isn't quite complete — the localization gap in that one string remains. The on-hardware validation (GATT write → NVS persist → advertising update → reboot → second-phone discovery) is also still pending, but that's a maintainer process step rather than a code fix. Tip: get faster answers by chatting with cubic’s review copilot in the review UI |
d07aa7b to
7da4d47
Compare
- Firmware: add device_name GATT characteristic and NVRAM persistence in settings.c - Transport: broadcast custom device name via BLE advertising data - App: add device name GATT read/write to OmiDeviceConnection with 25-byte clamp - UI: integrate device rename dialog in DeviceInfoGroups and DeviceSettings aligned with modern design system - Provider: add refreshDeviceInfo() to force refresh cached device name
…, force connection and cleanup copyWith
7da4d47 to
5b28774
Compare
|
Thanks @shuoYun114 — this is one of the more complete attempts at #2824; the firmware-side persistence is what previous attempts were missing, and it shows. What I verified in the diff:
Points I'd like a firmware maintainer to weigh in on before this moves forward:
The large file count is almost entirely the regenerated app_localizations dart files (one new string, maxDeviceNameBytesExceeded, across ~48 locales); the hand-written diff is a reasonable size, and the change is cohesive around one feature, so no split needed. Since this is a draft, please treat the above as input for the next revision. Firmware BLE write-permission and advertising-context decisions need maintainer sign-off before merge. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…void blocking in bluetooth context
|
Hi @Git-on-my-level, |
|
Thanks @shuoYun114 — this addresses exactly the gap that closed the earlier attempts at #2824: the name now lives in the device's own persistent storage, which is what was asked for on #3111. I reviewed the full diff across the firmware and app layers; overall this is well built. A few file-level notes: Firmware
App
No security or privacy concerns found in the diff. Since this spans firmware and the GATT/NVS contract, it needs maintainer sign-off on hardware (the new characteristic, the NVS key, and the restructured advertising data can't be validated by CI alone) plus the #2824 bounty acceptance decision before it can move forward. The draft status also suggests you may have more to do — happy to re-review when you mark it ready. AI-generated maintainer feedback on behalf of the Omi maintainers by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks @shuoYun114 — this is the first #2824 attempt that actually stores the name in onboard firmware storage rather than phone-local prefs, which is exactly what earlier attempts were missing. The end-to-end shape looks right:
Two things to address before this can move:
The PR is cohesive (one feature spanning firmware and client), so no split is needed. Leaving for human maintainer review: a new writable GATT characteristic and changed BLE advertising behavior in the Omi firmware need maintainer sign-off, and the #2824 bounty acceptance itself is a maintainer call. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks for this thorough end-to-end implementation — this addresses the exact gap that closed earlier attempts at #2824 (onboard firmware persistence rather than phone-local storage). The engineering quality shows: Two items before this can move forward:
Minor, non-blocking: in Since this PR spans firmware BLE surface, persistent storage, and app UX for a paid bounty, human maintainer review is needed before merge (the Automated maintainer review on behalf of the maintainers. AI-generated feedback — human review pending. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks @shuoYun114 — the rename feature core is unchanged from the earlier review rounds and still holds together end to end. This pass focused on the delta since then: the merge commits One cleanup needed: unrelated localization keys are riding along. Beyond the rename strings, the l10n integration added roughly twenty keys that have nothing to do with this feature — Also worth noting: on this head the mobile checks (Dart Analyze & Tests, Android JVM Unit Tests, Generated Files) are all skipped, so the regenerated localization files haven't been CI-validated — a local For the record, the feature files re-checked on this head are as previously reviewed and still look right:
Leaving for human maintainer review — the firmware persistence contract and #2824 bounty acceptance need a maintainer sign-off, and the unrelated l10n keys above should be dropped first. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Closing and withdrawing this contribution due to maintainers retiring the bounty program and closing the associated bounties without compensation. Code is not licensed for upstream incorporation. |
|
Hey @shuoYun114 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
UI-Evidence: none
Failure-Class: none
Product invariants affected
Summary
/claim #2824
Resolves #2824 ($300 Paid Bounty 💰)
Problem & Historical Context
Previous attempts for this bounty (#3111, #3324, #4749, #5952, #13182, #13418) were closed or not accepted because they only implemented phone-local SharedPreferences storage without firmware onboard persistence. As maintainer @aaravgarg clarified on #3111:
Solution & Architectural Changes
This PR provides a complete, robust end-to-end implementation spanning both firmware and the Flutter client:
Firmware Onboard Persistence & Dynamic Advertising (Zephyr RTOS & NVS):
omi/device_namesetting key handling inomi/firmware/omi/src/settings.candsettings.h, loaded automatically on boot viasettings_load_subtree("omi")into memory cache.app_settings_save_device_name(const char *name)andapp_settings_get_device_name(void)with safe null-termination and bounds checking (MAX_DEVICE_NAME_PAYLOAD_LEN = 25,MAX_DEVICE_NAME_LEN = 26including null-terminator).19b10014-e8f2-537e-4f6c-d104768a1214) under Settings Service (19b10010-e8f2-537e-4f6c-d104768a1214) inomi/firmware/omi/src/lib/core/transport.c.bt_sd) with runtimebt_le_adv_update_data()andbt_set_name(). Fits strictly within the 31-byte scan-response budget (4 + 2 + 25 = 31). When a second or new phone scans for nearby devices prior to pairing, it immediately discovers the custom onboard name!offset != 0bounds defense preventing partial write corruption.Mobile App Communication & Synchronization (Flutter):
settingsDeviceNameCharacteristicUuid(19b10014-e8f2-537e-4f6c-d104768a1214) toOmiDeviceConnection.performSetDeviceNameandperformGetDeviceNamewith UTF-8 byte measurement and 25-byte clamp guards.setDeviceNameandgetDeviceNameto baseDeviceConnectionwith safe no-op defaults for other hardware types.Future getDeviceInfo() asyncsignature for 100% test stub backward-compatibility, and introducedFuture refreshDeviceInfo() asyncto bypass cached firmware version short-circuits and immediately reflect newly renamed hardware state.BtDevice._getDeviceInfoFromOmiso any phone (including a newly connected or second phone) automatically pulls the onboard custom name upon connection/handshake and updatesBtDevice.name.User Interface (Device Settings):
_buildDeviceInfoSectionofapp/lib/pages/settings/device_settings.dartfor Omi devices to be interactive (showChevron: true)._showRenameDeviceDialogwith dynamic UTF-8 byte validation, 25-byte limit warning (Max 25 bytes ($bytes bytes, non-ASCII uses multiple bytes)), disabling Save on overflow, empty input validation, loading indicator, and toast notifications on update.ScaffoldMessengerprior to async gaps and cleanly disposing text controllers.Testing & Verification:
app/test/unit/device_onboard_rename_test.dartcovering UTF-8 byte encoding, multi-byte length clamping (e.g. 30-byte Chinese input clamped to 24-byte '一二三四五六七八'), characteristic decoding, empty/whitespace fallbacks, real GATT read failure throwing, andBtDevicename synchronization.clang-format.Android Compile Smoke,Android JVM Unit Tests,Dart Analyze & Tests,Seeded Journeys (hermetic),Formatting,Hygiene, andOpenAPI Contractall pass.Reward / Bounty Settlement Details
TGKmfSUmt2dggErAo8BicaCoXhkMwLetxV1NkUnv23H65ZYJn64pseAcWRA6sJitxh2f[email protected]