Informed by the discussion in the bug and the code in 'that other branch' the fix was clear. Just set a flag if we start handling a write, and use that flag to guard the long write complete call.
This commit is contained in:
parent
b551310c37
commit
2fd3d042b2
@ -219,6 +219,8 @@ void BLECharacteristic::handleGATTServerEvent(
|
|||||||
// - uint8_t exec_write_flag - Either ESP_GATT_PREP_WRITE_EXEC or ESP_GATT_PREP_WRITE_CANCEL
|
// - uint8_t exec_write_flag - Either ESP_GATT_PREP_WRITE_EXEC or ESP_GATT_PREP_WRITE_CANCEL
|
||||||
//
|
//
|
||||||
case ESP_GATTS_EXEC_WRITE_EVT: {
|
case ESP_GATTS_EXEC_WRITE_EVT: {
|
||||||
|
if(m_writeEvt){
|
||||||
|
m_writeEvt = false;
|
||||||
if (param->exec_write.exec_write_flag == ESP_GATT_PREP_WRITE_EXEC) {
|
if (param->exec_write.exec_write_flag == ESP_GATT_PREP_WRITE_EXEC) {
|
||||||
m_value.commit();
|
m_value.commit();
|
||||||
m_pCallbacks->onWrite(this); // Invoke the onWrite callback handler.
|
m_pCallbacks->onWrite(this); // Invoke the onWrite callback handler.
|
||||||
@ -233,6 +235,7 @@ void BLECharacteristic::handleGATTServerEvent(
|
|||||||
if (errRc != ESP_OK) {
|
if (errRc != ESP_OK) {
|
||||||
log_e("esp_ble_gatts_send_response: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
log_e("esp_ble_gatts_send_response: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
} // ESP_GATTS_EXEC_WRITE_EVT
|
} // ESP_GATTS_EXEC_WRITE_EVT
|
||||||
|
|
||||||
@ -277,6 +280,7 @@ void BLECharacteristic::handleGATTServerEvent(
|
|||||||
if (param->write.handle == m_handle) {
|
if (param->write.handle == m_handle) {
|
||||||
if (param->write.is_prep) {
|
if (param->write.is_prep) {
|
||||||
m_value.addPart(param->write.value, param->write.len);
|
m_value.addPart(param->write.value, param->write.len);
|
||||||
|
m_writeEvt = true;
|
||||||
} else {
|
} else {
|
||||||
setValue(param->write.value, param->write.len);
|
setValue(param->write.value, param->write.len);
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,7 @@ private:
|
|||||||
BLEService* m_pService;
|
BLEService* m_pService;
|
||||||
BLEValue m_value;
|
BLEValue m_value;
|
||||||
esp_gatt_perm_t m_permissions = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
|
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(
|
void handleGATTServerEvent(
|
||||||
esp_gatts_cb_event_t event,
|
esp_gatts_cb_event_t event,
|
||||||
|
Loading…
Reference in New Issue
Block a user