Garmin Edge sensor data in data frame

I have been trying to create a data field that calculates the DFA Alpha 1 variable based on beat-to-beat intervals. And I have achieved this by using the ANT+ lib by looking at the other posts on the forum. However, this requires that the user disconnects their heart rate monitor, which is not desirable. That is why I want to access the data using the Sensor lib. But again, I have problems using the API in a data field. And I have seen that this is only possible to do in a background process on an edge device? But again I have tried, but I still get either "Encountered an app crash." or that I am not allowed to access the API in a data field.

The app is implemented as a widget for now, but it would be better if the data were shown in a data field. So any ideas if it is possible?

  • If the sim crashes the sim window will go away.  If your app crashes, you'll see that in the console.

  • Ah, my bad. Then it is the data field app, even tho it sometimes happens after I have removed all the logic and only return a constant value in the compute function. 

    But about the other problem, is it possible to access the Sensor.HeartRateData another way then trough Sensor.registerSensorDataListener()? As this is apparently not working in a data field

  • I don't know of another way,

  • Okay, but thanks for the help anyway Slight smile

  • Have you made progress on this? This would be an amazing IQ field!!

  • Well, I have made the field and optimized it for a Garmin device. But as the Garmin API only make the RR data available for Widget's, and it is only the Edge 1030 that has enough processing power with 2 minutes of data at this point (According to my testing with the simulator). But if the Sensor.registerSensorDataListener() API is made available for DataField's in the future. Then I will release the application.

  • Oh man.... that’s a serious bummer... here’s hoping that Garmin does that. But... I won’t hold my breath. 

  • So i am having similar trouble. To keep it simple i am doing an app(not DF), and did not impliment background, or ActivityRecording.
    Wanted to avoid some of the possible issues mentioned in this thread.
    This code works fully as expected in the simulator on Edge 830, but i do not have this device.

    var options = {:period => 1, :heartBeatIntervals => {:enabled => true}};
    try {
    if (Sensor has :registerSensorDataListener) {
    Sensor.registerSensorDataListener(method(:hrCallback), options); // API 2.3.0, select devices only
    }

    For Edge 820 it fails in the call to registerSensorDataListener.
    Error: Invalid Value
    Details: Failed invoking <symbol>

    I did a sideload build for the 820, loaded it fine, no error, but seems like no callbacks.

    When running the sim for 820 it offer choice of API 2.4 or 3.1, i choose 3.1.
    Edge 820 is supposed to support SDK 3.1.3 which should be sufficient.
    I also tried using both SDK 3.2.5 and 4.0.4 in eclipse.
    I am not using the new SDK 4 stuff.

    Ideally i would like to get it working in the simulator - is there a bug in simulator?
    Did i miss some other limitation?

  • If I remember correctly can that error can appear if the type of application no not have access to either a library or method inside a library. That is also why I needed to change from a DataField application to a Widget / App.

  • Ahh found it i think, Toybox.Sensor.HeartRateData is only implemented in certain API 3.0.0 devices, not in the edge 820