[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/scp-mac/tos/system CodecNone.nc, NONE, 1.1 Csma.nc, NONE, 1.1 CsmaConst.h, NONE, 1.1 CsmaM.nc, NONE, 1.1 CsmaMsg.h, NONE, 1.1 Lpl.nc, NONE, 1.1 LplConst.h, NONE, 1.1 LplM.nc, NONE, 1.1 LplMsg.h, NONE, 1.1 Scp.nc, NONE, 1.1 ScpConst.h, NONE, 1.1 ScpM.nc, NONE, 1.1 ScpMsg.h, NONE, 1.1 StdReturn.h, NONE, 1.1 UartDebugByte.nc, NONE, 1.1 UartDebugByteM.nc, NONE, 1.1 UartDebugM.nc, NONE, 1.1 UartDebugNone.nc, NONE, 1.1 UartDebugStateEvent.nc, NONE, 1.1 UartDebugStateEventM.nc, NONE, 1.1 csmaEvents.h, NONE, 1.1 lplEvents.h, NONE, 1.1 scpEvents.h, NONE, 1.1
Wei Ye
weiyeisi at users.sourceforge.net
Tue May 6 10:31:01 PDT 2008
- Previous message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/scp-mac/tos/platform/micaz ClockSCP.nc, NONE, 1.1 ClockSCPM.nc, NONE, 1.1 HPLCC2420InterruptM.nc, NONE, 1.1 HPLUART0M.nc, NONE, 1.1 MakeXbowlocal, NONE, 1.1 PhyConst.h, NONE, 1.1 PhyRadio.nc, NONE, 1.1 PhyRadioM.nc, NONE, 1.1 PhyRadioMsg.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/scp-mac/tos/system
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv9805/scp-mac/tos/system
Added Files:
CodecNone.nc Csma.nc CsmaConst.h CsmaM.nc CsmaMsg.h Lpl.nc
LplConst.h LplM.nc LplMsg.h Scp.nc ScpConst.h ScpM.nc ScpMsg.h
StdReturn.h UartDebugByte.nc UartDebugByteM.nc UartDebugM.nc
UartDebugNone.nc UartDebugStateEvent.nc
UartDebugStateEventM.nc csmaEvents.h lplEvents.h scpEvents.h
Log Message:
scp-mac implementation from USC/ISI
--- NEW FILE: CodecNone.nc ---
/*
* Copyright (C) 2003-2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/* Authors: Wei Ye
*
* Since the Chipcon 1000 radio does Manchester coding internally,
* this component does nothing in software.
*/
module CodecNone
{
provides {
interface StdControl;
interface RadioEncoding as Codec;
}
}
implementation
{
command result_t StdControl.init()
{
return SUCCESS;
}
command result_t StdControl.start()
{
return SUCCESS;
}
command result_t StdControl.stop()
{
return SUCCESS;
}
async command result_t Codec.decode(uint8_t data)
{
signal Codec.decodeDone(data, 0);
return SUCCESS;
}
async command result_t Codec.encode_flush()
{
return SUCCESS;
}
async command result_t Codec.encode(uint8_t data)
{
signal Codec.encodeDone(data);
return SUCCESS;
}
} // end of implementation
--- NEW FILE: Csma.nc ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* This module implements basic CSMA protocol
* Physical layer carrier sense is used before sending each packet
* Random backoff when carrier sense fails
*/
configuration Csma
{
provides {
interface StdControl;
interface CsmaControl;
interface MacMsg;
interface MacActivity;
interface GetSetU8 as RadioTxPower;
interface RadioEnergy;
}
}
implementation
{
components CsmaM, PhyRadio, RandomLFSR, TimerC,
#if defined CSMA_UART_DEBUG_STATE_EVENT
UartDebugStateEvent as UartDbg,
#elif defined CSMA_UART_DEBUG_BYTE
UartDebugByte as UartDbg,
#else
UartDebugNone as UartDbg,
#endif
#ifdef CSMA_LED_DEBUG
LedsC;
#else
NoLeds as LedsC;
#endif
StdControl = CsmaM;
CsmaControl = CsmaM;
MacMsg = CsmaM;
MacActivity = CsmaM;
RadioTxPower = PhyRadio;
RadioEnergy = PhyRadio;
// wiring to lower layers
CsmaM.PhyControl -> PhyRadio;
CsmaM.RadioState -> PhyRadio;
CsmaM.CarrierSense -> PhyRadio;
CsmaM.CsThreshold -> PhyRadio;
CsmaM.PhyPkt -> PhyRadio;
CsmaM.PhyNotify -> PhyRadio;
CsmaM.PhyStreamByte -> PhyRadio;
CsmaM.Random -> RandomLFSR;
CsmaM.TimerControl -> TimerC;
CsmaM.NavTimer -> TimerC.Timer[unique("Timer")];
CsmaM.NeighbNavTimer -> TimerC.Timer[unique("Timer")];
CsmaM.BackoffTimer -> TimerC.Timer[unique("Timer")];
CsmaM.Leds -> LedsC;
CsmaM.UartDebug -> UartDbg;
}
--- NEW FILE: CsmaConst.h ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* CSMA constants that can be used by applications
*/
#ifndef CSMA_CONST
#define CSMA_CONST
// include lower layer constants
#include "PhyConst.h"
/***
* User-adjustable CSMA parameters
* Do not directly change this file
* Change default values in each application's config.h file
*/
// DCF interframe space -- minimum contention time
#ifndef DIFS
#define DIFS 2
#endif
// contention window size, 0--255
// if set to 0, will bypass carrier sense
// actual number of contention slots is DIFS + a random number in the window
#ifndef CSMA_CONT_WIN
#define CSMA_CONT_WIN 31
#endif
// backoff time when carrier sense fails, slightly longer than preamble time
// should redefine it if sending variable preamble packets
#ifndef CSMA_BACKOFF_TIME
#define CSMA_BACKOFF_TIME (PHY_BASE_PRE_BYTES * PHY_TX_BYTE_TIME / 1000 + 3)
#endif
// use RTS/CTS when unicast pkt length is larger than RTS threshold
#ifndef CSMA_RTS_THRESHOLD
#define CSMA_RTS_THRESHOLD 100
#endif
// re-Tx when a unicast data pkt does not receive an ACK or no CTS for RTS
#ifndef CSMA_RETX_LIMIT
#define CSMA_RETX_LIMIT 3
#endif
// when number of continues backoff reaches the limit, will give up Tx
#ifndef CSMA_BACKOFF_LIMIT
#define CSMA_BACKOFF_LIMIT 7
#endif
// CSMA disables overhearing by default. To enable, define the following
//#define CSMA_ENABLE_OVERHEARING
/***
* following parameters are not user adjustable, but can be used
*/
// processing delay, including that by PHY
#define CSMA_PROCESSING_DELAY (PHY_PROCESSING_DELAY + 1)
// transmission time of RTS packet
#define CSMA_RTS_DURATION ((PHY_BASE_PRE_BYTES + sizeof(RTSPkt)) * \
PHY_TX_BYTE_TIME / 1000 + 1)
// transmission time of CTS packet
#define CSMA_CTS_DURATION ((PHY_BASE_PRE_BYTES + sizeof(CTSPkt)) * \
PHY_TX_BYTE_TIME / 1000 + 1)
// transmission time of ACK packet
#define CSMA_ACK_DURATION ((PHY_BASE_PRE_BYTES + sizeof(ACKPkt)) * \
PHY_TX_BYTE_TIME / 1000 + 1)
#endif
--- NEW FILE: CsmaM.nc ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
[...962 lines suppressed...]
default event void MacActivity.radioDone(result_t result)
{
// default do-nothing handler
}
default event void MacActivity.virtualCSBusy()
{
// default do-nothing handler
}
default event void MacActivity.virtualCSIdle()
{
// default do-nothing handler
}
} // end of implementation
--- NEW FILE: CsmaMsg.h ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* Packet format for CSMA
*/
#ifndef CSMA_MSG
#define CSMA_MSG
// In Berkeley's stack, it is defined in AM.h
// Since we are not useing it, define it here.
// When using emtos, AM is included, so there's an enum-define collision
#ifndef PLATFORM_EMSTAR
#ifndef TOS_BCAST_DEFINED
#ifndef AM_H_INCLUDED
#define TOS_BCAST_ADDR 0xffff
#endif
#endif
#endif
#ifndef PHY_MSG
#include "PhyRadioMsg.h"
#endif
// # of bytes going out
#define AIRED_DATA_SIZE (sizeof(PhyHeader) + PHY_MAX_PAYLOAD +2)
// MAC header to be included by upper layer headers -- nested headers
// type: CSMA only uses higher 4 bits
// lower 4 bits can be used by a MAC above CSMA, such as SCP-MAC
// seqFragNo: for broadcast packets, it's just sequence no; for unicast,
// higher 5 bits are sequence no, lower 3 are fragment no.
typedef struct {
PhyHeader phyHdr;
uint8_t type; // type is the first byte following phyHdr
uint16_t fromAddr;
uint16_t toAddr;
#ifdef SCP_HEAVY_SYNC
uint16_t sync_time;
#endif
// uint8_t seqFragNo;
} __attribute__((packed)) CsmaHeader;
/**************************************************************
This is an example showing how an application that used S-MAC to
to define its packet structures.
App-layer header should include MAC_Header as its first field, e.g.,
typedef struct {
MACHeader hdr;
// now add app-layer header fields
char appField1;
int16_t appField2;
} AppHeader;
This is an nested header structure, as MACHeader includes PhyHeader
as its first field.
You can get the maximum payload length by the following macro.
#define MAX_APP_PAYLOAD (PHY_MAX_PKT_LEN - sizeof(AppHeader) - 2)
The app packet with maximum allowed length is then
typedef struct {
AppHeader hdr;
char data[MAX_APP_PAYLOAD];
int16_t crc; // must be last two bytes, required by PhyRadio.
} AppPkt;
******************************************************************/
// control packets -- internal to CSMA
typedef struct {
PhyHeader phyHdr; // include before my own stuff
uint8_t type; // type is the first byte following phyHdr
uint16_t fromAddr;
uint16_t toAddr;
uint16_t duration;
int16_t crc; // must be last two bytes, required by PhyRadio
} __attribute__((packed)) RTSPkt;
typedef struct {
PhyHeader phyHdr; // include before my own stuff
uint8_t type; // type is the first byte following phyHdr
uint16_t toAddr;
uint16_t duration;
int16_t crc; // must be last two bytes, required by PhyRadio
} __attribute__((packed)) CTSPkt;
typedef struct {
PhyHeader phyHdr; // include before my own stuff
uint8_t type; // type is the first byte following phyHdr
uint16_t toAddr;
// uint16_t duration; // for debugging
int16_t crc; // must be last two bytes, required by PhyRadio
} __attribute__((packed)) ACKPkt;
// control pkt buffer should have the size of the largest control pkt
#define CSMA_CTRL_PKT_BUF sizeof(RTSPkt)
#endif //CSMA_MSG
--- NEW FILE: Lpl.nc ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* This configuration wires for CSMA with low power listening (LPL)
*/
configuration Lpl
{
provides {
interface StdControl;
interface MacMsg;
interface LplControl;
interface MacActivity as LplActivity;
interface LplPollTimer;
interface GetSetU8 as RadioTxPower;
interface RadioEnergy;
}
}
implementation
{
components LplM, Csma, PhyRadio, LocalTimeC, TimerC,
#if defined LPL_UART_DEBUG_STATE_EVENT
UartDebugStateEvent as UartDbg,
#elif defined LPL_UART_DEBUG_BYTE
UartDebugByte as UartDbg,
#else
UartDebugNone as UartDbg,
#endif
#ifdef LPL_LED_DEBUG
LedsC;
#else
NoLeds as LedsC;
#endif
StdControl = LplM;
MacMsg = LplM;
LplControl = LplM;
LplActivity = LplM;
LplPollTimer = LplM;
RadioTxPower = PhyRadio;
RadioEnergy = PhyRadio;
// wiring to lower layers
LplM.CsmaStdControl -> Csma;
LplM.CsmaMacMsg -> Csma;
LplM.CsmaControl -> Csma;
LplM.CsmaActivity -> Csma;
LplM.RadioState -> PhyRadio;
LplM.CarrierSense -> PhyRadio;
LplM.PhyNotify -> PhyRadio;
LplM.LocalTime -> LocalTimeC;
LplM.PollTimer -> TimerC.TimerAsync[unique("Timer")];
LplM.WaitTimer -> TimerC.Timer[unique("Timer")];
LplM.Leds -> LedsC;
LplM.UartDebug -> UartDbg;
}
--- NEW FILE: LplConst.h ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* constants that can be used by applications
*/
#ifndef LPL_CONST
#define LPL_CONST
// include lower layer constants
#include "CsmaConst.h"
/* User-adjustable LPL parameters
* Do not directly change this file
* Change default values in each application's config.h file
*/
// period for each node to poll the channel
#ifndef LPL_POLL_PERIOD
#define LPL_POLL_PERIOD 512
#endif
/***
* Following parameters are not user adjustable
* but can be used by other components
*/
// min and max bytes to sample in polling when channel is idle
#define LPL_MIN_POLL_BYTES 1
#define LPL_MAX_POLL_BYTES (LPL_MIN_POLL_BYTES + PHY_MAX_CS_EXT)
// MicaZ specific parameters
#ifdef PLATFORM_MICAZ
// prevent LPL to return to sleep state too early
#ifndef LPL_EXTEND_RECEIVE_TIME
#define LPL_EXTEND_RECEIVE_TIME
#endif
#endif // PLATFORM_MICAZ
#endif // LPL_CONST
--- NEW FILE: LplM.nc ---
/* (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* This module implements CSMA with low power listening (LPL)
*/
module LplM
{
provides {
interface StdControl;
interface MacMsg;
interface LplControl;
interface MacActivity as LplActivity;
interface LplPollTimer;
}
uses {
interface StdControl as CsmaStdControl;
interface MacMsg as CsmaMacMsg;
interface CsmaControl;
interface MacActivity as CsmaActivity;
interface RadioState;
interface CarrierSense;
interface PhyNotify;
interface GetSetU32 as LocalTime;
interface TimerAsync as PollTimer;
interface Timer as WaitTimer;
interface Leds;
interface UartDebug;
}
}
implementation
{
#include "StdReturn.h"
#include "LplConst.h"
#include "lplEvents.h"
// LPL constants
// maximum pkt transmission time, used for receive timer
#define MAX_BASE_PKT_LEN (PHY_BASE_PRE_BYTES + PHY_MAX_PKT_LEN)
// maximum radio active time -- for wait/protection timer
#define MAX_BASE_PKT_TIME ((uint32_t)MAX_BASE_PKT_LEN * PHY_TX_BYTE_TIME / 1000 + 1)
#define MAX_PKT_EXCHANGE_TIME (CSMA_RTS_DURATION + CSMA_CTS_DURATION \
+ MAX_BASE_PKT_TIME + CSMA_ACK_DURATION + CSMA_PROCESSING_DELAY * 4 + 3)
// LPL states
enum {
// SLEEP,
IDLE,
POLL_CHANNEL
};
// state variables
uint8_t state; // LPL state
// Variables for Tx
bool pollEnabled; // if channel polling is enabled
bool sleepEnabled; // if radio sleeping is enabled
bool autoReTx; // automatically re-send a buffered packet
bool virtualCsIdle; // if virtual carrier sense indicates idle
bool txBuffered; // if I have buffered a msg to send
bool txStarted; // if I have started Tx (i.e., pass it to CSMA)
bool backoffRepeat; // if repeated backoff is enabled
uint8_t txPktLen;
uint16_t sendAddr;
uint32_t backoffTime; // wait for start symbol
uint8_t contWinSize; // contention window size
uint16_t maxWaitTime; // time to wait between packets
void* dataPkt; // pointer to data packet to be sent
uint8_t togglePin;
// function prototypes
result_t tryToSleep();
task void startWaitTimer();
command result_t StdControl.init()
{
// initialize LPL and lower level components
state = IDLE;
pollEnabled = TRUE;
sleepEnabled = TRUE;
autoReTx = TRUE;
virtualCsIdle = TRUE;
txBuffered = FALSE;
txStarted = FALSE;
backoffRepeat = TRUE;
contWinSize = CSMA_CONT_WIN; // CSMA contention window size
maxWaitTime = ((PHY_CS_SAMPLE_INTERVAL * (contWinSize + 1)) / 1000) + 2;
// maximum time needed to wait for a start symbol
// also used to set CSMA backoff time
backoffTime = (uint32_t)PHY_BASE_PRE_BYTES * PHY_TX_BYTE_TIME / 1000 + 1
+ LPL_POLL_PERIOD + 3;
togglePin = 1;
call CsmaStdControl.init(); // initialize physical layer
call Leds.init(); // initialize LEDs
// Mica2 radio seems sensitive to power supply. With 3V DC power adapter
// and the old programming board, the radio sometimes can't be correctly
// initialized (most of time, it can receive but can't transmit).
// initialize UART debugging
call UartDebug.init(); // initialize UART debugging
return SUCCESS;
}
command result_t StdControl.start()
{
// start MAC and lower-level components
uint16_t preamble; // used to wake up a sleeping node
call CsmaStdControl.start(); // start CSMA
// start LPL from fully active mode
preamble = (uint16_t)((uint32_t)LPL_POLL_PERIOD * 1000 /
PHY_TX_BYTE_TIME) + 1;
call CsmaControl.addPreamble(preamble); // set CSMA's preamble
call CsmaControl.setBackoffTime(backoffTime); // set CSMA backoff time
call PollTimer.start(TIMER_REPEAT, LPL_POLL_PERIOD);
// wait for clock to stablize before sleep
call WaitTimer.start(TIMER_ONE_SHOT, 10);
call UartDebug.txEvent(WAIT_TIMER_STARTED);
return SUCCESS;
}
command result_t StdControl.stop()
{
// stop clock and PHY, but states are cleared when start again
call CsmaStdControl.stop(); // stop physical layer
call PollTimer.stop(); // stop timer
state = IDLE;
call UartDebug.txState(state);
return SUCCESS;
}
command result_t MacMsg.send(void* msg, uint8_t length, uint16_t toAddr)
{
// standard command to send a message
uint8_t result;
// sanity check
if (msg == 0 || length == 0 || length > PHY_MAX_PKT_LEN) {
call UartDebug.txEvent(TX_REQUEST_REJECTED_MSG_ERROR);
return FAIL;
}
// Don't accept Tx request if I have already accepted a request
atomic {
if (txBuffered == FALSE) {
txBuffered = TRUE;
result = 1;
} else {
result = 0;
}
}
if (result == 0) {
call UartDebug.txEvent(TX_REQUEST_REJECTED_NO_BUFFER);
return FAIL;
}
call UartDebug.txEvent(TX_REQUEST_ACCEPTED);
dataPkt = msg;
txPktLen = length;
sendAddr = toAddr;
txStarted = FALSE;
if (state == IDLE) {
// pass to CSMA directly
if (call CsmaMacMsg.send(msg, length, toAddr)) {
txStarted = TRUE;
}
}
return SUCCESS;
}
command result_t MacMsg.sendCancel(void* msg)
{
// cancel a message to be sent (i.e., previously called MacMsg.send)
result_t result;
if (msg != dataPkt) return FAIL;
atomic {
if (txBuffered && !txStarted) {
txBuffered = FALSE;
result = SUCCESS;
} else {
result = FAIL;
}
}
if (result == SUCCESS) {
return result;
} else {
return call CsmaMacMsg.sendCancel(msg);
}
}
event void CsmaMacMsg.sendDone(void* msg, result_t result)
{
// message transmission is done by CSMA
txStarted = FALSE;
txBuffered = FALSE;
call Leds.redToggle();
call UartDebug.txEvent(TX_MSG_DONE);
signal MacMsg.sendDone(msg, result);
}
event void* CsmaMacMsg.receiveDone(void* msg)
{
// CSMA received a message
void* tmp;
// call WaitTimer.stop(); // stop receive timer
call Leds.greenToggle();
call UartDebug.txEvent(RX_MSG_DONE);
tmp = signal MacMsg.receiveDone(msg);
return tmp;
}
command void LplControl.enablePolling()
{
// enable regular, periodic channel polling
pollEnabled = TRUE;
call UartDebug.txEvent(POLL_CHANNEL_ENABLED);
}
command void LplControl.disablePolling()
{
// temporarily disable channel polling; will not stop poll timer
pollEnabled = FALSE;
call UartDebug.txEvent(POLL_CHANNEL_DISABLED);
}
command result_t LplControl.pollChannel()
{
// poll channel for possible activity now
uint8_t result;
if ((call RadioState.get() != RADIO_SLEEP) && sleepEnabled) { // radio is busy
call UartDebug.txEvent(POLL_CHANNEL_FAIL_NOT_SLEEP);
if (call WaitTimer.getRemainingTime() == 0) {
call WaitTimer.start(TIMER_ONE_SHOT, backoffTime + MAX_PKT_EXCHANGE_TIME);
call UartDebug.txEvent(WAIT_TIMER_STARTED);
}
return FAIL;
}
// turn on radio
result = call RadioState.idle();
if (result == FAILURE) {
call UartDebug.txEvent(POLL_CHANNEL_FAIL_WAKEUP_RADIO);
return FAIL;
}
// turn on radio successful, but may not be stable now
state = POLL_CHANNEL;
call Leds.yellowOn();
call UartDebug.txState(state);
if (result == SUCCESS_DONE) { // radio is stable now
call UartDebug.txEvent(START_CARRIER_SENSE);
if (!call CarrierSense.start(1)) {
state = IDLE;
call UartDebug.txState(state);
}
}
return SUCCESS;
}
command void LplControl.addPreamble(uint16_t length)
{
// set preamble length to wake up a node (not including base preamble)
call CsmaControl.addPreamble(length); // set CSMA's preamble
}
command void LplControl.setContWin(uint8_t numSlots)
{
// set CSMA contention window
contWinSize = numSlots;
maxWaitTime = ((PHY_CS_SAMPLE_INTERVAL * (contWinSize + 1)) / 1000) + 2;
call CsmaControl.setContWin(contWinSize);
}
command void LplControl.setBackoffTime(uint32_t time, bool repeat)
{
// set backoff time when carrier sense fails
backoffTime = time;
backoffRepeat = repeat;
call CsmaControl.setBackoffTime(backoffTime);
}
command void LplControl.disableAutoReTx()
{
// disable automatic re-send after previous attempt fails
autoReTx = FALSE;
call CsmaControl.disableAutoReTx();
}
command void LplControl.enableAutoReTx()
{
// enable automatic re-send after previous attempt fails
autoReTx = TRUE;
call CsmaControl.enableAutoReTx();
}
command void LplControl.disableSleeping()
{
// disable periodic radio sleeping
// in this mode, node will do idle listening,
// but Tx still uses long preambles
sleepEnabled = FALSE;
}
command void LplControl.enableSleeping()
{
// enable periodic radio sleeping
// this is normal LPL mode
sleepEnabled = TRUE;
}
command result_t LplPollTimer.start(uint16_t period)
{
// start the channel polling timer
return call PollTimer.start(TIMER_REPEAT, (uint32_t)period);
}
command result_t LplPollTimer.stop()
{
// stop the channel polling timer
return call PollTimer.stop();
}
command uint16_t LplPollTimer.get()
{
// get current poll timer value
volatile uint16_t time;
time = (uint16_t)call PollTimer.getRemainingTime();
//call UartDebug.txByte((uint8_t)(time & 0xff));
//call UartDebug.txByte((uint8_t)((time >> 8) & 0xff));
return time;
// return call PollTimer.getRemainingTime();
}
command result_t LplPollTimer.set(uint16_t time)
{
// set the remaining time of poll timer
return call PollTimer.setRemainingTime((uint32_t)time);
}
default async event result_t LplPollTimer.fired()
{
// default do-nothing handler
return SUCCESS;
}
event void CsmaActivity.radioDone(result_t result)
{
// CSMA is done with radio for packet Tx or Rx
// if result is SUCCESS, can start adaptive listen; otherwise sleep
call UartDebug.txEvent(CSMA_RADIO_DONE);
#ifdef LPL_EXTEND_RECEIVE_TIME
if (call WaitTimer.getRemainingTime() == 0){
call WaitTimer.start(TIMER_ONE_SHOT, maxWaitTime);
} else {
call WaitTimer.setRemainingTime(maxWaitTime);
}
#else
tryToSleep(); // sleep if I have nothing to send
signal LplActivity.radioDone(result);
#endif
}
event void CsmaActivity.virtualCSBusy()
{
// virtual carrier sense is busy now (NAV timer started)
virtualCsIdle = FALSE;
// call WaitTimer.stop(); // will wait for idle signal
call UartDebug.txEvent(VIRTUAL_CS_BUSY);
signal LplActivity.virtualCSBusy();
}
event void CsmaActivity.virtualCSIdle()
{
// virtual carrier sense is idle now (NAV timer fired)
virtualCsIdle = TRUE;
tryToSleep(); // sleep if I have nothing to send
call UartDebug.txEvent(VIRTUAL_CS_IDLE);
signal LplActivity.virtualCSIdle();
}
result_t tryToSleep()
{
// check Tx status and change state accordingly
state = IDLE; // LPL goes back to idle
call UartDebug.txState(state);
if (txBuffered && autoReTx) { // can't turn off radio
call UartDebug.txEvent(TRY_TO_SLEEP_FAILED);
if (!txStarted) { // start sending now
call CsmaMacMsg.send(dataPkt, txPktLen, sendAddr);
txStarted = TRUE;
}
return FAIL; // failed to sleep
} else {
if (!sleepEnabled) return FAIL; // sleeping is disabled
// now actually put radio into sleep state
call WaitTimer.stop();
call RadioState.sleep();
call Leds.yellowOff();
call UartDebug.txEvent(SET_RADIO_SLEEP);
return SUCCESS; // successfully sleep
}
}
async event result_t PollTimer.fired()
{
// time to wake up and poll channel activity
call UartDebug.txEvent(POLL_TIMER_FIRED);
if (pollEnabled && virtualCsIdle) {
call LplControl.pollChannel();
} else {
if (!pollEnabled)
call UartDebug.txEvent(POLL_CHANNEL_FAIL_NOT_ENABLED);
if (!virtualCsIdle)
call UartDebug.txEvent(POLL_CHANNEL_FAIL_VIRTUAL_CS);
}
// relay timer event
signal LplPollTimer.fired();
return SUCCESS;
}
async event result_t RadioState.wakeupDone()
{
// radio wakeup is done -- it becomes stable now
// only wake up radio for polling channel
if (state == POLL_CHANNEL) {
call UartDebug.txEvent(START_CARRIER_SENSE);
if (!call CarrierSense.start(1)) { // check channel activity
state = IDLE;
call UartDebug.txState(state);
}
}
return SUCCESS;
}
async event result_t CarrierSense.channelIdle()
{
// physical carrier sense indicate channel idle
if (state != POLL_CHANNEL) return FAIL;
call UartDebug.txEvent(CHANNEL_IDLE_DETECTED);
// poll channle didn't find activity
tryToSleep(); // check Tx status before sleep
return SUCCESS;
}
async event result_t CarrierSense.channelBusy()
{
// physical carrier sense indicate channel busy
// if (state != POLL_CHANNEL) return FAIL;
call UartDebug.txEvent(CHANNEL_BUSY_DETECTED);
// poll channel found activity, stay awake to receive
state = IDLE; // don't turn off radio
call UartDebug.txState(state);
// set timer to wait for start symbol
// call WaitTimer.start(TIMER_ONE_SHOT, backoffTime);
if (call WaitTimer.getRemainingTime() == 0) {
call WaitTimer.start(TIMER_ONE_SHOT, backoffTime);
} else {
call WaitTimer.setRemainingTime(backoffTime);
}
call UartDebug.txEvent(WAIT_TIMER_STARTED);
return SUCCESS;
}
async event result_t PhyNotify.startSymSent(void* packet)
{
// just sent out start symbol of a packet
return SUCCESS;
}
async event result_t PhyNotify.startSymDetected(void* packet, uint8_t bitOffset)
{
// just received a start symbol, must be in idle state
call UartDebug.txEvent(START_SYMBOL_DETECTED);
if (call WaitTimer.getRemainingTime() == 0) {
call WaitTimer.start(TIMER_ONE_SHOT, MAX_PKT_EXCHANGE_TIME);
} else {
call WaitTimer.setRemainingTime(MAX_PKT_EXCHANGE_TIME);
}
call UartDebug.txEvent(WAIT_TIMER_STARTED);
return SUCCESS;
}
event result_t WaitTimer.fired()
{
// can't receive start symbol or packet after waiting
call UartDebug.txEvent(WAIT_TIMER_FIRED);
if (state != IDLE) return FAIL;
tryToSleep();
/*
if (backoffRepeat) { // repeated backoff is enabled
// confirm channel idle before go to sleep
state = POLL_CHANNEL;
call UartDebug.txState(state);
call CarrierSense.start(1);
} else {
tryToSleep();
}
*/
return SUCCESS;
}
command result_t LplActivity.reSend()
{
// resend a previously buffered packet
if (!txBuffered) return FAIL;
if (state == POLL_CHANNEL) return FAIL;
call UartDebug.txEvent(RESEND_REQUESTED);
if (!txStarted) { // start sending now
call CsmaMacMsg.send(dataPkt, txPktLen, sendAddr);
txStarted = TRUE;
return SUCCESS;
} else {
return call CsmaActivity.reSend();
}
}
default event void LplActivity.virtualCSBusy()
{
// default do-nothing handler
}
default event void LplActivity.virtualCSIdle()
{
// default do-nothing handler
}
default event void LplActivity.radioDone(result_t result)
{
// default do-nothing handler
}
} // end of implementation
--- NEW FILE: LplMsg.h ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Author: Wei Ye
*
* Packet format of LPL is the same as CSMA
*/
#ifndef LPL_MSG
#define LPL_MSG
// include CSMA header and packet definitions
#include "CsmaMsg.h"
// just use CsmaHeader as LPL header -- no new field added
typedef CsmaHeader LplHeader;
#endif //LPL_MSG
--- NEW FILE: Scp.nc ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* This configuration wires for SCP-MAC
*/
configuration Scp
{
provides {
interface StdControl;
interface MacMsg;
interface GetSetU8 as RadioTxPower;
interface RadioEnergy;
}
}
implementation
{
components ScpM, Lpl, PhyRadio, RandomLFSR, LocalTimeC, TimerC,
#if defined SCP_UART_DEBUG_STATE_EVENT
UartDebugStateEvent as UartDbg,
#elif defined SCP_UART_DEBUG_BYTE
UartDebugByte as UartDbg,
#else
UartDebugNone as UartDbg,
#endif
#ifdef SCP_LED_DEBUG
LedsC;
#else
NoLeds as LedsC;
#endif
StdControl = ScpM;
MacMsg = ScpM;
RadioTxPower = PhyRadio;
RadioEnergy = PhyRadio;
// wiring to lower layers
ScpM.LplStdControl -> Lpl;
ScpM.LplMacMsg -> Lpl;
ScpM.LplControl -> Lpl;
ScpM.LplActivity -> Lpl;
ScpM.LplPollTimer -> Lpl;
ScpM.RadioState -> PhyRadio;
ScpM.Random -> RandomLFSR;
ScpM.CarrierSense -> PhyRadio;
ScpM.CsThreshold -> PhyRadio;
ScpM.TxPreamble -> PhyRadio;
ScpM.PhyNotify -> PhyRadio;
ScpM.LocalTime -> LocalTimeC;
ScpM.SyncTimer -> TimerC.Timer[unique("Timer")];
ScpM.NeighDiscTimer -> TimerC.Timer[unique("Timer")];
ScpM.TxTimer -> TimerC.TimerAsync[unique("Timer")];
ScpM.AdapTxTimer -> TimerC.TimerAsync[unique("Timer")];
ScpM.AdapPollTimer -> TimerC.TimerAsync[unique("Timer")];
ScpM.bootTimer -> TimerC.TimerAsync[unique("Timer")];
ScpM.Leds -> LedsC;
ScpM.UartDebug -> UartDbg;
}
--- NEW FILE: ScpConst.h ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* SCP-MAC constants that can be used by applications
*/
#ifndef SCP_CONST
#define SCP_CONST
// include lower layer constants
#include "LplConst.h"
/* User-adjustable SCP parameters
* Do not directly change this file
* Change default values in each application's config.h file
*/
// to enable booting the old way i.e. Master-Slave configuration
//#define USE_FIXED_BOOT
// in case of Fixed boot, only one master node starts a schedule in the network
// the master node will broadcast it schedule after it starts
// slave nodes only performs LPL and wait to synchronize with master schedule
//#define SCP_MASTER_SCHEDULE
// adaptive listen is enabled by default
// define the following macro to disable it
//#define SCP_DISABLE_ADAPTIVE_LISTEN
// make each node maintain Age of the Schedule
//#define MAINTAIN_SCHEDULE_AGE
// period for each node to poll the channel
#ifndef SCP_POLL_PERIOD
#define SCP_POLL_PERIOD 1024
#endif
// period for each node to poll the channel (default 10min)
#ifndef SCP_SYNC_PERIOD
#define SCP_SYNC_PERIOD 4096
//#define SCP_SYNC_PERIOD 614400
//#define SCP_SYNC_PERIOD 1228800
#endif
#ifndef NEIGH_DISC_PERIOD
#define NEIGH_DISC_PERIOD 81920
//#define NEIGH_DISC_PERIOD 1228800
//#define NEIGH_DISC_PERIOD 2457600
#endif
// contention window size on sending wakeup tone, max 127
#ifndef SCP_TONE_CONT_WIN
#define SCP_TONE_CONT_WIN 7
#endif
// contention window size on siding packets, must be, max 127
#ifndef SCP_PKT_CONT_WIN
#define SCP_PKT_CONT_WIN 15
#endif
// number of high-rate polling after receiving a pkt in regular polling
#ifndef SCP_NUM_HI_RATE_POLL
#define SCP_NUM_HI_RATE_POLL 3
#endif
// timeout for passive discovery mode in terms of number of SCP frames
#ifndef SCP_PASSIVE_DISCOVERY_TIMEOUT
#define SCP_PASSIVE_DISCOVERY_TIMEOUT 1
// <-1 invalid
// -1 implies infinite/blocking passive discovery mode
// 0 implies skipping passive discovery phase
// >0 valid
#endif
// timeout for each request in the active discovery mode in terms of number of SCP frames
#ifndef SCP_ACTIVE_DISCOVERY_TIMEOUT
#define SCP_ACTIVE_DISCOVERY_TIMEOUT 4
// <1 invalid
// >=1 valid
#endif
// number of retries for SYNC_REQ in active discovery mode
#ifndef NUM_SCP_ACTIVE_DISCOVERY_REQUESTS
#define NUM_SCP_ACTIVE_DISCOVERY_REQUESTS 5
// <-1 invalid
// -1 means infinite number of requests
// 0 implies skipping active discovery phase
// >0 valid
#endif
/***
* Following parameters are not user adjustable
* but can be used by other components
*/
// guard time (bytes) on schedule drift between sync info exchange
// minimum value is 2
#define SCP_GUARD_TIME 4
#define AGE_GUARD_TIME 10
#endif // SCP_CONST
--- NEW FILE: ScpM.nc ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
[...1315 lines suppressed...]
void setLplNormMode()
{
// set LPL into synchronized mode
call LplControl.addPreamble((uint16_t) ((uint32_t)SCP_POLL_PERIOD * 1000 / PHY_TX_BYTE_TIME) + 1);
call LplControl.setContWin(CSMA_CONT_WIN); //set contention window to CSMA
call LplControl.enableAutoReTx();
}
void ChangeMySchedule()
{
//set the following after sending sync
uint16_t pollTime; // neighbors polling time
pollTime = call LplPollTimer.get();
call TxTimer.setRemainingTime(nextTxTime( pollTime ));
}
#endif
} // end of implementation
--- NEW FILE: ScpMsg.h ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* Packet format for SCP-MAC
*/
#ifndef SCP_MSG
#define SCP_MSG
// include CSMA header and packet definitions
#include "CsmaMsg.h"
// just use CsmaHeader as SCP MAC header -- no new field added
typedef CsmaHeader ScpHeader;
// sync packet
typedef struct {
CsmaHeader csmaHdr; // include before my own stuff
volatile uint16_t pollTime; // my next channel polling time from now
#ifdef GLOBAL_SCHEDULE
uint16_t syncNode; // initializer of the my schedule
uint32_t schedAge; // schedule age
uint8_t txLplMod; // send in LPL node
uint8_t chgSched; // Schedule Changed
#endif
#ifdef SCP_SNOOPER_DEBUG
// debugging bytes
uint16_t OrglNode; // initiator of the my schedule
uint16_t myPollTm; // schedule age
uint16_t nbPollTm; // schedule age
int16_t timeDiff;
uint8_t normlpl;
uint8_t chgnums;
uint8_t suppressed;
uint32_t CurrAge; // my schedule age
uint32_t RecdAge; // received schedule age
int32_t ageDiff;
uint8_t reason1;
uint8_t reason2;
uint8_t numRxSync;
uint8_t syncbcast;
#endif
/*
#ifdef MAINTAIN_SCHEDULE_AGE
uint8_t validAge;
uint32_t scheduleAge; // age of the schedule
#endif
*/
int16_t crc; // must be last two bytes, required by PhyRadio
} __attribute__((packed)) SyncPkt;
#endif //SCP_MSG
--- NEW FILE: StdReturn.h ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* standard return values to function calls
*/
#ifndef STD_RETURN
#define STD_RETURN
enum {
FAILURE = 0,
SUCCESS_DONE = 1,
SUCCESS_WAIT = 2
};
#endif
--- NEW FILE: UartDebugByte.nc ---
/*
* Copyright (C) 2003-2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*/
configuration UartDebugByte
{
provides {
interface UartDebug;
}
}
implementation
{
components UartDebugByteM, UartDebugM;
UartDebug = UartDebugByteM;
// wiring to lower layers
UartDebugByteM.UartDebugInit -> UartDebugM;
UartDebugByteM.UartDebugTxByte -> UartDebugM;
}
--- NEW FILE: UartDebugByteM.nc ---
/*
* Copyright (C) 2003-2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* UART debugging: this component is for sending debugging bytes thru UART
* Note: can't be used with any application that uses the UART, e.g. motenic
*
* There are two known problems:
* 1) Initializing UART (e.g., for UART debugging) may cause a node fail to
* start or stop running when it's not connected with a serial board/cable.
* The reason needs to be checked further.
* 2) When HPLPowerManagement is enabled, the bytes sent to the UART could
* be corrupted. To be safe, HPLPowerManagement should be disabled when
* using UART debug.
*/
module UartDebugByteM
{
provides {
interface UartDebug;
}
uses {
command void UartDebugInit();
command void UartDebugTxByte(uint8_t byte);
}
}
implementation
{
command void UartDebug.init()
{
call UartDebugInit();
}
command void UartDebug.txState(uint8_t state)
{
// send a byte representing the state of a componet
}
command void UartDebug.txEvent(uint8_t eventNum)
{
// send a byte representing a pre-defined event
}
command void UartDebug.txByte(uint8_t byte)
{
// send an arbitrary byte, can't be used with state/event
call UartDebugTxByte(byte);
}
}
--- NEW FILE: UartDebugM.nc ---
/*
* Copyright (C) 2003-2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* UART debugging: this component is for sending debugging bytes thru UART
* Note: can't be used with any application that uses the UART, e.g. motenic
*
* There are two known problems:
* 1) Initializing UART (e.g., for UART debugging) may cause a node fail to
* start or stop running when it's not connected with a serial board/cable.
* The reason needs to be checked further.
* 2) When HPLPowerManagement is enabled, the bytes sent to the UART could
* be corrupted. To be safe, HPLPowerManagement should be disabled when
* using UART debug.
*/
module UartDebugM
{
provides {
command void UartDebugInit();
command void UartDebugTxByte(uint8_t byte);
}
}
implementation
{
#define DBG_BUF_LEN 50
#define ADVANCE(x) x = (((x+1) >= DBG_BUF_LEN) ? 0 : x+1) // from TXMAN.c
#define UART_IDLE 0
#define UART_BUSY 1
// variables for UART debugging
uint8_t UARTState;
uint8_t dbgBuf[DBG_BUF_LEN];
uint8_t dbgHead;
uint8_t dbgTail;
uint8_t dbgBufCount;
command void UartDebugInit()
{
// initialize UART
UARTState = UART_IDLE;
dbgBufCount = 0;
dbgHead = 0;
dbgTail = 0;
// initialize UART
// Set 57.6 KBps
outp(0,UBRR0H);
// outp(15, UBRR0L); // 57600 at 7.3728MHz
outp(16, UBRR0L); // 57600 at 8MHz
// Set UART double speed
outp((1<<U2X),UCSR0A);
// Set frame format: 8 data-bits, 1 stop-bit
outp(((1 << UCSZ1) | (1 << UCSZ0)) , UCSR0C);
// Enable reciever and transmitter and their interrupts
outp(((1 << RXCIE) | (1 << TXCIE) | (1 << RXEN) | (1 << TXEN)) ,UCSR0B);
// suppose global interrupt is enabled
}
command void UartDebugTxByte(uint8_t byte)
{
char prev = inp(SREG) & 0x80;
cli();
if (UARTState == UART_IDLE) { // send byte if UART is idle
UARTState = UART_BUSY;
if(prev) sei();
// send byte to UART
outp(byte, UDR0);
sbi(UCSR0A, TXC);
} else { // UART is busy, put byte into buffer
// if buffer is full, the byte will be dropped silently
if (dbgBufCount < DBG_BUF_LEN) {
dbgBuf[dbgTail] = byte;
ADVANCE(dbgTail);
dbgBufCount++;
}
if(prev) sei();
}
}
TOSH_INTERRUPT(SIG_UART0_TRANS)
{
// UART is able to send next byte
// This interrupt handler is using the INTERRUPT macro, in which
// the global interrupt is enabled, so the interrupt handler can
// be interruptted too.
uint8_t byte;
char prev = inp(SREG) & 0x80;
cli();
if(dbgBufCount > 0) {
byte = dbgBuf[dbgHead];
ADVANCE(dbgHead);
dbgBufCount--;
if(prev) sei();
// send next byte to UART
outp(byte, UDR0);
sbi(UCSR0A, TXC);
} else {
UARTState = UART_IDLE;
if(prev) sei();
}
}
TOSH_INTERRUPT(SIG_UART0_RECV)
{
}
}
--- NEW FILE: UartDebugNone.nc ---
/*
* Copyright (C) 2003-2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* UART debugging: this component is for sending debugging bytes thru UART
* Note: can't be used with any application that uses the UART, e.g. motenic
*
* There are two known problems:
* 1) Initializing UART (e.g., for UART debugging) may cause a node fail to
* start or stop running when it's not connected with a serial board/cable.
* The reason needs to be checked further.
* 2) When HPLPowerManagement is enabled, the bytes sent to the UART could
* be corrupted. To be safe, HPLPowerManagement should be disabled when
* using UART debug.
*/
module UartDebugNone
{
provides {
interface UartDebug;
}
}
implementation
{
command void UartDebug.init()
{
}
command void UartDebug.txState(uint8_t state)
{
}
command void UartDebug.txEvent(uint8_t eventNum)
{
}
command void UartDebug.txByte(uint8_t byte)
{
}
}
--- NEW FILE: UartDebugStateEvent.nc ---
/*
* Copyright (C) 2003-2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*/
configuration UartDebugStateEvent
{
provides {
interface UartDebug;
}
}
implementation
{
components UartDebugStateEventM, UartDebugM;
UartDebug = UartDebugStateEventM;
// wiring to lower layers
UartDebugStateEventM.UartDebugInit -> UartDebugM;
UartDebugStateEventM.UartDebugTxByte -> UartDebugM;
}
--- NEW FILE: UartDebugStateEventM.nc ---
/*
* Copyright (C) 2003-2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* UART debugging: this component is for sending debugging bytes thru UART
* Note: can't be used with any application that uses the UART, e.g. motenic
*
* There are two known problems:
* 1) Initializing UART (e.g., for UART debugging) may cause a node fail to
* start or stop running when it's not connected with a serial board/cable.
* The reason needs to be checked further.
* 2) When HPLPowerManagement is enabled, the bytes sent to the UART could
* be corrupted. To be safe, HPLPowerManagement should be disabled when
* using UART debug.
*/
module UartDebugStateEventM
{
provides {
interface UartDebug;
}
uses {
command void UartDebugInit();
command void UartDebugTxByte(uint8_t byte);
}
}
implementation
{
command void UartDebug.init()
{
call UartDebugInit();
}
command void UartDebug.txState(uint8_t state)
{
// send a byte representing the state of a componet
call UartDebugTxByte(state);
}
command void UartDebug.txEvent(uint8_t eventNum)
{
// send a byte representing a pre-defined event
call UartDebugTxByte(eventNum);
}
command void UartDebug.txByte(uint8_t byte)
{
// send an arbitrary byte, can't be used with state/event
}
}
--- NEW FILE: csmaEvents.h ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* this file defines the events in CSMA for debugging
*/
#ifndef CSMA_EVENTS
#define CSMA_EVENTS
#define INIT_EVENT_NO 11
// packet transmission
#define TX_MSG_ACCEPTED INIT_EVENT_NO
#define TX_MSG_REJECTED_ERROR (TX_MSG_ACCEPTED + 1)
#define TX_MSG_REJECTED_BUFFERED (TX_MSG_REJECTED_ERROR + 1)
#define TX_MSG_DONE (TX_MSG_REJECTED_BUFFERED + 1)
#define TX_BCAST_DONE (TX_MSG_DONE + 1)
#define TX_RTS_DONE (TX_BCAST_DONE + 1)
#define TX_CTS_DONE (TX_RTS_DONE + 1)
#define TX_UCAST_DONE (TX_CTS_DONE + 1)
#define TX_ACK_DONE (TX_UCAST_DONE + 1)
// packet reception
#define RX_MSG_ERROR (TX_ACK_DONE + 1)
#define RX_BCAST_DONE (RX_MSG_ERROR + 1)
#define RX_RTS_DONE (RX_BCAST_DONE + 1)
#define RX_CTS_DONE (RX_RTS_DONE + 1)
#define RX_UCAST_DONE (RX_CTS_DONE + 1)
#define RX_ACK_DONE (RX_UCAST_DONE + 1)
#define RX_UNKNOWN_PKT (RX_ACK_DONE + 1)
#define RX_RTS_OTHERS (RX_UNKNOWN_PKT + 1)
#define RX_CTS_OTHERS (RX_RTS_OTHERS + 1)
#define RX_UCAST_OTHERS (RX_CTS_OTHERS + 1)
#define RX_ACK_OTHERS (RX_UCAST_OTHERS + 1)
// timer event
#define TIMER_STARTED_NAV (RX_ACK_OTHERS + 1)
#define TIMER_UPDATED_NAV (TIMER_STARTED_NAV + 1)
#define TIMER_STARTED_NEIGHB_NAV (TIMER_UPDATED_NAV + 1)
#define TIMER_UPDATED_NEIGHB_NAV (TIMER_STARTED_NEIGHB_NAV + 1)
#define TIMER_FIRE_NAV (TIMER_UPDATED_NEIGHB_NAV + 1)
#define TIMER_FIRE_NEIGHB_NAV (TIMER_FIRE_NAV + 1)
#define TIMER_FIRE_BACKOFF (TIMER_FIRE_NEIGHB_NAV + 1)
// carrier sense
#define CHANNEL_BUSY_DETECTED (TIMER_FIRE_BACKOFF + 1)
#define CHANNEL_IDLE_DETECTED (CHANNEL_BUSY_DETECTED + 1)
#define START_SYMBOL_DETECTED (CHANNEL_IDLE_DETECTED + 1)
#define START_SYMBOL_SENT (START_SYMBOL_DETECTED + 1)
// other events
#define TRYTOSEND_SUCCESS (START_SYMBOL_SENT + 1)
#define TRYTOSEND_FAILURE (TRYTOSEND_SUCCESS + 1)
#define UPPER_LAYER_RADIO_ON (TRYTOSEND_FAILURE + 1)
#define UPPER_LAYER_RADIO_OFF (UPPER_LAYER_RADIO_ON + 1)
#define POLL_CHANNEL_SUCCESS (UPPER_LAYER_RADIO_OFF + 1)
#define POLL_CHANNEL_FAIL_NOT_SLEEP (POLL_CHANNEL_SUCCESS + 1)
#define POLL_CHANNEL_FAIL_NOT_ENABLED (POLL_CHANNEL_FAIL_NOT_SLEEP + 1)
#define POLL_CHANNEL_FAIL_VIRTUAL_CS (POLL_CHANNEL_FAIL_NOT_ENABLED + 1)
#define LPL_SLEEP_STATE_RADIO_DONE (POLL_CHANNEL_FAIL_VIRTUAL_CS + 1)
#define LPL_SLEEP_STATE_VIRTUAL_CS (LPL_SLEEP_STATE_RADIO_DONE + 1)
#define LPL_IDLE_STATE_TRYTOSLEEP_FAIL (LPL_SLEEP_STATE_VIRTUAL_CS + 1)
#define LPL_IDLE_STATE_CS_BUSY (LPL_IDLE_STATE_TRYTOSLEEP_FAIL + 1)
#define LPL_IDLE_STATE_WAIT_TIMER_FIRE (LPL_IDLE_STATE_CS_BUSY + 1)
#define LPL_IDLE_STATE_RESEND (LPL_IDLE_STATE_WAIT_TIMER_FIRE + 1)
#endif // SMAC_EVENTS
--- NEW FILE: lplEvents.h ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* this file defines the events in LPL for debugging
*/
#ifndef LPL_EVENTS
#define LPL_EVENTS
#define INIT_EVENT_NO 5
#define POLL_TIMER_FIRED (INIT_EVENT_NO)
#define START_CARRIER_SENSE (POLL_TIMER_FIRED + 1)
#define POLL_CHANNEL_FAIL_NOT_SLEEP (START_CARRIER_SENSE + 1)
#define POLL_CHANNEL_FAIL_NOT_ENABLED (POLL_CHANNEL_FAIL_NOT_SLEEP + 1)
#define POLL_CHANNEL_FAIL_VIRTUAL_CS (POLL_CHANNEL_FAIL_NOT_ENABLED + 1)
#define POLL_CHANNEL_FAIL_WAKEUP_RADIO (POLL_CHANNEL_FAIL_VIRTUAL_CS + 1)
#define POLL_CHANNEL_ENABLED (POLL_CHANNEL_FAIL_WAKEUP_RADIO + 1)
#define POLL_CHANNEL_DISABLED (POLL_CHANNEL_ENABLED + 1)
#define VIRTUAL_CS_IDLE (POLL_CHANNEL_DISABLED + 1)
#define VIRTUAL_CS_BUSY (VIRTUAL_CS_IDLE + 1)
#define TRY_TO_SLEEP_FAILED (VIRTUAL_CS_BUSY + 1)
#define CHANNEL_IDLE_DETECTED (TRY_TO_SLEEP_FAILED + 1)
#define CHANNEL_BUSY_DETECTED (CHANNEL_IDLE_DETECTED + 1)
#define WAIT_TIMER_STARTED (CHANNEL_BUSY_DETECTED + 1)
#define WAIT_TIMER_FIRED (WAIT_TIMER_STARTED + 1)
#define RESEND_REQUESTED (WAIT_TIMER_FIRED + 1)
#define TX_REQUEST_ACCEPTED (RESEND_REQUESTED + 1)
#define TX_REQUEST_REJECTED_MSG_ERROR (TX_REQUEST_ACCEPTED + 1)
#define TX_REQUEST_REJECTED_NO_BUFFER (TX_REQUEST_REJECTED_MSG_ERROR + 1)
#define TX_MSG_DONE (TX_REQUEST_REJECTED_NO_BUFFER + 1)
#define CSMA_RADIO_DONE (TX_MSG_DONE + 1)
#define START_SYMBOL_DETECTED (CSMA_RADIO_DONE + 1)
#define RX_MSG_DONE (START_SYMBOL_DETECTED + 1)
#define SET_RADIO_SLEEP (RX_MSG_DONE + 1)
#endif // LPL_EVENTS
--- NEW FILE: scpEvents.h ---
/*
* Copyright (C) 2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* this file defines the events in SCP for debugging
*/
#ifndef SCP_EVENTS
#define SCP_EVENTS
#define INIT_EVENT_NO 5
#define VIRTUAL_CS_IDLE (INIT_EVENT_NO)
#define VIRTUAL_CS_BUSY (VIRTUAL_CS_IDLE + 1)
#define CHANNEL_IDLE_DETECTED (VIRTUAL_CS_BUSY + 1)
#define CHANNEL_BUSY_DETECTED (CHANNEL_IDLE_DETECTED + 1)
#define TX_TIMER_FIRED (CHANNEL_BUSY_DETECTED + 1)
#define SYNC_TIMER_FIRED (TX_TIMER_FIRED + 1)
#define ADAPTIVE_TIMER_FIRED (SYNC_TIMER_FIRED + 1)
#define TX_REQUEST_ACCEPTED (ADAPTIVE_TIMER_FIRED + 1)
#define TX_REQUEST_REJECTED_MSG_ERROR (TX_REQUEST_ACCEPTED + 1)
#define TX_REQUEST_REJECTED_NO_BUFFER (TX_REQUEST_REJECTED_MSG_ERROR + 1)
#define TX_TONE_DONE (TX_REQUEST_REJECTED_NO_BUFFER + 1)
#define START_SYMBOL_SENT (TX_TONE_DONE + 1)
#define TX_MSG_DONE (START_SYMBOL_SENT + 1)
#define CSMA_RADIO_DONE (TX_MSG_DONE + 1)
#define START_SYMBOL_DETECTED (CSMA_RADIO_DONE + 1)
#define RX_MSG_DONE (START_SYMBOL_DETECTED + 1)
#define RADIO_IDLE_DONE (RX_MSG_DONE + 1)
#define RADIO_IDLE_WAIT (RADIO_IDLE_DONE + 1)
#define RADIO_IDLE_FAILED (RADIO_IDLE_WAIT + 1)
#define CARRIER_SENSE_STARTED (RADIO_IDLE_FAILED + 1)
#define ADAPTIVE_TX_TIMER_FIRED (CARRIER_SENSE_STARTED + 1)
#define ADAPTIVE_POLL_TIMER_FIRED (ADAPTIVE_TX_TIMER_FIRED + 1)
#define NO_PKT_TO_SEND (ADAPTIVE_POLL_TIMER_FIRED + 1)
#define NEIGH_DISC_TIMER_FIRED (NO_PKT_TO_SEND + 1)
#endif // LPL_EVENTS
- Previous message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/scp-mac/tos/platform/micaz ClockSCP.nc, NONE, 1.1 ClockSCPM.nc, NONE, 1.1 HPLCC2420InterruptM.nc, NONE, 1.1 HPLUART0M.nc, NONE, 1.1 MakeXbowlocal, NONE, 1.1 PhyConst.h, NONE, 1.1 PhyRadio.nc, NONE, 1.1 PhyRadioM.nc, NONE, 1.1 PhyRadioMsg.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list