-
Notifications
You must be signed in to change notification settings - Fork 3
📝 Add BLESecurity example #11
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
0a90a60 to
f687967
Compare
f687967 to
6009a40
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 PR adds a new BLE security example demonstrating how to implement secure BLE communication with authentication and encryption features. The example shows how to set up BLE security callbacks, configure encryption settings, and handle passkey authentication.
Key changes:
- Added a complete secure BLE serial communication example with authentication callbacks
- Included CI configuration to build the new secure example
- Demonstrated BLE security features including passkey generation and authentication flow
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| examples/SerialToSerialBLE_Secure/SerialToSerialBLE_Secure.ino | New example implementing BLE security with authentication callbacks and encryption |
| .github/workflows/platformio-ci.yml | Added CI build configuration for the new secure BLE example |
| } | ||
|
|
||
| uint32_t onPassKeyRequest(){ | ||
| ESP_LOGI(LOG_TAG, "PassKeyRequest"); |
Copilot
AI
Jul 27, 2025
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.
LOG_TAG is used but not defined. This will cause a compilation error. Define LOG_TAG as a const char* or use a string literal directly.
| } | ||
|
|
||
| void onPassKeyNotify(uint32_t pass_key){ | ||
| ESP_LOGI(LOG_TAG, "The passkey Notify number: %d", pass_key); |
Copilot
AI
Jul 27, 2025
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.
LOG_TAG is used but not defined. This will cause a compilation error. Define LOG_TAG as a const char* or use a string literal directly.
| } | ||
|
|
||
| bool onConfirmPIN(uint32_t pass_key){ | ||
| ESP_LOGI(LOG_TAG, "The passkey YES/NO number: %d", pass_key); |
Copilot
AI
Jul 27, 2025
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.
LOG_TAG is used but not defined. This will cause a compilation error. Define LOG_TAG as a const char* or use a string literal directly.
| } | ||
|
|
||
| bool onSecurityRequest(){ | ||
| ESP_LOGI(LOG_TAG, "SecurityRequest"); |
Copilot
AI
Jul 27, 2025
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.
LOG_TAG is used but not defined. This will cause a compilation error. Define LOG_TAG as a const char* or use a string literal directly.
| } | ||
|
|
||
| void onAuthenticationComplete(esp_ble_auth_cmpl_t cmpl){ | ||
| ESP_LOGI(LOG_TAG, "Starting BLE work!"); |
Copilot
AI
Jul 27, 2025
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.
LOG_TAG is used but not defined. This will cause a compilation error. Define LOG_TAG as a const char* or use a string literal directly.
| uint32_t passKey; | ||
|
|
Copilot
AI
Jul 27, 2025
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.
This global passKey variable appears to be unused since the AppSecurityCallbacks class has its own private passKey member. Consider removing this unused global variable.
| uint32_t passKey; |
|
|
||
| bool onConfirmPIN(uint32_t pass_key){ | ||
| ESP_LOGI(LOG_TAG, "The passkey YES/NO number: %d", pass_key); | ||
| vTaskDelay(5000); |
Copilot
AI
Jul 27, 2025
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.
The hardcoded 5000ms delay (5 seconds) is a magic number. Consider defining it as a named constant or adding a comment explaining why this specific delay is needed for the confirmation process.
| vTaskDelay(5000); | |
| vTaskDelay(CONFIRMATION_DELAY_MS); |
|
|
||
| BLEServer* pServer = BLEDevice::createServer(); | ||
|
|
||
| BLESecurity *pSecurity = new BLESecurity(); |
Copilot
AI
Jul 27, 2025
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.
Memory allocated for BLESecurity is never freed, causing a memory leak. Consider using a smart pointer or ensuring proper cleanup, or making it a stack variable if the lifetime permits.
Example of BLESecurity for #8