Can someone help me understanding how to interpret the data coming from the device
I have following code that reads data in to the Uint8Array array. Individual -
Code: Select all
// Get data for each service
console.log('number of services ' + device.__services.length)element of an array shows an integer. I dont know this is a right way to access data. If yes, what those individual array element values mean?
console.log('number of characteristic ' + device.__services[0].__characteristics.length)
{
//var characteristic = service.__characteristics[characteristicUUID]
device.readCharacteristic(
device.__services[0].__characteristics[0]['uuid'],
function (data) {
var test = new Uint8Array(data);
var result = "";
for (var i = 0; i < test.length; i++) {
console.log('data element is ' + test[i]);
console.log('data element string is ' + String.fromCharCode(parseInt(test[i], 2)));
result += String.fromCharCode(parseInt(test[i], 2));
}
console.log('data is ' + result);
},
function (errorCode) {
console.log('BLE readCharacteristic error: ' + errorCode);
});
}