react-native-ble-plx
react-native-ble-plx copied to clipboard
Bug Report - Getting Errors: Operation was rejected and Characteristic ... write failed for device ... and service ... when trying to write
Expected Behavior
Send data to arduino.
Current Behavior
Returning error when trying to send data to arduino.
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
- Create manager
- Scan for devices
- Connect to desired device
- Get characteristics and services (I got the second index of the characteristics json) second index of characteristics json:
"value":null,
"isIndicatable":false,
"isNotifiable":false,
"isWritableWithoutResponse":false,
"isWritableWithResponse":true,
"serviceUUID":"00001800-0000-1000-8000-00805f9b34fb",
"deviceID":"B4:99:4C:7C:D4:2D",
"isReadable":true,
"serviceID":1,
"isNotifying":false,
"uuid":"00002a02-0000-1000-8000-00805f9b34fb",
"id":4}
- Run:
base64Signal = Buffer.from(signal).toString('base64');
console.log(`SENDING SIGNAL (TYPE: ${typeof signal}): ` + signal);
console.log(`SENDING SIGNAL (TYPE: ${typeof base64Signal}): ` + base64Signal);
MANAGER.writeCharacteristicWithResponseForDevice(
BT05_DEVICE.id,
DEVICE_SERVICE_UUID,
DEVICE_CHARACTERISTICS_UUID,
base64Signal ,
)
.then(d => {
console.log('THEN: ' + d);
})
.catch(error => {
console.log('CATCH: ' + JSON.stringify(error));
});
- Then it sometimes returns
Characteristic ... write failed for device ... and service ...
and sometimesOperation was rejected
. I dont know when each and what makes each happen.
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions. Both JS and platform logs can be enabled via setLogLevel function call.
- Library version: 2.0.3
- Platform: Android
- Platform logs (logcat/XCode): No Errors except the ones explained above.
- JS logs: No Errors except the ones explained above.
- Contents of the
package.json
file:
{
"name": "on_air_project",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-native-async-storage/async-storage": "^1.17.5",
"@react-native-community/masked-view": "^0.1.11",
"@react-navigation/native": "^6.0.10",
"@react-navigation/stack": "^6.2.1",
"bleno": "^0.5.0",
"events": "^3.3.0",
"os": "^0.1.2",
"react": "17.0.2",
"react-native": "0.68.2",
"react-native-ble-manager": "^8.1.0",
"react-native-ble-plx": "^2.0.3",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^2.4.2",
"react-native-reanimated": "^2.8.0",
"react-native-safe-area-context": "^4.2.5",
"react-native-screens": "^3.13.1",
"react-navigation": "^4.4.4",
"rn-nodeify": "^10.3.0",
"util": "^0.12.4"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.67.0",
"react-test-renderer": "17.0.2"
},
"jest": {
"preset": "react-native"
}
}
- Formatted code sample or link to a repository: https://gist.github.com/KingOfTNT10/3aa77dd5cb5e9d32082afc2efbe778fb
Note: I'm using a HM-10 Device with bluetooth version 4
Same problem for me.
+1
+1
@SohaibKtb i actually solved my problem by sending data without response because thats what my device supported. Try that maybe.
@KingOfTNT10 thanks for your help, I changed to react native ble manager, it is more stable and easier, it takes me a day to migrate with no issues, the response is needed in my case, thanks again 🙏
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.