Commit ce5d890c authored by schneider's avatar schneider
Browse files

Merge branch 'schneider/ble-wait-disc-cfg-cmpl-2' into 'master'

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

See merge request !459
parents e181fcad a86715f2
Pipeline #5162 passed with stages
in 41 seconds
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment