Attempting to monitor changes and get the listener callback to fire when my hardware notifies the phone.
This code works as expected on IOS but I get no response from the listener on Android.
Followed these docs: https://polidea.github.io/react-native-ble-plx/#BleManager#monitorCharacteristicForDevice
Is there any known difference in functionality between the platforms? I've been digging around and logging out data in BleModule.java to try and get some feedback but I'm not getting anywhere.
Has anyone else had this problem?
These are my versions:
"react-native": "^0.47.0-rc.1",
"react-native-ble-plx": "^0.6.3",
The code in question:
let thisSubscription = this.manager.monitorCharacteristicForDevice(this.connectedDevice.id, this.serviceUUID, this.tagCharacteristicUUID, (err, characteristic) => {
// console.log('monitorCharacteristicForDevice fires once');
if(err) {
console.log('Err from pen', err);
return
}
console.log('data from pen: ', characteristic);
let tagValue = utils.base64toHEX(characteristic.value)
console.warn('Tag data: ', tagValue);
})
console.log('thisSubscription', thisSubscription);`
I'm having this issue as well. I was using the React Native BLE Manager library before I switched to this library. The characteristic update listener in that library was also not firing on Android while it works beautifully on iOS. Is there any update on this issue?
I definitely need Android's native module log to help you there. Are you sure that you are not missing notifications before you are monitoring them?
This is happening to me, as well. My current workaround for Android is to set the isReadable attribute on the characteristic to true.
Before reading, characteristic.value === null; after calling const charData = await characteristic.read(), charData.value has the data I expect.
@elailai94 I was using the same library before as well
@Cierpliwy I'll try and get the native logs up here soon
@wkoutre I'll give this workaround a try as well. I'm using custom hardware so we'll see if this works out with the software that's embedded
Been bogged with administrative tasks but I'm working on a paid project with this library so I'll be pretty motivated to help fix it sooner or later ;)
That would be very helpful @fogg4444 !
I guess I solved this issue.
The problem was RxAndroidBle which is used by react-native-ble-plx.
I found it sending BLE notification setup request to BLE device before it is ready to receive it.
I changed order to fix it.
See https://github.com/Polidea/RxAndroidBle/pull/336
To apply this fix, you have to use my own temporal version of react-native-ble-plx
https://github.com/mswokk/react-native-ble-plx/tree/develop
(Because it's not reviewed yet.)
You can test it follwing 2 steps.
package.json"dependencies": {
...
"react-native-ble-plx": "github:mswokk/react-native-ble-plx#develop", // replace this line
...
}
(your_project)/android/build.gradleallprojects {
repositories {
....
maven { url "https://jitpack.io" } // add this line
In my case, I always lost first notification from BLE device just after starting notification.
After this fix, it works well as on iPhone.
If you tried this fix, I hope you to reply here your test result on your device with this fix.
Thank you
Thanks for testing that the issue is caused by RxAndroidBle. I'll talk with @dariuszseweryn how we can proceed with a fix.
This should be fixed with version 0.8.0. Please reopen if there are any problems.
Thanks!! :)
@Cierpliwy
Hi there! It seems that problem is still there.
I'm using 0.9.1 version of library right now.
Phone Samsung s8, android version 8.0.0.
The goal is to subscribe to several Notification Services. After subscription they start to propagate data. On iOS everything works correct and on Android I had an issue written here.
I tried to find a core of the problem and found that if I put a break-point to first line of onCharacteristicChanged at class RxBleGattCallback - and resume it after stop immediately - everything starts to work - I get all messages on my Android Phone.
Thanx!
In version 0.8.0 I created a workaround, which caused some issues on our side. That's why I reverted it. I think that this should be fixed in RxAndroidBle directly and probably will look into it on Friday (my open source days).
What is recommended solution nowadays? :)
Sit tight, I am currently working on the solution ;)
Cool, but when we can expect fix to be published? We are currently working on the app that rely on react-native-ble-plx and we are getting closer to release date - on iOS everything works fine, but Android support is crucial in our app.
I've downgraded to 0.8.0 but still this doesn't fix my problem in Android, if there is any workaround that you suggest I'll be grateful for sharing It.
Great job anyway, on iOS works like a charm :+1:
1.0 should resolved this issue? Cause It's still present in my configuration on Android.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@dariuszseweryn @Cierpliwy In my case the problem is still there, is it really fixed? I'm using __1.0.3__
@hoffmannjan The original poster's issue should be fixed since 1.0.2. Could you explain your exact use case and add logs from Logcat?
@dariuszseweryn I've created a new issue #446
Most helpful comment
In version 0.8.0 I created a workaround, which caused some issues on our side. That's why I reverted it. I think that this should be fixed in RxAndroidBle directly and probably will look into it on Friday (my open source days).