Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kapetan opened this issue Oct 6, 2017 · 0 comments

Comments

@kapetan
Copy link

kapetan commented Oct 6, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant