Event System#
Zigbee event system API.
See zigbee_app_framework_event.h for source code.
Following a brief usage example that demonstrate how to create an event, initialize it and use it. In this example, the event is initialized and set to pending, then it gets rescheduled every second.
// Declare event as global
sl_zigbee_event_t my_event;
void my_event_hendler(sl_zigbee_event_t *event)
{
// Event expired, do something
// Reschedule the event to expire again in 1 second
sl_zigbee_event_set_delay_ms(&my_event, 1000);
}
void app_init(void)
{
// Initialize event
sl_zigbee_event_init(&my_event, my_event_handler);
// Set the event to expire immediately (that is, in the next iteration of the main loop)
sl_zigbee_event_set_active(&my_event);
}
API#
Application event initialization routine. Every application event must be initialized.
Schedule an event to run after a delay expressed in milliseconds.
Schedule an event to run immediately.
Cancel an event.
Returns true if the event is scheduled to run, false otherwise.
Returns the number of milliseconds before the event runs, or -1 if the event is not scheduled to run.
Typedefs#
ZigBee application event.
API Documentation#
sl_zigbee_event_init#
void sl_zigbee_event_init (sl_zigbee_event_t * event, void(*)(sl_zigbee_event_t *) handler)
Application event initialization routine. Every application event must be initialized.
[in] | event | A pointer to the sl_zigbee_event_t object to be initalized. Event objects must be global. |
[in] | handler | Handler function that shall be called when the event runs. |
91
of file app/framework/common/zigbee_app_framework_event.h
sl_zigbee_event_set_delay_ms#
void sl_zigbee_event_set_delay_ms (sl_zigbee_event_t * event, uint32_t delay)
Schedule an event to run after a delay expressed in milliseconds.
[in] | event | A pointer to the sl_zigbee_event_t object to be scheduled to run after a delay. |
[in] | delay | The delay in milliseconds after which the event shall run. |
114
of file app/framework/common/zigbee_app_framework_event.h
sl_zigbee_event_set_active#
void sl_zigbee_event_set_active (sl_zigbee_event_t * event)
Schedule an event to run immediately.
[in] | event | A pointer to the sl_zigbee_event_t object to be scheduled to run immediately. |
126
of file app/framework/common/zigbee_app_framework_event.h
sl_zigbee_event_set_inactive#
void sl_zigbee_event_set_inactive (sl_zigbee_event_t * event)
Cancel an event.
[in] | event | A pointer to the sl_zigbee_event_t object to be cancelled. |
138
of file app/framework/common/zigbee_app_framework_event.h
sl_zigbee_event_is_scheduled#
bool sl_zigbee_event_is_scheduled (sl_zigbee_event_t * event)
Returns true if the event is scheduled to run, false otherwise.
[in] | event | A pointer to an sl_zigbee_event_t object. |
Returns
true if the passed event is scheduled to run, false otherwise.
151
of file app/framework/common/zigbee_app_framework_event.h
sl_zigbee_event_get_remaining_ms#
uint32_t sl_zigbee_event_get_remaining_ms (sl_zigbee_event_t * event)
Returns the number of milliseconds before the event runs, or -1 if the event is not scheduled to run.
[in] | event | A pointer to an sl_zigbee_event_t object. |
Returns
The number of milliseconds before the event runs, or -1 if the event is not scheduled to run.
166
of file app/framework/common/zigbee_app_framework_event.h