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!