The Zigbee Multi Sensor with FreeRTOS example demonstrates how to use Zigbee stack with FreeRTOS and create a multi-threaded application. It is based on single-threaded Zigbee Multi Sensor Example that incorporates the ZCL Temperature Measurement Cluster and ZCL Pressure Measurement Cluster, among others.
The application includes several FreeRTOS-specific tasks.
You can find the source code in the following folder: <InstallFolder>\examples\zigbee\experimental\multi_sensor_freertos
To test the FreeRTOS example, complete the steps described in the Testing section in Zigbee Multi Sensor Example.
The only difference is the BSP_LED_0 (LED1) blinking when the FreeRTOS scheduler is running, and when the scheduler is switching tasks. There is no difference in blinking pattern between these two cases.
The following tasks are running within the target application and are specific to the Zigbee Multi Sensor with FreeRTOS example. They are started automatically with the application.
1
in sdk_config.h
. In this case, the logs generated by NRF_LOG_INFO, NRF_LOG_ERROR, and other events are processed by this task and written to the log backend (UART in the default configuration). temperature_measurement_timer_handler
gets called from this task. As the API is not thread-safe, the update of the ZCL Temperature Measurement Cluster attribute (zb_zcl_set_attr_val) must happen either guarded by mutex or from zigbee_main_task
. Because using blocking functions from the FreeRTOS API in the FreeRTOS timer handler is not allowed, a scheduling callback to zigbee_main_task
(using ZB_SCHEDULE_CALLBACK) is used instead. The callback updates the cluster attribute from the zigbee_main_task
context, so no locking is required.vApplicationIdleHook
responsible for lowering the power usage is called from this task. It has the lowest priority. vApplicationIdleHook
.