components TimeSyncMessageC as ActiveMessageC;
TimeSyncP.RadioControl -> ActiveMessageC;
- TimeSyncP.Send -> ActiveMessageC.TimeSyncAMSendMilli[AM_TIMESYNCMSG];
- TimeSyncP.Receive -> ActiveMessageC.Receive[AM_TIMESYNCMSG];
+ TimeSyncP.Send -> ActiveMessageC.TimeSyncAMSendMilli[TIMESYNC_AM_FTSP];
+ TimeSyncP.Receive -> ActiveMessageC.Receive[TIMESYNC_AM_FTSP];
TimeSyncP.TimeSyncPacket -> ActiveMessageC;
components HilTimerMilliC;
components new TimerMilliC() as TimerC;
TimeSyncP.Timer -> TimerC;
+ components RandomC;
+ TimeSyncP.Random -> RandomC;
+
#if defined(TIMESYNC_LEDS)
components LedsC;
#else
} TimeSyncMsg;
enum {
- AM_TIMESYNCMSG = 0x3E,
+ TIMESYNC_AM_FTSP = 0x3E,
TIMESYNCMSG_LEN = sizeof(TimeSyncMsg) - sizeof(nx_uint32_t),
TS_TIMER_MODE = 0, // see TimeSyncMode interface
TS_USER_MODE = 1, // see TimeSyncMode interface
interface TimeSyncAMSend<precision_tag,uint32_t> as Send;
interface Receive;
interface Timer<TMilli>;
+ interface Random;
interface Leds;
interface TimeSyncPacket<precision_tag,uint32_t>;
interface LocalTime<precision_tag> as LocalTime;
if( diff < -16 || diff > 16 )
return msg;
#endif
+
if( (state & STATE_PROCESSING) == 0
&& call TimeSyncPacket.isValid(msg)) {
message_t* old = processedMsg;
}
outgoingMsg->globalTime = globalTime;
-
#ifdef LOW_POWER_LISTENING
call LowPowerListening.setRemoteWakeupInterval(&outgoingMsgBuffer, LPL_INTERVAL);
#endif
}
command error_t TimeSyncMode.setMode(uint8_t mode_){
- if (mode == mode_)
- return SUCCESS;
-
if (mode_ == TS_TIMER_MODE){
- call Timer.startPeriodic((uint32_t)1000 * BEACON_RATE);
+ call Timer.startPeriodic((uint32_t)(896U+(call Random.rand16()&0xFF)) * BEACON_RATE);
}
else
call Timer.stop();
command error_t StdControl.start()
{
- mode = TS_TIMER_MODE;
heartBeats = 0;
outgoingMsg->nodeID = TOS_NODE_ID;
- call Timer.startPeriodic((uint32_t)1000 * BEACON_RATE);
+ call TimeSyncMode.setMode(TS_TIMER_MODE);
return SUCCESS;
}