Skip to content

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

Description

@Ashclan

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);
 }
}
```

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions