'unable to readCharacteristic in IOS using flutter_reactive_bel
IOS app is crashed after the connecting with device so for handle the crash using scanStream.cancel(), but after doing this one of my readCharacteristic is not working fine i am not getting the battery status from device, but this is working fine with Android. According to me this error is because of scanStream.cancel() because in IOS app we used this and Android we did not use this.
I am sharing the readCharacteristic method which is not working in IOS, please help me out into this.
version : flutter_reactive_ble: ^5.0.2
if (Platform.isIOS) {
connectedBluetooth.value = true;
connectionForData();
_scanStream.cancel();
}
Future<void> connectionForData() async {
try {
flutterReactiveBle
.readCharacteristic(characteristicBattery)
.then((List<int> result) {
debugPrint("HERE ==>> connected bluetooth then");
for (var i in result) {
///read the battery status (byte code)
debugPrint("HERE ==>> connected bluetooth for");
batteryStatus(i);
}
});
}, onError: (Object error) {
CommonUtils.toastMesg(error.toString());
// Handle a possible error
});
} catch (e) {
debugPrint("HERE ==>> ${e.toString()}");
}
Solution 1:[1]
https://github.com/PhilipsHue/flutter_reactive_ble/issues/385
For Android, I have to use the 128 bit ID, other it doesn't work, and for IOS I have to use the 16 bit ID. So I'm doing something like that :
final SERVICE_DEVICE_INFO = Platform.isAndroid ? "0000180A-0000-1000-8000-00805F9B34FB" : "180a";
And then later I call that string with Uuid.parse : Uuid.parse(SERVICE_DEVICE_INFO )
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Cedrick Naa |
