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)); } }