Skip to content

Fix BLE name fallback to T1000-E-BOOT for long node names#1801

Open
andrewdefilippis wants to merge 2 commits intomeshcore-dev:devfrom
andrewdefilippis:t1000e-ble-name-fix-v2
Open

Fix BLE name fallback to T1000-E-BOOT for long node names#1801
andrewdefilippis wants to merge 2 commits intomeshcore-dev:devfrom
andrewdefilippis:t1000e-ble-name-fix-v2

Conversation

@andrewdefilippis
Copy link
Copy Markdown

@andrewdefilippis andrewdefilippis commented Feb 22, 2026

Fixes #1769; concatenates head and tail of name to fix BLE name length constraint.

The Nordic SoftDevice S140 defaults to a 31-byte maximum GAP device
name. When "MeshCore-" (9 bytes) + node_name exceeds 31 bytes (i.e.
node names >= 23 chars), sd_ble_gap_device_name_set() silently fails
and the name falls back to USB_PRODUCT ("T1000-E-BOOT").

Add UTF-8 safe middle-truncation that preserves the beginning and end
of the node name (where users place emoji and device-type identifiers),
fitting the result within the 29-byte scan response limit so it
advertises as COMPLETE_LOCAL_NAME.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@andrewdefilippis
Copy link
Copy Markdown
Author

Verified fixed on my updated device. I have two T1000-E devices. Screenshot shows updated versus not updated device naming.

image

Comment thread src/helpers/nrf52/SerialBLEInterface.cpp Outdated
Comment thread src/helpers/nrf52/SerialBLEInterface.cpp
The original implementation accepted dest_size but only used it in the
snprintf fast path — manual memcpy assembly could overwrite the buffer
if a future caller passed a smaller destination. Additionally, an
unsigned underflow on name_budget when prefix_len >= BLE_NAME_MAX_LEN
could cascade into massive write lengths.

- Clamp all output to min(dest_size-1, BLE_NAME_MAX_LEN) via max_out
- Guard against prefix_len >= max_out to prevent unsigned underflow
- Validate UTF-8 continuation bytes in utf8CharLen to handle malformed
  node names (truncated sequences, missing continuations)
- Fix backward tail walk to detect malformed sequence at name[0]

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@spfmoby
Copy link
Copy Markdown

spfmoby commented Mar 31, 2026

Any reason not to merge this simple PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants