Skip to content

gap: read 128-bit service data UUIDs in little endian - #526

Open
Moret84 wants to merge 1 commit into
tinygo-org:devfrom
CrossoverTechnologies:raw-service-data-uuid-byte-order
Open

Moret84 wants to merge 1 commit into
tinygo-org:devfrom
CrossoverTechnologies:raw-service-data-uuid-byte-order

Conversation

@Moret84

@Moret84 Moret84 commented Oct 30, 2026

Copy link
Copy Markdown

rawAdvertisementPayload.ServiceData read the UUID of a Service Data 128-bit UUID field with NewUUID, which expects big endian. The field is little endian, as addServiceData writes it and as ServiceUUIDs reads 128-bit UUID lists, so the UUID came out with its bytes reversed.

This changes the UUID that the HCI and SoftDevice backends report. Code that compared it with the reversed value will stop matching. Linux and macOS get the UUID from the OS and do not change.

TestCreateAdvertisementPayload now checks the decoded 128-bit UUID. It fails without the fix.

The HCI backend has the same reversal for 128-bit service UUID lists in gap_hci.go. This PR does not touch it.

The UUID of a Service Data - 128-bit UUID field is sent in little endian,
like addServiceData writes it, but ServiceData read it as big endian and
returned the UUID with its bytes reversed.
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.

1 participant