react-native-ble-plx: Question: BleError: Characteristic xxx read failed for device xxx and service xxx
Prerequisites
I am using "react-native-ble-plx": "^2.0.3",
Question
Thank you in advance for your help 😁. I really appreciate all the hard work you put into this amazing package ♥️.
I am getting an error when running the below code after what seems to be a successful scan:
export let tryToConnectToDevice = async device => {
console.log('try to connect to device')
await manager().stopDeviceScan()
events.triggerEvent(eventNames.searchingEnded)
let d = await manager().connectToDevice(device.id)
console.log('connected to device: ', bluetoothContracts.cleanUpBtShit(d))
let dCheck = await manager().connectedDevices([serviceAndCharacteristicIds.service])
console.log('connectedDevices: ', dCheck)
let servicesAndCharacteristics = await d.discoverAllServicesAndCharacteristics()
console.log(
'servicesAndCharacteristics: ',
bluetoothContracts.cleanUpBtShit(servicesAndCharacteristics),
)
let services = await manager().servicesForDevice(d.id)
console.log('services: ', services)
let characteristics = await manager().characteristicsForDevice(
d.id,
serviceAndCharacteristicIds.service,
)
console.log('characteristics: ', characteristics)
if (characteristics[0]?.uuid == serviceAndCharacteristicIds.tx) {
let characteristic = await manager().readCharacteristicForDevice(
d.id,
serviceAndCharacteristicIds.service,
serviceAndCharacteristicIds.tx,
)
console.log('readCharacteristicForDevice: ', characteristic)
} else {
await manager().cancelDeviceConnection(d.id)
}
}
console:
LOG try to connect to device
LOG connected to device: {"_manager": {"_activePromises": {}, "_activeSubscriptions": {"1": [Object]}, "_eventEmitter": {"_nativeModule": [Object]}, "_scanEventSubscription": null, "_uniqueId": 4}, "id": "xxx", "isConnectable": null, "localName": null, "manufacturerData": null, "mtu": 23, "name": "xxx", "overflowServiceUUIDs": null, "rssi": null, "serviceData": null, "serviceUUIDs": null, "solicitedServiceUUIDs": null, "txPowerLevel": null}
LOG connectedDevices: [{"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 5}, "id": "xxx", "isConnectable": null, "localName": null, "manufacturerData": null, "mtu": 23, "name": "xxx", "overflowServiceUUIDs": null, "rssi": null, "serviceData": null, "serviceUUIDs": null, "solicitedServiceUUIDs": null, "txPowerLevel": null}]
LOG servicesAndCharacteristics: {"_manager": {"_activePromises": {}, "_activeSubscriptions": {"1": [Object]}, "_eventEmitter": {"_nativeModule": [Object]}, "_scanEventSubscription": null, "_uniqueId": 7}, "id": "xxx", "isConnectable": null, "localName": null, "manufacturerData": null, "mtu": 23, "name": "xxx", "overflowServiceUUIDs": null, "rssi": null, "serviceData": null, "serviceUUIDs": null, "solicitedServiceUUIDs": null, "txPowerLevel": null}
LOG services: [{"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 8}, "deviceID": "xxx", "id": 10791587712, "isPrimary": true, "uuid": "xxx"}]
LOG characteristics: [{"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "xxx", "id": 10740079456, "isIndicatable": false, "isNotifiable": true, "isNotifying": false, "isReadable": false, "isWritableWithResponse": false, "isWritableWithoutResponse": false, "serviceID": 10791587712, "serviceUUID": "xxx", "uuid": "xxx", "value": "AK5tAw=="}, {"_manager": {"_activePromises": [Object], "_activeSubscriptions": [Object], "_eventEmitter": [NativeEventEmitter], "_scanEventSubscription": null, "_uniqueId": 9}, "deviceID": "xxx", "id": 10740079840, "isIndicatable": false, "isNotifiable": false, "isNotifying": false, "isReadable": false, "isWritableWithResponse": true, "isWritableWithoutResponse": true, "serviceID": 10791587712, "serviceUUID": "xxx", "uuid": "xxx", "value": null}]
WARN Possible Unhandled Promise Rejection (id: 0):
BleError: Characteristic xxx read failed for device xxx and service xxx
BleError: Characteristic xxx read failed for device xxx and service xxx
at construct (native)
at apply (native)
at _construct (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:3348:28)
at Wrapper (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:3310:25)
at construct (native)
at _createSuperInternal (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:103132:322)
at call (native)
at BleError (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:103140:26)
at parseBleError (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:103170:30)
at ?anon_0_ (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:103394:47)
at throw (native)
at asyncGeneratorStep (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:4644:26)
at _throw (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:4666:29)
at tryCallOne (/Users/distiller/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:53:16)
at anonymous (/Users/distiller/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:139:27)
at apply (native)
at anonymous (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:29744:26)
at _callTimer (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:29663:17)
at _callReactNativeMicrotasksPass (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:29693:17)
at callReactNativeMicrotasks (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:29856:44)
at __callReactNativeMicrotasks (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:2793:46)
at anonymous (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:2605:45)
at __guard (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:2777:15)
at flushedQueue (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:2604:21)
at invokeCallbackAndReturnFlushedQueue (http://192.168.1.3:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:2598:33)
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 29
Phisical iphone, Emulator not working.
I am actually in the process of doing the same. Was sad to have to eject for this. I hope I am not wasting my time.
The new major release updates the core packages that support the latest versions of the operating system and fixes some old bugs. Please confirm if the issue still persists and create a new issue if it still does.
In my video I used in iphone ( sorry my bad english )
refresh your useeffect
https://drive.google.com/file/d/195EQiATdzcWfwH31M06XnT4xLO40DusY/view?usp=share_link
yes, a moment sir.
I am using this package https://www.npmjs.com/package/react-native-ble-manager
But can’t get it to send me a value for the expected characteristics.
I was able to use another library… I suggest using it.
react-native-ble-manager,