|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Subscribe to system events and publish module events. More...
Macros | |
| #define | EVENT_KEY_PRESSED (1u << 0) |
| #define | EVENT_KEY_RELEASED (1u << 1) |
| #define | EVENT_KEY_LONG_PRESS (1u << 2) |
| #define | EVENT_POWER_USB_CONN (1u << 3) |
| #define | EVENT_POWER_USB_DISCONN (1u << 4) |
| #define | EVENT_POWER_CHARGING (1u << 5) |
| #define | EVENT_POWER_BATT_LOW (1u << 6) |
| #define | EVENT_POWER_BATT_CRIT (1u << 7) |
| #define | EVENT_SYSTEM_UNLOCK (1u << 8) |
| #define | EVENT_SYSTEM_LOCK (1u << 9) |
| #define | EVENT_SYSTEM_SLEEP (1u << 10) |
| #define | EVENT_SYSTEM_WAKE (1u << 11) |
| #define | EVENT_BLE_CONNECTED (1u << 12) |
| #define | EVENT_BLE_DISCONNECTED (1u << 13) |
| #define | EVENT_TIMER_TICK (1u << 14) |
| #define | EVENT_LANGUAGE_CHANGED (1u << 15) |
| #define | EVENT_MODULE_EVENT (1u << 16) |
Functions | |
| int | host_event_subscribe (uint32_t event_mask, uint32_t action_id) |
| Subscribe to one or more events. | |
| int | host_event_unsubscribe (uint32_t subscription_id) |
| Cancel a subscription returned by host_event_subscribe. | |
| int | host_event_publish (uint32_t module_event_subtype, uint32_t value) |
| Publish an EVENT_MODULE_EVENT carrying subtype and value. | |
Subscribe to system events and publish module events.
Subscriptions are dispatched as plugin actions. Background-capable plugins receive events even when not on screen. The action fires with idx = the event-type ordinal (the bit position of the matching EVENT_* flag: EVENT_KEY_PRESSED -> 0, EVENT_KEY_RELEASED -> 1, ...) and user_data = the event payload. For key events user_data is the ASCII key code ('0'..'9', 'Y' = 89, 'N' = 78).
| #define EVENT_BLE_CONNECTED (1u << 12) |
Definition at line 1222 of file host_api.h.
| #define EVENT_BLE_DISCONNECTED (1u << 13) |
Definition at line 1223 of file host_api.h.
| #define EVENT_KEY_LONG_PRESS (1u << 2) |
Definition at line 1212 of file host_api.h.
| #define EVENT_KEY_PRESSED (1u << 0) |
Definition at line 1210 of file host_api.h.
| #define EVENT_KEY_RELEASED (1u << 1) |
Definition at line 1211 of file host_api.h.
| #define EVENT_LANGUAGE_CHANGED (1u << 15) |
Definition at line 1225 of file host_api.h.
| #define EVENT_MODULE_EVENT (1u << 16) |
Definition at line 1226 of file host_api.h.
| #define EVENT_POWER_BATT_CRIT (1u << 7) |
Definition at line 1217 of file host_api.h.
| #define EVENT_POWER_BATT_LOW (1u << 6) |
Definition at line 1216 of file host_api.h.
| #define EVENT_POWER_CHARGING (1u << 5) |
Definition at line 1215 of file host_api.h.
| #define EVENT_POWER_USB_CONN (1u << 3) |
Definition at line 1213 of file host_api.h.
| #define EVENT_POWER_USB_DISCONN (1u << 4) |
Definition at line 1214 of file host_api.h.
| #define EVENT_SYSTEM_LOCK (1u << 9) |
Definition at line 1219 of file host_api.h.
| #define EVENT_SYSTEM_SLEEP (1u << 10) |
Definition at line 1220 of file host_api.h.
| #define EVENT_SYSTEM_UNLOCK (1u << 8) |
Definition at line 1218 of file host_api.h.
| #define EVENT_SYSTEM_WAKE (1u << 11) |
Definition at line 1221 of file host_api.h.
| #define EVENT_TIMER_TICK (1u << 14) |
Definition at line 1224 of file host_api.h.
| int host_event_publish | ( | uint32_t | module_event_subtype, |
| uint32_t | value ) |
Publish an EVENT_MODULE_EVENT carrying subtype and value.
Definition at line 116 of file host_api_event.cpp.
References cdc::core::Event::data, HOST_OK, cdc::core::EventBus::instance(), cdc::core::MODULE_EVENT, cdc::core::EventBus::publish(), cdc::core::Event::timestamp, cdc::core::Event::type, and cdc::core::Event::value.
Referenced by cdc::plugin_manager::w_host_event_publish().
| int host_event_subscribe | ( | uint32_t | event_mask, |
| uint32_t | action_id ) |
Subscribe to one or more events.
| event_mask | Bitwise OR of EVENT_* flags. |
| action_id | Plugin action invoked when any subscribed event fires. |
Definition at line 79 of file host_api_event.cpp.
References cdc::plugin_manager::SlotTable< T, N >::allocate(), HOST_ERR_NO_CAPABILITY, HOST_ERR_NO_MEMORY, cdc::core::EventBus::instance(), plg_get_active_plugin(), plg_log_warn(), and cdc::core::EventBus::subscribe().
Referenced by cdc::plugin_manager::w_host_event_subscribe().
| int host_event_unsubscribe | ( | uint32_t | subscription_id | ) |
Cancel a subscription returned by host_event_subscribe.
Definition at line 105 of file host_api_event.cpp.
References HOST_ERR_NOT_FOUND, and HOST_OK.
Referenced by cdc::plugin_manager::w_host_event_unsubscribe().