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#

void
sl_zigbee_event_init(sl_zigbee_event_t *event, void(*handler)(sl_zigbee_event_t *))

Application event initialization routine. Every application event must be initialized.

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.

void
sl_zigbee_event_set_active(sl_zigbee_event_t *event)

Schedule an event to run immediately.

void
sl_zigbee_event_set_inactive(sl_zigbee_event_t *event)

Cancel an event.

bool
sl_zigbee_event_is_scheduled(sl_zigbee_event_t *event)

Returns true if the event is scheduled to run, false otherwise.

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.

Typedefs#

typedef EmberEvent

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.

Parameters
[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.


Definition at line 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.

Parameters
[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.


Definition at line 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.

Parameters
[in]event

A pointer to the sl_zigbee_event_t object to be scheduled to run immediately.


Definition at line 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.

Parameters
[in]event

A pointer to the sl_zigbee_event_t object to be cancelled.


Definition at line 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.

Parameters
[in]event

A pointer to an sl_zigbee_event_t object.

Returns

  • true if the passed event is scheduled to run, false otherwise.


Definition at line 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.

Parameters
[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.


Definition at line 166 of file app/framework/common/zigbee_app_framework_event.h

Typedef Documentation#

sl_zigbee_event_t#

typedef EmberEvent sl_zigbee_event_t

ZigBee application event.


Definition at line 77 of file app/framework/common/zigbee_app_framework_event.h