4.4.1 Task Management

The Zigbee stack task uses an internal priority-based proprietary scheduler to process requests from various Zigbee stack layers, which are organized as tasks. To manage task execution, the Zigbee stack may employ two functions:
  • SYS_RunTask() function – Must be called within the infinite loop of the Zigbee task to prompt the stack to process the next task
  • SYS_PostTask() function – Checks which components have posted tasks and executes them according to the priority of the layers
The priority of Zigbee layers increases from top to bottom, meaning the lower layers receive higher priority. The priority order from high to low is as follows:
  • MAC/PHY
  • Network
  • APS
  • ZDO and more

Executing a task involves calling the task handler function of the corresponding layer, such as ZDO_TaskHandler() or NWK_TaskHandler(). Each task handler function implements the state machine of the component, selecting the appropriate code to execute based on the current state.