That works quite well so far.
Code: Select all
class MySecurity : public BLESecurityCallbacks {
bool onConfirmPIN(uint32_t pin){
return false;
}
uint32_t onPassKeyRequest(){
//ESP_LOGI(LOG_TAG, "PassKeyRequest");
return 123456;
}
void onPassKeyNotify(uint32_t pass_key){
// ESP_LOGI(LOG_TAG, "On passkey Notify number:%d", pass_key);
}
bool onSecurityRequest(){
//ESP_LOGI(LOG_TAG, "On Security Request");
return true;
}
void onAuthenticationComplete(esp_ble_auth_cmpl_t cmpl){
//ESP_LOGI(LOG_TAG, "Starting BLE work!");
if(cmpl.success){
uint16_t length;
esp_ble_gap_get_whitelist_size(&length);
//ESP_LOGD(LOG_TAG, "size: %d", length);
}
}
};
//inside BLE init
BLESecurity *pSecurity = new BLESecurity();
pSecurity->setStaticPIN(000000);
However, when the ESP32 restarts. The phone ask again for the PIN. How can I restore the pairing settings after the restart? I know I have to safe something in the NVS. But what and how can I restore this?
Many thanks