fix: stop changing phone's Bluetooth device name during BLE advertising#630
Conversation
BleAdvertiser was temporarily setting bluetoothAdapter.name to
"RNS-{identity}" before each advertising start and refresh, then
restoring it after a 1-second delay. This caused the phone's visible
Bluetooth device name to change, which was unexpected and disruptive.
Remove all bluetoothAdapter.name assignments and set
setIncludeDeviceName(false) in the scan response. Device discovery
relies on the service UUID in the advertise data, not the device name.
https://claude.ai/code/session_018JqnJit5nfabGBysYU8QZ6
Greptile SummaryThis PR fixes an unintended side-effect in Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant App as BleAdvertiser
participant BTA as BluetoothAdapter
participant BLEA as BluetoothLeAdvertiser
participant Central as Remote Device
Note over App,Central: Before this PR (removed behaviour)
App->>BTA: name = "RNS-{identity}"
App->>BLEA: startAdvertising(scanResponse: includeDeviceName=true)
App-->>BTA: restore original name (after 1 s delay)
Note over App,Central: After this PR (new behaviour)
App->>BLEA: startAdvertising(advertiseData: serviceUUID only,<br/>scanResponse: includeDeviceName=false)
Central->>BLEA: scan / connect (discovers via service UUID)
Note over App: actualDeviceName used for logging only
|
…oval Update KDoc and inline comments that still referenced the old behavior of temporarily changing the phone's Bluetooth adapter name for BLE advertising. The code was already fixed but three comments were left behind referencing identity-based naming, payload constraints, and "name moved to scan response". https://claude.ai/code/session_018JqnJit5nfabGBysYU8QZ6
| // Do not include device name to avoid changing the phone's Bluetooth name. | ||
| // Devices discover us via the service UUID in the advertise data. | ||
| val scanResponseData = | ||
| AdvertiseData |
There was a problem hiding this comment.
Bug: The change removes the identity-based device name from BLE advertisements. The shouldSkipDiscoveredDevice function now fails to find the "RNS-" prefix, breaking the deduplication logic.
Severity: HIGH
Suggested Fix
Re-introduce a mechanism to broadcast the identity-based device name. This could involve restoring the logic that temporarily sets bluetoothAdapter.name before advertising, or finding an alternative way to include the identity in the advertisement or scan response data so that the shouldSkipDiscoveredDevice function can correctly parse it.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location:
reticulum/src/main/java/com/lxmf/messenger/reticulum/ble/server/BleAdvertiser.kt#L247
Potential issue: The PR removes the code that sets the `bluetoothAdapter.name` to an
identity-based string like `"RNS-{identity}"` and also stops including the device name
in the BLE advertisement packet. The scanner's fallback to `device.name` will now
retrieve the phone's system Bluetooth name, which lacks the expected `"RNS-"` or
`"Reticulum-"` prefix. Consequently, the `shouldSkipDiscoveredDevice` function will
always return `false`, effectively disabling the deduplication cooldown mechanism. This
could lead to reconnection loops with recently discovered devices.
Did we get this right? 👍 / 👎 to inform future reviews.
After removing the bluetoothAdapter.name assignment, the deviceName parameter in startAdvertisingInternal() became unused, which triggers detekt's UnusedPrivateMember rule. Remove the parameter and the now-unused local variable in refreshAdvertising(). https://claude.ai/code/session_018JqnJit5nfabGBysYU8QZ6
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
PR #630 stopped advertising device names in BLE scan responses. This made shouldSkipDiscoveredDevice() always return false since it relied on matching "RNS-"/"Reticulum-" prefixes in advertised names. The GATT-layer identity dedup remains intact. Removed: - shouldSkipDiscoveredDevice() and its scanner callback wrapper - recentlyDeduplicatedIdentities map + deduplicationCooldownMs - BleAdvertiser.setTransportIdentity() + transportIdentityHash - IDENTITY_BYTES_IN_ADVERTISED_NAME constant - 15 dead tests and 6 dead test helpers - Stale detekt baseline entry and docs references Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…edup-code Remove dead name-based dedup code after PR #630
PR torlando-tech#630 stopped advertising device names in BLE scan responses. This made shouldSkipDiscoveredDevice() always return false since it relied on matching "RNS-"/"Reticulum-" prefixes in advertised names. The GATT-layer identity dedup remains intact. Removed: - shouldSkipDiscoveredDevice() and its scanner callback wrapper - recentlyDeduplicatedIdentities map + deduplicationCooldownMs - BleAdvertiser.setTransportIdentity() + transportIdentityHash - IDENTITY_BYTES_IN_ADVERTISED_NAME constant - 15 dead tests and 6 dead test helpers - Stale detekt baseline entry and docs references Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
BleAdvertiser was temporarily setting bluetoothAdapter.name to
"RNS-{identity}" before each advertising start and refresh, then
restoring it after a 1-second delay. This caused the phone's visible
Bluetooth device name to change, which was unexpected and disruptive.
Remove all bluetoothAdapter.name assignments and set
setIncludeDeviceName(false) in the scan response. Device discovery
relies on the service UUID in the advertise data, not the device name.
https://claude.ai/code/session_018JqnJit5nfabGBysYU8QZ6