Author Topic: Locus API, get heart rate value  (Read 389 times)

Offline mzperx

  • Newbie
  • *
  • Posts: 6
    • View Profile
  • Device: Nexus 5, Samsung Gear Live
Locus API, get heart rate value
« on: January 05, 2017, 16:19:37 »
Hi,

is it possible to retrieve the actual heart rate value from Locus API? I would like to extend the "Locus Map - add-on Wearables" to see the actual heart rate on the watch.
 

Offline menion

  • Administrator
  • Professor of Locus
  • *****
  • Posts: 9914
  • Thanked: 51 times
    • View Profile
    • http://www.asamm.com
  • Device: SGS7
Re: Locus API, get heart rate value
« Reply #1 on: January 06, 2017, 06:58:03 »
Hello,

to fill track recording screen on watches is used this method: https://github.com/asamm/locus-addon-wearables/blob/master/wear/src/main/java/com/asamm/locus/addon/wearables/gui/TrackRecordActivity.java#L189

Here is a key object : TrackStats . This object contains also Heart rate values, see here: https://github.com/asamm/locus-api/blob/master/locus-api/src/main/java/locus/api/objects/extra/TrackStats.java#L376 , so you may simple use getHrmAvg() or getHrmMax() functions. Value '0' means that no HRM was recorded yet.
Ideas, wishes, problems
Advanced topics, public discussion, sharing of knowledges, testing beta versions: you're here!
 

Offline mzperx

  • Newbie
  • *
  • Posts: 6
    • View Profile
  • Device: Nexus 5, Samsung Gear Live
Re: Locus API, get heart rate value
« Reply #2 on: January 06, 2017, 11:54:18 »
Hello Menion,

thank you for your fast reply!
I have already found the function and the object and I have already added hrmAvg and hrmMax to my fork of the add-on, but I would like to add the actual heart rate value too (the actual heart beatings) this is what I have referred to in my first post.
I have found neither UpdateContainer nor TrackStats contains this value this is why I think I should extend they with this value. But the question is how can I obtain the actual heart rate value. Is it supported by Locus API?
 

Offline menion

  • Administrator
  • Professor of Locus
  • *****
  • Posts: 9914
  • Thanked: 51 times
    • View Profile
    • http://www.asamm.com
  • Device: SGS7
Re: Locus API, get heart rate value
« Reply #3 on: January 06, 2017, 12:01:47 »
Ah sorry, my bad.

All current sensor data are attached to current users location. So from received UpdateContainer object, just get Location with

Code: [Select]
container.getLocMyLocation()
In this location object are then all sensor data, so something like
Code: [Select]
if (myLocation.hasSensorHeartRate()) {
  myLocation.getSensorHeartRate();
}

More here:
https://github.com/asamm/locus-api/blob/master/locus-api/src/main/java/locus/api/objects/extra/Location.java#L762

Simply:
TrackStats - container for complete statistics of currently recording track
Location - object that has not just users location at certain time, but also sensor values at this time
Ideas, wishes, problems
Advanced topics, public discussion, sharing of knowledges, testing beta versions: you're here!
 

Offline mzperx

  • Newbie
  • *
  • Posts: 6
    • View Profile
  • Device: Nexus 5, Samsung Gear Live
Re: Locus API, get heart rate value
« Reply #4 on: January 06, 2017, 12:34:59 »
Thank you I think this is what I'm looking for, I will try it!