From 2fb619ed6eac19afd7ed3b2c7baa4adc253f418e Mon Sep 17 00:00:00 2001 From: turret Date: Sat, 30 Mar 2024 20:35:30 -0500 Subject: net: event handler in subsys.h: include init.h to ensure l5_initcall availability also: add example/ directory to provide some user-code in the skeleton (will likely be made defunct as i make the remainder of the skeleton, such as a /ping command and user action and maybe some buttons, which will require more organisation) --- include/dbs/event.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 include/dbs/event.h (limited to 'include/dbs/event.h') diff --git a/include/dbs/event.h b/include/dbs/event.h new file mode 100644 index 0000000..6be3378 --- /dev/null +++ b/include/dbs/event.h @@ -0,0 +1,20 @@ +#ifndef __EVENT_H +#define __EVENT_H + +#include + +enum Event { +#define E(ev_name, _) ev_name, +#include +#undef E +}; + +int ev_set_handler(enum Event event, int (*ev_handler)(cJSON*)); + +#define declare_event(event, handler) \ + void __decl_##event_##handler() { \ + ev_set_handler(event, handler); \ + } \ + l3_initcall(__decl_##event_##handler) + +#endif -- cgit v1.2.3