This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE Android Library never finish sendNotification() queue

Hello,

We have been trying the sendNotification call and after getting a success log we are not able to send a second notification. I'll copy the snippet of code that we are using to send the notification.

fun sendNotification(intent: Intent) {
      coroutineScope.launch {
          val deferred = async {
              logger.d(TAG, "sendNotification with intent: ${intent.toString()}")
              sendNotification(serverNotificationCharacteristic, intent.formattNotification())
                  .await()
              logger.d(TAG, "sendNotification DON'T FINISH")
          }
          deferred.await()
          logger.d(TAG, "sendNotification finished")
      }
  }

the returned logs are:

D/: Target initialized
D/: Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 01-00
D/: Notifications enabled
D/: Target initialized
D/: sendNotification with intent: Intent { act=com.mobilejazz.ble.ACTION_NOTIFICATION (has extras) }
D/: [Server] Sending notification to 46df2ad2-c827-47ae-9932-b64c3da77adc
D/: server.notifyCharacteristicChanged(device, 46df2ad2-c827-47ae-9932-b64c3da77adc, false)
D/: [Server callback] Notification sent (status=0)
D/: sendNotification with intent: Intent { act=com.mobilejazz.ble.ACTION_NOTIFICATION (has extras) }
D/: sendNotification with intent: Intent { act=com.mobilejazz.ble.ACTION_NOTIFICATION (has extras) }

as you can see:


[Server callback] Notification sent (status=0) is shown (from the Ble library) but somehow

sendNotification finished nor sendNotification DON'T FINISH hasn't been shown and we are making a synchronous call so it should be reached.

We also tried to call enqueue() instead of await() but the behavior is exactly the same.

Our Bluetooth device is receiving the first notification and after that, we can not send more notifications.

It looks, following the logs, that we are enabling the notifications correctly for the correct characteristics so we are a little bit lost about that.

I also open an issue in Github because I didn't know where to ask.
Github Issue

Related