Chapter 2. API Reference
esp_err_t esp_event_handler_register_with(esp_event_loop_handle_t event_loop,
esp_event_base_t event_base, int32_t event_id,
esp_event_handler_t event_handler, void
*event_handler_arg)
Register an event handler to a specific loop (legacy).
This function behaves in the same manner as esp_event_handler_register, except the additional specification
of the event loop to register the handler to.
Note This function is obsolete and will be deprecated soon, please use
esp_event_handler_instance_register_with() instead.
Note 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
Return
• 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
Parameters
• [in] event_loop: the event loop to register this handler function to, must not be NULL
• [in] event_base: the base id of the event to register the handler for
• [in] event_id: the id of the event to register the handler for
• [in] event_handler: the handler function which gets called when the event is dispatched
• [in] event_handler_arg: data, aside from event data, that is passed to the handler when it
is called
esp_err_t esp_event_handler_instance_register_with(esp_event_loop_handle_t
event_loop, esp_event_base_t
event_base, int32_t event_id,
esp_event_handler_t event_handler,
void *event_handler_arg,
esp_event_handler_instance_t
*instance)
Register an instance of event handler to a specific loop.
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
Besides the error, the function returns an instance object as output parameter to identify each registration. This
is necessary to remove (unregister) the registration before the event loop is deleted.
Registering multiple handlers to events, registering a single handler to multiple events as well as registering the
same handler to the same event multiple times is possible. Each registration yields a distinct instance object
which identifies it over the registration lifetime.
Note 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
Return
• 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 or instance is NULL
• Others: Fail
Parameters
• [in] event_loop: the event loop to register this handler function to, must not be NULL
• [in] event_base: the base id of the event to register the handler for
• [in] event_id: the id of the event to register the handler for
• [in] event_handler: the handler function which gets called when the event is dispatched
Espressif Systems 840
Submit Document Feedback
Release v4.4