|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Message-transfer host API for plugins: register MIME handlers, pull a received payload, and push a typed payload to a nearby badge. More...
#include "plugin_manager/host_api.h"#include "plugin_manager/Plugin.h"#include "plugin_manager/PluginManager.h"#include "cdc_msg/MessageTransfer.h"#include "esp_attr.h"#include "freertos/FreeRTOS.h"#include "freertos/semphr.h"#include <cstring>Go to the source code of this file.
Functions | |
| void * | plg_get_active_plugin (void) |
| int | host_msg_register_handler (const char *mime_type, uint32_t action_id) |
| Register that this plugin handles an incoming MIME type. | |
| int | host_msg_unregister_handler (const char *mime_type) |
| Drop a previously registered handler. | |
| int | host_msg_consume (uint8_t *buf, size_t buf_size, char *mime_out, size_t mime_size) |
| Pull the payload delivered by the most recent inbound message action. | |
| int | host_msg_send_interactive (const char *mime_type, const uint8_t *data, size_t len) |
| Send a typed payload via the firmware-owned interactive peer picker. | |
| int | host_msg_send (const uint8_t addr[6], uint8_t addr_type, const char *mime_type, const uint8_t *data, size_t len) |
| Send a typed payload directly to a known peer address (no picker). | |
| void | plg_msg_init (void) |
| void | plg_msg_pump (void) |
| void | plg_msg_on_unload (void *plugin) |
Message-transfer host API for plugins: register MIME handlers, pull a received payload, and push a typed payload to a nearby badge.
Threading mirrors the BLE consume idiom. The cdc_msg deliver callback runs on the main task; it only stashes the payload + sets a pending flag (never calls into WASM). plg_msg_pump() runs on the plugin tick task, moves the stash into a per-action slot and fires the plugin's action, which then pulls the bytes with host_msg_consume. The handler table and the per-action slot are only touched on the tick task, so only the pending stash needs a mutex (it crosses the main <-> tick boundary). Registration therefore never holds that mutex while calling into cdc_msg, avoiding a lock-ordering deadlock.
Definition in file host_api_msg.cpp.
| void * plg_get_active_plugin | ( | void | ) |
Definition at line 24 of file plugin_log_bridge.cpp.
Referenced by host_msg_register_handler(), and host_msg_unregister_handler().
| void plg_msg_init | ( | void | ) |
Definition at line 259 of file host_api_msg.cpp.
References cdc::plugin_manager::PluginManager::instance(), and cdc::plugin_manager::PluginManager::messageTypeInstalled().
Referenced by cdc::plugin_manager::PluginManager::init().
| void plg_msg_on_unload | ( | void * | plugin | ) |
Definition at line 293 of file host_api_msg.cpp.
| void plg_msg_pump | ( | void | ) |
Definition at line 268 of file host_api_msg.cpp.
References cdc::plugin_manager::PluginManager::dispatchActionTo(), and cdc::plugin_manager::PluginManager::instance().
Referenced by cdc::plugin_manager::PluginManager::dispatchTick().