Hello! I have a issue because I can have comunication with my bluetooth module (I can write) but I don’t know how can I have the response of my bluetooth module, for example after write in my bluetooth module I need obten the response like a “WRITE_OK” and after that, to do ble.disconnect.
In the documentation:
I can see that the function “write” have 4 parameters (deviceId, serviceUUID, characteristicUUID, value) and Returns a Promise.
In spite of in this link:
I can see that the function “write” would have two more parameters: ble.write(device_id, service_uuid, characteristic_uuid, data, success, failure);
where:
success: Success callback function that is invoked when the connection is successful. [optional]
failure: Error callback function, invoked when error occurs. [optional]
OK, so… If I try to do with parameters success and failure I have the next error:
"Supplied parameters do not match any signature of call target. "
Then, I think the correct form is with only 4 parameters but in that case how can I have the response of my bluetooth module? Now, my code is like this:
BLE.write(deviceId, serviceUUID, characteristicUUID, this.stringToBytes(value)).then(data => {
console.log(data);
}, err => {
let alert = this.alertCtrl.create({
title: 'Error',
subTitle: 'No information was written: '+err,
buttons: ['Close']
});
alert.present();
});
stringToBytes(string) {
var array = new Uint8Array(string.length);
for (var i = 0, l = string.length; i < l; i++) {
array[i] = string.charCodeAt(i);
}
return array.buffer;
}
If somebody know how can I fix the problem, tell me please.
Thanks in advance!!