Fenix 3 HR App Issue

I'm having an issue acquiring HR readings in an app I have developed on my Fenix 3 (software version 6.50). I can run an app and acquire an HR reading once (sometimes twice). Quitting and re-running the app results in no HR reading. A power down and restart will allow me to run the app once more, successfully, but future runs result in no HR reading.

I have not seen this issue until recently, so it may be related to my upgrade to 6.50. Also the same app does not exhibit this issue, and runs as expected, on a friends Vivoactive, and in the simulator in Fenix 3 mode. I have seen this issue now in: Cardiometer (my app), the demo below, RHR (downloaded from app store)

I have created a trivial sample app, detailed below which demonstrates this issue. Any ideas or help are much apreciated.

Test.mc
class SensorTester extends Ui.View
{
var string_HR;

//! Constructor
function initialize()
{
Snsr.setEnabledSensors( [Snsr.SENSOR_HEARTRATE] );
Snsr.enableSensorEvents( method(:onSnsr) );

string_HR = "---bpm";
}

//! Handle the update event
function onUpdate(dc)
{
dc.setColor(Gfx.COLOR_BLACK, Gfx.COLOR_BLACK);
dc.clear();

dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT );

dc.drawText( 100, 90, Gfx.FONT_LARGE, string_HR, Gfx.TEXT_JUSTIFY_CENTER);
}

function onSnsr(sensor_info)
{
var HR = sensor_info.heartRate;
var bucket;
if( sensor_info.heartRate != null )
{
string_HR = HR.toString() + "bpm";
}
else
{
string_HR = "---bpm";
}

Ui.requestUpdate();
}
}

//! main is the primary start point for a Monkeybrains application
class TestApp extends App.AppBase
{
function onStart()
{
return false;
}

function getInitialView()
{
return [new SensorTester()];
}

function onStop()
{
return false;
}
}


Edit: Changed code sample to Sensor example app based code.
  • function initialize()
    {
    Snsr.setEnabledSensors( [Snsr.SENSOR_HEARTRATE] );
    Snsr.enableSensorEvents( method(:onSnsr) );
    HR_graph = new LineGraph( 20, 10, Gfx.COLOR_RED );

    string_HR = "---bpm";
    }

    function onSnsr(sensor_info)
    {
    var HR = sensor_info.heartRate;
    var bucket;
    if( sensor_info.heartRate != null )
    {
    string_HR = HR.toString() + "bpm";

    //Add value to graph
    HR_graph.addItem(HR);
    }
    else
    {
    string_HR = "---bpm";
    }

    Ui.requestUpdate();
    }


    can you try the above? that's from the sensor example in the SDK.
  • Thanks for the suggestion NIKEOW. I'll try building the Sensor example app and side loading it to my Fenix3 tonight. The snippet you included appears to be using much the same process as my sample, but with the added complication of a graph. However it'll be good to use an official code sample to re-verify my issue.
  • can you try the above? that's from the sensor example in the SDK.


    I have tried two further things, based on your suggestion:

    1) I have built and side loaded the example Sensor widget. This appears to work, I've run it 10 or so times in a row, just keeps working.

    2) I have rebuilt a test WatchApp, where the App and View code is a copy and paste of the Sensor widget source code, with the App name changed, and the HR_graph references removed. This exhibits similar behaviour to my original test. I can run it 1-2 times successfully, and then it will fail to pick up the HR until a restart. Also, once the WatchApp has started failing, the Widget also fails in the same way.
  • I've updated my original post to have the Sensor example based code.
  • New discovery: going into a standard app (e.g. Run) will reset the system enough so that the widget version of the Sensor example works again. But it does not fix the WatchApp version. And after the WatchApp version has run, the widget will not work again until Run has been used, or the system re-started. WatchApp appears to always need a re-start to fix.
  • HR monitoring on Fenix 3 WatchApp broken.

    Is there any chance of getting any form of response on the rather serious bug I raised a week ago? So far apart from NIKEOW's helpful pointer to a better source of demo code, which replicated my issue, there has been nothing. Maybe I have not made the issue clear so let me restate:

    On a Fenix 3 (6.50) monitoring HR from a WatchApp is broken!

    It will usually work successfully 1 or 2 times after each watch full restart, then it will fail for all future attempts. Does anyone at Garmin care that this feature of Connect IQ appears to be broken on the Fenix 3? I appreciate that you are probably busy, but any form of response would be appreciated. Can't be reproduced? Under investigation? Anything?
  • This has been reported for further investigation. I don't have much to comment on at the moment, however. I will try to report back here once I find out more.
  • Thank you for the response. Good to know it's been looked at.
  • I had a problem that seems similar; probably not the same problem. I was getting this error message when I tried to run the following code on my simulator. When I replaced line 199 with line 200 (see below) it worked without problems. Not sure if this is your same problem, but this seemed like a language quirk.

    Failed invoking <symbol>
    Unexpected Type Error in onUpdate (C:\Documents\workspace\Myprogram\source\MyView.mc:199)


    The following is my code
    // app.mc
    //...
    using Toybox.Sensor as Snsr;
    //...

    var gView;

    class MyApp extends App.AppBase {
    function initialize() {
    AppBase.initialize();
    }
    function onStart() {
    Pos.enableLocationEvents(Pos.LOCATION_CONTINUOUS, method(:onPosition));
    Snsr.setEnabledSensors([Snsr.SENSOR_HEARTRATE]);
    Snsr.enableSensorEvents(method(:onSensorHR));

    }
    function onStop() {
    gView.endActivityRecording();
    Pos.enableLocationEvents(Pos.LOCATION_DISABLE, method(:onPosition));
    Snsr.setEnabledSensors([]);
    }
    function onSensorHR(hrinfo) {
    gView.setHeartRate(hrinfo);
    }

    function onPosition(posinfo) {
    gView.setPosition(posinfo);
    }
    function getInitialView() {
    gView = new MyView();
    return [ gView, new gViewDelegate() ];
    }
    }


    // MyView.mc
    //...
    using Toybox.Sensor as Snsr;
    using Toybox.Lang as Lang;
    //...
    var hrText = "No HR";
    var globalSensorInfo = null;

    var globalPositionInfo = null;

    class MyView extends Ui.View
    //...
    function setPosition(pinfo) {
    globalPositionInfo = pinfo;
    Ui.requestUpdate();
    }
    function setHeartRate(sinfo) {
    globalSensorInfo = sinfo;
    }

    function onUpdate(dc) {
    //...
    if( globalSensorInfo != null ) {
    var HR = globalSensorInfo.heartRate;
    hrText = HR.toString(); // line 199 here... DID NOT WORK;
    hrText = Lang.format( "$1$" , [ HR ] ); // this line WORKED as a replacement for line 199
    } else {
    hrText = "---";
    }
    //...
    }
  • Has there been any developments in this respect?
    the 6.5 FW seems to be "on" and "off"