capacitor-community / bluetooth-le

Capacitor plugin for Bluetooth Low Energy
MIT License
284 stars 86 forks source link

Notifications don't stop when the disconnection is triggered by the device side #619

Closed robsonos closed 8 months ago

robsonos commented 9 months ago

Describe the bug Notifications don't stop when the disconnection is triggered by the device side. Future BleClient.startNotifications won't work for future reconnections in that situation. Using BleClient.stopNotifications inside onDisconnect doesn't help as the device is already disconnected at that point.

To Reproduce Steps to reproduce the behavior:

BleClient.connect(device.deviceId, async (disconnectDeviceId: string) => {
  try {
    await BleClient.stopNotifications(
      disconnectDeviceId,
      CONSTANTS.UUID16_SVC_BATTERY,
      CONSTANTS.UUID16_SVC_BATTERY_CHAR_BATTERY_LEVEL,
    );
    await BleClient.stopNotifications(
      disconnectDeviceId,
      CONSTANTS.UUID128_SVC_NORDIC_UART,
      CONSTANTS.UUID128_SVC_NORDIC_UART_CHAR_TXD,
    );
  } catch (error: any) {
    console.warn(`onDisconnect: ${error.message}`);
  }
}),

Expected behavior Notification should stop when the disconnection is triggered by the device side

Plugin version:

pwespi commented 9 months ago

I cannot reproduce this. On which platform is this happening (iOS or Android)? Can you share the native logs?

github-actions[bot] commented 8 months ago

It looks like this issue didn't get the information it needed, so I'll close it for now. If I made a mistake, sorry! I am just a bot.

Have a great day! Capacitor Community Bot 💙