ronelib
Operating System for the r-one robot
 All Data Structures Files Functions Variables Typedefs
BroadcastComms.h
Go to the documentation of this file.
1 
30 #include "roneos.h"
31 #ifndef BROADCASTCOMMS_H_
32 #define BROADCASTCOMMS_H_
33 
34 // the maximum number of hops for any broadcast message
35 #define BROADCAST_MSG_HOPS_MAX 15
36 
37 // message time to live. Defined in rounds
38 #define BROADCAST_MSG_MAX_TIMEOUT 4
39 
43 typedef struct BroadcastMessage {
44  boolean active;
45  uint8 senderID;
47  boolean isSource;
48  uint8 hopsMax;
52  NbrData msgSourceID;
53  NbrData msgHops;
54  NbrData msgTimestamp;
56 
57 
65 void broadcastMsgCreate(BroadcastMessage* msgPtr, uint8 maxHops);
66 
67 void broadcastMsgUpdateNav(BroadcastMessage* msgPtr, NbrList* nbrListPtr);
68 
69 
76 void broadcastMsgClear(BroadcastMessage* msgPtr);
77 
78 
86 void broadcastMsgSetSource(BroadcastMessage* msgPtr, boolean val);
87 
88 boolean broadcastMsgIsSource(BroadcastMessage* msgPtr);
89 
90 
99 void broadcastMsgUpdate(BroadcastMessage* msgPtr, NbrList* nbrListPtr);
100 
101 
110 void broadcastMsgUpdateLeaderElection(BroadcastMessage* msgPtr, NbrList* nbrListPtr);
111 
112 
120 void broadcastMsgUpdateNbrData(BroadcastMessage* msgPtr, NbrData* nbrDataPtr);
121 
122 
129 uint8 broadcastMsgGetHops(BroadcastMessage* msgPtr);
130 
131 
139 uint8 broadcastMsgGetHopsNbr(BroadcastMessage* msgPtr, Nbr* nbrPtr);
140 
141 
148 uint8 broadcastMsgGetSourceID(BroadcastMessage* msgPtr);
149 
150 
158 uint8 broadcastMsgGetSourceIDNbr(BroadcastMessage* msgPtr, Nbr* nbrPtr);
159 
160 
167 uint8 broadcastMsgGetSenderID(BroadcastMessage* msgPtr);
168 
169 
177 uint8 broadcastMsgGetSenderIDNbr(BroadcastMessage* msgPtr, Nbr* nbrPtr);
178 
179 
187 uint8 broadcastMsgGetTimestampNbr(BroadcastMessage* msgPtr, Nbr* nbrPtr);
188 
189 
196 uint8 broadcastMsgGetTimestamp(BroadcastMessage* msgPtr);
197 
198 
199 
207 void nbrListPrintHops(NbrList* nbrListPtr, BroadcastMessage* broadcastMessagePtr, char* name);
208 
209 
218 NbrList* nbrListGetParents(NbrList* nbrListParents, NbrList* nbrListIn, BroadcastMessage* msgPtr);
219 
220 
229 NbrList* nbrListGetSiblings(NbrList* nbrListSiblings, NbrList* nbrListIn, BroadcastMessage* msgPtr);
230 
231 
240 NbrList* nbrListGetChildren(NbrList* nbrListChildren, NbrList* nbrListIn, BroadcastMessage* msgPtr);
241 
242 
249 Nbr* nbrListFindSource(NbrList* nbrListPtr, BroadcastMessage* msgPtr);
250 
251 
252 
253 //TODO: Not Connected ton anything
254 void nbrListPickParents(NbrList* ParentListOut1, NbrList* Parents, NbrList* Siblings,BroadcastMessage* msgPtr);
255 
256 
257 //TODO: implement or remove?
258 //void nbrListSortParents(nbrList* ParentListOut, nbrList* ParentListIn,BroadcastMessage* msgPtr);
259 //void nbrListPrint(NbrList* nbrListPtr, char* name);
260 //void nbrListPrintDebug(NbrList* nbrListPtr, char* name);
261 
262 //void broadcastMsgSetHops(uint8 hops);
263 //uint8 broadcastMsgGetChildCountNbr(Nbr* nbrPtr);
264 //uint8 broadcastMsgGetParentIDNbr(Nbr* nbrPtr);
265 //void broadcastMsgSetStationary(uint8 stationary);
266 //void broadcastMsgSetChildCount(uint8 childrenCount);
267 //void broadcastMsgSetParentID(uint8 parentID);
268 //void broadcastMsgSetData(uint8 sourceID, uint8 hops, uint8 childrenCount, uint8 stationary, uint8 parentID);
269 
270 
271 #endif /* BROADCASTCOMMS_H_ */