113 #define NWK_NEIGHBORHEARTBEATTIMEOUT 9
115 #define NWK_START_TIMEOUT 10
117 #define NWK_FLAGIDX_SINK 0x01
118 #define NWK_FLAGIDX_NSINK 0xFE
119 #define NWK_FLAGIDX_BOUND 0x02
120 #define NWK_FLAGIDX_NBOUND 0xFD
121 #define NWK_FLAGIDX_SENDFAIL 0x04
122 #define NWK_FLAGIDX_NSENDFAIL 0xFB
123 #define NWK_FLAGIDX_FAILJOIN 0x08
124 #define NWK_FLAGIDX_NFAILJOIN 0xF7
138 NWK_S_CONFIGSTARTWAIT,
145 NWK_S_POSTSTARTCONFIGURE,
295 nwk_neighbors[portIndex].foreignAddress = 0xFFFF;
296 nwk_neighbors[portIndex].foreignPort = 0;
297 nwk_neighbors[portIndex].timeOut = 0;
316 nwk_flags &= NWK_FLAGIDX_NBOUND & NWK_FLAGIDX_NSINK;
318 case NWK_S_SUSPENDED:
320 case NWK_S_CONFIGSTART:
327 case NWK_S_CONFIGSTARTWAIT:
330 case NWK_S_SETDEVICETYPE:
332 nwk_flags &= NWK_FLAGIDX_NBOUND;
339 case NWK_S_RESETWAIT:
342 case NWK_S_CONFIGURE:
360 nwk_flags &= NWK_FLAGIDX_NBOUND;
370 case NWK_S_STARTWAIT:
374 nwk_flags ^= NWK_FLAGIDX_FAILJOIN;
375 if (nwk_flags & NWK_FLAGIDX_FAILJOIN) {
386 case NWK_S_POSTSTARTCONFIGURE:
400 case NWK_S_CHECKFORBIND:
402 if (nwk_flags & NWK_FLAGIDX_SINK)
418 if (!(nwk_flags & (NWK_FLAGIDX_SINK | NWK_FLAGIDX_BOUND)))
429 if (nwk_neighbors[portIndex].foreignAddress != 0xFFFF)
430 if (nwk_neighbors[portIndex].timeOut)
431 nwk_neighbors[portIndex].timeOut--;
433 nwk_neighbors[portIndex].foreignAddress = 0xFFFF;
434 nwk_neighbors[portIndex].foreignPort = 0;
476 case NWK_S_CONFIGSTARTWAIT:
477 case NWK_S_RESETWAIT:
480 case NWK_S_SUSPENDED:
489 case NWK_S_POSTSTARTCONFIGURE:
494 case NWK_S_STARTWAIT:
577 case NWK_S_CONFIGSTART:
594 case NWK_S_SETDEVICETYPE:
624 case NWK_S_CONFIGURE:
710 case NWK_S_POSTSTARTCONFIGURE:
763 case NWK_S_CONFIGSTART:
770 case NWK_S_SETDEVICETYPE:
777 case NWK_S_CONFIGURE:
784 case NWK_S_POSTSTARTCONFIGURE:
956 nwk_flags |= NWK_FLAGIDX_BOUND;
958 nwk_flags &= NWK_FLAGIDX_NBOUND;
1168 return nwk_flags & NWK_FLAGIDX_SINK;
1180 return nwk_flags & NWK_FLAGIDX_BOUND;
1198 nwk_flags |= NWK_FLAGIDX_SINK;
1201 nwk_flags &= NWK_FLAGIDX_NSINK;
1406 nwk_flags &= NWK_FLAGIDX_NBOUND;
1408 if (nwk_flags & NWK_FLAGIDX_SENDFAIL) {
1409 nwk_flags &= NWK_FLAGIDX_NSENDFAIL & NWK_FLAGIDX_NBOUND;
1411 nwk_flags |= NWK_FLAGIDX_SENDFAIL;
1414 if (nwk_flags & NWK_FLAGIDX_BOUND) {
1415 nwk_flags &= NWK_FLAGIDX_NSENDFAIL;
1436 src = pBuf[3] | (pBuf[4] << 8);
1437 cmd = pBuf[5] | (pBuf[6] << 8);
1438 len = pBuf[7] | (pBuf[8] << 8);
1445 nwk_neighbors[portNumber - 1u].timeOut =
1455 if (
nwk_address == (pBuf[i] | (pBuf[i + 1u] << 8))) {
1456 nwk_neighbors[portNumber - 1u].foreignPort = pBuf[i + 2u];
1493 if (nwk_neighbors[portIndex].foreignAddress != 0xFFFF) {
1502 if (nwk_neighbors[portIndex].foreignAddress != 0xFFFF) {
1528 if (nwk_neighbors[portIndex].foreignAddress == a) {
1529 return portIndex + 1;
1549 return nwk_neighbors[portNumber].foreignPort;
1565 return nwk_neighbors[portNumber].foreignAddress;
1584 if (nwk_neighbors[portIndex].foreignAddress == 0xFFFF) {
1585 nwk_neighbors[portIndex].foreignAddress = a;
1586 nwk_neighbors[portIndex].foreignPort = 0;
1588 return portIndex + 1;
UInt8 nwk_isSink()
Is sink.
Network functions interface.
uint64_t * nwk_getPIeeeAddress()
Get pointer to the IEEE address.
void nwk_allow_bindConfirm(char *pBuf)
Allow bind confirmation.
UInt8 ccai_s_zb_start_request()
Start request.
UInt8 nwk_dataHandle
Handle used to identify one packet.
UInt8 nwk_sndInt64(int64_t *p)
Send signed 64 bits integer.
#define CCAI_CFGD_BIT_STARTOPT_AUTO_START
This is undocumented. This bit is present on ZASA cc2480.h file, but reserved on the description of s...
#define CCAI_CFGD_ZCD_NV_STARTUP_OPTION
Device startup options.
#define CCAI_CFGD_LOGICAL_TYPE_ROUTER
Set device type as a router.
#define CCAI_INFO_ZBPANID
Request PAN id of the ZigBee network.
UInt8 nwk_register()
Register application request.
UInt16 nwk_address
Short address of the device.
UInt8 nwk_start()
Start network request.
UInt8 nwk_sndUInt64(uint64_t *p)
Send unsigned 64 bits integer.
UInt8 nwk_sendHeartBeat()
Send heart beat.
UInt8 nwk_setPermitJoin(UInt8 timeout)
Permit join request.
void nwk_allow_bindRsp()
Allow bind response.
UInt8 nwk_getNeighborForeignPort(UInt8 portNumber)
Get neighbor foreign port.
None, invalid in a network.
#define CCAI_INFO_PARENTSHORTADDRESS
Request short address of the parent device.
void nwk_registerRsp(UInt8 status)
Register application response.
UInt8 nwk_wakeUp()
Network wake up.
void nwk_suspend()
network suspend
void nwk_setPermitJoinRsp()
Permit join response.
void nwk_configureWriteRsp(UInt8 status)
Response to a configuration write.
#define CCAI_CFGN_ZCD_NV_PRECFGKEY
Used to secure and un-secure packets when security is enabled.
#define CCAI_CFGD_LOGICAL_TYPE_COORDINATOR
Set device type as a coordinator.
UInt8 nwk_sndUInt48(uint64_t *p)
Send unsigned 48 bits integer.
void nwk_setSink(UInt8 sink)
Set sink.
#define CCAI_CFGD_BIT_STARTOPT_CLEAR_STATE
Clear network state.
UInt8 ccai_s_zb_bind_device(UInt8 create, UInt16 commandId, uint64_t destination)
Bind device request.
#define NWK_CFG_APPPROFILEID
Profile id of application.
UInt8 ccai_s_zb_send_data_request_payload(UInt8 len, void *pBuf)
Append data to the payload of send data request.
UInt8 nwk_isClient()
Is client.
void nwk_bind_deviceRsp()
Bind device response.
#define CCAI_CFGN_ZCD_NV_PRECFGKEYS_ENABLE
Configure if key is pre-configured (1) or sent when device joins (0).
#define CCAI_CFGN_ZCD_NV_SECURITY_MODE
Turn security on or off.
#define NWK_NEIGHBORHEARTBEATTIMEOUT
Timeout after a neighbor is considered disconnected.
#define CCAI_CFGN_ZCD_NV_CHANLIST
List of channels to operate on, each bit is a channel.
#define CCAI_CFGN_ZCD_NV_BCAST_RETRIES
Maximum retransmissions when sending a broadcast packet.
#define NWK_CFG_OUTPUTCMDLIST
Output command list.
UInt16 nwk_getShortAddress()
Get shotr address.
#define CCAI_INFO_ZBCHANNEL
Request operation channel of the ZigBee network.
nwk_neighbor nwk_neighbors[NWK_NEIGHBORMAX]
Neighbors information.
UInt8 ccai_s_zb_allow_bind(UInt8 timeout)
Allow bind request.
UInt8 nwk_sndUInt32(UInt32 *p)
Send unsigned 32 bits integer.
UInt8 nwk_isBound()
Is bound.
void ccai_resetFull()
Full reset.
UInt8 nwk_lastParamSuccess
Last successful parameter.
#define NWK_CMDIDHEARTBEAT
Command id for child heartbeat.
UInt8 ccai_s_zb_get_device_info(UInt8 param)
Get device information request.
nwk_state nwk_currentState
Current state of the LEDs control.
#define NWK_CFG_INPUTCMDCOUNT
Number of input commands.
UInt8 nwk_sndUInt16(UInt16 v)
Send unsigned 16 bits integer.
#define CCAI_STA_ZAPSNOBOUNDDEVICE
ZApsNoBoundDevice.
#define NWK_CFG_DEVICEID
Application specific.
void nwk_startRsp()
Start network response.
#define CCAI_CFGN_ZCD_NV_PANID
Identifies the ZigBee network.
UInt8 nwk_freezeDetect
Counter used to detect freezes.
void nwk_setDeviceType(nwk_devType newType)
Set device type.
UInt8 nwk_sndUInt8(UInt8 v)
Send unsigned 8 bits integer.
UInt8 nwk_disallowJoin()
Disallow join.
UInt8 nwk_getDeviceInfo()
Get device information request.
UInt8 ccai_s_zb_send_data_request_begin(UInt16 destination, UInt16 commandId, UInt8 handle, UInt8 ack, UInt8 radius, UInt8 len)
Begin request to send data.
#define NWK_CFG_OUTPUTCMDCOUNT
Number of output commands.
#define CCAI_STA_ZFAILURE
ZFailure.
void nwk_init()
Network initialization.
void nwk_resetResume()
Resume from CC2480 reset.
UInt8 uart_forwardCmd(char *pBuf)
Forward command.
#define NWK_CFG_ROUTE_EXPIRY_TIME
swra175a.pdf - 6.2.4.9 ZCD_NV_ROUTE_EXPIRY_TIME
void ccai_resetLight()
Reset.
#define NWK_CMDIDRPT
Command id for report.
uint64_t nwk_ieeeAddress
Short address of the device.
#define CCAI_CFGN_ZCD_NV_ROUTE_EXPIRY_TIME
Time (s) after an idle route is marked as expired.
#define NWK_CFG_PASSIVE_ACK_TIMEOUT
swra175a.pdf - 6.2.4.7 ZCD_NV_PASSIVE_ACK_TIMEOUT
#define NWK_NEIGHBORMAX
Max number of expected direct neighbors.
void led_redConfigure(UInt8 n, UInt16 offDelay)
Configures red led.
UInt16 nwk_process()
Network process.
#define NWK_CFG_BCAST_RETRIES
swra175a.pdf - 6.2.4.6 ZCD_NV_BCAST_RETRIES
#define NWK_CFG_BCAST_DELIVERY_TIME
swra175a.pdf - 6.2.4.8 ZCD_NV_BCAST_DELIVERY_TIME
nwk_devType nwk_currentDevType
Current device type.
#define CCAI_CFGN_ZCD_NV_BCAST_DELIVERY_TIME
Maximum time (units of 100ms) to a broadcast packet propagate through the entire network.
#define NWK_CFG_CHANLIST
swra175a.pdf - 6.2.4.2 ZCD_NV_CHANLIST
#define CCAI_CFGD_LOGICAL_TYPE_ENDDEVICE
Set device type as an end-device.
nwk_devType nwk_getDeviceType()
This function gets the device type.
#define CCAI_STA_ZSUCCESS
ZSuccess.
void nwk_rcv(char *pBuf)
Network receive.
#define CCAI_INFO_STATE
Request state of the device.
void nwk_send_dataConfirm(UInt8 dataHandle, UInt8 status)
Send data confirmation.
UInt8 ccai_s_zb_app_register_request(UInt8 appEndPoint, UInt16 appProfileId, UInt16 DeviceId, UInt8 DeviceVersion, UInt8 inputCommandsNum, char *InputCommandsList, UInt8 OutputCommandsNum, char *OutputCommandsList)
Application register request.
#define NWK_CFG_PANID
swra175a.pdf - 6.2.4.1 ZCD_NV_PANID
UInt8 nwk_allowJoin()
Allow join.
void nwk_getDeviceInfoRsp(UInt8 param, void *pValue)
Get device information response.
uint64_t nwk_getIeeeAddress()
Get IEEE address.
UInt8 nwk_bind_device(UInt8 create, UInt16 commandId, uint64_t destination)
Bind device request.
#define NWK_CFG_DEVICEVERSION
Application specific.
UInt8 nwk_startFrame(UInt16 destination, UInt16 cmdId, UInt8 radius, UInt8 len)
Start Frame.
#define CCAI_INFO_IEEEADDRESS
Request IEEE address of the device.
#define NWK_DEFACK
Default ACK request. On transmitted packets, 1 to request ACK, 0 to don't.
#define NWK_CFG_APPENDPOINT
The endpoint of the device.
UInt8 nwk_runCounter
Children information.
UInt8 nwk_snd(UInt8 len, void *pBuf)
Send data.
#define NWK_DEVTYPE_DEFALUT
The default device type on network initialization.
nwk_state
States for the network.
UInt8 nwk_configureWrite()
Write configuration.
nwk_state nwk_returnState
State on suspend.
#define CCAI_INFO_PARENTIEEEADDRESS
Request IEEE address of the parent device.
#define NWK_CFG_PRECFGKEY
swra175a.pdf - 6.2.4.3 ZCD_NV_PRECFGKEY
void nwk_bind_deviceConfirm(char *pBuf)
Bind device confirmation.
#define CCAI_CFGD_BIT_STARTOPT_CLEAR_CONFIG
Overwrite all configuration parameters except this one.
UInt8 nwk_lastParam
Last parameter.
#define NWK_CFG_PRECFGKEYS_ENABLE
swra175a.pdf - 6.2.4.4 ZCD_NV_PRECFGKEYS_ENABLE
UInt8 ccai_s_zb_write_configuration(UInt8 configId, UInt8 len, void *pBuf)
Write configuration request.
#define NWK_CFG_INPUTCMDLIST
Input command list.
UInt8 nwk_allow_bind(UInt8 timeout)
Allow bind request.
#define CCAI_INFO_ZBEXTENDEDPANID
Request Extended PAN id of the ZigBee network.
UInt8 nwk_getNeighborPort(UInt16 a)
Get neighbor port.
void nwk_endFrame(UInt8 forwardToSerial)
End frame.
UInt8 nwk_registerNeighbor(UInt16 a)
Register neighbor.
UInt16 nwk_getNeighborAddress(UInt8 portNumber)
Get neighbor address.
UInt8 ccai_s_zb_permit_joining_request(UInt16 destination, UInt8 timeOut)
Permit join change request.
#define CCAI_CFGN_ZCD_NV_PASSIVE_ACK_TIMEOUT
Time (units of 100ms) to wait before retransmitting a broadcast packet.
#define CCAI_INFO_SHORTADDRESS
Request shor address of the device.
#define CCAI_CFGD_ZCD_NV_LOGICAL_TYPE
Logical type of the device in the ZigBee network.
void nwk_startConfirm(UInt8 status)
Start network confirmation.
#define NWK_CFG_SECURITY_MODE
swra175a.pdf - 6.2.4.5 ZCD_NV_SECURITY_MODE
void ccai_s_zb_send_data_request_end(UInt8 forwardToSerial)
Terminate the request to send data and send it to CC2480.