Event API
The Event API implements an event-driven callback system that allows modules to communicate without direct coupling.System configuration
Capacity:- Maximum callbacks: 192 (
EVENT_MAX_CALLBACKS)
Data structures
Event_t
Defines an event callback registration.Event type identifier
Context pointer passed to callback
Function pointer to invoke when event is triggered
Event types
Events are identified by numeric types. Common event types include: Bluetooth events:BT_EVENT_BOOT- Bluetooth module boot completeBT_EVENT_DEVICE_CONNECTED- Device connectedBT_EVENT_DEVICE_DISCONNECTED- Device disconnectedBT_EVENT_PLAYBACK_STATUS_CHANGE- Playback state changedBT_EVENT_METADATA_UPDATE- Track metadata receivedBT_EVENT_CALL_STATUS_UPDATE- Call status changed
IBUS_EVENT_MODULE_STATUS_RESP- Module status responseIBUS_EVENT_IGN_STATUS_UPDATE- Ignition status changedIBUS_EVENT_FIRST_MESSAGE_RX- First I-Bus message received
UI_EVENT_SETTING_CHANGE- Configuration setting changed
Event type constants are defined in the respective module header files (bt.h, ibus.h, etc.).
Functions
EventRegisterCallback
Registers a callback function for an event type.Event type to listen for
Context pointer to pass to callback
Callback function with signature:
void callback(void *context, unsigned char *data)Multiple callbacks can be registered for the same event type. All registered callbacks will be invoked when the event is triggered.
EventUnregisterCallback
Removes a callback registration for an event type.Event type to unregister from
Callback function to remove
1 if callback was found and removed, 0 otherwise
EventTriggerCallback
Triggers all callbacks registered for an event type.Event type to trigger
Data pointer to pass to callbacks (can be NULL)
Callback signature
All event callbacks must use this signature:context- The context pointer provided during registrationdata- Event-specific data pointer (may be NULL)
Usage patterns
Module initialization
Modules typically register callbacks during initialization:Event triggering
Modules trigger events when state changes:Data passing
Pass data through the event system:Constants
See also
- Timer API - Scheduled task system
- Architecture - Event-driven architecture overview