Zigbee Application Framework Support for Nodes on Multiple Networks#

The Zigbee application framework provides additional network management functionality to help you easily build and deploy devices that operate on multiple networks. For more information on implementing multi-network functionality with the Zigbee application framework, see UG491: Zigbee Application Framework Developer's Guide for SDK 7.0 and Higher. The Zigbee application framework provides many advantages to the application developer in terms of reduced complexity, mostly relating to how it seamlessly manages the different network contexts when sending and receiving messages, before invoking callbacks, and before triggering event handlers for certain types of events.

The Zigbee application framework allows users to configure options such as the Zigbee device type and security for the individual networks on the Zigbee stack. When operating a device concurrently on two Zigbee networks in a host-NCP configuration, you must choose a similarly capable NCP that matches the host configuration. Multi-network library and multi-pan library components are provided to enable and implement the appropriate functionality on the Zigbee stack.

The EmberZNet PRO SDK comes with the following sample applications that demonstrate one potential configuration. You can use these as a reference to make a different application while being mindful of the limitations. Refer to Design Considerations for additional guidance.

  • Zigbee - Host MpZ3TcCustomTc: A host application that implements a node which is able to serve as a coordinator on two networks. The first network uses Zigbee 3.0 security and the second network uses no-security. You can use this host application in combination with either of the following NCP sample applications.

  • Zigbee - NCP MpNcpUartHw: A multi-PAN aware NCP application that communicates with the host over UART with hardware flow control.

  • Zigbee - NCP MpNcpSpi: A multi-PAN aware NCP application that communicates with the host over SPI.

Handling of Different Network Contexts#

  • Endpoint mapping: For Zigbee PRO networks, the Zigbee application framework maintains a mapping between network contexts and disjoint sets of endpoints. For example, network 0 may be associated with the set of endpoints {1,2,3} while network 1 is associated with the set {4,5,6}. Notice that these two sets of endpoints must be disjoint; that is, the same endpoint cannot be associated with two different network contexts. For each application framework API that is endpoint-related, the framework switches network context according to the endpoint mapping. For instance, when we send a unicast message using the application framework API emberAfSendUnicast(), the application framework looks into the source endpoint specified in the passed apsFrame struct and switches to the corresponding network context prior to passing the packet to the stack. The network context is then restored to the original one.

  • Callbacks and network-specific handlers: The Zigbee application framework ensures that the network context is always correctly set when an application framework callback or network context-sensitive event handlers are invoked. For example, when emberAfPreMessageReceivedCallback() is called, the current network context gets set to that of the receiving network. Note that framework sets the network context for callbacks with the emberAf prefix, but does not set the context for handlers called by the stack. For example, the network context will not be set automatically when the stack calls emberPollCompleteHandler(). However, the End Device Support plugin will set the appropriate context before calling emberAfPluginEndDeviceSupportPollCompletedCallback(). The following example provides sample code to query the network index in an application framework callback.

void emberAfPluginEndDeviceSupportPollCompletedCallback(EmberStatus status)
{
 //Get network index for end device support poll complete handler
 uint8_t nwkIndex = emberGetCallbackNetwork();

}

Multi-Network Application Framework APIs#

The application framework provides a set of APIs for dealing with network context. These APIs are used in the application framework code to perform network context switching as described above. Notice that in all the code provided by the application framework, net- work context switching is performed using the APIs in the following table.

API

Description

EmberStatus emberAfPushNetworkIndex(uint8_t index)

Sets the current network to that of the given index and adds it to the stack of networks maintained by the framework. Every call to this API must be paired with a subsequent call to emberAfPopNetworkIndex().

EmberStatus emberAfPushCallbackNetworkIndex(void)

Sets the current network to the callback network and adds it to the stack of networks maintained by the framework. Every call to this API must be paired with a subsequent call to emberAfPopNetworkIndex().

EmberStatus emberAfPushEndpointNetworkIndex(uint8_t endpoint)

Sets the current network to that of the given endpoint and adds it to the stack of networks maintained by the framework. Every call to this API must be paired with a subsequent call to emberAfPopNetworkIndex().

EmberStatus emberAfPopNetworkIndex(void)

Removes the topmost network from the stack of networks maintained by the framework and sets the current network to the new topmost network. Every call to this API must be paired with a prior call to emberAf- PushNetworkIndex(), emberAfPushCallbackNetworkIndex(), or emberAfPushEndPointNetworkIndex().

uint8_t emberAfPrimaryEndpointForNetworkIndex(uint8_t index)

Returns the primary endpoint of the given network in- dex or 0xFF if no endpoints belong to the network.

uint8_t emberAfPrimaryEndpointForCurrentNetworkIndex(void)

Returns the primary endpoint of the current network index or 0xFF if no endpoints belong to the current network.

uint8_t emberAfNetworkIndexFromEndpoint(uint8_t endpoint)

Returns the network index of a given endpoint or 0xFF if the endpoint does not exist.

uint8_t emberAfNetworkIndexFromEndpointIndex(uint8_t index)

Returns the network index of the endpoint corresponding to the passed index or 0xFF if no endpoint is currently stored at the passed index.