Any updates on this issue? I believed that the Whitelisting was still broken, thus the path you ended up going down would not work.
I have tried several attempts to solve this problem and ended up with little to no success. At the moment I am trying to detect if a connection has a Long Term BLE Key stored on my device when a connection is opened. If the long term key exists I will let the device connect otherwise I will reject the connection. It isn't looking promising though.
Activate BLE Bonding and security with Button and show special services
Re: Activate BLE Bonding and security with Button and show special services
Alright, this may not be a solution for you, but it worked for my problem.
What I believe you should do is change the security level when the button is pressed and then change it back for ten seconds. By default you should set the security level to:
This will allow previously bonded connections to bypass the GAP layer and stop all new connections. Once the button is pressed run the code:
This will allow connections to create new bonds. Let me know if this works for you. Again, this solution does not handle GATT layer permissions. This simply controls the window in which new devices are able to access your BLE interface.
What I believe you should do is change the security level when the button is pressed and then change it back for ten seconds. By default you should set the security level to:
Code: Select all
esp_ble_auth_req_t auth_req = ESP_LE_AUTH_REQ_SC_MITM_BOND;
esp_ble_gap_set_security_param(ESP_BLE_SM_AUTHEN_REQ_MODE, &auth_req, sizeof(uint8_t));
Code: Select all
esp_ble_auth_req_t auth_req = ESP_LE_AUTH_BOND; //bonding with peer device after authentication
esp_ble_gap_set_security_param(ESP_BLE_SM_AUTHEN_REQ_MODE, &auth_req, sizeof(uint8_t));
Re: Activate BLE Bonding and security with Button and show special services
I know it's being a long time since the question posted. "Why device is unvisable after disconnect?"
But today I solved similar problems and some good peoples help me. So I have to share this with followers.
The only thing we have to do after client (this means smartphone) connect to the server (this is our ESP BLE module, board or device) is to start advertisibg again.
Just like this:
class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
//Here restart advertising
pServer->getAdvertising()->start();
};
void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
//Or it can be done here after distonnection of the first client to prevent from probability of multi connection at the same time
pServer->getAdvertising()->start();//Here restart advertising
};
};
But today I solved similar problems and some good peoples help me. So I have to share this with followers.
The only thing we have to do after client (this means smartphone) connect to the server (this is our ESP BLE module, board or device) is to start advertisibg again.
Just like this:
class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
//Here restart advertising
pServer->getAdvertising()->start();
};
void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
//Or it can be done here after distonnection of the first client to prevent from probability of multi connection at the same time
pServer->getAdvertising()->start();//Here restart advertising
};
};
Who is online
Users browsing this forum: No registered users and 52 guests