Fixes Maximum BLE Device Length #7901
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
Fixes IDF esp_ble_gap_set_device_name() that allows name length bigger than Advertsing payload space.
The device name must have the maximum length of 29 characters.
If the device name has between 30 and 32 characters long, an error of Stack smashing protect failure! + ABORT & RESET will occur
If the device name has a length of 33 or more, it won't reset the board, but the last valid device name will be used.
Also, an error message will be displayed in the Serial Console.
[BLEDevice.cpp:416] init(): esp_ble_gap_set_device_name: rc=258 Unknown ESP_ERR error
There is a "gap" that allows name with 30 to 32 bytes to move forward and it leads to abort and reset the board.
Changing the device name to something that call Arduino User attention may also help.
Another way to heko the Arduino User, would be to change
void BLEDevice::init(std::string deviceName)
to return a bool in case of failure in order to allow the Sketch to identify it and take some action.Tests scenarios
Testing case from #7894
New
bool BLEDevice::init()
shall allow testing if it was successful.This code demonstrates the initial issue:
Related links
Fixes #7894