14.2.3.6.2 Handling Network notifications

Each application must implement the ZDO_MgmtNwkUpdateNotf (ZDO_MgmtNwkUpdateNotf_t * nwkParams) function. The function is called by the stack when certain network events occur. The type of the event is observed with the nwkParams->status field. The application can choose to ignore or to process any of the events. Possible event types are given in the following list:

  • ZDO_NETWORK_STARTED_STATUS

    Received when the stack performs network start by itself, not initiated on the application level, e.g. when the node automatically rejoined to the network after it had lost connection to the parent.

  • ZDO_NETWORK_LOST_STATUS

    Indicates parent loss. After issuing this notification, the stack automatically attempts to rejoin the network. This status can be received only on end devices.

  • ZDO_NETWORK_LEFT_STATUS

    Is received either when the node loses its parent and fails to rejoin the network or when the node leaves the network by itself in response to a ZDP command.

  • ZDO_NWK_UPDATE_STATUS

    Indicates that one or more of network parameters have been changed. Parameters include PANID, channel mask, and node`s short address.

  • ZDO_CHILD_JOINED_STATUS

    Indicates that a new child has successfully joined to the current node. This status is not valid for end devices. The notification is raised when the current node, from its side, finishes all procedures as the parent of the new node: for example, if security is applied in the network, when the node sends a transport key command. This does not necessarily mean that the child device will successfully decrypt the transport key command and complete network join. This is only verified by the device announcement frame. The parent node can track its reception by subscribing to the BC_EVENT_DEVICE_ANNCE event.

  • ZDO_CHILD_REMOVED_STATUS

    Indicates that a child has left the network.

  • ZDO_STATIC_ADDRESS_CONFLICT_STATUS

    Indicates that a short address set statically has leaded to the address conflict. The event is raised on the node that discovered the conflict. The application is responsible for resolving the conflict, typically by choosing a different short address and updating its value on the node via a ZDP request.

  • ZDO_NO_KEY_PAIR_DESCRIPTOR_STATUS

    The status is valid only if a security mode with link keys is used. The event is raised on the trust center node and indicates that the link key for the device that attempts to join the network has not been found. The application can save the extended address of the potential child to extract the link key for it from an external source of information, so that the child can be authenticated when it makes the next attempt to join the network.

The definition of the ZDO_MgmtNwkUpdateNotf() function in the application code might look like the following:

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 use of the _LINK_SECURITY_ define. It marks code parts that will be included if the application is compiled with standard link security mode. If the code in the callback may consume more than 10ms, its execution should be deferred.