Events, Callbacks, Event Handlers and Execution Contexts

Events and Contexts

ZentriOS is an event driven system. See ZAP Operation.

There are several types of event, grouped according to the triggers for the event and the context in which the event executes. See Native API Event Types below.

In this documentation we distinguish between the terms callback and event handler, according to the execution context:

ZentriOS can respond to events with callbacks or event handlers that execute in a particular execution contexts. An Execution Context is a thread, except in the cases of the IRQ Execution Context and the RTOS Timer Context.

Execution contexts are listed below. These are covered in more detail in Execution Contexts.

Event handlers for TCP events are executed in the ZAP context.

Special Context Considerations

Some execution contexts have limited resources. To switch processing to another execution context, you can issue an event with an event handler that executes in another context. For example, you can issue an event with zn_event_issue.

Limited resource contexts include RTOS Timer, IRQ and System Event Thread.

System Event Context

Events executing in the System event thread MUST NOT block as no other events can execute until it completes.

Command Context

ZentriOS commands and custom commands execute in the Command thread context. Custom commands cannot call any of the zn_issue_command functions, as it would create a deadlock. The ZentriOS API explicitly prevents a deadlock: a call to zn_issue_command from within the Command thread fails automatically with a ZOS_NESTED_CMD result code. See zos_result_t.

Native API Event Types

In this section, events are listed according to type, with details of:


Issued Events

Timed Events

For more detail see Timed Events.

Event API

RTOS Timer

File System Events

Hardware IRQ Events

UART Events

HTTP/S Server Events

HTTP/S Server Stream Events

Network Events

Unregistering a Network Event

There is only one network event. To unregister it, pass a NULL to the register API:

zn_network_register_event_handler(WLAN, NULL)

Periodic Broadcast Events


System Functions, Miscellaneous

System Monitor Events

TCP Events

UDP Events

Button Events

Web Setup Events

WebSocket Events

Library Event Functions