OpenWSN Firmware
schedule.h
Go to the documentation of this file.
1 #ifndef __SCHEDULE_H
2 #define __SCHEDULE_H
3 
11 #include "openwsn.h"
12 
13 //=========================== define ==========================================
14 
20 #define SUPERFRAME_LENGTH 11 //should be 101
21 
22 #define NUMADVSLOTS 1
23 #define NUMSHAREDTXRX 5
24 #define NUMSERIALRX 3
25 
36 #define MAXACTIVESLOTS (NUMADVSLOTS+NUMSHAREDTXRX+NUMSERIALRX)
37 
45 #define MINBE 2
46 
52 #define MAXBE 4
53 //6tisch minimal draft
54 #define SCHEDULE_MINIMAL_6TISCH_ACTIVE_CELLS 5
55 #define SCHEDULE_MINIMAL_6TISCH_EB_CELLS 1
56 #define SCHEDULE_MINIMAL_6TISCH_SLOTFRAME_SIZE 101
57 #define SCHEDULE_MINIMAL_6TISCH_DEFAULT_SLOTFRAME_HANDLE 1 //id of slotframe
58 #define SCHEDULE_MINIMAL_6TISCH_DEFAULT_SLOTFRAME_NUMBER 1 //1 slotframe by default.
59 
60 //=========================== typedef =========================================
61 
62 typedef uint8_t channelOffset_t;
63 typedef uint16_t slotOffset_t;
64 typedef uint16_t frameLength_t;
65 
66 typedef enum {
74 } cellType_t;
75 
76 typedef struct {
79  bool shared;
80  uint8_t channelOffset;
82  uint8_t numRx;
83  uint8_t numTx;
84  uint8_t numTxACK;
86  void* next;
88 
89 BEGIN_PACK
90 typedef struct {
91  uint8_t row;
93  uint8_t type;
94  bool shared;
95  uint8_t channelOffset;
97  uint8_t numRx;
98  uint8_t numTx;
99  uint8_t numTxACK;
102 END_PACK
103 
104 typedef struct {
105  uint8_t address[LENGTH_ADDR64b];
107  bool shared;
111 
112 //=========================== variables =======================================
113 
114 typedef struct {
117  uint16_t frameLength;
119  uint8_t backoff;
120  uint8_t debugPrintRow;
122 
123 //=========================== prototypes ======================================
124 
125 // admin
126 void schedule_init(void);
127 bool debugPrint_schedule(void);
128 bool debugPrint_backoff(void);
129 
130 // from 6top
131 void schedule_setFrameLength(frameLength_t newFrameLength);
133  slotOffset_t slotOffset,
134  cellType_t type,
135  bool shared,
136  uint8_t channelOffset,
137  open_addr_t* neighbor
138 );
139 
141  slotOffset_t slotOffset,
142  open_addr_t* neighbor,
143  slotinfo_element_t* info
144 );
145 
147  slotOffset_t slotOffset,
148  open_addr_t* neighbor
149 );
150 bool schedule_isSlotOffsetAvailable(uint16_t slotOffset);
151 
152 // from IEEE802154E
153 void schedule_syncSlotOffset(slotOffset_t targetSlotOffset);
154 void schedule_advanceSlot(void);
158 void schedule_getNeighbor(open_addr_t* addrToWrite);
160 bool schedule_getOkToSend(void);
161 void schedule_resetBackoff(void);
162 void schedule_indicateRx(asn_t* asnTimestamp);
164  asn_t* asnTimestamp,
165  bool succesfullTx
166  );
167 
173 #endif
void schedule_advanceSlot()
advance to next active slot
Definition: schedule.c:420
void schedule_indicateRx(asn_t *asnTimestamp)
Indicate the reception of a packet.
Definition: schedule.c:577
bool shared
Definition: schedule.h:94
frameLength_t schedule_getFrameLength()
Get the frame length.
Definition: schedule.c:451
uint8_t backoffExponent
Definition: schedule.h:118
bool schedule_isSlotOffsetAvailable(uint16_t slotOffset)
Definition: schedule.c:383
uint16_t frameLength
Definition: schedule.h:117
slotOffset_t slotOffset
Definition: schedule.h:92
bool schedule_getOkToSend()
Check whether I can send on this slot.
Definition: schedule.c:527
scheduleEntry_t * currentScheduleEntry
Definition: schedule.h:116
uint8_t numRx
Definition: schedule.h:82
open_addr_t neighbor
Definition: schedule.h:96
uint8_t numTx
Definition: schedule.h:98
void * next
Definition: schedule.h:86
Definition: schedule.h:73
bool shared
Definition: schedule.h:79
uint8_t owerror_t
Definition: openwsn.h:265
uint8_t row
Definition: schedule.h:91
uint8_t numRx
Definition: schedule.h:97
void schedule_indicateTx(asn_t *asnTimestamp, bool succesfullTx)
Indicate the transmission of a packet.
Definition: schedule.c:594
asn_t lastUsedAsn
Definition: schedule.h:85
channelOffset_t schedule_getChannelOffset()
Get the channel offset of the current schedule entry.
Definition: schedule.c:502
void schedule_syncSlotOffset(slotOffset_t targetSlotOffset)
Definition: schedule.c:405
uint8_t numTxACK
Definition: schedule.h:99
Definition: schedule.h:90
uint8_t numTxACK
Definition: schedule.h:84
uint8_t channelOffset
Definition: schedule.h:80
uint8_t type
Definition: schedule.h:93
Definition: schedule.h:104
bool debugPrint_schedule()
Trigger this module to print status information, over serial.
Definition: schedule.c:90
Definition: openwsn.h:268
void schedule_getSlotInfo(slotOffset_t slotOffset, open_addr_t *neighbor, slotinfo_element_t *info)
Get the information of a specific slot.
Definition: schedule.c:182
Definition: schedule.h:72
#define MAXACTIVESLOTS
Maximum number of active slots in a superframe.
Definition: schedule.h:36
owerror_t schedule_removeActiveSlot(slotOffset_t slotOffset, open_addr_t *neighbor)
Remove an active slot from the schedule.
Definition: schedule.c:312
#define LENGTH_ADDR64b
Definition: openwsn.h:35
cellType_t
Definition: schedule.h:66
open_addr_t neighbor
Definition: schedule.h:81
uint16_t frameLength_t
Definition: schedule.h:64
Definition: openwsn.h:276
void schedule_init()
Initialize this module.
Definition: schedule.c:25
slotOffset_t slotOffset
Definition: schedule.h:108
Definition: schedule.h:70
uint8_t channelOffset_t
Definition: schedule.h:62
Definition: schedule.h:76
uint8_t numTx
Definition: schedule.h:83
uint8_t backoff
Definition: schedule.h:119
Definition: schedule.h:71
channelOffset_t channelOffset
Definition: schedule.h:109
slotOffset_t slotOffset
Definition: schedule.h:77
Definition: schedule.h:114
Definition: schedule.h:68
uint8_t debugPrintRow
Definition: schedule.h:120
bool debugPrint_backoff()
Trigger this module to print status information, over serial.
Definition: schedule.c:141
cellType_t type
Definition: schedule.h:78
cellType_t schedule_getType()
Get the type of the current schedule entry.
Definition: schedule.c:469
void schedule_resetBackoff()
Reset the backoff and backoffExponent.
Definition: schedule.c:561
Definition: schedule.h:69
owerror_t schedule_addActiveSlot(slotOffset_t slotOffset, cellType_t type, bool shared, channelOffset_t channelOffset, open_addr_t *neighbor)
Add a new active slot into the schedule.
Definition: schedule.c:219
bool shared
Definition: schedule.h:107
slotOffset_t schedule_getNextActiveSlotOffset()
return slotOffset of next active slot
Definition: schedule.c:433
cellType_t link_type
Definition: schedule.h:106
uint16_t slotOffset_t
Definition: schedule.h:63
uint8_t channelOffset
Definition: schedule.h:95
asn_t lastUsedAsn
Definition: schedule.h:100
void schedule_getNeighbor(open_addr_t *addrToWrite)
Get the neighbor associated wit the current schedule entry.
Definition: schedule.c:487
void schedule_setFrameLength(frameLength_t newFrameLength)
Set frame length.
Definition: schedule.c:165
Definition: schedule.h:67