OpenWSN Firmware
IEEE802154E.c File Reference
#include "openwsn.h"
#include "IEEE802154E.h"
#include "radio.h"
#include "radiotimer.h"
#include "IEEE802154.h"
#include "openqueue.h"
#include "idmanager.h"
#include "openserial.h"
#include "schedule.h"
#include "packetfunctions.h"
#include "scheduler.h"
#include "leds.h"
#include "neighbors.h"
#include "debugpins.h"
#include "sixtop.h"
#include "adaptive_sync.h"
#include "processIE.h"


void activity_synchronize_newSlot (void)
void activity_synchronize_startOfFrame (PORT_RADIOTIMER_WIDTH capturedTime)
void activity_synchronize_endOfFrame (PORT_RADIOTIMER_WIDTH capturedTime)
void activity_ti1ORri1 (void)
void activity_ti2 (void)
void activity_tie1 (void)
void activity_ti3 (void)
void activity_tie2 (void)
void activity_ti4 (PORT_RADIOTIMER_WIDTH capturedTime)
void activity_tie3 (void)
void activity_ti5 (PORT_RADIOTIMER_WIDTH capturedTime)
void activity_ti6 (void)
void activity_tie4 (void)
void activity_ti7 (void)
void activity_tie5 (void)
void activity_ti8 (PORT_RADIOTIMER_WIDTH capturedTime)
void activity_tie6 (void)
void activity_ti9 (PORT_RADIOTIMER_WIDTH capturedTime)
void activity_ri2 (void)
void activity_rie1 (void)
void activity_ri3 (void)
void activity_rie2 (void)
void activity_ri4 (PORT_RADIOTIMER_WIDTH capturedTime)
void activity_rie3 (void)
void activity_ri5 (PORT_RADIOTIMER_WIDTH capturedTime)
void activity_ri6 (void)
void activity_rie4 (void)
void activity_ri7 (void)
void activity_rie5 (void)
void activity_ri8 (PORT_RADIOTIMER_WIDTH capturedTime)
void activity_rie6 (void)
void activity_ri9 (PORT_RADIOTIMER_WIDTH capturedTime)
bool isValidRxFrame (ieee802154_header_iht *ieee802514_header)
 Decides whether the packet I just received is valid received frame. More...
bool isValidAck (ieee802154_header_iht *ieee802514_header, OpenQueueEntry_t *packetSent)
 Decides whether the packet I just received is a valid ACK. More...
bool ieee154e_processIEs (OpenQueueEntry_t *pkt, uint16_t *lenIE)
void ieee154e_processSlotframeLinkIE (OpenQueueEntry_t *pkt, uint8_t *ptr)
void incrementAsnOffset (void)
void asnStoreFromAdv (uint8_t *asn)
void joinPriorityStoreFromAdv (uint8_t jp)
void synchronizePacket (PORT_RADIOTIMER_WIDTH timeReceived)
void synchronizeAck (PORT_SIGNED_INT_WIDTH timeCorrection)
void changeIsSync (bool newIsSync)
void notif_sendDone (OpenQueueEntry_t *packetSent, owerror_t error)
void notif_receive (OpenQueueEntry_t *packetReceived)
void resetStats (void)
void updateStats (PORT_SIGNED_INT_WIDTH timeCorrection)
uint8_t calculateFrequency (uint8_t channelOffset)
 Calculates the frequency channel to transmit on, based on the absolute slot number and the channel offset of the requested slot. More...
void changeState (ieee154e_state_t newstate)
 Changes the state of the IEEE802.15.4e FSM. More...
void endSlot ()
 Housekeeping tasks to do at the end of each slot. More...
bool debugPrint_asn ()
 Trigger this module to print status information, over serial. More...
bool debugPrint_isSync ()
 Trigger this module to print status information, over serial. More...
void ieee154e_init ()
 This function initializes this module. More...
PORT_RADIOTIMER_WIDTH ieee154e_asnDiff (asn_t *someASN)
void isr_ieee154e_newSlot ()
 Indicates a new slot has just started. More...
void isr_ieee154e_timer ()
 Indicates the FSM timer has fired. More...
void ieee154e_startOfFrame (PORT_RADIOTIMER_WIDTH capturedTime)
 Indicates the radio just received the first byte of a packet. More...
void ieee154e_endOfFrame (PORT_RADIOTIMER_WIDTH capturedTime)
 Indicates the radio just received the last byte of a packet. More...
bool debugPrint_macStats ()
 Trigger this module to print status information, over serial. More...
port_INLINE void ieee154e_getAsn (uint8_t *array)
bool ieee154e_isSynch ()


ieee154e_vars_t ieee154e_vars
ieee154e_stats_t ieee154e_stats
ieee154e_dbg_t ieee154e_dbg

Function Documentation

