BLE: Recipe for handling BLE pairing with ESP32 acting as a peripheral
Posted: Thu Jun 29, 2017 3:50 am
I'm studying how to make the BLE be a peripheral to controllers. I'm testing with Android phones and a Chrome book. I have placed my ESP32 into a BLE advertising state and the controller devices seem to be able to see the ESP32 (BLE) device just fine. When I try and pair, I see the following events occur at the ESP32 (BLE) end:
ESP_GATTS_CONNECT_EVT
ESP_GAP_BLE_SEC_REQ_EVT
-> I response with a call to esp_ble_gap_security_rsp() with accept=true
On my devices, I see a message asking if I "see" a passkey on my peripheral?
40 seconds later I see (on the ESP32 BLE side) a:
ESP_GAP_BLE_AUTH_CMPL_EVT with decoded information:
[bd_addr: 60:93:99:c5:61:da, key_present: 0, key: ***, key_type: 0, success: 0, fail_reason: 99, addr_type: ***, dev_type: ESP_BT_DEVICE_TYPE_BLE]
My mystery is to understand this protocol flow. I initiate the pairing from the controller, the ESP32 (BLE) then receives the events described above ... but it seems that my ESP32 (BLE) is missing a step ... it is almost as though the ESP32 is supposed to respond when it receives a ESP_GAP_BLE_SEC_REQ_EVT ... unfortunately I don't know what that might be.
ESP_GATTS_CONNECT_EVT
ESP_GAP_BLE_SEC_REQ_EVT
-> I response with a call to esp_ble_gap_security_rsp() with accept=true
On my devices, I see a message asking if I "see" a passkey on my peripheral?
40 seconds later I see (on the ESP32 BLE side) a:
ESP_GAP_BLE_AUTH_CMPL_EVT with decoded information:
[bd_addr: 60:93:99:c5:61:da, key_present: 0, key: ***, key_type: 0, success: 0, fail_reason: 99, addr_type: ***, dev_type: ESP_BT_DEVICE_TYPE_BLE]
My mystery is to understand this protocol flow. I initiate the pairing from the controller, the ESP32 (BLE) then receives the events described above ... but it seems that my ESP32 (BLE) is missing a step ... it is almost as though the ESP32 is supposed to respond when it receives a ESP_GAP_BLE_SEC_REQ_EVT ... unfortunately I don't know what that might be.