Applications demonstrating the Bluetooth peripheral functionality may be extended by adding Zigbee protocol support to them. In this way, dynamic multiprotocol functionality can be achieved.
For reference, see <InstallFolder>\examples\multiprotocol\experimental\ble_zigbee_dynamic_light_switch_nus
, which is a modified version of the ble_app_uart
example.
Add the following settings to sdk_config.h
in order to configure the Zigbee stack:
Modify these settings if they appear in sdk_config.h:
Add the following define to the compiler options:
nRF5 SDK for Zigbee provides precompiled libraries which must be added to the project.
The default set of libraries for an Zigbee router or coordinator device is:
For the Zigbee end device the following set of libraries should be used:
Additionally one of the following defines, indicating the device type should be added to the compiler options:
There is no need to add the additional define for Zigbee coordinator device.
Add the below snippet, replacing libzboss library with the selected variant, to the Makefile of a BLE application:
Add the below snippet to compile all platform-dependent source files, required by Zigbee stack. To do that, add the following lines inside of the SRC_FILES section:
In order to use the Zigbee API, you need to add headers include paths. To do that, add the following lines inside of the INC_FOLDERS section:
For reference, see the Makefile that already supports dynamic Zigbee/BLE: <InstallFolder>\examples\multiprotocol\experimental\ble_zigbee_dynamic_light_switch_nus\pca10056\s140\armgcc\Makefile
In order to add libraries under the IAR compiler, click Project -> Add Files. Then, choose the file type of Library/Object Files and navigate to \external\zboss\lib\iar
.
Select all needed libraries according to the section above.
Afterwards, add all platform-dependent source files, required by Zigbee stack. In order to add source files under the IAR compiler, click Project -> Add Files. Then, choose the file type of Source Files, navigate to \external\zboss\osif
and select the following files:
Afterwards add the Zigbee stack error parsing module, located under \external\zboss\zb_error
:
In order to use the Zigbee API, you need to add headers include paths. To do that, click Project -> Options and choose the C/C++ Compiler section. In the Preprocessor tab, navigate to the Additional include directory section. Add the path to the \external\zboss\osif
and the \external\zboss\include
folder, with all subdirectories inside it.
After the folder path is added, depending on your project location, the following records should be visible.
For reference, see the IAR project that already supports dynamic Zigbee/BLE: <InstallFolder>\examples\multiprotocol\experimental\ble_zigbee_dynamic_light_switch_nus\ble_zigbee_dynamic_light_switch_nus.eww
1) At the top of the main.c file, add all necessary includes, depending on the Zigbee use case.
2) After the section which contains defines and static variables, add the following lines:
3) Define all clusters and endpoints that should be present on your Zigbee device:
4) Add the function for initializing the Zigbee protocol. Note that it depends on your use case.
For reference on how to add the dimmable switch functionality (for example) see: <InstallFolder>\examples\multiprotocol\experimental\ble_zigbee_dynamic_light_switch_nus\main.c
5) Add the function for handling Zigbee events:
6) Call the zigbee_init
function inside of the application main function.
Important! This function must be called after the SoftDevice has been initialized.
7) Add the following snippet inside the main loop of your application:
For more information about defining and implementing Zigbee device see Application development user guide.
Timeslot API has been tested with a set of default parameters on the nRF52840 Development Kit. These parameters are preset when the is initialized.
However, in case your application needs to use a different set of parameters for the Timeslot API, the exposes the nrf_raal_softdevice_config()
function to change the default Timeslot API parameters.
One of the parameters is the crystal accuracy in PPM units, which by default is set to 25 PPM. The application may use the nrf_raal_softdevice_config()
function to change the PPM value of the currently used crystal.
Instructions on how to select other parameters for specific applications will be available in the subsequent releases of nRF5 SDK for Thread and Zigbee.
Note that Zigbee's hardware requirements must be met in transformed examples. Refer to the Zigbee hardware requirements page.