Skip to content

connectToDevice calls both the success and failure callbacks in some cases #146

@kapetan

Description

@kapetan

There is an issue where the plugin first calls the success callback and later the failure callback. I would expect that either the success or failure callback fires, not both.

evothings.ble.connectToDevice(
  device,
  function () {
    // called first
  },
  function () {
    // never called
  },
  function (errorCode) {
    // called second
  })

The logic to reproduce:

  1. Try to connect to device
  2. GattHandler#onConnectionStateChange is called with GATT_SUCCESS and STATE_CONNECTED.
  3. GattHandler sends a message back to the JavaScript code which triggers the success callback.

After some time the device is disconnected (e.g. turned off).

  1. GattHandler#onConnectionStateChange is called with !GATT_SUCCESS (the status argument is not GATT_SUCCESS) and STATE_DISCONNECTED.
  2. GattHandler now calls callbackContext.error triggering the failure callback in the JavaScript code.

I've experienced this a couple of times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions