Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to display Subscribe data in HTML which is continuous change every second in Angular 4 #16

Open
Ashclan opened this issue Jul 18, 2019 · 1 comment

Comments

@Ashclan
Copy link

Ashclan commented Jul 18, 2019

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


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);
 }
}
```
@tearforfear007
Copy link

I think you have your answer already,
your {{ heartrate }} in HTML should work fine. ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants