I am using GenericChannel to connect to a Garmin Alpha and receive dog tracking data. I have based my code on the MO2Display sample. On a Vivoactive HR, I occasionally have issues where the GenericChannel.open() returns true, but I never get any ant messages to my message handler. Even if the Alpha isn't turned on, I should get the basic setup messages. If I stop the app and re-start it, or even just delete and recreate my sensor object without restarting the app, it works every time. If I let the watch sit at the standard watch face for awhile (about 15 minutes) and then relaunch my app, it usually (possibly always, I'm verifying) seems to fail again.
This doesn't happen on my FR630.
So it seems like there is some timing issue with the GenericChannel.open() call on the VAHR where something isn't setup yet in the GenericChannel code or hardware.
Again, this works fine in the simulator, on my 630, and on the VAHR (after the first attempt).
Here is my code.
in the App.onStart I have {mSensor=new TrackerSensor(); mSensor.open();}
function initialize()
{
// Get the channel
chanAssign = new Ant.ChannelAssignment(
0,//Ant.CHANNEL_TYPE_RX_NOT_TX,
Ant.NETWORK_PLUS);
GenericChannel.initialize(method(:onMessage), chanAssign);
// Set the configuration
deviceCfg = new Ant.DeviceConfig( {
:deviceNumber => 0, //47052 //Wildcard our search
:deviceType => 41,
:transmissionType => 0,
:messagePeriod => 2048,
:radioFrequency => 57, //Ant+ Frequency
:searchTimeoutLowPriority => 25, //Timeout in 25s
:searchThreshold => 0} ); //Pair to all transmitting sensors
GenericChannel.setDeviceConfig(deviceCfg);
searching = true;
}
function open()
{
isOpen = GenericChannel.open();
//Sys.println("isOpen="+isOpen);
searching = true;
}
function onMessage(msg)
{
//this function never gets called when this doesn't work
}