Open Ashclan opened 5 years ago
i m working BLE native library in ionic. I m try to display heartbeat on screen. Here,i m able to get heartrate value on console.log() which is continuously change. what i want is to show heartrate value in html page live.
{{ heartrate }}
This is my code
this.ble.startNotification("EB:53:D1:0A:A0:78", "180D", "2A37").subscribe((buffer)=>{ this.getHeartRateNotifications(buffer); console.log(buffer); },(err)=>{ console.log('aa',JSON.stringify(err)) })
getHeartRateNotifications(buffer){ console.log(buffer); console.log('array : ', String.fromCharCode.apply(null, new Uint8Array(buffer))); const value = new DataView(buffer); console.log("I am value: ", JSON.stringify(value)); const flags = value.getUint8(0); console.log('FLAGS', flags); if(this.session.isEven(flags)){ this.heartRate = value.getUint8(1); console.log('HEART RATE 8 bit: ', this.heartRate); }else if(this.session.isOdd(flags)){ this.heartRate = value.getUint16(2); console.log('HEART RATE 16 bit: ', this.heartRate); } }
I think you have your answer already, your {{ heartrate }} in HTML should work fine. ^^
i m working BLE native library in ionic. I m try to display heartbeat on screen. Here,i m able to get heartrate value on console.log() which is continuously change. what i want is to show heartrate value in html page live.
{{ heartrate }}
Where heartrate:number = 0;global variable.This is my code