VSF Documented
esp_event_base.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2026 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18/*
19 * Clean-room re-implementation of ESP-IDF public API "esp_event_base.h".
20 *
21 * Authored from ESP-IDF v5.x public API only. No code copied from the
22 * ESP-IDF source tree.
23 */
24
25#ifndef __VSF_ESPIDF_ESP_EVENT_BASE_H__
26#define __VSF_ESPIDF_ESP_EVENT_BASE_H__
27
28#include <stdint.h>
29#include <stddef.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/*============================ TYPES =========================================*/
36
37/* An event base is a string-pointer tag that groups related event ids. The
38 * ESP-IDF contract is that all users of a base reference the SAME global
39 * variable, so that pointer equality identifies the base. This port also
40 * falls back to strcmp when pointers differ, for defensive matching. */
41typedef const char * esp_event_base_t;
42
43/* Opaque loop handle (default loop is accessed via the _default APIs). */
45
46/* Opaque handler-instance handle returned by the *_instance_register APIs. */
48
49/* Handler entry point. event_data/event_data_size come from esp_event_post.
50 * The buffer pointed to by event_data is only valid for the duration of the
51 * handler call (the dispatcher owns the storage). */
52typedef void (*esp_event_handler_t)(void *event_handler_arg,
53 esp_event_base_t event_base,
54 int32_t event_id,
55 void *event_data);
56
57/*============================ MACROS ========================================*/
58
59/* Wildcards accepted by register/unregister/post. */
60#define ESP_EVENT_ANY_BASE ((esp_event_base_t)NULL)
61#define ESP_EVENT_ANY_ID (-1)
62
63/* Declare a base symbol in a header; define it exactly once in one .c file
64 * with ESP_EVENT_DEFINE_BASE. Matching relies on a unique symbol address. */
65#define ESP_EVENT_DECLARE_BASE(id) extern esp_event_base_t id
66#define ESP_EVENT_DEFINE_BASE(id) esp_event_base_t id = #id
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif // __VSF_ESPIDF_ESP_EVENT_BASE_H__
void * esp_event_loop_handle_t
Definition esp_event_base.h:44
void(* esp_event_handler_t)(void *event_handler_arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
Definition esp_event_base.h:52
const char * esp_event_base_t
Definition esp_event_base.h:41
void * esp_event_handler_instance_t
Definition esp_event_base.h:47
int int32_t
Definition stdint.h:8
Generated from commit: vsfteam/vsf@015f4d1