Skip to content

Commit d1134fd

Browse files
chegewarame-no-dev
authored andcommitted
Fix issue with semaphores (#2974)
1 parent d5fdd71 commit d1134fd

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

libraries/BLE/src/BLEClient.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,11 @@ void BLEClient::gattClientEventHandler(
184184
if (m_pClientCallbacks != nullptr) {
185185
m_pClientCallbacks->onDisconnect(this);
186186
}
187-
BLEDevice::removePeerDevice(m_appId, true);
188187
esp_ble_gattc_app_unregister(m_gattc_if);
188+
m_semaphoreOpenEvt.give(ESP_GATT_IF_NONE);
189189
m_semaphoreRssiCmplEvt.give();
190190
m_semaphoreSearchCmplEvt.give(1);
191+
BLEDevice::removePeerDevice(m_appId, true);
191192
break;
192193
} // ESP_GATTC_DISCONNECT_EVT
193194

libraries/BLE/src/BLERemoteCharacteristic.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ std::string BLERemoteCharacteristic::readValue() {
400400
// Check to see that we are connected.
401401
if (!getRemoteService()->getClient()->isConnected()) {
402402
log_e("Disconnected");
403-
// throw BLEDisconnectedException(); TODO:: think about error reporting mechanism
404403
return std::string();
405404
}
406405

@@ -552,7 +551,7 @@ void BLERemoteCharacteristic::writeValue(uint8_t* data, size_t length, bool resp
552551
// Check to see that we are connected.
553552
if (!getRemoteService()->getClient()->isConnected()) {
554553
log_e("Disconnected");
555-
// throw BLEDisconnectedException();
554+
return;
556555
}
557556

558557
m_semaphoreWriteCharEvt.take("writeValue");

libraries/BLE/src/BLERemoteDescriptor.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ std::string BLERemoteDescriptor::readValue() {
5555
// Check to see that we are connected.
5656
if (!getRemoteCharacteristic()->getRemoteService()->getClient()->isConnected()) {
5757
log_e("Disconnected");
58-
// throw BLEDisconnectedException(); TODO:: think about error reporting mechanism
5958
return std::string();
6059
}
6160

@@ -134,7 +133,6 @@ void BLERemoteDescriptor::writeValue(uint8_t* data, size_t length, bool response
134133
// Check to see that we are connected.
135134
if (!getRemoteCharacteristic()->getRemoteService()->getClient()->isConnected()) {
136135
log_e("Disconnected");
137-
// throw BLEDisconnectedException(); TODO:: think about error reporting mechanism
138136
return;
139137
}
140138

0 commit comments

Comments
 (0)