114 #define NWK_NEIGHBORHEARTBEATTIMEOUT 9
116 #define NWK_START_TIMEOUT 10
118 #define NWK_FLAGIDX_SINK 0x01
119 #define NWK_FLAGIDX_NSINK 0xFE
120 #define NWK_FLAGIDX_BOUND 0x02
121 #define NWK_FLAGIDX_NBOUND 0xFD
122 #define NWK_FLAGIDX_SENDFAIL 0x04
123 #define NWK_FLAGIDX_NSENDFAIL 0xFB
124 #define NWK_FLAGIDX_FAILJOIN 0x08
125 #define NWK_FLAGIDX_NFAILJOIN 0xF7
139 NWK_S_CONFIGSTARTWAIT,
146 NWK_S_POSTSTARTCONFIGURE,
296 nwk_neighbors[portIndex].foreignAddress = 0xFFFF;
297 nwk_neighbors[portIndex].foreignPort = 0;
298 nwk_neighbors[portIndex].timeOut = 0;
317 nwk_flags &= NWK_FLAGIDX_NBOUND & NWK_FLAGIDX_NSINK;
319 case NWK_S_SUSPENDED:
321 case NWK_S_CONFIGSTART:
328 case NWK_S_CONFIGSTARTWAIT:
331 case NWK_S_SETDEVICETYPE:
333 nwk_flags &= NWK_FLAGIDX_NBOUND;
340 case NWK_S_RESETWAIT:
343 case NWK_S_CONFIGURE:
361 nwk_flags &= NWK_FLAGIDX_NBOUND;
371 case NWK_S_STARTWAIT:
375 nwk_flags ^= NWK_FLAGIDX_FAILJOIN;
376 if (nwk_flags & NWK_FLAGIDX_FAILJOIN) {
387 case NWK_S_POSTSTARTCONFIGURE:
401 case NWK_S_CHECKFORBIND:
403 if (nwk_flags & NWK_FLAGIDX_SINK)
419 if (!(nwk_flags & (NWK_FLAGIDX_SINK | NWK_FLAGIDX_BOUND)))
430 if (nwk_neighbors[portIndex].foreignAddress != 0xFFFF)
431 if (nwk_neighbors[portIndex].timeOut)
432 nwk_neighbors[portIndex].timeOut--;
434 nwk_neighbors[portIndex].foreignAddress = 0xFFFF;
435 nwk_neighbors[portIndex].foreignPort = 0;
477 case NWK_S_CONFIGSTARTWAIT:
478 case NWK_S_RESETWAIT:
481 case NWK_S_SUSPENDED:
490 case NWK_S_POSTSTARTCONFIGURE:
495 case NWK_S_STARTWAIT:
578 case NWK_S_CONFIGSTART:
595 case NWK_S_SETDEVICETYPE:
625 case NWK_S_CONFIGURE:
711 case NWK_S_POSTSTARTCONFIGURE:
764 case NWK_S_CONFIGSTART:
771 case NWK_S_SETDEVICETYPE:
778 case NWK_S_CONFIGURE:
785 case NWK_S_POSTSTARTCONFIGURE:
957 nwk_flags |= NWK_FLAGIDX_BOUND;
959 nwk_flags &= NWK_FLAGIDX_NBOUND;
1171 return nwk_flags & NWK_FLAGIDX_SINK;
1183 return nwk_flags & NWK_FLAGIDX_BOUND;
1201 nwk_flags |= NWK_FLAGIDX_SINK;
1204 nwk_flags &= NWK_FLAGIDX_NSINK;
1409 nwk_flags &= NWK_FLAGIDX_NBOUND;
1411 if (nwk_flags & NWK_FLAGIDX_SENDFAIL) {
1412 nwk_flags &= NWK_FLAGIDX_NSENDFAIL & NWK_FLAGIDX_NBOUND;
1414 nwk_flags |= NWK_FLAGIDX_SENDFAIL;
1417 if (nwk_flags & NWK_FLAGIDX_BOUND) {
1418 nwk_flags &= NWK_FLAGIDX_NSENDFAIL;
1439 src = pBuf[3] | (pBuf[4] << 8);
1440 cmd = pBuf[5] | (pBuf[6] << 8);
1441 len = pBuf[7] | (pBuf[8] << 8);
1448 nwk_neighbors[portNumber - 1u].timeOut =
1458 if (
nwk_address == (pBuf[i] | (pBuf[i + 1u] << 8))) {
1459 nwk_neighbors[portNumber - 1u].foreignPort = pBuf[i + 2u];
1486 || ((pBuf[9 + 28] | (pBuf[9 + 29] << 8)) == 0xFFFF))) {
1510 if (nwk_neighbors[portIndex].foreignAddress != 0xFFFF) {
1519 if (nwk_neighbors[portIndex].foreignAddress != 0xFFFF) {
1545 if (nwk_neighbors[portIndex].foreignAddress == a) {
1546 return portIndex + 1;
1566 return nwk_neighbors[portNumber].foreignPort;
1582 return nwk_neighbors[portNumber].foreignAddress;
1601 if (nwk_neighbors[portIndex].foreignAddress == 0xFFFF) {
1602 nwk_neighbors[portIndex].foreignAddress = a;
1603 nwk_neighbors[portIndex].foreignPort = 0;
1605 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.
void ptp_initEnd()
PTP initialization completion.
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 NWK_CMDIDPTP
Command id for PTP messages.
#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 ptp_rcvmessage(ptp_octet *pBuf, ptp_uinteger8 portNumber, ptp_uinteger16 size)
Receive message.
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.