diff --git a/node/code/inc/EVENTS.hpp b/node/code/inc/EVENTS.hpp index 771b531b..d2dff6a1 100644 --- a/node/code/inc/EVENTS.hpp +++ b/node/code/inc/EVENTS.hpp @@ -2,7 +2,7 @@ #include -enum EVENTS: uint16_t { +extern "C" enum EVENTS: uint16_t { TERMINATE, WILDCARD, // Subscribe to all events [Special case] PING, diff --git a/node/code/inc/dispatch_handler.hpp b/node/code/inc/dispatch_handler.hpp index 33aa3385..4c7ad915 100644 --- a/node/code/inc/dispatch_handler.hpp +++ b/node/code/inc/dispatch_handler.hpp @@ -46,7 +46,7 @@ class DispatchHandler { * @brief Send an event to the dispatcher. * @param event The event to send. */ - static void sendEvent(msg_t *event) { + void sendEvent(msg_t *event) { if (DISPATCHER_PID == -1) { cout << "Dispatcher PID not set yet!" << endl; return; diff --git a/node/code/inc/dispatch_sender.hpp b/node/code/inc/dispatch_sender.hpp new file mode 100644 index 00000000..b1e02876 --- /dev/null +++ b/node/code/inc/dispatch_sender.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "shell_commands.hpp" +#include "msg.h" + +/** + * @brief Send an event to the dispatcher (with C support) + * @param event The event to send. + */ +extern "C" void sendEvent(msg_t *event) { + if (DISPATCHER_THREAD_ID == -1) { + cout << "Dispatcher PID not set yet!" << endl; + return; + } + + msg_try_send(event, DISPATCHER_PID); +}