This logic works almost all of the time and my data field gets reliable data from my TEMPE ANT sensor. But every once in a blue moon, mid-ride, my data field aborts on ORANGE line after successfully listening to my TEMPE sensor for maybe a few hours into the ride.
Today the reported error was:
Error: System Error
Details: 'Failed invoking <symbol>'
Is my try/catch logic wrong, or this just isn't catchable?
What would cause a "Failed Invoking" abort in code that almost always works perfectly fine? You can see the only places I set "search = true", other than the initialization. So possibly it is rare that I ever call "getDeviceConfig()" a 2nd time, and that is when this fails?
Or maybe I need to force a channel close and open, if I ever get to "MSG_CODE_EVENT_RX_FAIL_GO_TO_SEARCH"?
Any ideas? I want to prevent the data field from aborting mid-ride on users.
Thanks!
====
function onMessage(msg) {
var payload = msg.getPayload();
var myPage = payload[0].toNumber() & 0xFF;
var dp;
myATTRIBS = "Page:" + myPage + "/" + msg.messageId + "/" + msg.deviceType + "/" + msg.transmissionType + "/" + msg.rssi;
//! THIS BLOCK DEALS WITH BROADCAST DATA
if (Ant.MSG_ID_BROADCAST_DATA == msg.messageId ) {
// Were we searching?
if (searching == true) {
searching = false;
try { deviceCfg = GenericChannel.getDeviceConfig(); } catch(ex) { deviceCfg = null; }
}
if (deviceCfg != null) { TEMPEinstance.deviceNum = deviceCfg.deviceNumber; }
dp = new TempeDataPage();
dp.TEMPEparse(payload, TEMPEinstance);
}
//! THIS BLOCK DEALS A CHANNEL RESPONSE EVENT
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)) { GenericChannel.open(); searching = true; }
else if (Ant.MSG_CODE_EVENT_RX_FAIL_GO_TO_SEARCH == (payload[1] & 0xFF) ) { searching = true; }
}
}
}