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:
Try to connect to device
GattHandler#onConnectionStateChange is called with GATT_SUCCESS and STATE_CONNECTED.
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).
GattHandler#onConnectionStateChange is called with !GATT_SUCCESS (the status argument is not GATT_SUCCESS) and STATE_DISCONNECTED.
GattHandler now calls callbackContext.error triggering the failure callback in the JavaScript code.
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.
The logic to reproduce:
GattHandler#onConnectionStateChange
is called withGATT_SUCCESS
andSTATE_CONNECTED
.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).
GattHandler#onConnectionStateChange
is called with!GATT_SUCCESS
(the status argument is notGATT_SUCCESS
) andSTATE_DISCONNECTED
.GattHandler
now callscallbackContext.error
triggering the failure callback in the JavaScript code.I've experienced this a couple of times.