Skip to content

Fix #4046 Details below: #4086

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 1 commit into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 17 additions & 13 deletions libraries/BLE/src/BLECharacteristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,22 @@ void BLECharacteristic::handleGATTServerEvent(
// - uint8_t exec_write_flag - Either ESP_GATT_PREP_WRITE_EXEC or ESP_GATT_PREP_WRITE_CANCEL
//
case ESP_GATTS_EXEC_WRITE_EVT: {
if (param->exec_write.exec_write_flag == ESP_GATT_PREP_WRITE_EXEC) {
m_value.commit();
m_pCallbacks->onWrite(this); // Invoke the onWrite callback handler.
} else {
m_value.cancel();
}
// ???
esp_err_t errRc = ::esp_ble_gatts_send_response(
gatts_if,
param->write.conn_id,
param->write.trans_id, ESP_GATT_OK, nullptr);
if (errRc != ESP_OK) {
log_e("esp_ble_gatts_send_response: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
if(m_writeEvt){
m_writeEvt = false;
if (param->exec_write.exec_write_flag == ESP_GATT_PREP_WRITE_EXEC) {
m_value.commit();
m_pCallbacks->onWrite(this); // Invoke the onWrite callback handler.
} else {
m_value.cancel();
}
// ???
esp_err_t errRc = ::esp_ble_gatts_send_response(
gatts_if,
param->write.conn_id,
param->write.trans_id, ESP_GATT_OK, nullptr);
if (errRc != ESP_OK) {
log_e("esp_ble_gatts_send_response: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
}
}
break;
} // ESP_GATTS_EXEC_WRITE_EVT
Expand Down Expand Up @@ -277,6 +280,7 @@ void BLECharacteristic::handleGATTServerEvent(
if (param->write.handle == m_handle) {
if (param->write.is_prep) {
m_value.addPart(param->write.value, param->write.len);
m_writeEvt = true;
} else {
setValue(param->write.value, param->write.len);
}
Expand Down
1 change: 1 addition & 0 deletions libraries/BLE/src/BLECharacteristic.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class BLECharacteristic {
BLEService* m_pService;
BLEValue m_value;
esp_gatt_perm_t m_permissions = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
bool m_writeEvt = false; // If we have started a long write, this tells the commit code that we were the target

void handleGATTServerEvent(
esp_gatts_cb_event_t event,
Expand Down