I’m able to read the BLE data just fine & store it in an array. However if I want to update my view and put the array values into my this.first_BLE_stat it simply won’t work. Nothing happens. I can do an alert and print data[0] and it is perfect. I’ve been reading for hours and still can’t figure it out - apologies i’m an ionic newbie!
connect(id) {
BLE.connect(id).subscribe (
peripheralData => {
alert("Connect:" + JSON.stringify(peripheralData));
BLE.read(this.deviceID, this.service_UUID, this.color_UUID).then(function (buffer){
alert("I'm running first");
//convert bytes to string
var convertData = String.fromCharCode.apply(null, new Uint8Array(buffer));
var data = [];
for (var i = 0; i < convertData.length; i++) {
var resultNumber = convertData.charCodeAt(i);
data[i] = (resultNumber.toString());
alert("data from BLE: " + data[i]);
}
alert(data[0]);
this.first_BLE_stat= data[0];
alert("first BLE stat" + this.first_BLE_stat);
}, function(error) {
alert("Error Read" + JSON.stringify(error));
});
},
error => alert("Error Connecting" + JSON.stringify(error))
);
}
In my HTML i just have a{{first_BLE_stat}}.
I’ve also tried using Ng zone & updating the variable inside but no luck
Any help appreciated…I think I’m going insane