But i have some problems to read some characteristics. Here is my reading function :
onReadCharacteristic(deviceID, service, characteristic){
this.ble.read(deviceID,service,characteristic).then(
function(buffer){
var databuffer = new Uint8Array(buffer);
alert("buffer " + String.fromCharCode.apply(null,databuffer));
}
)}
It works well when i tryc to read the Device Information service 0x180A, the buffer return me the good informations (device name, manufacturer name, device number etc…).
But when i try to read the Battery Service 0x180F (characteristic 0x2A19) for example, the buffer return me a strange thing like “[” :
Have you ever try to read IR Temperature on Ti SensorTag ?
I am trying to read the IR temperature object, first i write “01” in 0xAA02 characteristic config like mentionned in the documentation
var value = "01";
this.ble.write("F000AA00-0451-4000-B000-000000000000","F000AA02-0451-4000-B000-000000000000",value).then(
function(res){
alert("Ecriture : " + JSON.stringify(res));
}
);
But when i read the temperature object i always get 00 00 00 00. And when i read the config parameter i have “211” instead of “01”. I also tried the following values :
var value = "0x01";
var value = 1;
var value = new Uint8Array(1);
value[0] = 0x01
But the characteristic config still return “211”
Ok, i found the problem ! To correctly write 0x01 in the characteristic we have to use value.buffer
var value = new Uint8Array(1);
value[0] = 0x01;
this.onWriteCharacteristic("F000AA00-0451-4000-B000-000000000000","F000AA02-0451-4000-B000-000000000000",value.buffer);