From f2a128bf537fb131a1a4ff1228198d748dff2f57 Mon Sep 17 00:00:00 2001 From: "Morgan 'ARR\\!' Allen" Date: Fri, 10 Sep 2021 14:46:45 -0700 Subject: [PATCH] discovery needs to be stopped before connecting is possible --- main/ble.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main/ble.c b/main/ble.c index 1960aa6..22af09b 100644 --- a/main/ble.c +++ b/main/ble.c @@ -341,8 +341,11 @@ static int ble_gap_event(struct ble_gap_event *event, void *arg) { if(strstr(name, "BARBACK") != NULL) { ESP_LOGI(TAG, "Let's Party!"); - uint8_t addr_type = *(uint8_t*)arg; - (ble_gap_connect(addr_type, &(event->disc).addr, 30000, NULL, ble_gap_event, NULL)); + uint8_t addr_type; + ble_gap_disc_cancel(); + + ESP_ERROR_CHECK(ble_hs_id_infer_auto(0, &addr_type)); + ESP_ERROR_CHECK(ble_gap_connect(addr_type, &event->disc.addr, 30000, NULL, ble_gap_event, NULL)); } }