SZS 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 2
130 
136 #define NWK_CFG_INPUTCMDLIST "\x01\x00\x02\x00"
137 
142 #define NWK_CFG_OUTPUTCMDCOUNT 2
143 
149 #define NWK_CFG_OUTPUTCMDLIST "\x01\x00\x02\x00"
150 
157 #define NWK_CMDIDHEARTBEAT 1
158 
163 #define NWK_CMDIDRPT 2
164 
184 #define NWK_DEFDEST 0xFFFE
185 
189 #define NWK_DEFACK 0
190 
194 #define NWK_DEFRADIUS 10
195 
202 #define NWK_DEVTYPE_DEFALUT NWK_DEVTYPE_ROUTER
203 
207 #define NWK_NEIGHBORMAX 3
208 
209 /*
210  * ======== Types ========
211  */
212 
216 typedef enum nwk_devType {
221 } nwk_devType;
222 
228 typedef struct nwk_neighbor {
229  UInt16 foreignAddress;
230  UInt8 foreignPort;
231  UInt8 timeOut;
232 } nwk_neighbor;
233 
234 /*
235  * ======== Global Variables ========
236  */
237 
242 
243 /*
244  * ======== Global Functions ========
245  */
246 
247 void nwk_init();
248 UInt16 nwk_process();
249 
250 void nwk_suspend();
251 UInt8 nwk_wakeUp();
252 
253 void nwk_setDeviceType(nwk_devType newType);
255 
256 void nwk_resetResume();
257 UInt8 nwk_configureWrite();
258 void nwk_configureWriteRsp(UInt8 status);
259 
260 UInt8 nwk_register();
261 void nwk_registerRsp(UInt8 status);
262 
263 UInt8 nwk_start();
264 void nwk_startRsp();
265 void nwk_startConfirm(UInt8 status);
266 
267 UInt8 nwk_allow_bind(UInt8 timeout);
268 void nwk_allow_bindRsp();
269 void nwk_allow_bindConfirm(char *pBuf);
270 
271 UInt8 nwk_bind_device(UInt8 create, UInt16 commandId, uint64_t destination);
272 void nwk_bind_deviceRsp();
273 void nwk_bind_deviceConfirm(char *pBuf);
274 
275 UInt8 nwk_getDeviceInfo();
276 void nwk_getDeviceInfoRsp(UInt8 param, void *pValue);
277 
278 UInt8 nwk_isClient();
279 
280 UInt8 nwk_isSink();
281 UInt8 nwk_isBound();
282 void nwk_setSink(UInt8 sink);
283 
284 UInt16 nwk_getShortAddress();
285 uint64_t nwk_getIeeeAddress();
286 uint64_t * nwk_getPIeeeAddress();
287 UInt16 nwk_getParentShortAddress();
288 
289 UInt8 nwk_setPermitJoin(UInt8 timeout);
290 void nwk_setPermitJoinRsp();
291 UInt8 nwk_allowJoin();
292 UInt8 nwk_disallowJoin();
293 
294 UInt8 nwk_startFrame(UInt16 destination, UInt16 cmdId, UInt8 radius, UInt8 len);
295 UInt8 nwk_snd(UInt8 size, void *pBuf);
296 void nwk_endFrame(UInt8 forwardToSerial);
297 UInt8 nwk_sndUInt8(UInt8 v);
298 UInt8 nwk_sndUInt16(UInt16 v);
299 UInt8 nwk_sndUInt32(UInt32 *p);
300 UInt8 nwk_sndUInt48(uint64_t *p);
301 UInt8 nwk_sndUInt64(uint64_t *p);
302 UInt8 nwk_sndInt64(int64_t *p);
303 
304 void nwk_send_dataConfirm(UInt8 dataHandle, UInt8 status);
305 
306 void nwk_rcv(char *pBuf);
307 
308 UInt8 nwk_getNeighborPort(UInt16 a);
309 UInt8 nwk_getNeighborForeignPort(UInt8 i);
310 UInt16 nwk_getNeighborAddress(UInt8 i);
311 UInt8 nwk_registerNeighbor(UInt16 a);
312 
316 #endif /* NWK_H_ */
UInt8 nwk_isSink()
Is sink.
Definition: nwk.c:1167
Coordinator.
Definition: nwk.h:217
uint64_t * nwk_getPIeeeAddress()
Get pointer to the IEEE address.
Definition: nwk.c:1242
void nwk_allow_bindConfirm(char *pBuf)
Allow bind confirmation.
Definition: nwk.c:912
UInt8 nwk_sndInt64(int64_t *p)
Send signed 64 bits integer.
Definition: nwk.c:1391
UInt8 nwk_register()
Register application request.
Definition: nwk.c:806
UInt8 nwk_start()
Start network request.
Definition: nwk.c:838
UInt8 nwk_sndUInt64(uint64_t *p)
Send unsigned 64 bits integer.
Definition: nwk.c:1377
UInt8 nwk_setPermitJoin(UInt8 timeout)
Permit join request.
Definition: nwk.c:1104
void nwk_allow_bindRsp()
Allow bind response.
Definition: nwk.c:900
UInt8 nwk_getNeighborForeignPort(UInt8 i)
Get neighbor foreign port.
Definition: nwk.c:1545
None, invalid in a network.
Definition: nwk.h:220
void nwk_registerRsp(UInt8 status)
Register application response.
Definition: nwk.c:822
UInt8 nwk_wakeUp()
Network wake up.
Definition: nwk.c:474
void nwk_suspend()
network suspend
Definition: nwk.c:458
void nwk_setPermitJoinRsp()
Permit join response.
Definition: nwk.c:1118
void nwk_configureWriteRsp(UInt8 status)
Response to a configuration write.
Definition: nwk.c:748
UInt8 nwk_sndUInt48(uint64_t *p)
Send unsigned 48 bits integer.
Definition: nwk.c:1363
void nwk_setSink(UInt8 sink)
Set sink.
Definition: nwk.c:1195
Router.
Definition: nwk.h:218
UInt8 nwk_isClient()
Is client.
Definition: nwk.c:1153
void nwk_bind_deviceRsp()
Bind device response.
Definition: nwk.c:940
UInt16 nwk_getShortAddress()
Get shotr address.
Definition: nwk.c:1214
nwk_neighbor nwk_neighbors[NWK_NEIGHBORMAX]
Neighbors information.
Definition: nwk.c:158
UInt8 nwk_sndUInt32(UInt32 *p)
Send unsigned 32 bits integer.
Definition: nwk.c:1346
UInt8 nwk_isBound()
Is bound.
Definition: nwk.c:1179
UInt8 nwk_sndUInt16(UInt16 v)
Send unsigned 16 bits integer.
Definition: nwk.c:1330
void nwk_startRsp()
Start network response.
Definition: nwk.c:849
void nwk_setDeviceType(nwk_devType newType)
Set device type.
Definition: nwk.c:516
UInt8 nwk_sndUInt8(UInt8 v)
Send unsigned 8 bits integer.
Definition: nwk.c:1314
UInt8 nwk_disallowJoin()
Disallow join.
Definition: nwk.c:1142
UInt8 nwk_getDeviceInfo()
Get device information request.
Definition: nwk.c:974
void nwk_init()
Network initialization.
Definition: nwk.c:276
void nwk_resetResume()
Resume from CC2480 reset.
Definition: nwk.c:548
#define NWK_NEIGHBORMAX
Max number of expected direct neighbors.
Definition: nwk.h:207
UInt16 nwk_process()
Network process.
Definition: nwk.c:310
nwk_devType nwk_getDeviceType()
This function gets the device type.
Definition: nwk.c:534
void nwk_rcv(char *pBuf)
Network receive.
Definition: nwk.c:1427
struct nwk_neighbor nwk_neighbor
Neighbor data.
void nwk_send_dataConfirm(UInt8 dataHandle, UInt8 status)
Send data confirmation.
Definition: nwk.c:1404
UInt8 nwk_allowJoin()
Allow join.
Definition: nwk.c:1131
void nwk_getDeviceInfoRsp(UInt8 param, void *pValue)
Get device information response.
Definition: nwk.c:1037
uint64_t nwk_getIeeeAddress()
Get IEEE address.
Definition: nwk.c:1227
Neighbor data.
Definition: nwk.h:228
UInt8 nwk_bind_device(UInt8 create, UInt16 commandId, uint64_t destination)
Bind device request.
Definition: nwk.c:931
UInt8 nwk_startFrame(UInt16 destination, UInt16 cmdId, UInt8 radius, UInt8 len)
Start Frame.
Definition: nwk.c:1261
End device.
Definition: nwk.h:219
UInt8 nwk_snd(UInt8 size, void *pBuf)
Send data.
Definition: nwk.c:1282
UInt8 nwk_configureWrite()
Write configuration.
Definition: nwk.c:571
void nwk_bind_deviceConfirm(char *pBuf)
Bind device confirmation.
Definition: nwk.c:949
UInt8 nwk_allow_bind(UInt8 timeout)
Allow bind request.
Definition: nwk.c:889
UInt8 nwk_getNeighborPort(UInt16 a)
Get neighbor port.
Definition: nwk.c:1522
void nwk_endFrame(UInt8 forwardToSerial)
End frame.
Definition: nwk.c:1297
nwk_devType
Device types.
Definition: nwk.h:216
UInt8 nwk_registerNeighbor(UInt16 a)
Register neighbor.
Definition: nwk.c:1578
UInt16 nwk_getNeighborAddress(UInt8 i)
Get neighbor address.
Definition: nwk.c:1561
void nwk_startConfirm(UInt8 status)
Start network confirmation.
Definition: nwk.c:867