-
Notifications
You must be signed in to change notification settings - Fork 551
Description
Prerequisites
- I checked the documentation and FAQ without finding a solution
- I checked to make sure that this issue has not already been filed
- I'm sure that question is related to the library itself and not Bluetooth Low Energy or Classic in general. If that so, please post your question on StackOverflow.
- I'm running the latest version
Question
I am starting a subscription of a certain characteristic like this:
const subscription = this.txCharacteristic.monitor(async (error, char) => {
And I remove the subscription whenever the device disconnects.
It works on iOS and Android, but on Android, whenever the device reconnects it starts getting duplicate messages on the listener. Every time it reconnects, there is another duplicate message. For example, I have a command that returns the battery level of the BLE device. The first time it connects, I only read one response to that message. But on the 5th reconnect, I get 5 duplicate responses.
I've debugged everything I can and am pretty confident at this point that there's no leftover listener or subscription in the React Native side of things. Also, if there was, it would presumably affect iOS as well, and I'm only seeing this behavior on Android.
Is it possible there's something wrong with the Android native side of things that's causing it to not properly remove subscriptions? Like maybe there really is only one listener at any given time in the React Native side, but in the native Android code there's still multiple that get forwarded to that one listener. Not sure how that binding happens.