port_INLINE void activity_ri2 ( void  )
port_INLINE void activity_ri3 ( void  )
port_INLINE void activity_ri4 ( PORT_RADIOTIMER_WIDTH  capturedTime)
port_INLINE void activity_ri5 ( PORT_RADIOTIMER_WIDTH  capturedTime)
port_INLINE void activity_ri6 ( void  )
port_INLINE void activity_ri7 ( void  )
port_INLINE void activity_ri8 ( PORT_RADIOTIMER_WIDTH  capturedTime)
port_INLINE void activity_ri9 ( PORT_RADIOTIMER_WIDTH  capturedTime)
port_INLINE void activity_rie1 ( void  )
port_INLINE void activity_rie2 ( void  )
port_INLINE void activity_rie3 ( void  )
port_INLINE void activity_rie4 ( void  )
port_INLINE void activity_rie5 ( void  )
port_INLINE void activity_rie6 ( void  )
port_INLINE void activity_synchronize_endOfFrame ( PORT_RADIOTIMER_WIDTH  capturedTime)
port_INLINE void activity_synchronize_newSlot ( void  )
port_INLINE void activity_synchronize_startOfFrame ( PORT_RADIOTIMER_WIDTH  capturedTime)
port_INLINE void activity_ti1ORri1 ( void  )
port_INLINE void activity_ti2 ( void  )
port_INLINE void activity_ti3 ( void  )
port_INLINE void activity_ti4 ( PORT_RADIOTIMER_WIDTH  capturedTime)
port_INLINE void activity_ti5 ( PORT_RADIOTIMER_WIDTH  capturedTime)
port_INLINE void activity_ti6 ( void  )
port_INLINE void activity_ti7 ( void  )
port_INLINE void activity_ti8 ( PORT_RADIOTIMER_WIDTH  capturedTime)
port_INLINE void activity_ti9 ( PORT_RADIOTIMER_WIDTH  capturedTime)
port_INLINE void activity_tie1 ( void  )
port_INLINE void activity_tie2 ( void  )
port_INLINE void activity_tie3 ( void  )
port_INLINE void activity_tie4 ( void  )
port_INLINE void activity_tie5 ( void  )
port_INLINE void activity_tie6 ( void  )
port_INLINE void asnStoreFromAdv ( uint8_t *  asn)
port_INLINE uint8_t calculateFrequency ( uint8_t  channelOffset)

Calculates the frequency channel to transmit on, based on the absolute slot number and the channel offset of the requested slot.

During normal operation, the frequency used is a function of the channelOffset indicating in the schedule, and of the ASN of the slot. This ensures channel hopping, consecutive packets sent in the same slot in the schedule are done on a difference frequency channel.

During development, you can force single channel operation by having this function return a constant channel number (between 11 and 26). This allows you to use a single-channel sniffer; but you can not schedule two links on two different channel offsets in the same slot.

[in]channelOffsetchannel offset for the current slot
The calculated frequency channel, an integer between 11 and 26.
void changeIsSync ( bool  newIsSync)
void changeState ( ieee154e_state_t  newstate)

Changes the state of the IEEE802.15.4e FSM.

Besides simply updating the state global variable, this function toggles the FSM debug pin.

[in]newstateThe state the IEEE802.15.4e FSM is now in.
void endSlot ( )

Housekeeping tasks to do at the end of each slot.

This functions is called once in each slot, when there is nothing more to do. This might be when an error occured, or when everything went well. This function resets the state of the FSM so it is ready for the next slot.

Note that by the time this function is called, any received packet should already have been sent to the upper layer. Similarly, in a Tx slot, the sendDone function should already have been done. If this is not the case, this function will do that for you, but assume that something went wrong.

port_INLINE bool ieee154e_processIEs ( OpenQueueEntry_t pkt,
uint16_t *  lenIE 
void ieee154e_processSlotframeLinkIE ( OpenQueueEntry_t pkt,
uint8_t *  ptr 
port_INLINE void incrementAsnOffset ( void  )
port_INLINE bool isValidAck ( ieee802154_header_iht ieee802514_header,
OpenQueueEntry_t packetSent 

Decides whether the packet I just received is a valid ACK.

A packet is a valid ACK if it satisfies the following conditions:

  • the IEEE802.15.4 header is valid
  • the frame type is 'ACK'
  • the sequence number in the ACK matches the sequence number of the packet sent
  • the ACK contains my PANid
  • the packet is unicast to me
  • the packet comes from the neighbor I sent the data to
[in]ieee802514_headerIEEE802.15.4 header of the packet I just received
[in]packetSentpoints to the packet I just sent
TRUE if packet is a valid ACK, FALSE otherwise.
port_INLINE bool isValidRxFrame ( ieee802154_header_iht ieee802514_header)

Decides whether the packet I just received is valid received frame.

A valid Rx frame satisfies the following constraints:

  • its IEEE802.15.4 header is well formatted
  • it's a DATA of BEACON frame (i.e. not ACK and not COMMAND)
  • it's sent on the same PANid as mine
  • it's for me (unicast or broadcast)
[in]ieee802514_headerIEEE802.15.4 header of the packet I just received
TRUE if packet is valid received frame, FALSE otherwise
port_INLINE void joinPriorityStoreFromAdv ( uint8_t  jp)
void notif_receive ( OpenQueueEntry_t packetReceived)
void notif_sendDone ( OpenQueueEntry_t packetSent,
owerror_t  error 
port_INLINE void resetStats ( void  )
void synchronizeAck ( PORT_SIGNED_INT_WIDTH  timeCorrection)
void synchronizePacket ( PORT_RADIOTIMER_WIDTH  timeReceived)
void updateStats ( PORT_SIGNED_INT_WIDTH  timeCorrection)

Variable Documentation

ieee154e_dbg_t ieee154e_dbg
ieee154e_stats_t ieee154e_stats
ieee154e_vars_t ieee154e_vars