50ButtonsEach / flic2lib-android

Flic2 SDK for Android
Other
17 stars 8 forks source link

BLE Peripheral breaks Flic library #37

Open alexlarocca opened 4 months ago

alexlarocca commented 4 months ago

I created an app using this library and it works well. But as soon as I run a BLE Peripheral, indifferently from the same app or even an external app (for instance https://play.google.com/store/apps/details?id=com.cozyoz.bletool), my app continues to work well (receiving click events) for 30 seconds only, then it stops to work. Even an app restart does not help. I have to restart the device and then my app works again, until a BLE Peripheral starts.

I notice that the peripheral does not need to start advertising to create the problem. Just adding the BluetoothGattService is enough to break.

Another behavior I noticed. If I start the peripheral first, and only after the service is added, I start the Flic manager, I can see the following:

Tested on Android 9 and Android 13

Emill commented 4 months ago

Is this reproducible with Android 14?

I just tried to reproduce what you describe on Pixel 7 running Android 14, but I couldn't.

Steps:

  1. Have Flic app installed (which uses this SDK), and nRF Connect as well.
  2. Open Flic app.
  3. Open nRF Connect app, add GATT server, start advertising.
  4. Try to pair a Flic button inside the Flic app.
  5. The button can be successfully paired and it continues to work even after 30 seconds.
alexlarocca commented 4 months ago

I do not have an Android 14 device. But I just reproduced the issue on your sample app (https://github.com/50ButtonsEach/flic2lib-android-sample). Also this stopped to receive click event and failed to pairing like my app. I'm going to test this problem with the official app.

alexlarocca commented 4 months ago

Even the official Flic app breaks like mine on Android 9. While it works properly on Android 13. Any chance to reproduce and fix this issue on Android 9? This my target since I'm going to create an app for Amazon Firestick and other Android TV BOX that use that Android version. And my app need to start a BLE peripheral too.

Emill commented 4 months ago

Have you reproduced this on any Android phone with version < 14? In that case, what phone models?

alexlarocca commented 4 months ago

Reproduced on Xiaomi Mi MIx 2 (Android 9)

alexlarocca commented 4 months ago

On Amazon Fire Stick (Android 9) it works perfectly. Even running a peripheral from the same app, it continues to receive click events and still able to pair new buttons.

So probably the issue is related to that specific phone (Xiaomi Mi Mix 2).