Home Tutorial


Implementing IEEE802.15.4e requires you to define the following variables local to the IEEE802.15.4e code. Because IEEE802.15.4e runs entirely from interrupt context, if you want to access these variables from outside IEEE802.15.4e (either task level or different interrupt priority), you need to access them inside a critical section to ensure atomicity.

As with all modules in OpenWSN, module variables are stored in a single structure.

In C-code:

typedef struct {
   asn_t              asn;                // current absolute slot number
   uint8_t            state;              // state of the FSM
   uint8_t            dsn;                // data sequence number
   uint16_t           capturedTime;       // last captures time
   uint16_t           syncTimeout;        // how many slots left before looses sync
   bool               isSync;             // TRUE iff mote synchronized to network
   OpenQueueEntry_t*  dataToSend;         // pointer to the data to send
   OpenQueueEntry_t*  dataReceived;       // pointer to the data received
   OpenQueueEntry_t*  ackToSend;          // pointer to the ack to send
   OpenQueueEntry_t*  ackReceived;        // pointer to the ack received
} ieee154e_vars_t;

ieee154e_vars_t ieee154e_vars;


The Absolute Slot Number. A number which increments at each new slot. Nodes learn the current ASN of the network when joining. The ASN is used as an index to the schedule, and to calculate the frequency when channel hopping.


Represents the state of the IEEE802.15.4e FSM. Possible values are:

enum ieee154e_state_enum {
   S_SLEEP                   = 0x00,   // ready for next slot
   // synchronizing
   S_SYNCHRONIZING           = 0x01,   // synchronizing to the network
   // TX
   S_TXDATAOFFSET            = 0x02,   // waiting to prepare for Tx data
   S_TXDATAPREPARE           = 0x03,   // preparing for Tx data
   S_TXDATAREADY             = 0x04,   // ready to Tx data, waiting for 'go'
   S_TXDATADELAY             = 0x05,   // 'go' signal given, waiting for SFD Tx data
   S_TXDATA                  = 0x06,   // Tx data SFD received, sending bytes
   S_RXACKOFFSET             = 0x07,   // Tx data done, waiting to prepare for Rx ACK
   S_RXACKPREPARE            = 0x08,   // preparing for Rx ACK
   S_RXACKREADY              = 0x09,   // ready to Rx ACK, waiting for 'go'
   S_RXACKLISTEN             = 0x0a,   // idle listening for ACK
   S_RXACK                   = 0x0b,   // Rx ACK SFD received, receiving bytes
   S_TXPROC                  = 0x0c,   // processing sent data
   // RX
   S_RXDATAOFFSET            = 0x0d,   // waiting to prepare for Rx data
   S_RXDATAPREPARE           = 0x0e,   // preparing for Rx data
   S_RXDATAREADY             = 0x0f,   // ready to Rx data, waiting for 'go'
   S_RXDATALISTEN            = 0x10,   // idle listening for data
   S_RXDATA                  = 0x11,   // data SFD received, receiving more bytes
   S_TXACKOFFSET             = 0x12,   // waiting to prepare for Tx ACK
   S_TXACKPREPARE            = 0x13,   // preparing for Tx ACK
   S_TXACKREADY              = 0x14,   // Tx ACK ready, waiting for 'go'
   S_TXACKDELAY              = 0x15,   // 'go' signal given, waiting for SFD Tx ACK
   S_TXACK                   = 0x16,   // Tx ACK SFD received, sending bytes
   S_RXPROC                  = 0x17,   // processing received data


The data Sequence Number increments at every frame transmitted (not retransmitted) and is used for very simple duplicate packet filtering at the MAC layer.


Holds the time it was (relative to the start of the slot) when the last capture was performed. It holds its value until the next capture. It is used to start timers relative to some event in the slot, and to resynchronize the nodes.


The number of slots left before the mote looses sync. It can be thought of as a software timer which changes at every slot. If the mote resynchronizes, its value is reset to SYNCTIMEOUT.


A boolean which indicates whether the mote is currently synchronized to the network.


A pointer to the data frame to be sent. This frame is created by the upper layer. IEEE802.15.4e sends the frame (potentially in multiple tries) and informs the upper layer once that succeeded/failed. It's the upper layer's responsibility to free the corresponding memory buffer.


A pointer to the data frame received by the radio. This frame is created by the radio driver. IEEE802.15.4e receives this frame. It passes the frame on to the upper layer if it's valid (which is the responsible to free is), and frees it otherwise.


A pointer to the acknowledgment frame. This frame is created by IEEE802.15.4e , which also requests the corresponding memory buffer. After is it sent, IEEE802.15.4e is also reponsible for freeing the buffer.


A pointer to the ack frame received by the radio. This frame is created by the radio driver. IEEE802.15.4e receives the ACK, and frees the corresponding memory buffer.