[BREAKING]- Refactor client

* General code cleanup and rename variables to use a consistent style.
* Removes the disconnect timer and will use the BLE_GAP_EVENT_TERM_FAILURE event to handle failed disconnects.
* `NimBLEClient::getConnId` has been renamed to `getConnHandle` to be consistent with bluetooth terminology.
* `NimBLEClient::disconnect` now returns a `bool = true on success` instead of an int to be consistent with the rest of the library.
* `NimBLEClient::setPeerAddress` now returns a bool, true on success.
* `NimBLEClientCallbacks::onConfirmPIN` renamed to `NimBLEClientCallbacks::onConfirmPasskey` to be consistent with bluetooth terminology.
* `NimBLEClient::setDataLen` now returns bool, true if successful.
* `NimBLEClient::updateConnParams` now returns bool, true if successful.
* `NimBLEClient::getServices` now returns a const reference to std::vector<NimBLERemoteService*> instead of a pointer to the internal vector.
This commit is contained in:
h2zero
2024-11-03 18:12:20 -07:00
committed by h2zero
parent 68b82f5b85
commit 020c61700d
19 changed files with 532 additions and 667 deletions
+2 -3
View File
@@ -324,8 +324,7 @@ bool NimBLEDevice::deleteClient(NimBLEClient* pClient) {
int rc = 0;
if (pClient->isConnected()) {
rc = pClient->disconnect();
if (rc != 0 && rc != BLE_HS_EALREADY && rc != BLE_HS_ENOTCONN) {
if (!pClient->disconnect()) {
return false;
}
@@ -378,7 +377,7 @@ size_t NimBLEDevice::getCreatedClientCount() {
*/
NimBLEClient* NimBLEDevice::getClientByHandle(uint16_t connHandle) {
for (const auto clt : m_pClients) {
if (clt != nullptr && clt->getConnId() == connHandle) {
if (clt != nullptr && clt->getConnHandle() == connHandle) {
return clt;
}
}