4.6.2 Handling Network Notifications
Each application must implement the ZDO_MgmtNwkUpdateNotf (ZDO_MgmtNwkUpdateNotf_t
* nwkParams
) function. The stack calls this function in response to specific network events. The event type can be determined by examining the nwkParams->status
field. The application can choose to ignore or to process any of the events. The following table provides details about the possible event types:Event Type | Description |
---|---|
ZDO_NETWORK_STARTED_STATUS | The application receives the ZDO_NETWORK_STARTED_STATUS when the network stack independently initiates a network start not triggered by the application. For example, when a node rejoins the network automatically after losing connection to the parent. |
ZDO_NETWORK_LOST_STATUS | Signals parent loss. After issuing this notification, the stack, then, automatically attempts network rejoining. Only end devices receive this status. |
ZDO_NETWORK_LEFT_STATUS | Occurs when a node either fails to rejoin the network after losing its parent or leaves the network voluntarily in response to a ZDP command. |
ZDO_NWK_UPDATE_STATUS | Signals changes to one or more network parameters, such as PANID, channel mask or the node’s short address. |
ZDO_CHILD_JOINED_STATUS | Indicates that a new child successfully joined the current node. This status is not valid for end devices. The notification is raised when the current node finishes all procedures as the parent of the new node. For example, this can occur if security is applied in the network and the node sends a transport key command. However, this does not necessarily mean that the child device is going to successfully decrypt the transport key command and complete joining the network. Only the device announcement frame can verify the successful joining of the child device to the network. The parent node can track its reception by subscribing to the BC_EVENT_DEVICE_ANNCE event. |
ZDO_CHILD_REMOVED_STATUS | Signals that a child has exited the network. |
ZDO_STATIC_ADDRESS_CONFLICT_STATUS | Occurs when a statically set short address causes an address conflict. The node that detects the conflict raises the event. The application must resolve the conflict by selecting a different short address and updating the node’s value via a ZDP request. |
ZDO_NO_KEY_PAIR_DESCRIPTOR_STATUS | Applies only when the network uses a Security mode with link keys. The event arises on the trust center node and indicates the absence of a link key for the device attempting network joining. The application can store the extended address of the potential child to retrieve the link key from an external information source. This enables the authentication of the child device on its next attempt to join the network. |
The definition of the
ZDO_MgmtNwkUpdateNotf()
function in the application code:void ZDO_MgmtNwkUpdateNotf(ZDO_MgmtNwkUpdateNotf_t *nwkParams) { switch (nwkParams->status) { case ZDO_NETWORK_STARTED_STATUS: //More code goes here, e.g. the application may save new //network parameters ... break; case ZDO_NO_KEY_PAIR_DESCRIPTOR_STATUS: #ifdef _LINK_SECURITY_ //The event can occur in high security mode on the trust center only //Extract the extended address of the device attempting to join the network extAddr_t addr = nwkParams->childInfo.extAddr; uint8_t linkKey[16] = ...; //Find out the link key value and store in this variable APS_SetLinkKey(&addr, linkKey); //Set the link key for the given extended address #endif break; default: break; } }
Note: The
_LINK_SECURITY_
definition marks code sections for inclusion when compiling the application in standard link Security mode. If the code in the callback takes more than 10 ms to execute, it defers its execution.