To reproduce the problem:
1) Install the Moxy Data Field on a Data page. Leave the Sensor number set to 0 for wildcard search.
2) Open a Ride but don't start it.
3) Go to the data page with the Moxy Data Field on it.
4) Wait for the Edge to pair to a Moxy Sensor (SimulANT works fine too)
5) Let the Edge go to sleep or make it sleep by doing a short press on the power button.
6) Wait 30 seconds.
7) Wake up the Edge with a short press on the power button.
The Moxy Data field will be frozen on the values it was displaying before the Edge went to sleep.
The only way to recover from this is to reinstall the data field or to shut down the Edge completely.
I made a work around to fix this, but it's pretty ugly. I had to null out the Generic ANT channel and recreate it. Just closing it and reopening it would not allow it to start working again.
There are no messages coming in to the Generic ANT channel so I had to make a timer to detect how long it's been since a message was received.
Here's the code snippets I came up with for a work around.
In the onMessage function in the Generic Ant channel, I record the time of the last message.
function onMessage(msg) {
var payload = msg.getPayload();
msgTime = Sys.getTimer()/1000;
In onUpdate, I check how long it's been since the last message was received. If it's been too long, then I null and recreate the ANT channel. This will also get tripped if the DataField simply doesn't find a sensor in 10 seconds. This is pretty ugly because the Moxy Data field is frozen on the old readings for 10 seconds after waking up. Maybe there's a better way to detect that the Generic ANT channel is dead???
if (now - sensor.msgTime > 10) {
App.getApp().resetSensor();
}
Then in resetSensor, I null and recreate the Generic Channel.
function resetSensor() {
var sensorId = 0;
var sensorLx = getProperty("SensorLx").toNumber();
if (mSensor != null) {
var sensorId = mSensor.getId(); //If we've already paired to a sensor, remember the sensor number
}
mSensor = null;//null the dead Generic Ant Channel
try {
mSensor = new MoxySensor(sensorId, sensorLx);//create a new Generic Ant Channel
mSensor.open(); //Open the new channel
}
catch (exception) {
mSensor = null;
}
if (mView != null) {
mView.setSensor(mSensor);//pass the new channel into the View
}
}
It doesn't seem like this should be the intended functionality for a Generic ANT channel after waking up from sleep. A native ANT channel like cadence picks right up with new readings immediately upon reawakening.
Is this a bug in the Edge or should I keep working on a more elegant way to work around this issue?