-
-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Description
I'm investigating an issue where bluetooth.connect() fails to resolve the promise when a serviceUUID falls under the Bluetooth Assigned Numbers list:
- BT specification: https://www.bluetooth.com/specifications/assigned-numbers/
my project versions:
{
"@nativescript/core": "^8.4.1",
"@nativescript-community/ble": "^3.1.11",
}
the call to bluetooth.connect():
await this.bluetooth.connect({
UUID: deviceUuid,
// autoDiscoverAll causes the hang... but only for those Assigned Number serviceUUIDs (link above)
autoDiscoverAll: true,
onConnected: (peripheral) => {
// the onConnected() callback is never called...
},
onDisconnected: function (peripheral) {
// onDisconnected IS called, on disconnect
}
});
I have tracked the problem down to:
https://github.com/nativescript-community/ble/blob/master/src/bluetooth.ios.ts#L1643-L1644
@bluetoothEnabled
@prepareArgs
public discoverCharacteristics(args: DiscoverCharacteristicsOptions) {
// ...
const sUUID = CBUUIDToString(service.UUID);
if (UUID === pUUID && sUUID === args.serviceUUID) {
// ...
}
// ...
}
the issue is the following comparison fails:
# "0000181a-0000-1000-8000-00805f9b34fb" == "181a"
sUUID === args.serviceUUID
args.serviceUUID is being be modified by the decorator prepareArgs()
to a "Short UUID", if the service's UUID matches a Bluetooth Assigned Number of the form
const pattern = /0000(.{4})-0000-1000-8000-00805f9b34fb/;
however, sUUID returned by CBUUIDToString(service.UUID)
is a "Long UUID"
Long vs Short UUIDs:
I'll work on a fix and submit a PR today hopefully...
Metadata
Metadata
Assignees
Labels
No labels