Skip to content

Duplicate responses on characteristic monitor (Android) #1308

Description

@ThomasBurgess2000

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.

Question related code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions