BLE Library onRead Callback fix and Client disconnect feature (#2913)

* BLEServer::disconnect()

* Invoke Read callback first, to make data update possible before read
This commit is contained in:
Roman Savrulin
2019-07-09 19:35:07 +03:00
committed by Me No Dev
parent e1548e9b7e
commit 05de017bd5
3 changed files with 10 additions and 4 deletions

View File

@ -378,6 +378,10 @@ void BLECharacteristic::handleGATTServerEvent(
}
} else { // read.is_long == false
if (m_pCallbacks != nullptr) { // If is.long is false then this is the first (or only) request to read data, so invoke the callback
m_pCallbacks->onRead(this); // Invoke the read callback.
}
std::string value = m_value.getValue();
if (value.length() + 1 > maxOffset) {
@ -392,10 +396,6 @@ void BLECharacteristic::handleGATTServerEvent(
rsp.attr_value.offset = 0;
memcpy(rsp.attr_value.value, value.data(), rsp.attr_value.len);
}
if (m_pCallbacks != nullptr) { // If is.long is false then this is the first (or only) request to read data, so invoke the callback
m_pCallbacks->onRead(this); // Invoke the read callback.
}
}
rsp.attr_value.handle = param->read.handle;
rsp.attr_value.auth_req = ESP_GATT_AUTH_REQ_NONE;