-
Notifications
You must be signed in to change notification settings - Fork 7.7k
fix(ble): Fix BLESecurity and add examples #11681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
👋 Hello lucasssvaz, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
Test Results 76 files 76 suites 15m 4s ⏱️ Results for commit 586e497. ♻️ This comment has been updated with latest results. |
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
3f549d3
to
f83d7f3
Compare
f83d7f3
to
511c1d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request fixes missing static member initialization in the BLESecurity class and adds comprehensive security examples. The changes improve BLE security functionality by properly initializing static variables, enhancing error handling, and providing clearer security configuration APIs.
- Initializes missing static members in BLESecurity class to prevent undefined behavior
- Improves security callback handling and removes deprecated server/client callback methods
- Adds comprehensive secure BLE server and client examples with static passkey authentication
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
BLESecurity.h/cpp | Adds static member initialization, new security APIs, and improved callback handling |
BLEServer.h/cpp | Removes deprecated security callbacks and adds advertise-on-disconnect functionality |
BLEClient.h/cpp | Removes deprecated security callbacks and improves security integration |
BLEDevice.h/cpp | Moves security level handling to BLESecurity class and adds stack detection |
BLEUtils.h/cpp | Fixes const correctness and logging macro usage |
BLECharacteristic.h/cpp | Adds authorization support and improves permission handling |
BLEDescriptor.h/cpp | Updates permission type from uint8_t to uint16_t |
BLERemoteCharacteristic.cpp | Adds security enabled checks before attempting secure connections |
BLERemoteDescriptor.cpp | Adds security enabled checks before attempting secure connections |
Examples | Adds comprehensive secure BLE server and client examples with documentation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
libraries/BLE/examples/Server_secure_static_passkey/Server_secure_static_passkey.ino
Outdated
Show resolved
Hide resolved
libraries/BLE/examples/Client_secure_static_passkey/Client_secure_static_passkey.ino
Outdated
Show resolved
Hide resolved
I note that your above "BLESecurity.cpp" has the static class function "setAuthenticationMode()" containing:
But I wonder why it is necessary to have "uint8_t BLESecurity::m_authReq = 0;" at all, as would it not make more sence just to use the passed "auth_req" directly, or instead to just to define it inside the function itself? (And similarly for m_iocap, m_initKey and m_respKey?) PS. Thankyou for the new "static passkey" examples! |
@lucasssvaz please take care of the typos https://github.com/espressif/arduino-esp32/actions/runs/17464095894/job/49595433898?pr=11681#step:9:29 |
@Rob58329 These values are accessed directly by other classes by declaring them as friend classes. |
@me-no-dev Done |
@lucasssvaz Speifically if you delete all saved bonds (eg. using the code below), my Android phone can connect to the ESP32 fine, and even though it gets the pop-up "Bluetooth paring request" box, you click on "pair" and it pairs without asking for or checking any paring code). (In fact I cant currently get any of my old SDK v3.1.1 paring-code software to work!) (I am using Windows10 with Arduino IDE v1.8.19 and https://github.com/espressif/arduino-esp32 as at 5Sep25) The "delete saves bonds" code I am using is:
|
@Rob58329 I tested everything with the nrf connect and it was working as expected. Could you please try erasing the flash before the sketch upload to clear the nvs ? |
@lucasssvaz I've just done a "Flash memory erased successfully in 6.0 seconds." and then re-flashed your Secure_server_with_static_passkey.ino" example . But with my ESP32 (orig) I still can connect to the ESP32 using BLE with "nRF Connect" on my Android phone without enterning any PIN code and read the "Secure Hello World" message (as well as the "Insecure Hello World" message). PS. also tried on a brand new NodeMCU ESP32 which has never been flashed before and it too connected without needing to enter any PIN (after pressing the "PAIR" option on the phone it just connects without giving you the option to enter a PIN). (Perhaps the BLE on the ESP32 (orig) works differently to that on the ESP32C6 etc?) |
Description of Change
This pull request fixes the missing static members initialization in BLESecurity.
Tests scenarios
Tested locally
Related links
Closes #11671