Skip to content
Snippets Groups Projects
Commit a86715f2 authored by schneider's avatar schneider
Browse files

feat(ble): Don't send DM and ATT events until disc/cfg complete

parent e181fcad
No related branches found
No related tags found
1 merge request!459feat(ble): Don't send DM and ATT events until disc/cfg complete
Pipeline #5161 passed
......@@ -26,6 +26,8 @@ static uint8_t adv_data_buf[HCI_ADV_DATA_LEN];
static uint8_t sr_data_buf[HCI_ADV_DATA_LEN];
static dmEvt_t connection_open_event;
static bool connection_open;
int epic_ble_free_event(struct epic_ble_event *e)
{
if (e->data) {
......@@ -46,6 +48,25 @@ void ble_epic_ble_api_trigger_event(enum epic_ble_event_type type, void *data)
struct epic_ble_event e = { .type = type, .data = data };
if (type == BLE_EVENT_DM_EVENT) {
dmEvt_t *dm_event = data;
if (dm_event->hdr.event == DM_CONN_OPEN_IND) {
connection_open = true;
}
if (dm_event->hdr.event == DM_CONN_CLOSE_IND) {
connection_open = false;
}
}
if (!connection_open &&
(type == BLE_EVENT_ATT_EVENT || type == BLE_EVENT_DM_EVENT)) {
// Don't forward DM and ATT events until epicardium is done setting up
// the connection
epic_ble_free_event(&e);
return;
}
if (enabled) {
if (xQueueSend(ble_event_queue, &e, 0) != pdTRUE) {
/* Print a warning if the app is missing events. Missing scan results
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment