Tool/software: TI-RTOS
Hi,
I am currently running a program based on the sensor example given by TI, with a collector based on the one also given by TI.
We are running in beacon mode, and I noticed a strange behavior (which I can easily follow in debug).
Say I have a sensor successfully associated to a collector in beacon mode. To simulate a sync loss, I reset the collector. Therefore, the sensor looses its synchronization to the collector, and the syncLossCb is hit in jdllc.c. Here I recall the code (given by TI) of the callback :
static void syncLossCb(ApiMac_mlmeSyncLossInd_t *pData) { if(pData->reason == ApiMac_status_beaconLoss) { /* Initialize counter for re-join delay calculation */ interimDelayTicks = Clock_getTicks(); if((parentFound == false) && (numSyncLoss == 0) && (devInfoBlock.currentJdllcState == Jdllc_states_joining)) { if(devInfoBlock.currentDevState != Jdllc_deviceStates_scanPassive) { switchState(Jdllc_deviceStates_scanPassive); } } else { /* Update stats */ device_msgStats.syncLossIndications++; if(numSyncLoss == 0) { numSyncLoss++; parentFound = false; /* retry sync request */ switchState(Jdllc_deviceStates_syncReq); } else { if(!CONFIG_RX_ON_IDLE) { /* Stop polling */ Ssf_setPollClock(0); } /* set up orphan scan */ switchState(Jdllc_deviceStates_scanOrphan); updateState(Jdllc_states_orphan); } } } if(macCallbacksCopy.pSyncLossIndCb != NULL) { macCallbacksCopy.pSyncLossIndCb(pData); } }
Notice the numSyncLoss variable, which is 0 the first time we loose the sync. So switchState(Jdllc_deviceStates_syncReq); is executed and an ApiMac_mlmeSyncReq() is issued to the mac layer. The sync is acquired back, all is well.
However, as there is no callback triggered when the sync is acquired, the numSyncLoss variable is not set back to 0.
So, say for exemple that 2 weeks later you loose the sync for some reason, then, you go back to the syncLossCb, but as numSyncLoss is now 1, the state is now changed to orphan instead of syncReq, and a ScanInd is issued and in my case, no scanCnf is received. The sensor is then unreachable.
Is there a way to detect that a sync was acquired back and then put this numSyncLoss back to 0 ? or is it safe, in Beacon mode, to stay in syncReq and not to go in orphan mode ?
Thanks for your help.
Alex