Skip to content

Commit

Permalink
[BREAKING]- Refactor client
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
h2zero committed Nov 3, 2024
1 parent 68b9e26 commit 9398816
Show file tree
Hide file tree
Showing 17 changed files with 519 additions and 656 deletions.
2 changes: 1 addition & 1 deletion docs/Migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ The security callback methods are now incorporated in the `NimBLEServerCallbacks

The callback methods are:

> `bool onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pin)`
> `bool onConfirmPasskey(NimBLEConnInfo& connInfo, uint32_t pin)`
Receives the pin when using numeric comparison authentication.
Call `NimBLEDevice::injectConfirmPasskey(connInfo, true);` to accept or `NimBLEDevice::injectConfirmPasskey(connInfo, false);` to reject.
Expand Down
2 changes: 1 addition & 1 deletion examples/NimBLE_Client/NimBLE_Client.ino
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ClientCallbacks : public NimBLEClientCallbacks {
NimBLEDevice::injectPassKey(connInfo, 123456);
};

void onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pass_key){
void onConfirmPasskey(NimBLEConnInfo& connInfo, uint32_t pass_key){
Serial.print("The passkey YES/NO number: ");Serial.println(pass_key);
/** Inject false if passkeys don't match. */
NimBLEDevice::injectConfirmPasskey(connInfo, true);
Expand Down
2 changes: 1 addition & 1 deletion examples/NimBLE_Server/NimBLE_Server.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ServerCallbacks: public NimBLEServerCallbacks {
return 123456;
};

void onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pass_key) {
void onConfirmPasskey(NimBLEConnInfo& connInfo, uint32_t pass_key) {
Serial.print("The passkey YES/NO number: ");Serial.println(pass_key);
/** Inject false if passkeys don't match. */
NimBLEDevice::injectConfirmPasskey(connInfo, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MyClientCallback : public BLEClientCallbacks {
NimBLEDevice::injectPassKey(connInfo, 123456);
}

void onConfirmPIN(const BLEConnInfo& connInfo, uint32_t pass_key) {
void onConfirmPasskey(const BLEConnInfo& connInfo, uint32_t pass_key) {
Serial.print("The passkey YES/NO number: ");Serial.println(pass_key);
NimBLEDevice::injectConfirmPasskey(connInfo, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MyServerCallbacks: public BLEServerCallbacks {
return 123456;
}

void onConfirmPIN(const BLEConnInfo& connInfo, uint32_t pass_key) {
void onConfirmPasskey(const BLEConnInfo& connInfo, uint32_t pass_key) {
Serial.print("The passkey YES/NO number: ");Serial.println(pass_key);
/** Inject false if passkeys don't match. */
NimBLEDevice::injectConfirmPasskey(connInfo, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MyServerCallbacks: public BLEServerCallbacks {
return 123456;
}

void onConfirmPIN(const BLEConnInfo& connInfo, uint32_t pass_key) {
void onConfirmPasskey(const BLEConnInfo& connInfo, uint32_t pass_key) {
Serial.print("The passkey YES/NO number: ");Serial.println(pass_key);
/** Inject false if passkeys don't match. */
NimBLEDevice::injectConfirmPasskey(connInfo, true);
Expand Down
Loading

0 comments on commit 9398816

Please sign in to comment.