We are using an esp32 in one of our devices. We succesfully managed to setup BLE with GATT, GAP server and Secure bonding and read out characteristics however, when I pair with our device using an IOS app, then clear the whitelist and bonding info on the device and try to reconnect again using the IOS app (without forgetting the device in the BT menu) It won't be able to connect. When I try the same thing with an android device it works fine.
I'm using ESP-IDF 3.0
Could it be possible that the esp is not initiating a new pair request?
If I choose "forget" in IOS and then pair the device it works fine, also reconnecting to the device works fine.
Regards
Code: Select all
esp_ble_auth_req_t auth_req = ESP_LE_AUTH_REQ_SC_BOND;
ESP_ERROR_CHECK(esp_ble_gap_set_security_param(ESP_BLE_SM_AUTHEN_REQ_MODE, &auth_req, sizeof(uint8_t)));
//set the IO capability to No output No input
//because device has no LCD screen or numpad
esp_ble_io_cap_t iocap = ESP_IO_CAP_NONE;
ESP_ERROR_CHECK(esp_ble_gap_set_security_param(ESP_BLE_SM_IOCAP_MODE, &iocap, sizeof(uint8_t)));
//the key size should be 7~16 bytes
uint8_t key_size = 16;
ESP_ERROR_CHECK(esp_ble_gap_set_security_param(ESP_BLE_SM_MAX_KEY_SIZE, &key_size, sizeof(uint8_t)));
//set enc key, id key, and CSR key (required for LE secure)
uint8_t init_key = ESP_BLE_ID_KEY_MASK | ESP_BLE_CSR_KEY_MASK | ESP_BLE_ENC_KEY_MASK;
uint8_t rsp_key = ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK | ESP_BLE_CSR_KEY_MASK;
ESP_ERROR_CHECK(esp_ble_gap_set_security_param(ESP_BLE_SM_SET_INIT_KEY, &init_key, sizeof(uint8_t)));
ESP_ERROR_CHECK(esp_ble_gap_set_security_param(ESP_BLE_SM_SET_RSP_KEY, &rsp_key, sizeof(uint8_t)));