/* * event_reporter.h -- Thread-safe event queue for BT callback -> UART NDJSON. * * BT callbacks run on the Bluedroid task; touching UART from there is * asking for trouble. Instead, callbacks push lightweight event structs * onto a FreeRTOS queue. A dedicated reporter task drains the queue * and serialises each event as a single NDJSON line over UART. */ #pragma once #include #include #include "cJSON.h" /* Lifecycle */ void event_reporter_init(void); /* * Generic event push. Takes ownership of `data` (will be freed by the * reporter task after serialisation). Safe to call from any task/ISR * context that can tolerate a brief queue-send timeout. */ void event_report(const char *event_name, cJSON *data); /* Convenience helpers -- build the cJSON internally. */ void event_report_pair_request(const char *address, const char *type, int passkey); void event_report_pair_complete(const char *address, bool success); void event_report_connect(const char *address, const char *transport); void event_report_disconnect(const char *address, const char *transport); void event_report_gatt_read(uint16_t char_handle, const char *address); void event_report_gatt_write(uint16_t char_handle, const char *address, const uint8_t *value, uint16_t len); void event_report_gatt_subscribe(uint16_t char_handle, bool subscribed);