Activate BLE Bonding and security with Button and show special services

Rx-365
Posts: 10
Joined: Wed Jan 17, 2018 12:08 am

Re: Activate BLE Bonding and security with Button and show special services

Postby Rx-365 » Mon Jul 08, 2019 5:22 pm

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.

Rx-365
Posts: 10
Joined: Wed Jan 17, 2018 12:08 am

Re: Activate BLE Bonding and security with Button and show special services

Postby Rx-365 » Wed Jul 10, 2019 4:02 pm

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:

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));
This will allow previously bonded connections to bypass the GAP layer and stop all new connections. Once the button is pressed run the code:

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

Who is online

Users browsing this forum: No registered users and 10 guests