[Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/telosb/mac/tkn154 Ieee802154BeaconEnabledC.nc, NONE, 1.1 Ieee802154NonBeaconEnabledC.nc, NONE, 1.1 platform_message.h, 1.1, 1.2 TKN154_platform.h, 1.2, 1.3 TKN154TimingP.nc, 1.2, 1.3
Jan-Hinrich Hauer
janhauer at users.sourceforge.net
Wed Mar 4 10:31:58 PST 2009
Update of /cvsroot/tinyos/tinyos-2.x/tos/platforms/telosb/mac/tkn154
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17605/tos/platforms/telosb/mac/tkn154
Modified Files:
platform_message.h TKN154_platform.h TKN154TimingP.nc
Added Files:
Ieee802154BeaconEnabledC.nc Ieee802154NonBeaconEnabledC.nc
Log Message:
- re-designed the radio driver interfaces, restructured/improved the CC2420 radio driver
- split the main MAC configuration (was TKN154P.nc) in two: one for beacon-enabled mode the other for nonbeacon-enabled mode (this decision has to be made at compile time now)
- added (serial) debugging functions (compile with "TKN154_DEBUG=1 make telosb" and use the java PrintfClient, see tinyos-2.x/apps/tests/TestPrintf/README.txt)
- improved readability, added comments
--- NEW FILE: Ieee802154BeaconEnabledC.nc ---
/*
* Copyright (c) 2008, Technische Universitaet Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Technische Universitaet Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* - Revision -------------------------------------------------------------
* $Revision: 1.1 $
* $Date: 2009/03/04 18:31:50 $
* @author: Jan Hauer <hauer at tkn.tu-berlin.de>
* ========================================================================
*/
#include "TKN154.h"
#include "TKN154_DEBUG.h"
configuration Ieee802154BeaconEnabledC
{
provides
{
// MCPS-SAP
interface MCPS_DATA;
interface MCPS_PURGE;
// MLME-SAP
interface MLME_ASSOCIATE;
interface MLME_BEACON_NOTIFY;
interface MLME_COMM_STATUS;
interface MLME_DISASSOCIATE;
interface MLME_GET;
/* interface MLME_GTS;*/
interface MLME_ORPHAN;
interface MLME_POLL;
interface MLME_RESET;
interface MLME_RX_ENABLE;
interface MLME_SCAN;
interface MLME_SET;
interface MLME_START;
interface MLME_SYNC;
interface MLME_SYNC_LOSS;
interface IEEE154Frame;
interface IEEE154BeaconFrame;
interface IEEE154TxBeaconPayload;
interface SplitControl as PromiscuousMode;
interface Get<uint64_t> as LocalExtendedAddress;
interface Timestamp;
interface Packet;
}
}
implementation
{
components TKN154BeaconEnabledP as MAC;
MLME_START = MAC;
MLME_GET = MAC;
MLME_SET = MAC;
MLME_RESET = MAC;
MLME_SYNC = MAC;
MLME_SYNC_LOSS = MAC;
MLME_BEACON_NOTIFY = MAC;
MLME_SCAN = MAC;
MCPS_DATA = MAC;
MCPS_PURGE = MAC;
MLME_ASSOCIATE = MAC;
MLME_DISASSOCIATE = MAC;
MLME_COMM_STATUS = MAC;
MLME_RX_ENABLE = MAC;
MLME_POLL = MAC;
MLME_ORPHAN = MAC;
IEEE154Frame = MAC;
IEEE154BeaconFrame = MAC;
LocalExtendedAddress = MAC;
IEEE154TxBeaconPayload = MAC;
PromiscuousMode = MAC;
Packet = MAC;
components CC2420TKN154C as PHY,
new Alarm62500hz32C() as PHYAlarm1,
new Alarm62500hz32VirtualizedC() as PHYAlarm2,
new Alarm62500hz32C() as TKN154TimingPAlarm,
LocalTime62500hzC, TKN154TimingP;
// wire PHY to the PIB
PHY.PIBUpdate[IEEE154_macShortAddress] -> MAC.PIBUpdate[IEEE154_macShortAddress];
PHY.PIBUpdate[IEEE154_macPANId] -> MAC.PIBUpdate[IEEE154_macPANId];
PHY.PIBUpdate[IEEE154_phyCurrentChannel] -> MAC.PIBUpdate[IEEE154_phyCurrentChannel];
PHY.PIBUpdate[IEEE154_phyTransmitPower] -> MAC.PIBUpdate[IEEE154_phyTransmitPower];
PHY.PIBUpdate[IEEE154_phyCCAMode] -> MAC.PIBUpdate[IEEE154_phyCCAMode];
PHY.PIBUpdate[IEEE154_macPanCoordinator] -> MAC.PIBUpdate[IEEE154_macPanCoordinator];
Timestamp = PHY;
PHY.Alarm1 -> PHYAlarm1;
PHY.Alarm2 -> PHYAlarm2;
PHY.LocalTime -> LocalTime62500hzC;
PHY.CaptureTime -> TKN154TimingP;
PHY.ReliableWait -> TKN154TimingP;
PHY.ReferenceTime -> TKN154TimingP;
PHY.TimeCalc -> MAC;
TKN154TimingP.TimeCalc -> MAC;
TKN154TimingP.Leds -> LedsC;
TKN154TimingP.CCA -> PHY;
TKN154TimingP.SymbolAlarm -> TKN154TimingPAlarm;
components new Alarm62500hz32VirtualizedC() as MACAlarm1,
new Alarm62500hz32VirtualizedC() as MACAlarm2,
new Alarm62500hz32VirtualizedC() as MACAlarm3,
new Alarm62500hz32VirtualizedC() as MACAlarm4,
new Alarm62500hz32VirtualizedC() as MACAlarm5,
new Alarm62500hz32VirtualizedC() as MACAlarm6,
new Alarm62500hz32VirtualizedC() as MACAlarm7,
new Alarm62500hz32VirtualizedC() as MACAlarm8,
new Alarm62500hz32VirtualizedC() as MACAlarm9,
new Timer62500C() as MACTimer1,
new Timer62500C() as MACTimer2,
new Timer62500C() as MACTimer3,
new Timer62500C() as MACTimer4,
new Timer62500C() as MACTimer5;
MAC.Alarm1 -> MACAlarm1;
MAC.Alarm2 -> MACAlarm2;
MAC.Alarm3 -> MACAlarm3;
MAC.Alarm4 -> MACAlarm4;
MAC.Alarm5 -> MACAlarm5;
MAC.Alarm6 -> MACAlarm6;
MAC.Alarm7 -> MACAlarm7;
MAC.Alarm8 -> MACAlarm8;
MAC.Alarm9 -> MACAlarm9;
MAC.Timer1 -> MACTimer1;
MAC.Timer2 -> MACTimer2;
MAC.Timer3 -> MACTimer3;
MAC.Timer4 -> MACTimer4;
MAC.Timer5 -> MACTimer5;
MAC.LocalTime -> LocalTime62500hzC;
// wire MAC <-> PHY
MAC.RadioTx -> PHY;
MAC.SlottedCsmaCa -> PHY;
MAC.RadioRx -> PHY;
MAC.RadioOff -> PHY;
MAC.EnergyDetection -> PHY;
MAC.PhySplitControl -> PHY;
MAC.RadioPromiscuousMode -> PHY.RadioPromiscuousMode;
PHY.FrameUtility -> MAC;
components RandomC, LedsC, NoLedsC;
MAC.Random -> RandomC;
MAC.Leds -> LedsC;
PHY.Random -> RandomC;
#ifdef TKN154_DEBUG
components DebugC;
#endif
}
--- NEW FILE: Ieee802154NonBeaconEnabledC.nc ---
/*
* Copyright (c) 2008, Technische Universitaet Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Technische Universitaet Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* - Revision -------------------------------------------------------------
* $Revision: 1.1 $
* $Date: 2009/03/04 18:31:50 $
* @author: Jan Hauer <hauer at tkn.tu-berlin.de>
* ========================================================================
*/
#include "TKN154.h"
#include "TKN154_DEBUG.h"
configuration Ieee802154NonBeaconEnabledC
{
provides
{
// MCPS-SAP
interface MCPS_DATA;
interface MCPS_PURGE;
// MLME-SAP
interface MLME_ASSOCIATE;
interface MLME_BEACON_NOTIFY;
interface MLME_COMM_STATUS;
interface MLME_DISASSOCIATE;
interface MLME_GET;
interface MLME_ORPHAN;
interface MLME_POLL;
interface MLME_RESET;
interface MLME_RX_ENABLE;
interface MLME_SCAN;
interface MLME_SET;
interface MLME_START;
interface IEEE154Frame;
interface IEEE154BeaconFrame;
interface SplitControl as PromiscuousMode;
interface Get<uint64_t> as LocalExtendedAddress;
interface Timestamp;
interface Packet;
}
}
implementation
{
components TKN154NonBeaconEnabledP as MAC;
MLME_START = MAC;
MLME_GET = MAC;
MLME_SET = MAC;
MLME_RESET = MAC;
MLME_BEACON_NOTIFY = MAC;
MLME_SCAN = MAC;
MCPS_DATA = MAC;
MCPS_PURGE = MAC;
MLME_ASSOCIATE = MAC;
MLME_DISASSOCIATE = MAC;
MLME_COMM_STATUS = MAC;
MLME_RX_ENABLE = MAC;
MLME_POLL = MAC;
MLME_ORPHAN = MAC;
IEEE154Frame = MAC;
IEEE154BeaconFrame = MAC;
LocalExtendedAddress = MAC;
PromiscuousMode = MAC;
Packet = MAC;
components CC2420TKN154C as PHY,
new Alarm62500hz32C() as PHYAlarm1,
new Alarm62500hz32VirtualizedC() as PHYAlarm2,
new Alarm62500hz32C() as TKN154TimingPAlarm,
LocalTime62500hzC, TKN154TimingP;
// wire PHY to the PIB
PHY.PIBUpdate[IEEE154_macShortAddress] -> MAC.PIBUpdate[IEEE154_macShortAddress];
PHY.PIBUpdate[IEEE154_macPANId] -> MAC.PIBUpdate[IEEE154_macPANId];
PHY.PIBUpdate[IEEE154_phyCurrentChannel] -> MAC.PIBUpdate[IEEE154_phyCurrentChannel];
PHY.PIBUpdate[IEEE154_phyTransmitPower] -> MAC.PIBUpdate[IEEE154_phyTransmitPower];
PHY.PIBUpdate[IEEE154_phyCCAMode] -> MAC.PIBUpdate[IEEE154_phyCCAMode];
PHY.PIBUpdate[IEEE154_macPanCoordinator] -> MAC.PIBUpdate[IEEE154_macPanCoordinator];
Timestamp = PHY;
PHY.Alarm1 -> PHYAlarm1;
PHY.Alarm2 -> PHYAlarm2;
PHY.LocalTime -> LocalTime62500hzC;
PHY.CaptureTime -> TKN154TimingP;
PHY.ReliableWait -> TKN154TimingP;
PHY.ReferenceTime -> TKN154TimingP;
PHY.TimeCalc -> MAC;
TKN154TimingP.TimeCalc -> MAC;
TKN154TimingP.Leds -> LedsC;
TKN154TimingP.CCA -> PHY;
TKN154TimingP.SymbolAlarm -> TKN154TimingPAlarm;
components new Timer62500C() as MACTimer1,
new Timer62500C() as MACTimer2,
new Timer62500C() as MACTimer3,
new Timer62500C() as MACTimer4,
new Timer62500C() as MACTimer5;
MAC.Timer1 -> MACTimer1;
MAC.Timer2 -> MACTimer2;
MAC.Timer3 -> MACTimer3;
MAC.Timer4 -> MACTimer4;
MAC.Timer5 -> MACTimer5;
MAC.LocalTime -> LocalTime62500hzC;
// wire MAC <-> PHY
MAC.RadioTx -> PHY;
MAC.UnslottedCsmaCa -> PHY;
MAC.RadioRx -> PHY;
MAC.RadioOff -> PHY;
MAC.EnergyDetection -> PHY;
MAC.PhySplitControl -> PHY;
MAC.RadioPromiscuousMode -> PHY.RadioPromiscuousMode;
PHY.FrameUtility -> MAC;
components RandomC, LedsC, NoLedsC;
MAC.Random -> RandomC;
MAC.Leds -> LedsC;
PHY.Random -> RandomC;
#ifdef TKN154_DEBUG
components DebugC;
#endif
}
Index: platform_message.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/telosb/mac/tkn154/platform_message.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** platform_message.h 16 Jun 2008 18:05:14 -0000 1.1
--- platform_message.h 4 Mar 2009 18:31:50 -0000 1.2
***************
*** 12,16 ****
typedef struct {
uint8_t control; // stores length (lower 7 bits), top bit -> promiscuous mode
! uint8_t mhr[23];
} ieee154_header_t;
--- 12,16 ----
typedef struct {
uint8_t control; // stores length (lower 7 bits), top bit -> promiscuous mode
! uint8_t mhr[23]; // maximum header size without security
} ieee154_header_t;
***************
*** 22,28 ****
#endif
! #ifdef TOSH_DATA_LENGTH
! #undef TOSH_DATA_LENGTH
! #endif
// TOSH_DATA_LENGTH may be smaller than 118, but then we'll
// not be able to receive/send all IEEE 802.15.4 packets
--- 22,28 ----
#endif
! //#ifdef TOSH_DATA_LENGTH
! //#undef TOSH_DATA_LENGTH
! //#endif
// TOSH_DATA_LENGTH may be smaller than 118, but then we'll
// not be able to receive/send all IEEE 802.15.4 packets
Index: TKN154_platform.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/telosb/mac/tkn154/TKN154_platform.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TKN154_platform.h 25 Nov 2008 09:35:09 -0000 1.2
--- TKN154_platform.h 4 Mar 2009 18:31:56 -0000 1.3
***************
*** 39,72 ****
/****************************************************
* The following constants define guard times on Tmote Sky / TelosB.
! * All values are in symbol time (1 symbol = 16 us)
*/
enum {
! // guard time to give up the token before actual end of CAP/CFP
! IEEE154_ACTIVE_PERIOD_GUARD_TIME = 300,
!
! // the expected time for a RadioTx.prepare() operation to execute (return)
! IEEE154_RADIO_TX_PREPARE_DELAY = 220,
!
! // the *guaranteed maximum* time between calling a RadioTx.transmit() and the
! // first PPDU bit being put onto the channel, assuming that RadioTx.transmit()
! // is called inside an atomic block
! IEEE154_RADIO_TX_SEND_DELAY = 100,
!
! // the expected time for a RadioRx.prepare() operation to execute (return)
! IEEE154_RADIO_RX_PREPARE_DELAY = 300,
! // the *guaranteed maximum* time between calling a RadioTx.transmit() and the
! // first PPDU bit being put onto the channel, assuming that RadioTx.transmit()
! // is called inside an atomic block
! IEEE154_RADIO_RX_DELAY = 100,
! // defines at what time the MAC payload for a beacon frame is assembled prior
! // to the next scheduled beacon transmission time; must be smaller than both
! // the beacon interval and IEEE154_RADIO_TX_PREPARE_DELAY
BEACON_PAYLOAD_UPDATE_INTERVAL = 2500,
};
! typedef uint32_t ieee154_reftime_t;
#endif
--- 39,62 ----
/****************************************************
* The following constants define guard times on Tmote Sky / TelosB.
! * All values are in symbol time (1 symbol = 16 us) and assume the
! * default system configuration (MCLK running at 4.6 MHz)
*/
enum {
! // the expected maximum time between calling a transmit() operation and
! // the radio putting the first byte on the channel assuming no CSMA-CA
! IEEE154_RADIO_TX_DELAY = 400,
! // the expected maximum time between calling a receive() operation and the
! // the radio actually being put in receive mode
! IEEE154_RADIO_RX_DELAY = 400,
! // defines at what time the MAC payload for a beacon frame is assembled before
! // the next scheduled beacon transmission time; the value must be smaller than
! // the beacon interval plus the time for preparing the Tx operation
BEACON_PAYLOAD_UPDATE_INTERVAL = 2500,
};
! typedef uint32_t ieee154_timestamp_t;
#endif
Index: TKN154TimingP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/telosb/mac/tkn154/TKN154TimingP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TKN154TimingP.nc 25 Nov 2008 09:35:09 -0000 1.2
--- TKN154TimingP.nc 4 Mar 2009 18:31:56 -0000 1.3
***************
*** 36,41 ****
/**
* In slotted CSMA-CA frames must be sent on backoff boundaries (slot width:
! * 320 us). The TelosB platform lacks a clock with sufficient precision/
! * accuracy, i.e. for slotted CSMA-CA the timing is *not* standard compliant.
*/
--- 36,42 ----
/**
* In slotted CSMA-CA frames must be sent on backoff boundaries (slot width:
! * 320 us). The TelosB platform lacks a clock with sufficient precision and
! * accuracy, i.e. for slotted CSMA-CA the timing is *not* standard compliant
! * (this code is experimental)
*/
***************
*** 47,50 ****
--- 48,52 ----
provides interface ReferenceTime;
uses interface TimeCalc;
+ uses interface GetNow<bool> as CCA;
uses interface Alarm<T62500hz,uint32_t> as SymbolAlarm;
uses interface Leds;
***************
*** 60,71 ****
uint8_t m_state = S_WAIT_OFF;
! async command void CaptureTime.convert(uint16_t time, ieee154_reftime_t *localTime, int16_t offset)
{
// TimerB is used for capturing, it is sourced by ACLK (32768Hz),
! // we now need to convert the capture "time" into ieee154_reftime_t.
// With the 32768Hz quartz we don't have enough precision anyway,
// so the code below generates a timestamp that is not accurate
- // (deviating about +-50 microseconds, which could probably
- // improved if we don't go through LocalTime)
uint16_t tbr1, tbr2, delta;
uint32_t now;
--- 62,71 ----
uint8_t m_state = S_WAIT_OFF;
! async command error_t CaptureTime.convert(uint16_t time, ieee154_timestamp_t *localTime, int16_t offset)
{
// TimerB is used for capturing, it is sourced by ACLK (32768Hz),
! // we now need to convert the capture "time" into ieee154_timestamp_t.
// With the 32768Hz quartz we don't have enough precision anyway,
// so the code below generates a timestamp that is not accurate
uint16_t tbr1, tbr2, delta;
uint32_t now;
***************
*** 81,135 ****
else
delta = ~(time - tbr1) + 1;
! *localTime = now - delta*2 + offset;
}
! async command void ReliableWait.busyWait(uint16_t dt)
{
! uint16_t tbr1, tbr2, tbrVal;
! atomic {
! do {
! tbr1 = TBR;
! tbr2 = TBR;
! } while (tbr1 != tbr2); // majority vote required (see msp430 manual)
! }
! tbrVal = tbr1 + dt;
! atomic {
! do {
! tbr1 = TBR;
! tbr2 = TBR;
! } while (tbr1 != tbr2 || tbr1 != tbrVal); // majority vote required (see msp430 manual)
! }
}
! async command void ReliableWait.waitRx(ieee154_reftime_t *t0, uint16_t dt)
{
if (m_state != S_WAIT_OFF){
! call Leds.led0On();
return;
}
m_state = S_WAIT_RX;
! call SymbolAlarm.startAt(*t0 - 12, dt); // subtract 12 symbols required for Rx calibration
! //signal SymbolAlarm.fired();
}
! async command void ReliableWait.waitTx(ieee154_reftime_t *t0, uint16_t dt)
{
if (m_state != S_WAIT_OFF){
! call Leds.led0On();
return;
}
m_state = S_WAIT_TX;
! call SymbolAlarm.startAt(*t0 - 12, dt); // subtract 12 symbols required for Tx calibration
}
! async command void ReliableWait.waitBackoff(ieee154_reftime_t *t0, uint16_t dt)
{
if (m_state != S_WAIT_OFF){
! call Leds.led0On();
return;
}
m_state = S_WAIT_BACKOFF;
! call SymbolAlarm.startAt(*t0, dt);
! //signal SymbolAlarm.fired();
}
--- 81,129 ----
else
delta = ~(time - tbr1) + 1;
! *localTime = now - delta * 2 + offset; /* one tick of TimerB ~ two symbols */
! return SUCCESS;
}
! async command bool ReliableWait.ccaOnBackoffBoundary(ieee154_timestamp_t *slot0)
{
! // There is no point in trying
! return (call CCA.getNow() ? 20: 0);
}
! async command bool CaptureTime.isValidTimestamp(uint16_t risingSFDTime, uint16_t fallingSFDTime)
! {
! // smallest packet (ACK) takes
! // length field (1) + MPDU (5) = 6 byte => 12 * 16 us = 192 us
! return (fallingSFDTime - risingSFDTime) > 5;
! }
!
! async command void ReliableWait.waitRx(uint32_t t0, uint32_t dt)
{
if (m_state != S_WAIT_OFF){
! ASSERT(0);
return;
}
m_state = S_WAIT_RX;
! call SymbolAlarm.startAt(t0 - 16, dt); // subtract 12 symbols required for Rx calibration
}
! async command void ReliableWait.waitTx(ieee154_timestamp_t *t0, uint32_t dt)
{
if (m_state != S_WAIT_OFF){
! ASSERT(0);
return;
}
m_state = S_WAIT_TX;
! call SymbolAlarm.startAt(*t0 - 16, dt); // subtract 12 symbols required for Tx calibration
}
! async command void ReliableWait.waitBackoff(uint32_t dt)
{
if (m_state != S_WAIT_OFF){
! ASSERT(0);
return;
}
m_state = S_WAIT_BACKOFF;
! call SymbolAlarm.start(dt);
}
***************
*** 141,164 ****
case S_WAIT_TX: m_state = S_WAIT_OFF; signal ReliableWait.waitTxDone(); break;
case S_WAIT_BACKOFF: m_state = S_WAIT_OFF; signal ReliableWait.waitBackoffDone(); break;
! default: call Leds.led0On(); break;
}
}
! async command void ReliableWait.busyWaitSlotBoundaryCCA(ieee154_reftime_t *t0, uint16_t *dt) { }
! async command void ReliableWait.busyWaitSlotBoundaryTx(ieee154_reftime_t *t0, uint16_t dt)
! {
! // we cannot meet the timing constraints, but there should at least roughly
! // be 20 symbols between the first and the seconds CCA
! call ReliableWait.busyWait(20);
! }
!
! async command void ReferenceTime.getNow(ieee154_reftime_t* reftime, uint16_t dt)
{
! *reftime = call SymbolAlarm.getNow() + dt;
}
! async command uint32_t ReferenceTime.toLocalTime(ieee154_reftime_t* refTime)
{
! return *refTime;
}
--- 135,150 ----
case S_WAIT_TX: m_state = S_WAIT_OFF; signal ReliableWait.waitTxDone(); break;
case S_WAIT_BACKOFF: m_state = S_WAIT_OFF; signal ReliableWait.waitBackoffDone(); break;
! default: ASSERT(0); break;
}
}
! async command void ReferenceTime.getNow(ieee154_timestamp_t* timestamp, uint16_t dt)
{
! *timestamp = call SymbolAlarm.getNow() + dt;
}
! async command uint32_t ReferenceTime.toLocalTime(const ieee154_timestamp_t* timestamp)
{
! return *timestamp;
}
More information about the Tinyos-2-commits
mailing list