Skip to content
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
8 changes: 4 additions & 4 deletions libraries/BLE/src/BLECharacteristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions libraries/BLE/src/BLEServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,9 @@ void BLEServer::updateConnParams(esp_bd_addr_t remote_bda, uint16_t minInterval,
conn_params.timeout = timeout; // timeout = 400*10ms = 4000ms
esp_ble_gap_update_conn_params(&conn_params);
}

void BLEServer::disconnect(uint16_t connId) {
esp_ble_gatts_close(m_gatts_if, connId);
}

#endif // CONFIG_BT_ENABLED
1 change: 1 addition & 0 deletions libraries/BLE/src/BLEServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class BLEServer {
BLEService* getServiceByUUID(const char* uuid);
BLEService* getServiceByUUID(BLEUUID uuid);
bool connect(BLEAddress address);
void disconnect(uint16_t connId);
uint16_t m_appId;
void updateConnParams(esp_bd_addr_t remote_bda, uint16_t minInterval, uint16_t maxInterval, uint16_t latency, uint16_t timeout);

Expand Down