noble
noble copied to clipboard
macOSX binding for 'readValue()' causes crash
When running the following example on macOSX machine:
node node_modules/@abandonware/noble/examples/peripheral-explorer-async.js a4-c1-38-82-a4-83
I get the following output and a crash at the end:
> node node_modules/@abandonware/noble/examples/peripheral-explorer-async.js a4-c1-38-82-a4-83
Peripheral with ID 7a95243d5b874477a300834c07ea1ada found
Local Name = LYWSD03MMC
Service Data = [
{
"uuid": "fe95",
"data": {
"type": "Buffer",
"data": [
48,
88,
91,
5,
1,
131,
164,
130,
56,
193,
164,
40,
1,
0
]
}
}
]
Services and characteristics:
180a (Device Information)
2a24 (Model Number String)
properties read
value 4c5957534430334d4d4300 | 'LYWSD03MMC'
2a25 (Serial Number String)
properties read
value 46312e302d43464d4b2d4c422d464c442d2d2d2d | 'F1.0-CFMK-LB-FLD----'
2a26 (Firmware Revision String)
properties read
value 312e302e305f3031303900 | '1.0.0_0109'
2a27 (Hardware Revision String)
properties read
value 42312e34 | 'B1.4'
2a28 (Software Revision String)
properties read
value 3031303900 | '0109'
2a29 (Manufacturer Name String)
properties read
value 6d69616f6d69616f63652e636f6d00 | 'miaomiaoce.com'
180f (Battery Service)
2a19 (Battery Level)
properties read, notify
value 63 | 'c'
000102030405060708090a0b0c0d1912
2022-05-01 17:30:18.140 node[68333:12204633] -[NSTaggedPointerString bytes]: unrecognized selector sent to instance 0x486ca73b7029c609
2022-05-01 17:30:18.141 node[68333:12204633] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString bytes]: unrecognized selector sent to instance 0x486ca73b7029c609'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff2054829b __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff20281d92 objc_exception_throw + 48
2 CoreFoundation 0x00007fff205caddd -[NSObject(NSObject) __retain_OA] + 0
3 CoreFoundation 0x00007fff204b030b ___forwarding___ + 1448
4 CoreFoundation 0x00007fff204afcd8 _CF_forwarding_prep_0 + 120
5 binding.node 0x000000010446f4b0 -[BLEManager peripheral:didUpdateValueForDescriptor:error:] + 896
6 CoreBluetooth 0x00007fff30967caa -[CBPeripheral handleAttributeEvent:args:attributeSelector:delegateSelector:delegateFlag:] + 219
7 CoreBluetooth 0x00007fff30967e74 -[CBPeripheral handleDescriptorEvent:descriptorSelector:delegateSelector:delegateFlag:] + 113
8 CoreBluetooth 0x00007fff309644f6 -[CBPeripheral handleMsg:args:] + 291
9 CoreBluetooth 0x00007fff30959dda -[CBCentralManager handleMsg:args:] + 189
10 CoreBluetooth 0x00007fff3094c037 -[CBManager xpcConnectionDidReceiveMsg:args:] + 177
11 CoreBluetooth 0x00007fff3094bf73 __30-[CBXpcConnection _handleMsg:]_block_invoke + 66
12 libdispatch.dylib 0x00007fff2022b623 _dispatch_call_block_and_release + 12
13 libdispatch.dylib 0x00007fff2022c806 _dispatch_client_callout + 8
14 libdispatch.dylib 0x00007fff202325ea _dispatch_lane_serial_drain + 606
15 libdispatch.dylib 0x00007fff202330e0 _dispatch_lane_invoke + 417
16 libdispatch.dylib 0x00007fff20232493 _dispatch_lane_serial_drain + 263
17 libdispatch.dylib 0x00007fff202330ad _dispatch_lane_invoke + 366
18 libdispatch.dylib 0x00007fff2023cc0d _dispatch_workloop_worker_thread + 811
19 libsystem_pthread.dylib 0x00007fff203d345d _pthread_wqthread + 314
20 libsystem_pthread.dylib 0x00007fff203d242f start_wqthread + 15
)
libc++abi: terminating with uncaught exception of type NSException
Drilling down the callstack shows that in node_modules/@abandonware/noble/lib/noble.js
this code is the last JavaScript code executed:
// defined by Noble.prototype.readValue = function (peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid) {
this._bindings.readValue(peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid);
Here the values of the parameters:
- peripheralUuid = "7a95243d5b874477a300834c07ea1ada"
- serviceUuid = "000102030405060708090a0b0c0d1912"
- characteristicUuid = "000102030405060708090a0b0c0d2b12"
- descriptorUuid = "2901"
Compared to "nRF Connect" on my Android phone the values are correct (don't know about peripheralUuid).
Versions:
- macOSX: Big Sur 11.6.5
- XCode: 13.2.1
- @abandonware/noble: github:abandonware/noble#203824af98f94374322950c08b1ca19c6f7a80e4" (from 2022-05-01)