Skip to content

Commit

Permalink
Update esp-nimble-cpp to match upstream (#253)
Browse files Browse the repository at this point in the history
* Updated esp-nimble-cpp submodule to match upstream (which now has changes applied)
* Update ble gatt server and menu to use newer versions of the APIs for the client connection setting / clearing and return type of deleteAllBonds
  • Loading branch information
finger563 authored Jun 5, 2024
1 parent 646fee0 commit 3dee929
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
9 changes: 4 additions & 5 deletions components/ble_gatt_server/include/ble_gatt_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,11 @@ class BleGattServer : public BaseComponent {
logger_.error("Client not created");
return {};
}
auto peer_address = conn_info.getAddress();
// since this connection is handled by the server, we won't manually
// connect, and instead inform the client that we are already connected
// using this conn handle
client_->setPeerAddress(peer_address);
client_->setConnId(conn_info.getConnHandle());
client_->clearConnection();
client_->setConnection(conn_info);
// refresh the services
client_->getServices(true);
// now get Generic Access Service
Expand Down Expand Up @@ -594,8 +593,8 @@ class BleGattServer : public BaseComponent {
// since this connection is handled by the server, we won't manually
// connect, and instead inform the client that we are already connected
// using this conn handle
client_->setPeerAddress(peer_address);
client_->setConnId(conn_info.getConnHandle());
client_->clearConnection();
client_->setConnection(conn_info);
// and read the RSSI from the client
auto rssi = client_->getRssi();
logger_.info("RSSI for connected device {}: {}", peer_address.toString(), rssi);
Expand Down
6 changes: 2 additions & 4 deletions components/ble_gatt_server/include/ble_gatt_server_menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@ class BleGattServerMenu {
"unpair",
[this](std::ostream &out) -> void {
auto devices = server_.get().unpair_all();
int return_code = NimBLEDevice::deleteAllBonds();
bool success = return_code == 0;
out << "Unpaired " << devices.size() << " devices individually\n";
bool success = NimBLEDevice::deleteAllBonds();
if (!success) {
out << "Failed to deleteAllBonds\n";
out << "Return code: " << return_code << "\n";
out << "Then failed to deleteAllBonds\n";
} else {
out << "Then deleted all bonds\n";
}
Expand Down

0 comments on commit 3dee929

Please sign in to comment.