react-native-ble-manager
react-native-ble-manager copied to clipboard
Android 10 - startNotification gives error "Error writing descriptor stats=133"
Version
- react-native-ble-manager v7.4.1
- react-native v0.63.4
- iOS/Android v.10 kernel 4.19.95
Expected behaviour
startNotification should start notification on characteristic
Actual behaviour
Gives error: Error writing descriptor stats=133
Code to reproduce
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
App.js
const connect = async device => {
await BleManager.connect(device.id)
console.log('Connected......')
const info = await BleManager.retrieveServices(device.id)
console.log('Got service...', info)
const characteristic = info.characteristics[3]
const service = characteristic.service
const charect = characteristic.characteristic
console.log(service, charect)
setTimeout(async () => {
await BleManager.startNotification(device.id, service, charect)
debugger
await BleManager.disconnect(device.id)
console.log('Disonnected......')
}, 500)
}
Stack trace and console log
{advertising: {…}, rssi: -56, id: "04:91:62:93:03:59", name: "MyDevice"}
App.js:65 Connected......
App.js:67 Got service... {characteristics: Array(4), services: Array(3), advertising: {…}, name: "MyDevice", rssi: -56, …}
App.js:71 11020304-0506-0708-0900-0a0b0c0d0e0f 11223344-5566-7788-9900-aabbccddeeff
backend.js:32 Possible Unhandled Promise Rejection (id: 0):
"Error writing descriptor stats=133"
...
Could it be the new UBSan (Bounds Sanitizer) in Android 10? https://source.android.com/devices/tech/debug/bounds-sanitizer
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'ubsan: out-of-bounds'
It here in Peripheral.java where it fails: (line 501)
if (gatt.writeDescriptor(descriptor)) {
Log.d(BleManager.LOG_TAG, "setNotify complete");
} else {
registerNotifyCallback = null;
callback.invoke(
"Failed to set client characteristic notification for " + characteristicUUID);
}
Hi, I don't have an android 10 phone so i can't reproduce your issue.
Hi, if you buy Nokia 5.3 with Android 10 as I did i will pay for the phone. There are already customers complaining since our app is in Google Play store and important functionality for our company.
i got same issue
It's a OS/Hardware bug.
Did anybody find a workaround for this?
I have this same problem, on a Samsung note 10 Android 11 (Kernel 4.14) But works fine on Android 11 (Kernel 4.9) Galaxy Tab S5e
Any update on this issue?
I had the same issue with the phone OPPO A53 (ColorOS 7.2 based on Android 10). After struggling on it for several days, I found out that I need to create a bond first and then it works (I never had to do that with any other Android phones).
After catching the error stats=133, the following seems to work:
- Wait until the device is truly disconnected (about 10 sec),
- Call the function BleManager.createBond(peripheral.id),
- Accept the pairing pop-up that shows up on the screen,
- Wait until the device is truly disconnected (about 25 sec),
- Start again with BleManager.connect, BleManager.retrieveServices, BleManager.startNotification
This needs to be done only once. The next connections are working as usual, since the two devices are bonded.
I hope it helps someone...
the error rarely occured. I saw it once.