SZSPTP ez430-RF2480 1.0

ZigBee Sensor Network with synchronized time and time-stamped measurements.
nwk.h
Go to the documentation of this file.
1 /*
2  * nwk.h
3  *
4  * Date: 19/06/2014
5  * Author: Fernando Biazi Nascimento
6  * Copyright © 2014 Fernando Biazi Nascimento. All rights reserved.
7  *
8  * License of use and copy on file license.txt
9  *
10  */
11 
20 #ifndef NWK_H_
21 #define NWK_H_
22 
23 /*
24  * ======== Includes ========
25  */
26 
27 #include <xdc/std.h>
28 
29 /*
30  * ======== Doxygen ========
31  */
40 /*
41  * ======== Constants ========
42  */
43 
44 /*
45  * ======== Macros ========
46  */
47 
51 #define NWK_CFG_PANID "\xFF\xFF"
52 
55 #define NWK_CFG_CHANLIST "\x00\x00\x01\x00"
56 
59 #define NWK_CFG_PRECFGKEY "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
60 
63 #define NWK_CFG_PRECFGKEYS_ENABLE "\x01"
64 
67 #define NWK_CFG_SECURITY_MODE "\x00"
68 
71 #define NWK_CFG_BCAST_RETRIES "\x02"
72 
75 #define NWK_CFG_PASSIVE_ACK_TIMEOUT "\x05"
76 
79 #define NWK_CFG_BCAST_DELIVERY_TIME "\x1E"
80 
83 #define NWK_CFG_ROUTE_EXPIRY_TIME "\x3C"
84 
101 #define NWK_CFG_APPENDPOINT 1
102 
109 #define NWK_CFG_APPPROFILEID 0x0F10
110 
116 #define NWK_CFG_DEVICEID 0x0003
117 
123 #define NWK_CFG_DEVICEVERSION 1
124 
129 #define NWK_CFG_INPUTCMDCOUNT 3
130 
136 #define NWK_CFG_INPUTCMDLIST "\x01\x00\x02\x00\x03\x00"
137 
142 #define NWK_CFG_OUTPUTCMDCOUNT 3
143 
149 #define NWK_CFG_OUTPUTCMDLIST "\x01\x00\x02\x00\x03\x00"
150 
157 #define NWK_CMDIDHEARTBEAT 1
158 
163 #define NWK_CMDIDRPT 2
164 
169 #define NWK_CMDIDPTP 3
170 
190 #define NWK_DEFDEST 0xFFFE
191 
195 #define NWK_DEFACK 0
196 
200 #define NWK_DEFRADIUS 10
201 
208 #define NWK_DEVTYPE_DEFALUT NWK_DEVTYPE_ROUTER
209 
213 #define NWK_NEIGHBORMAX 3
214 
215 /*
216  * ======== Types ========
217  */
218 
222 typedef enum nwk_devType {
227 } nwk_devType;
228 
234 typedef struct nwk_neighbor {
235  UInt16 foreignAddress;
236  UInt8 foreignPort;
237  UInt8 timeOut;
238 } nwk_neighbor;
239 
240 /*
241  * ======== Global Variables ========
242  */
243 
248 
249 /*
250  * ======== Global Functions ========
251  */
252 
253 void nwk_init();
254 UInt16 nwk_process();
255 
256 void nwk_suspend();
257 UInt8 nwk_wakeUp();
258 
259 void nwk_setDeviceType(nwk_devType newType);
261 
262 void nwk_resetResume();
263 UInt8 nwk_configureWrite();
264 void nwk_configureWriteRsp(UInt8 status);
265 
266 UInt8 nwk_register();
267 void nwk_registerRsp(UInt8 status);
268 
269 UInt8 nwk_start();
270 void nwk_startRsp();
271 void nwk_startConfirm(UInt8 status);
272 
273 UInt8 nwk_allow_bind(UInt8 timeout);
274 void nwk_allow_bindRsp();
275 void nwk_allow_bindConfirm(char *pBuf);
276 
277 UInt8 nwk_bind_device(UInt8 create, UInt16 commandId, uint64_t destination);
278 void nwk_bind_deviceRsp();
279 void nwk_bind_deviceConfirm(char *pBuf);
280 
281 UInt8 nwk_getDeviceInfo();
282 void nwk_getDeviceInfoRsp(UInt8 param, void *pValue);
283 
284 UInt8 nwk_isClient();
285 
286 UInt8 nwk_isSink();
287 UInt8 nwk_isBound();
288 void nwk_setSink(UInt8 sink);
289 
290 UInt16 nwk_getShortAddress();
291 uint64_t nwk_getIeeeAddress();
292 uint64_t * nwk_getPIeeeAddress();
293 
294 UInt8 nwk_setPermitJoin(UInt8 timeout);
295 void nwk_setPermitJoinRsp();
296 UInt8 nwk_allowJoin();
297 UInt8 nwk_disallowJoin();
298 
299 UInt8 nwk_startFrame(UInt16 destination, UInt16 cmdId, UInt8 radius, UInt8 len);
300 UInt8 nwk_snd(UInt8 size, void *pBuf);
301 void nwk_endFrame(UInt8 forwardToSerial);
302 UInt8 nwk_sndUInt8(UInt8 v);
303 UInt8 nwk_sndUInt16(UInt16 v);
304 UInt8 nwk_sndUInt32(UInt32 *p);
305 UInt8 nwk_sndUInt48(uint64_t *p);
306 UInt8 nwk_sndUInt64(uint64_t *p);
307 UInt8 nwk_sndInt64(int64_t *p);
308 
309 void nwk_send_dataConfirm(UInt8 dataHandle, UInt8 status);
310 
311 void nwk_rcv(char *pBuf);
312 
313 UInt8 nwk_getNeighborPort(UInt16 a);
314 UInt8 nwk_getNeighborForeignPort(UInt8 i);
315 UInt16 nwk_getNeighborAddress(UInt8 i);
316 UInt8 nwk_registerNeighbor(UInt16 a);
317 
321 #endif /* NWK_H_ */
UInt8 nwk_isSink()
Is sink.
Definition: nwk.c:1170
Coordinator.
Definition: nwk.h:223
uint64_t * nwk_getPIeeeAddress()
Get pointer to the IEEE address.
Definition: nwk.c:1245
void nwk_allow_bindConfirm(char *pBuf)
Allow bind confirmation.
Definition: nwk.c:913
UInt8 nwk_sndInt64(int64_t *p)
Send signed 64 bits integer.
Definition: nwk.c:1394
UInt8 nwk_register()
Register application request.
Definition: nwk.c:807
UInt8 nwk_start()
Start network request.
Definition: nwk.c:839
UInt8 nwk_sndUInt64(uint64_t *p)
Send unsigned 64 bits integer.
Definition: nwk.c:1380
UInt8 nwk_setPermitJoin(UInt8 timeout)
Permit join request.
Definition: nwk.c:1107
void nwk_allow_bindRsp()
Allow bind response.
Definition: nwk.c:901
UInt8 nwk_getNeighborForeignPort(UInt8 i)
Get neighbor foreign port.
Definition: nwk.c:1562
None, invalid in a network.
Definition: nwk.h:226
void nwk_registerRsp(UInt8 status)
Register application response.
Definition: nwk.c:823
UInt8 nwk_wakeUp()
Network wake up.
Definition: nwk.c:475
void nwk_suspend()
network suspend
Definition: nwk.c:459
void nwk_setPermitJoinRsp()
Permit join response.
Definition: nwk.c:1121
void nwk_configureWriteRsp(UInt8 status)
Response to a configuration write.
Definition: nwk.c:749
UInt8 nwk_sndUInt48(uint64_t *p)
Send unsigned 48 bits integer.
Definition: nwk.c:1366
void nwk_setSink(UInt8 sink)
Set sink.
Definition: nwk.c:1198
Router.
Definition: nwk.h:224
UInt8 nwk_isClient()
Is client.
Definition: nwk.c:1156
void nwk_bind_deviceRsp()
Bind device response.
Definition: nwk.c:941
UInt16 nwk_getShortAddress()
Get shotr address.
Definition: nwk.c:1217
nwk_neighbor nwk_neighbors[NWK_NEIGHBORMAX]
Neighbors information.
Definition: nwk.c:159
UInt8 nwk_sndUInt32(UInt32 *p)
Send unsigned 32 bits integer.
Definition: nwk.c:1349
UInt8 nwk_isBound()
Is bound.
Definition: nwk.c:1182
UInt8 nwk_sndUInt16(UInt16 v)
Send unsigned 16 bits integer.
Definition: nwk.c:1333
void nwk_startRsp()
Start network response.
Definition: nwk.c:850
void nwk_setDeviceType(nwk_devType newType)
Set device type.
Definition: nwk.c:517
UInt8 nwk_sndUInt8(UInt8 v)
Send unsigned 8 bits integer.
Definition: nwk.c:1317
UInt8 nwk_disallowJoin()
Disallow join.
Definition: nwk.c:1145
UInt8 nwk_getDeviceInfo()
Get device information request.
Definition: nwk.c:975
void nwk_init()
Network initialization.
Definition: nwk.c:277
void nwk_resetResume()
Resume from CC2480 reset.
Definition: nwk.c:549
#define NWK_NEIGHBORMAX
Max number of expected direct neighbors.
Definition: nwk.h:213
UInt16 nwk_process()
Network process.
Definition: nwk.c:311
nwk_devType nwk_getDeviceType()
This function gets the device type.
Definition: nwk.c:535
void nwk_rcv(char *pBuf)
Network receive.
Definition: nwk.c:1430
struct nwk_neighbor nwk_neighbor
Neighbor data.
void nwk_send_dataConfirm(UInt8 dataHandle, UInt8 status)
Send data confirmation.
Definition: nwk.c:1407
UInt8 nwk_allowJoin()
Allow join.
Definition: nwk.c:1134
void nwk_getDeviceInfoRsp(UInt8 param, void *pValue)
Get device information response.
Definition: nwk.c:1038
uint64_t nwk_getIeeeAddress()
Get IEEE address.
Definition: nwk.c:1230
Neighbor data.
Definition: nwk.h:234
UInt8 nwk_bind_device(UInt8 create, UInt16 commandId, uint64_t destination)
Bind device request.
Definition: nwk.c:932
UInt8 nwk_startFrame(UInt16 destination, UInt16 cmdId, UInt8 radius, UInt8 len)
Start Frame.
Definition: nwk.c:1264
End device.
Definition: nwk.h:225
UInt8 nwk_snd(UInt8 size, void *pBuf)
Send data.
Definition: nwk.c:1285
UInt8 nwk_configureWrite()
Write configuration.
Definition: nwk.c:572
void nwk_bind_deviceConfirm(char *pBuf)
Bind device confirmation.
Definition: nwk.c:950
UInt8 nwk_allow_bind(UInt8 timeout)
Allow bind request.
Definition: nwk.c:890
UInt8 nwk_getNeighborPort(UInt16 a)
Get neighbor port.
Definition: nwk.c:1539
void nwk_endFrame(UInt8 forwardToSerial)
End frame.
Definition: nwk.c:1300
nwk_devType
Device types.
Definition: nwk.h:222
UInt8 nwk_registerNeighbor(UInt16 a)
Register neighbor.
Definition: nwk.c:1595
UInt16 nwk_getNeighborAddress(UInt8 i)
Get neighbor address.
Definition: nwk.c:1578
void nwk_startConfirm(UInt8 status)
Start network confirmation.
Definition: nwk.c:868