From c2446e77b000475fd96907b3c3e12ec1fd90c3ab Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Mon, 24 Aug 2009 21:13:21 -0600 Subject: [PATCH] FTSP related updates from CVS head, after tag release_tinyos_2_1_0_0. * Changes on CVS head through 8/23/09 for tos/lib/ftsp only. * Upstream commits to tos/chips/cc2420, Aug 7 2008 thru Jul 16 2009, EXCEPT: kusy Wed Aug 13 07:37:05 2008 +0000 Fixing T32khz to TMilli conversion - coeficient 32 needs to be... * Substitue for newest getTime32() by Miklos. --- tos/chips/cc2420/CC2420.h | 39 +++++++++- tos/chips/cc2420/CC2420ActiveMessageP.nc | 5 ++ tos/chips/cc2420/CC2420TimeSyncMessageC.nc | 7 +- tos/chips/cc2420/CC2420TimeSyncMessageP.nc | 16 ++-- tos/chips/cc2420/csma/CC2420CsmaP.nc | 3 +- tos/chips/cc2420/lpl/DefaultLplP.nc | 4 +- tos/chips/cc2420/receive/CC2420ReceiveP.nc | 27 +++++-- tos/chips/cc2420/spi/CC2420SpiC.nc | 2 + tos/chips/cc2420/transmit/CC2420TransmitP.nc | 65 ++++++++++------ tos/lib/ftsp/TimeSync32kC.nc | 80 ++++++++++++++++++++ tos/lib/ftsp/TimeSyncC.nc | 5 ++ tos/lib/ftsp/TimeSyncMsg.h | 14 +++- tos/lib/ftsp/TimeSyncP.nc | 36 ++++++--- 13 files changed, 244 insertions(+), 59 deletions(-) create mode 100644 tos/lib/ftsp/TimeSync32kC.nc diff --git a/tos/chips/cc2420/CC2420.h b/tos/chips/cc2420/CC2420.h index 1d607b92..798107f0 100644 --- a/tos/chips/cc2420/CC2420.h +++ b/tos/chips/cc2420/CC2420.h @@ -43,8 +43,43 @@ typedef uint8_t cc2420_status_t; #endif /** - * CC2420 header. An I-frame (interoperability frame) header has an - * extra network byte specified by 6LowPAN + * CC2420 header definition. + * + * An I-frame (interoperability frame) header has an extra network + * byte specified by 6LowPAN + * + * Length = length of the header + payload of the packet, minus the size + * of the length byte itself (1). This is what allows for variable + * length packets. + * + * FCF = Frame Control Field, defined in the 802.15.4 specs and the + * CC2420 datasheet. + * + * DSN = Data Sequence Number, a number incremented for each packet sent + * by a particular node. This is used in acknowledging that packet, + * and also filtering out duplicate packets. + * + * DestPan = The destination PAN (personal area network) ID, so your + * network can sit side by side with another TinyOS network and not + * interfere. + * + * Dest = The destination address of this packet. 0xFFFF is the broadcast + * address. + * + * Src = The local node ID that generated the message. + * + * Network = The TinyOS network ID, for interoperability with other types + * of 802.15.4 networks. + * + * Type = TinyOS AM type. When you create a new AMSenderC(AM_MYMSG), + * the AM_MYMSG definition is the type of packet. + * + * TOSH_DATA_LENGTH defaults to 28, it represents the maximum size of + * the payload portion of the packet, and is specified in the + * tos/types/message.h file. + * + * All of these fields will be filled in automatically by the radio stack + * when you attempt to send a message. */ typedef nx_struct cc2420_header_t { nxle_uint8_t length; diff --git a/tos/chips/cc2420/CC2420ActiveMessageP.nc b/tos/chips/cc2420/CC2420ActiveMessageP.nc index be409637..0db2423c 100644 --- a/tos/chips/cc2420/CC2420ActiveMessageP.nc +++ b/tos/chips/cc2420/CC2420ActiveMessageP.nc @@ -62,6 +62,11 @@ implementation { message_t* msg, uint8_t len) { cc2420_header_t* header = call CC2420PacketBody.getHeader( msg ); + + if (len > call Packet.maxPayloadLength()) { + return ESIZE; + } + header->type = id; header->dest = addr; header->destpan = call CC2420Config.getPanAddr(); diff --git a/tos/chips/cc2420/CC2420TimeSyncMessageC.nc b/tos/chips/cc2420/CC2420TimeSyncMessageC.nc index 745bd08e..94ed0c9a 100644 --- a/tos/chips/cc2420/CC2420TimeSyncMessageC.nc +++ b/tos/chips/cc2420/CC2420TimeSyncMessageC.nc @@ -60,8 +60,11 @@ implementation TimeSyncPacketMilli = CC2420TimeSyncMessageP; Packet = CC2420TimeSyncMessageP; - CC2420TimeSyncMessageP.SubSend -> CC2420ActiveMessageC.AMSend; - CC2420TimeSyncMessageP.SubPacket -> CC2420ActiveMessageC.Packet; + // use the AMSenderC infrastructure to avoid concurrent send clashes + components AMQueueP, ActiveMessageC; + CC2420TimeSyncMessageP.SubSend -> AMQueueP.Send[unique(UQ_AMQUEUE_SEND)]; + CC2420TimeSyncMessageP.AMPacket -> ActiveMessageC; + CC2420TimeSyncMessageP.SubPacket -> ActiveMessageC; CC2420TimeSyncMessageP.PacketTimeStamp32khz -> CC2420PacketC; CC2420TimeSyncMessageP.PacketTimeStampMilli -> CC2420PacketC; diff --git a/tos/chips/cc2420/CC2420TimeSyncMessageP.nc b/tos/chips/cc2420/CC2420TimeSyncMessageP.nc index a4e11573..70e677ae 100644 --- a/tos/chips/cc2420/CC2420TimeSyncMessageP.nc +++ b/tos/chips/cc2420/CC2420TimeSyncMessageP.nc @@ -37,7 +37,8 @@ module CC2420TimeSyncMessageP uses { - interface AMSend as SubSend[uint8_t id]; + interface Send as SubSend; + interface AMPacket; interface Packet as SubPacket; interface PacketTimeStamp as PacketTimeStamp32khz; @@ -93,7 +94,9 @@ implementation void * timesync = msg->data + len; *(timesync_radio_t*)timesync = event_time; - err = call SubSend.send[id](addr, msg, len + sizeof(timesync_radio_t)); + call AMPacket.setDestination(msg, addr); + call AMPacket.setType(msg, id); + err = call SubSend.send(msg, len + sizeof(timesync_radio_t)); call PacketTimeSyncOffset.set(msg); return err; } @@ -101,19 +104,19 @@ implementation command error_t TimeSyncAMSend32khz.cancel[am_id_t id](message_t* msg) { call PacketTimeSyncOffset.cancel(msg); - return call SubSend.cancel[id](msg); + return call SubSend.cancel(msg); } default event void TimeSyncAMSend32khz.sendDone[am_id_t id](message_t* msg, error_t error) {} command uint8_t TimeSyncAMSend32khz.maxPayloadLength[am_id_t id]() { - return call SubSend.maxPayloadLength[id]() - sizeof(timesync_radio_t); + return call SubSend.maxPayloadLength() - sizeof(timesync_radio_t); } command void* TimeSyncAMSend32khz.getPayload[am_id_t id](message_t* msg, uint8_t len) { - return call SubSend.getPayload[id](msg, len + sizeof(timesync_radio_t)); + return call SubSend.getPayload(msg, len + sizeof(timesync_radio_t)); } /*----------------- TimeSyncAMSendMilli -----------------*/ @@ -142,8 +145,9 @@ implementation } /*----------------- SubSend.sendDone -------------------*/ - event void SubSend.sendDone[am_id_t id](message_t* msg, error_t error) + event void SubSend.sendDone(message_t* msg, error_t error) { + am_id_t id = call AMPacket.type(msg); signal TimeSyncAMSend32khz.sendDone[id](msg, error); signal TimeSyncAMSendMilli.sendDone[id](msg, error); } diff --git a/tos/chips/cc2420/csma/CC2420CsmaP.nc b/tos/chips/cc2420/csma/CC2420CsmaP.nc index 670b7181..e67f9217 100644 --- a/tos/chips/cc2420/csma/CC2420CsmaP.nc +++ b/tos/chips/cc2420/csma/CC2420CsmaP.nc @@ -72,7 +72,6 @@ implementation { /****************** Prototypes ****************/ task void startDone_task(); - task void startDone_task(); task void stopDone_task(); task void sendDone_task(); @@ -144,7 +143,7 @@ implementation { metadata->ack = FALSE; metadata->rssi = 0; metadata->lqi = 0; - metadata->timesync = FALSE; + //metadata->timesync = FALSE; metadata->timestamp = CC2420_INVALID_TIMESTAMP; ccaOn = TRUE; diff --git a/tos/chips/cc2420/lpl/DefaultLplP.nc b/tos/chips/cc2420/lpl/DefaultLplP.nc index d93debb0..3ada9db6 100644 --- a/tos/chips/cc2420/lpl/DefaultLplP.nc +++ b/tos/chips/cc2420/lpl/DefaultLplP.nc @@ -230,7 +230,7 @@ implementation { return 0; } - return (DUTY_ON_TIME * (10000 - dutyCycle)) / dutyCycle; + return ((uint32_t)DUTY_ON_TIME * (10000 - dutyCycle)) / dutyCycle; } /** @@ -245,7 +245,7 @@ implementation { return 10000; } - return getActualDutyCycle((DUTY_ON_TIME * 10000) + return getActualDutyCycle(((uint32_t)DUTY_ON_TIME * 10000) / (sleepInterval + DUTY_ON_TIME)); } diff --git a/tos/chips/cc2420/receive/CC2420ReceiveP.nc b/tos/chips/cc2420/receive/CC2420ReceiveP.nc index 30a42191..5bd4e852 100644 --- a/tos/chips/cc2420/receive/CC2420ReceiveP.nc +++ b/tos/chips/cc2420/receive/CC2420ReceiveP.nc @@ -126,6 +126,10 @@ implementation { reset_state(); m_state = S_STARTED; atomic receivingPacket = FALSE; + /* Note: + We use the falling edge because the FIFOP polarity is reversed. + This is done in CC2420Power.startOscillator from CC2420ControlP.nc. + */ call InterruptFIFOP.enableFallingEdge(); } return SUCCESS; @@ -281,16 +285,25 @@ implementation { call SpiResource.release(); } - if ( m_timestamp_size ) { - if ( rxFrameLength > 10 ) { - call PacketTimeStamp.set(m_p_rx_buf, m_timestamp_queue[ m_timestamp_head ]); + //new packet is buffered up, or we don't have timestamp in fifo, or ack + if ( ( m_missed_packets && call FIFO.get() ) || !call FIFOP.get() + || !m_timestamp_size + || rxFrameLength <= 10) { + call PacketTimeStamp.clear(m_p_rx_buf); + } + else { + if (m_timestamp_size==1) + call PacketTimeStamp.set(m_p_rx_buf, m_timestamp_queue[ m_timestamp_head ]); m_timestamp_head = ( m_timestamp_head + 1 ) % TIMESTAMP_QUEUE_SIZE; m_timestamp_size--; - } - } else { - call PacketTimeStamp.clear(m_p_rx_buf); + + if (m_timestamp_size>0) { + call PacketTimeStamp.clear(m_p_rx_buf); + m_timestamp_head = 0; + m_timestamp_size = 0; + } } - + // We may have received an ack that should be processed by Transmit // buf[rxFrameLength] >> 7 checks the CRC if ( ( buf[ rxFrameLength ] >> 7 ) && rx_buf ) { diff --git a/tos/chips/cc2420/spi/CC2420SpiC.nc b/tos/chips/cc2420/spi/CC2420SpiC.nc index 13e17c4f..50e015e9 100644 --- a/tos/chips/cc2420/spi/CC2420SpiC.nc +++ b/tos/chips/cc2420/spi/CC2420SpiC.nc @@ -79,6 +79,7 @@ generic configuration CC2420SpiC() { provides interface CC2420Register as MANAND; provides interface CC2420Register as MANOR; provides interface CC2420Register as AGCCTRL; + provides interface CC2420Register as RXFIFO_REGISTER; // ram provides interface CC2420Ram as IEEEADR; @@ -142,6 +143,7 @@ implementation { MANAND = Spi.Reg[ CC2420_MANAND ]; MANOR = Spi.Reg[ CC2420_MANOR ]; AGCCTRL = Spi.Reg[ CC2420_AGCCTRL ]; + RXFIFO_REGISTER = Spi.Reg[ CC2420_RXFIFO ]; // ram IEEEADR = Spi.Ram[ CC2420_RAM_IEEEADR ]; diff --git a/tos/chips/cc2420/transmit/CC2420TransmitP.nc b/tos/chips/cc2420/transmit/CC2420TransmitP.nc index 1b6cd48f..cd640b1e 100644 --- a/tos/chips/cc2420/transmit/CC2420TransmitP.nc +++ b/tos/chips/cc2420/transmit/CC2420TransmitP.nc @@ -236,12 +236,11 @@ implementation { } - inline uint32_t time16to32(uint16_t time, uint32_t recent_time) + inline uint32_t getTime32(uint16_t time) { - if ((recent_time&0xFFFF)data + (call PacketTimeSyncOffset.get(m_msg) - sizeof(cc2420_header_t)); - timesync_radio_t *timesync = (timesync_radio_t*)taddr; + uint8_t absOffset = sizeof(message_header_t)-sizeof(cc2420_header_t)+call PacketTimeSyncOffset.get(m_msg); + timesync_radio_t *timesync = (timesync_radio_t *)((nx_uint8_t*)m_msg+absOffset); // set timesync event time as the offset between the event time and the SFD interrupt time (TEP 133) *timesync -= time32; call CSN.clr(); - call TXFIFO_RAM.write( call PacketTimeSyncOffset.get(m_msg), (uint8_t*)timesync, sizeof(timesync_radio_t) ); + call TXFIFO_RAM.write( absOffset, (uint8_t*)timesync, sizeof(timesync_radio_t) ); call CSN.set(); + //restoring the event time to the original value + *timesync += time32; } if ( (call CC2420PacketBody.getHeader( m_msg ))->fcf & ( 1 << IEEE154_FCF_ACK_REQ ) ) { @@ -284,16 +290,11 @@ implementation { releaseSpiResource(); call BackoffTimer.stop(); - - if ( ( ( (call CC2420PacketBody.getHeader( m_msg ))->fcf >> IEEE154_FCF_FRAME_TYPE ) & 7 ) == IEEE154_TYPE_DATA ) { - call PacketTimeStamp.set(m_msg, time32); - } - if ( call SFD.get() ) { break; } /** Fall Through because the next interrupt was already received */ - + case S_EFD: sfdHigh = FALSE; call CaptureSFD.captureRisingEdge(); @@ -311,9 +312,12 @@ implementation { /** Fall Through because the next interrupt was already received */ default: - if ( !m_receiving ) { + /* this is the SFD for received messages */ + if ( !m_receiving && sfdHigh == FALSE ) { sfdHigh = TRUE; call CaptureSFD.captureFallingEdge(); + // safe the SFD pin status for later use + sfd_state = call SFD.get(); call CC2420Receive.sfd( time32 ); m_receiving = TRUE; m_prev_time = time; @@ -321,18 +325,29 @@ implementation { // wait for the next interrupt before moving on return; } + // if SFD.get() = 0, then an other interrupt happened since we + // reconfigured CaptureSFD! Fall through } - sfdHigh = FALSE; - call CaptureSFD.captureRisingEdge(); - m_receiving = FALSE; - if ( time - m_prev_time < 10 ) { - call CC2420Receive.sfd_dropped(); - if (m_msg) - call PacketTimeStamp.clear(m_msg); + if ( sfdHigh == TRUE ) { + sfdHigh = FALSE; + call CaptureSFD.captureRisingEdge(); + m_receiving = FALSE; + /* if sfd_state is 1, then we fell through, but at the time of + * saving the time stamp the SFD was still high. Thus, the timestamp + * is valid. + * if the sfd_state is 0, then either we fell through and SFD + * was low while we safed the time stamp, or we didn't fall through. + * Thus, we check for the time between the two interrupts. + * FIXME: Why 10 tics? Seams like some magic number... + */ + if ((sfd_state == 0) && (time - m_prev_time < 10) ) { + call CC2420Receive.sfd_dropped(); + if (m_msg) + call PacketTimeStamp.clear(m_msg); + } + break; } - break; - } } } diff --git a/tos/lib/ftsp/TimeSync32kC.nc b/tos/lib/ftsp/TimeSync32kC.nc new file mode 100644 index 00000000..f709829e --- /dev/null +++ b/tos/lib/ftsp/TimeSync32kC.nc @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2002, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti, Brano Kusy, Janos Sallai + * Date last modified: 3/17/03 + * Ported to T2: 3/17/08 by Brano Kusy (branislav.kusy@gmail.com) + * Adapted for 32kHz and LPL: 6/16/09 by Thomas Schmid (thomas.schmid@ucla.edu) + */ + +#include "TimeSyncMsg.h" + +configuration TimeSync32kC +{ + uses interface Boot; + provides interface Init; + provides interface StdControl; + provides interface GlobalTime; + + //interfaces for extra fcionality: need not to be wired + provides interface TimeSyncInfo; + provides interface TimeSyncMode; + provides interface TimeSyncNotify; +} + +implementation +{ + components new TimeSyncP(T32khz) as TimeSyncP; + + GlobalTime = TimeSyncP; + StdControl = TimeSyncP; + Init = TimeSyncP; + Boot = TimeSyncP; + TimeSyncInfo = TimeSyncP; + TimeSyncMode = TimeSyncP; + TimeSyncNotify = TimeSyncP; + + components TimeSyncMessageC as ActiveMessageC; + TimeSyncP.RadioControl -> ActiveMessageC; + TimeSyncP.Send -> ActiveMessageC.TimeSyncAMSend32khz[AM_TIMESYNCMSG]; + TimeSyncP.Receive -> ActiveMessageC.Receive[AM_TIMESYNCMSG]; + TimeSyncP.TimeSyncPacket -> ActiveMessageC; + + components Counter32khz32C, new CounterToLocalTimeC(T32khz) as LocalTime32khzC; + LocalTime32khzC.Counter -> Counter32khz32C; + TimeSyncP.LocalTime -> LocalTime32khzC; + + components new TimerMilliC() as TimerC; + TimeSyncP.Timer -> TimerC; + +#if defined(TIMESYNC_LEDS) + components LedsC; +#else + components NoLedsC as LedsC; +#endif + TimeSyncP.Leds -> LedsC; + +#ifdef LOW_POWER_LISTENING + components CC2420ActiveMessageC; + TimeSyncP.LowPowerListening -> CC2420ActiveMessageC; +#endif + + +} diff --git a/tos/lib/ftsp/TimeSyncC.nc b/tos/lib/ftsp/TimeSyncC.nc index 58af71d2..8022d8a9 100644 --- a/tos/lib/ftsp/TimeSyncC.nc +++ b/tos/lib/ftsp/TimeSyncC.nc @@ -69,4 +69,9 @@ implementation #endif TimeSyncP.Leds -> LedsC; +#ifdef LOW_POWER_LISTENING + components CC2420ActiveMessageC; + TimeSyncP.LowPowerListening -> CC2420ActiveMessageC; +#endif + } diff --git a/tos/lib/ftsp/TimeSyncMsg.h b/tos/lib/ftsp/TimeSyncMsg.h index a9e6e393..f45c2b34 100644 --- a/tos/lib/ftsp/TimeSyncMsg.h +++ b/tos/lib/ftsp/TimeSyncMsg.h @@ -32,10 +32,16 @@ typedef nx_struct TimeSyncMsg nx_uint16_t nodeID; // the node if of the sender nx_uint8_t seqNum; // sequence number for the root - /* This field is initially set to the offset between global time and local - * time. The TimeStamping component will add the current local time when the - * message is actually transmitted. Thus the receiver will receive the - * global time of the sender when the message is actually sent. */ + /* + * After TEP 133, the message timestamp contains the difference between + * event time and the time the message was actually sent out. TimeSyncP + * sends the local time associated with this globalTime to the + * TimeStamping mechanism, which then calculates the difference. + * + * On the receiving side, the difference is applied to the local + * timestamp. The receiving timestamp thus represents the time on the + * receiving clock when the remote globalTime was taken. + */ nx_uint32_t globalTime; //just for convenience diff --git a/tos/lib/ftsp/TimeSyncP.nc b/tos/lib/ftsp/TimeSyncP.nc index fc2ef994..3c3affe8 100644 --- a/tos/lib/ftsp/TimeSyncP.nc +++ b/tos/lib/ftsp/TimeSyncP.nc @@ -46,6 +46,12 @@ generic module TimeSyncP(typedef precision_tag) interface Leds; interface TimeSyncPacket; interface LocalTime as LocalTime; + + +#ifdef LOW_POWER_LISTENING + interface LowPowerListening; +#endif + } } implementation @@ -61,7 +67,7 @@ implementation IGNORE_ROOT_MSG = 4, // after becoming the root ignore other roots messages (in send period) ENTRY_VALID_LIMIT = 4, // number of entries to become synchronized ENTRY_SEND_LIMIT = 3, // number of entries to send sync messages - ENTRY_THROWOUT_LIMIT = 100, // if time sync error is bigger than this clear the table + ENTRY_THROWOUT_LIMIT = 500, // if time sync error is bigger than this clear the table }; typedef struct TableItem @@ -150,6 +156,8 @@ implementation float newSkew = skew; uint32_t newLocalAverage; int32_t newOffsetAverage; + int32_t localAverageRest; + int32_t offsetAverageRest; int64_t localSum; int64_t offsetSum; @@ -169,16 +177,23 @@ implementation newOffsetAverage = table[i].timeOffset; localSum = 0; + localAverageRest = 0; offsetSum = 0; + offsetAverageRest = 0; while( ++i < MAX_ENTRIES ) if( table[i].state == ENTRY_FULL ) { + /* + This only works because C ISO 1999 defines the signe for modulo the same as for the Dividend! + */ localSum += (int32_t)(table[i].localTime - newLocalAverage) / tableEntries; + localAverageRest += (table[i].localTime - newLocalAverage) % tableEntries; offsetSum += (int32_t)(table[i].timeOffset - newOffsetAverage) / tableEntries; + offsetAverageRest += (table[i].timeOffset - newOffsetAverage) % tableEntries; } - newLocalAverage += localSum; - newOffsetAverage += offsetSum; + newLocalAverage += localSum + localAverageRest / tableEntries; + newOffsetAverage += offsetSum + offsetAverageRest / tableEntries; localSum = offsetSum = 0; for(i = 0; i < MAX_ENTRIES; ++i) @@ -218,8 +233,6 @@ implementation uint32_t age, oldestTime = 0; int32_t timeError; - tableEntries = 0; - // clear table if the received entry's been inconsistent for some time timeError = msg->localTime; call GlobalTime.local2Global((uint32_t*)(&timeError)); @@ -229,10 +242,11 @@ implementation { if (++numErrors>3) clearTable(); + return; // don't incorporate a bad reading } - else - numErrors = 0; + tableEntries = 0; // don't reset table size unless you're recounting + numErrors = 0; for(i = 0; i < MAX_ENTRIES; ++i) { age = msg->localTime - table[i].localTime; @@ -302,7 +316,8 @@ implementation if( diff < -16 || diff > 16 ) return msg; #endif - if( (state & STATE_PROCESSING) == 0 ) { + if( (state & STATE_PROCESSING) == 0 + && call TimeSyncPacket.isValid(msg)) { message_t* old = processedMsg; processedMsg = msg; @@ -344,6 +359,9 @@ implementation outgoingMsg->globalTime = globalTime; +#ifdef LOW_POWER_LISTENING + call LowPowerListening.setRxSleepInterval(&outgoingMsgBuffer, LPL_INTERVAL); +#endif // we don't send time sync msg, if we don't have enough data if( numEntries < ENTRY_SEND_LIMIT && outgoingMsg->rootID != TOS_NODE_ID ){ ++heartBeats; @@ -399,7 +417,7 @@ implementation if (mode == mode_) return SUCCESS; - if (mode_ == TS_USER_MODE){ + if (mode_ == TS_TIMER_MODE){ call Timer.startPeriodic((uint32_t)1000 * BEACON_RATE); } else -- 2.39.2