[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-02 19:00:07 -06:00
committed by h2zero
parent 68b82f5b85
commit 020c61700d
19 changed files with 532 additions and 667 deletions

View File

@@ -368,7 +368,7 @@ int NimBLEServer::peerNameCB(uint16_t conn_handle,
const struct ble_gatt_error *error,
struct ble_gatt_attr *attr,
void *arg) {
ble_task_data_t *pTaskData = (ble_task_data_t*)arg;
BleTaskData *pTaskData = (BleTaskData*)arg;
std::string *name = (std::string*)pTaskData->buf;
int rc = error->status;
@@ -414,7 +414,7 @@ int NimBLEServer::peerNameCB(uint16_t conn_handle,
*/
std::string NimBLEServer::getPeerNameInternal(uint16_t conn_handle, TaskHandle_t task, int cb_type) {
std::string *buf = new std::string{};
ble_task_data_t *taskData = new ble_task_data_t{this, task, cb_type, buf};
BleTaskData *taskData = new BleTaskData{this, task, cb_type, buf};
ble_uuid16_t uuid {{BLE_UUID_TYPE_16}, BLE_SVC_GAP_CHR_UUID16_DEVICE_NAME};
int rc = ble_gattc_read_by_uuid(conn_handle,
1,
@@ -628,7 +628,7 @@ int NimBLEServer::handleGapEvent(struct ble_gap_event *event, void *arg) {
if (rc != 0) {
return 0;
}
pServer->m_pServerCallbacks->onConnParamsUpdate(peerInfo);
return 0;
} // BLE_GAP_EVENT_CONN_UPDATE