-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
darwin: properly handle 16-bit UUIDs for service and characteristics #50
Conversation
…in the unique format used by macOS Signed-off-by: Ron Evans <ron@hybridgroup.com>
Tested on both Catalina and Big Sur, so this seems ready to merge. |
d.prph.DiscoverServices(cbuuids) | ||
d.prph.DiscoverServices([]cbgo.UUID{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you no longer passing the uuids
slice to DiscoverServices
? See the documentation:
Note
If the
servicesUUIDs
parameter isnil
, this method returns all of the peripheral’s available services. This is much slower than providing an array of service UUIDs to search for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not actually working, it seems. Not sure if that is because of cbgo or something else. I tried a whole bunch of different things but could not get it to work as documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is unfortunate. What if you put in a literal nil
instead of []cbgo.UUID{}
? (That's in fact semantically different, []cbgo.UUID{}
is not equal to nil
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the source of cbgo that is unlikely to have an effect. I'm working on a possible patch to cbgo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, I was confused.
This is indeed rather unfortunate. Maybe you can raise a bug at the cbgo repository?
uuid[0] = 0x00000000 | ||
uuid[1] = 0x00000000 | ||
uuid[2] = 0x00000000 | ||
uuid[3] = uint32(shortUUID) << 16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If MacOS uses this nonstandard format, then 🤷
It's a bit weird though, as the Bluetooth specification has clearly specified how to encode 16-bit UUIDs in a 128-bit UUID. Other platforms use that standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what is returned by cbgo, hence why I had to make these changes.
macOS does some various other things with anonymizing BLE info, but beats me why this is the case.
One alternative to consider to the change to |
I have submitted an issue into the cbgo repo @aykevl In the meantime, I would prefer to not make any further changes to this PR unless absolutely needed. We can work on macOS further in future iterations. |
This PR properly handles the 16-bit UUIDs for service and characteristics in the unique format used by macOS.