Repository navigation
feat: onboard BLE device rename with Zephyr NVS persistence & settings UI (#2824) - #23938
malek-bounties wants to merge 4 commits into
Conversation
|
Verdict: the implementation direction is right and correctly targets the onboard-persistence requirement from #2824 (name stored in device NVS, readable by a new phone), and I found no blocking correctness bug — but three concrete issues should be addressed before this is merge-ready. What looks good:
To address:
Security note: the new characteristic is plain READ|WRITE like the neighboring settings characteristics, so anyone in BLE range can rename a device. That matches the existing service posture (mic gain, dim ratio), so I'm not requesting a change — just maintainer sign-off that this is acceptable. USER IMPACT: users can rename their Omi in Device Settings; the custom name persists on the device itself and shows up on other phones, with a phone-local fallback for older firmware. What I'd still want as a reviewer: a firmware build confirmation (no CI ran on the omi/firmware changes in this PR), a test documenting the intended behavior when the onboard write fails after a local alias save, and on-hardware verification of the rename + re-advertise path — and note that #13182, #14289, and #14558 are also open for #2824, so a maintainer will need to pick which candidate carries the feature. Leaving for human maintainer review: choosing among the competing open #2824 PRs and signing off on the firmware BLE surface are maintainer calls, not mine. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…UTF-8 bytes (BasedHardware#2824) - renameDevice() now returns DeviceRenameResult; after writing 0x19B10014 it reads the name back and reports deviceWriteFailed on write error, read error or mismatch instead of silently succeeding. - Device settings shows a localized snackbar (deviceNameSaveFailed, 49 locales) when the name was saved on the phone but not on the Omi. - App alias budget is now the firmware's 25-byte UTF-8 limit (SharedPreferencesUtil.maxDeviceNameBytes) instead of 40 characters; the rename field uses a UTF-8 byte-limit formatter with a byte counter. - Tests for read-back success/failure paths, byte-based validation and the formatter.
…ceeds (BasedHardware#2824) Keeps the 0x19B10014 read-back truthful: if settings_save_one() fails the characteristic keeps returning the previous (persisted) name.
|
Verdict: this is a well-built, cohesive feature — firmware + app rename with a verified read-back and genuinely good test coverage. Nothing blocking from my side; a few non-blocking findings and two checks I'd want before a maintainer merges. I verified the main behavioral claim: transport.c moves the BLE name out of the advertisement (bt_ad) into the scan response (bt_sd) to fit the 31-byte budget with a 25-byte name. I checked app/lib/services/devices/discovery/native_bluetooth_discoverer.dart on main — Omis are classified solely by service UUID (_hasService(p, omiServiceUuid)) and bt_ad still carries the audio service UUID, so app discovery is unaffected. The name stays visible in the scan response and via GAP (bt_set_name), which active scanners read. Non-blocking findings:
Two checks before merge: (1) confirm CONFIG_BT_DEVICE_NAME_MAX >= 26 in this build so bt_set_name() doesn't truncate the GAP name (the scan response is set directly and is unaffected); (2) no CI check runs are visible on this PR at all — please make sure the app test suite runs on this head. What's notably good: settings.c persists to NVS first and only adopts the name in RAM after flash accepts it, so a GATT read-back can never report a name that would be lost on reboot; the 25-byte UTF-8 budget is enforced consistently at three layers (validator in preferences.dart, byte-limit formatter with a byte counter in device_settings.dart, and truncateUtf8ToBytes in omi_connection.dart which refuses to split a codepoint); device_onboard_rename_test.dart covers the multi-byte boundary, GATT read/write failures, and an acked-but-dropped write caught by the read-back. Blast radius: the writable characteristic needs no encryption/auth — the same trust model as the existing settings characteristics (mic gain, dim ratio), and a display name is non-sensitive. The advertising-layout change is visible to every BLE observer of the device, not just the app. USER IMPACT: users can rename their Omi in Device Settings; with new firmware the name persists on the device itself and shows up on other phones, with a phone-local fallback name on older firmware. Leaving for human maintainer review: this adds a new cross-surface firmware protocol (a new GATT characteristic and a change to the advertising layout) plus an alias-precedence product decision — a firmware maintainer should sign off on the protocol and adv changes. This review was produced by the repo's automated maintainer-review assistant 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 |
Fixes #2824
Summary
Lets users rename their Omi from Device Settings → Device Name. The name is stored on the device (Zephyr settings/NVS), re-advertised over BLE, and read by any phone that connects, with a phone-local alias as a fallback for older firmware.
How it works (matches the diff)
Firmware (
omi/firmware/omi/)omi.conf:CONFIG_BT_DEVICE_NAME_DYNAMIC=y.settings.h/settings.c:MAX_DEVICE_NAME_PAYLOAD_LEN = 25bytes,app_settings_save_device_name()/app_settings_get_device_name(), persisted under settings keyomi/device_name. The in-RAM name is only replaced aftersettings_save_one()succeeds, so a read-back never reports a name that would be lost on reboot.transport.c: new characteristic19B10014-E8F2-537E-4F6C-D104768A1214(READ | WRITE | NOTIFY) in the existing settings service, next to dim ratio (…0011), mic gain (…0012) and charging status (…0013). Writes reject a non-zero offset, zero length and anything over 25 bytes. A successful write saves to NVS, callsbt_set_name(), and updates the scan response through a work item. At boot,transport_start()re-applies the saved name before advertising. The name moves from the advertisement into the scan response. Discovery still works because the app matches Omi devices by service UUID.App (
app/lib/)omi_connection.dart:performSetDeviceName()/performGetDeviceName()on…0014, with UTF-8 truncation that won't split a character (truncateUtf8ToBytes,maxDeviceNameBytes = 25).getDeviceInfo()reads the onboard name, so a new phone shows it.DeviceConnectionprovides safe defaults (setDeviceName→ false,getDeviceName→ null,supportsOnboardDeviceName→ false). Only Omi connections opt in.preferences.dart: phone-local alias underdeviceAlias:<deviceId>. Validation uses the same 25-byte UTF-8 budget as the firmware (maxDeviceNameBytes,isValidDeviceName), not a character count, so the renaming phone and every other phone show the same name.device_provider.dart:renameDevice()returns aDeviceRenameResult:savedOnDevice: the BLE write succeeded and a read-back of…0014matched.deviceWriteFailed: the alias was saved on the phone, but the onboard write threw or was rejected, the read-back failed, or the read-back didn't match (this covers old firmware without the characteristic).savedLocally: the device isn't connected, or the connection type can't store a name.failed: the name is invalid or over budget, the device is unknown, or the alias couldn't be saved.The alias is re-applied in
setConnectedDevice()/getDeviceInfo()and cleared on Forget Device.device_settings.dart/device_info_groups.dart: tapping the Device Name row opens_renameDevice. The text field caps input at 25 UTF-8 bytes (Utf8ByteLimitFormatter) and shows a byte counter (n/25). If the result isdeviceWriteFailed, a localized error snackbar says the name was saved only on this phone (deviceNameSaveFailed, translated in all 49 locales).Changelog:
app/changelog/unreleased/onboard-device-rename.json.Review feedback addressed
Verification
flutter test test/unit/device_onboard_rename_test.dart test/providers/device_provider_test.dart: 58/58 pass (16 rename/connection tests, 42 provider tests including the existing suite).flutter analyzeon every touched Dart file: no errors and no warnings. The only notices are pre-existingavoid_print/ naming infos inomi_connection.dart.dart format -l 120is clean.Not verified (honest disclosure)
omi.conf,settings.h,settings.c,transport.c) with the nRF Connect SDK / Zephyr toolchain, and no CI ran onomi/firmwarefor this PR.…0014is plain READ/WRITE, like the neighboring settings characteristics, so anyone in BLE range could rename a device. This needs maintainer sign-off.