Register an event handler to the system event loop (legacy). This function can be used to register a handler for either: (1) specific events, (2) all events of a certain event base, or (3) all events known by the system event loop. - specific events: specify exact event_base and event_id - all events of a certain base: specify exact event_base and use ESP_EVENT_ANY_ID as the event_id - all events known by the loop: use ESP_EVENT_ANY_BASE for event_base and ESP_EVENT_ANY_ID as the event_id Registering multiple handlers to events is possible. Registering a single handler to multiple events is also possible. However, registering the same handler to the same event multiple times would cause the previous registrations to be overwritten.
the base ID of the event to register the handler for
event_id
the ID of the event to register the handler for
event_handler
the handler function which gets called when the event is dispatched
event_handler_arg
data, aside from event data, that is passed to the handler when it is called
Return value
- ESP_OK: Success - ESP_ERR_NO_MEM: Cannot allocate memory for the handler - ESP_ERR_INVALID_ARG: Invalid combination of event base and event ID - Others: Fail
Notes
the event loop library does not maintain a copy of event_handler_arg, therefore the user should ensure that event_handler_arg still points to a valid location by the time the handler gets called
Examples
esp_event_handler_register() is referenced by 36 libraries and example projects: