Validate buttonless DFU advertising name length#562
Open
nrbrook wants to merge 1 commit intonordicsemi:mainfrom
Open
Validate buttonless DFU advertising name length#562nrbrook wants to merge 1 commit intonordicsemi:mainfrom
nrbrook wants to merge 1 commit intonordicsemi:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DFUError.invalidAdvertisementNamewhen the name is too long for the current connection.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.