Skip to content

Validate buttonless DFU advertising name length#562

Open
nrbrook wants to merge 1 commit intonordicsemi:mainfrom
nrbrook:name-length-fix
Open

Validate buttonless DFU advertising name length#562
nrbrook wants to merge 1 commit intonordicsemi:mainfrom
nrbrook:name-length-fix

Conversation

@nrbrook
Copy link
Copy Markdown
Contributor

@nrbrook nrbrook commented May 5, 2026

Summary

  • Validate buttonless DFU advertising name requests against the current write-with-response payload before writing.
  • Preserve user-specified names instead of truncating them, and fail with DFUError.invalidAdvertisementName when the name is too long for the current connection.
  • Document the conservative 18-byte limit for default ATT MTU and the runtime MTU-dependent behavior.

Problem

The existing implementation truncates a user-specified alternative advertising name to 20 bytes, matching the buttonless DFU service's maximum advertising name length. However, the full set-name write also includes the opcode and length byte, so a 20-byte name requires a 22-byte ATT write payload.

With the default ATT MTU, the write-with-response payload can be only 20 bytes. In that case, CoreBluetooth may send the oversized set-name command using ATT Prepare Write requests instead of a single ATT Write Request. Nordic's buttonless DFU set-name command is handled as a single write, and does not respond to prepare write, resulting in a connection timeout.

This change validates against the actual maximumWriteValueLength(for: .withResponse) at runtime. User-specified names that do not fit fail clearly instead of being truncated.

Fail oversized user-specified advertising names before CoreBluetooth can fall back to ATT Prepare Write, which is not handled by Nordic's buttonless DFU set-name command.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 5, 2026

CLA assistant check
All committers have signed the CLA.

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.

2 participants