Skip to content

Have BLECLient gattc event handlers verify conn_id #4064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 30, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libraries/BLE/src/BLEClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ void BLEClient::gattClientEventHandler(
// - uint16_t conn_id
// - esp_bd_addr_t remote_bda
case ESP_GATTC_DISCONNECT_EVT: {
if (evtParam->disconnect.conn_id != getConnId()) break;
// If we receive a disconnect event, set the class flag that indicates that we are
// no longer connected.
m_isConnected = false;
Expand Down Expand Up @@ -227,13 +228,15 @@ void BLEClient::gattClientEventHandler(
} // ESP_GATTC_REG_EVT

case ESP_GATTC_CFG_MTU_EVT:
if (evtParam->cfg_mtu.conn_id != getConnId()) break;
if(evtParam->cfg_mtu.status != ESP_GATT_OK) {
log_e("Config mtu failed");
}
m_mtu = evtParam->cfg_mtu.mtu;
break;

case ESP_GATTC_CONNECT_EVT: {
if (evtParam->connect.conn_id != getConnId()) break;
BLEDevice::updatePeerDevice(this, true, m_gattc_if);
esp_err_t errRc = esp_ble_gattc_send_mtu_req(gattc_if, evtParam->connect.conn_id);
if (errRc != ESP_OK) {
Expand All @@ -255,6 +258,7 @@ void BLEClient::gattClientEventHandler(
// - uint16_t conn_id
//
case ESP_GATTC_SEARCH_CMPL_EVT: {
if (evtParam->search_cmpl.conn_id != getConnId()) break;
esp_ble_gattc_cb_param_t* p_data = (esp_ble_gattc_cb_param_t*)evtParam;
if (p_data->search_cmpl.status != ESP_GATT_OK){
log_e("search service failed, error status = %x", p_data->search_cmpl.status);
Expand Down Expand Up @@ -285,6 +289,7 @@ void BLEClient::gattClientEventHandler(
// - esp_gatt_id_t srvc_id
//
case ESP_GATTC_SEARCH_RES_EVT: {
if (evtParam->search_res.conn_id != getConnId()) break;
BLEUUID uuid = BLEUUID(evtParam->search_res.srvc_id);
BLERemoteService* pRemoteService = new BLERemoteService(
evtParam->search_res.srvc_id,
Expand Down