Espressif ESP32-S2 Programming Manual page 852

Table of Contents

Advertisement

Chapter 2. API Reference
• [in] event_handler_arg: data, aside from event data, that is passed to the handler when it
is called
• [out] instance: An event handler instance object related to the registered event handler and
data, can be NULL. This needs to be kept if the specific callback instance should be unregistered
before deleting the whole event loop. Registering the same event handler multiple times is possible
and yields distinct instance objects. The data can be the same for all registrations. If no unregistration
is needed but the handler should be deleted when the event loop is deleted, instance can be NULL.
esp_err_t esp_event_handler_instance_register(esp_event_base_t
Register an instance of event handler to the default loop.
This function does the same as esp_event_handler_instance_register_with, except that it registers the handler
to the default event loop.
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_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
• [out] instance: An event handler instance object related to the registered event handler and
data, can be NULL. This needs to be kept if the specific callback instance should be unregistered
before deleting the whole event loop. Registering the same event handler multiple times is possible
and yields distinct instance objects. The data can be the same for all registrations. If no unregistration
is needed but the handler should be deleted when the event loop is deleted, instance can be NULL.
esp_err_t esp_event_handler_unregister(esp_event_base_t
Unregister a handler with the system event loop (legacy).
Unregisters a handler so it will no longer be called during dispatch. Handlers can be unregistered for any com-
bination of event_base and event_id which were previously registered. To unregister a handler, the event_base
and event_id arguments must match exactly the arguments passed to esp_event_handler_register() when that
handler was registered. Passing ESP_EVENT_ANY_BASE and/or ESP_EVENT_ANY_ID will only unreg-
ister handlers that were registered with the same wildcard arguments.
Note This
function
esp_event_handler_instance_unregister() instead.
Note When using ESP_EVENT_ANY_ID, handlers registered to specific event IDs using the same base will
not be unregistered. When using ESP_EVENT_ANY_BASE, events registered to specific bases will
also not be unregistered. This avoids accidental unregistration of handlers registered by other users or
components.
Return ESP_OK success
Return ESP_ERR_INVALID_ARG invalid combination of event base and event id
Return others fail
Parameters
• [in] event_base: the base of the event with which to unregister the handler
• [in] event_id: the id of the event with which to unregister the handler
• [in] event_handler: the handler to unregister
Espressif Systems
esp_event_handler_t
is
obsolete
and
841
Submit Document Feedback
event_base,
event_id,
event_handler, void *event_handler_arg,
esp_event_handler_instance_t
event_base,
event_handler)
will
be
deprecated
int32_t
esp_event_handler_t
*instance)
int32_t
event_id,
soon,
please
use
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Questions and answers

Table of Contents

Save PDF