This information applies to the following SoCs: nRF52833 and nRF52840.
Zigbee CLI wrapper (zb_cli_wrapper) is a Python package for the nRF5 SDK for Zigbee that includes a wrapper for automating communication with the Zigbee CLI Agent example and improving the control of the Zigbee network.
It is a standalone package and can be used on both Windows and Linux machines.
Usage
The wrapper allows you to:
- Communicate with multiple boards that run Zigbee CLI example, send Zigbee commands, and parse responses.
- Connect to the board specified by SEGGER number, serial number or the COM port the board is connected to.
Supported CLI commands
Zigbee CLI Wrapper automates the communication with Zigbee CLI Agent example by wrapping the following CLI commands to Python functions and by parsing command responses:
- Network and device management:
- Discovering devices
- Requesting device addresses and endpoints
- Binding devices
- Removing devices from network
- Zigbee device control over network:
- Reading attribute value and writing to attribute
- Sending ping command
- Sending ZCL command
- Zigbee CLI device control:
- Setting role and channels to operate
- Creating Zigbee network
- Subscribing to cluster attributes
- Collecting CLI responses and logs for individual parsing
- Setting number of child devices
- Radio channel control:
- Setting and getting radio channel
Installing the wrapper
The Zigbee CLI wrapper package is available for download from the Zigbee CLI wrapper PyPI repository.
MQTT Zigbee Gateway example
The wrapper package includes an example of how the Zigbee CLI co-processor design can be used for the implementation of a MQTT Zigbee Gateway.
The gateway is a Python application that translates the data stored in MQTT topics to Zigbee cluster-based data storage. This way, it enables access to the Zigbee network that uses the MQTT protocol.
Figure 1. Zigbee to MQTT gateway with the CLI wrapper.
To access or control the Zigbee network (or both), the application uses:
- the nRF52 SoC that is running the Zigbee CLI Agent example;
- the zb_cli_wrapper library to handle connection with the nRF52 device and wrap CLI commands;
- the paho_mqtt Python MQTT client library to handle the MQTT connection and communication.
- This is an external library that you need to install for the example to work properly.
The example source files can be found in the example
directory in the wrapper package, which also includes the readme.md
file with information about the installation procedure.