HRM-Tri Running Dynamics ant chan

Hi!
I'm new to garmin iq and I'm trying to play/learn with the sdk.

I want to test fetching data from an ant channel and the only ant+ sensor I have is Garmin HRM-tri. I know I can get the running dynamics metrics with the sdk but I want to test how I can do a ant connection.

I'm using the following code:

devices = [];
var chanAssign = new Ant.ChannelAssignment(
Ant.CHANNEL_TYPE_RX_NOT_TX,
Ant.NETWORK_PLUS);
GenericChannel.initialize(method(:onMessage), chanAssign);
// Set the configuration
deviceCfg = new Ant.DeviceConfig( {
:deviceNumber => 0,
:deviceType => 0,
:transmissionType => 0,
:messagePeriod => 8192,
:radioFrequency => 57, //Ant+ Frequency
:searchTimeoutLowPriority => 10, //Timeout in 25s
:searchThreshold => 0,
} ); //Pair to all transmitting sensors

GenericChannel.setDeviceConfig(deviceCfg);
openChannel();

function onMessage(msg) {

// Parse the payload
var payload = msg.getPayload();

if (Ant.MSG_ID_BROADCAST_DATA == msg.messageId) {
searching = 0;


var page = (payload[0] & 0xFF);
System.println(initN + " deviceNumber:" + msg.deviceNumber);
System.println(initN + " deviceType:" + msg.deviceType);
System.println(initN + " transmissionType:" + msg.transmissionType);
System.println(initN + " getPayload:" + msg.getPayload());
System.println(initN + " messageId:" + msg.messageId);


} else if (Ant.MSG_ID_CHANNEL_RESPONSE_EVENT == msg.messageId) {

if (Ant.MSG_ID_RF_EVENT == (payload[0] & 0xFF)) {
if (Ant.MSG_CODE_EVENT_CHANNEL_CLOSED == (payload[1] & 0xFF)) {

closeChannel();
} else if (Ant.MSG_CODE_EVENT_RX_SEARCH_TIMEOUT == (payload[1] & 0xFF)) {

closeChannel();
} else if (Ant.MSG_ID_LOW_PRIORITY_SEARCH_TIMEOUT == (payload[1] & 0xFF)) {

closeChannel();
}
}
}
}

Which seems to output only in walking app but not on running app:

1 broadcastdata:
1 deviceNumber:30943
1 deviceType:120
1 transmissionType:1
1 getPayload:[132, 1, 84, 117, 173, 119, 253, 101]
1 messageId:78

1 broadcastdata:
1 deviceNumber:30943
1 deviceType:120
1 transmissionType:1
1 getPayload:[4, 0, 178, 146, 50, 149, 9, 97]
1 messageId:78

My question is, why in running app I don't have output? Is because only one connection is allowed? and running app already has a connection?

Thank you!

Top Replies

All Replies

  • When you talk about walking app and running app, you mean walking and running activities on device? And you are developing a datafield here?

  • If you plan to connect directly to HR sensor (or any other sensors) via Ant API, you must make sure that your device is not connecting to it automatically. So disable it from sensors menu. 

    Can it be that someway walking activity is not using external HR sensor (meaning it is available for your usage), but in case or running it is using the HR sensors (meaning it is NOT available via Ant API)?

  • You won't get much worthwhile RD data when you are walking.  You're moving too slow.

    Heart should be fine though.

  • I'm not really concerned about actual data, just the connection and visibility of sensor for API usage

  • Yes, I mean walking/running activities and I'm testing it on a datafield.

    I'm not interested in getting worthwhile RD while walking, it's just the only ANT sensor that I have for testing/learning.

    I've tried to disconnected the sensor from settings, and now it seems  that I can get the payload also on running activities.
    Is this because if the activity is already using the sensor you cannot open a new ant channel to it? In this case is there any other way to get them?

    I know I can get them using Toybox.AntPlus.RunningDynamics, but I'm trying to learn how to use the GenericChannel

    Also is there any documentation on how to parse the payload for this HRM-tri sensor to know which metrics are?
    Payload:[129, 216, 95, 131, 158, 188, 162, 89]
    Payload:[4, 0, 197, 202, 94, 206, 167, 80]
    Payload:[132, 0, 196, 216, 51, 220, 171, 72]

  • I've tried to disconnected the sensor from settings, and now it seems  that I can get the payload also on running activities.
    Is this because if the activity is already using the sensor you cannot open a new ant channel to it? In this case is there any other way to get them?

    I know I can get them using Toybox.AntPlus.RunningDynamics, but I'm trying to learn how to use the GenericChannel

    Yes, that's how it works. If you have sensor connected to Garmin device via settings, then firmware will "own" the sensor and it won't be visible for other usages via Ant API. If you want to use such sensors, AntPlus API is for that (which you already know). BTW HR sensors aren't supported by AntPlus.

    Otherwise there isn't really any way. If you have dual sensors (supporting BLE and ANT+), you could connect from settings using BLE which would leave ANT+ connection available for you.

  • It comes down to this.  If a sensor is paired to the watch, you can't connect to it with CIQ ant code.  No way around it. Same for external HR, footpods, Tempe, dog trackers, etc

  • Also is there any documentation on how to parse the payload for this HRM-tri sensor to know which metrics are?

    Documents for ANT+ device profiles are here:

    https://www.thisisant.com/developer/resources/downloads/#documents_tab

    In there you can find heart rate document (also running dynamics), which contains info about the bytes. If this is HR profile (device type 120), then for example the last byte in payload is always the calculated heart rate (here: 89, 80, 72). 

    Before you can access the documents, you need to register to thisisant pages. After registration is completed, in addition you need to  upgrade to "ANT+ Adopter Member", this can be done in your user profile. All this is still free, but may take few days to get approved.