Allow valueSize changes after initialization to adjust to MTU size
When trying to implement a BLE MIDI wrapper on top of ArduinoBLE I was losing data because the MTU negotiated with the server (in this case Apple Mac or iOS devices) was not matching the valueSize / buffer. Normally this might not be an issue but in the particular case of MIDI over BLE, the official spec and parsing of the data requires that packets are handled discreetly, so if the server thinks the packet size is X and we (the client) think it's Y then messages are sent incorrectly.
I suspect there are also other situations where matching the buffer size in the BLE parsing code and the MTU is better, more efficient and/or the only way to be accurate.
This implementation adds the methods necessary to resize, check the MTU size and be notified of MTU negotiation changes, but leaves the decision to resize up to the user of the library.
Codecov Report
Attention: Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.
Project coverage is 9.56%. Comparing base (
c91c02c) to head (d22a91c). Report is 21 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #391 +/- ##
=========================================
- Coverage 9.62% 9.56% -0.07%
=========================================
Files 28 28
Lines 3656 3679 +23
=========================================
Hits 352 352
- Misses 3304 3327 +23
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Memory usage change @ d22a91cde773155bb31a1dda033841a9f8c5640d
| Board | flash | % | RAM for global variables | % |
|---|---|---|---|---|
arduino:mbed_nano:nano33ble |
:small_red_triangle: +136 - +136 | +0.01 - +0.01 | :small_red_triangle: +8 - +8 | 0.0 - 0.0 |
arduino:mbed_nano:nanorp2040connect |
:small_red_triangle: +140 - +140 | 0.0 - 0.0 | :small_red_triangle: +8 - +8 | 0.0 - 0.0 |
arduino:megaavr:uno2018:mode=on |
:small_red_triangle: +180 - +180 | +0.37 - +0.37 | :small_red_triangle: +4 - +4 | +0.07 - +0.07 |
arduino:renesas_uno:unor4wifi |
:small_red_triangle: +120 - +136 | +0.05 - +0.05 | :small_red_triangle: +8 - +8 | +0.02 - +0.02 |
arduino:samd:mkrwifi1010 |
:small_red_triangle: +136 - +144 | +0.05 - +0.05 | :small_red_triangle: +8 - +8 | +0.02 - +0.02 |
arduino:samd:nano_33_iot |
:small_red_triangle: +136 - +144 | +0.05 - +0.05 | :small_red_triangle: +8 - +8 | +0.02 - +0.02 |
Click for full report table
| Board | examples/Central/LedControlflash |
% | examples/Central/LedControlRAM for global variables |
% | examples/Central/PeripheralExplorerflash |
% | examples/Central/PeripheralExplorerRAM for global variables |
% | examples/Central/Scanflash |
% | examples/Central/ScanRAM for global variables |
% | examples/Central/ScanCallbackflash |
% | examples/Central/ScanCallbackRAM for global variables |
% | examples/Central/SensorTagButtonflash |
% | examples/Central/SensorTagButtonRAM for global variables |
% | examples/Peripheral/Advertising/EnhancedAdvertisingflash |
% | examples/Peripheral/Advertising/EnhancedAdvertisingRAM for global variables |
% | examples/Peripheral/Advertising/RawDataAdvertisingflash |
% | examples/Peripheral/Advertising/RawDataAdvertisingRAM for global variables |
% | examples/Peripheral/BatteryMonitorflash |
% | examples/Peripheral/BatteryMonitorRAM for global variables |
% | examples/Peripheral/ButtonLEDflash |
% | examples/Peripheral/ButtonLEDRAM for global variables |
% | examples/Peripheral/CallbackLEDflash |
% | examples/Peripheral/CallbackLEDRAM for global variables |
% | examples/Peripheral/EncryptedBatteryMonitorflash |
% | examples/Peripheral/EncryptedBatteryMonitorRAM for global variables |
% | examples/Peripheral/LEDflash |
% | examples/Peripheral/LEDRAM for global variables |
% |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
arduino:mbed_nano:nano33ble |
136 | 0.01 | 8 | 0.0 | 136 | 0.01 | 8 | 0.0 | 136 | 0.01 | 8 | 0.0 | 136 | 0.01 | 8 | 0.0 | 136 | 0.01 | 8 | 0.0 | 136 | 0.01 | 8 | 0.0 | 136 | 0.01 | 8 | 0.0 | 136 | 0.01 | 8 | 0.0 | 136 | 0.01 | 8 | 0.0 | 136 | 0.01 | 8 | 0.0 | 136 | 0.01 | 8 | 0.0 | 136 | 0.01 | 8 | 0.0 |
arduino:mbed_nano:nanorp2040connect |
140 | 0.0 | 8 | 0.0 | 140 | 0.0 | 8 | 0.0 | 140 | 0.0 | 8 | 0.0 | 140 | 0.0 | 8 | 0.0 | 140 | 0.0 | 8 | 0.0 | 140 | 0.0 | 8 | 0.0 | 140 | 0.0 | 8 | 0.0 | 140 | 0.0 | 8 | 0.0 | 140 | 0.0 | 8 | 0.0 | 140 | 0.0 | 8 | 0.0 | 140 | 0.0 | 8 | 0.0 | 140 | 0.0 | 8 | 0.0 |
arduino:megaavr:uno2018:mode=on |
180 | 0.37 | 4 | 0.07 | 180 | 0.37 | 4 | 0.07 | 180 | 0.37 | 4 | 0.07 | 180 | 0.37 | 4 | 0.07 | 180 | 0.37 | 4 | 0.07 | 180 | 0.37 | 4 | 0.07 | 180 | 0.37 | 4 | 0.07 | 180 | 0.37 | 4 | 0.07 | 180 | 0.37 | 4 | 0.07 | 180 | 0.37 | 4 | 0.07 | 180 | 0.37 | 4 | 0.07 | 180 | 0.37 | 4 | 0.07 |
arduino:renesas_uno:unor4wifi |
136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 120 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 |
arduino:samd:mkrwifi1010 |
136 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 |
arduino:samd:nano_33_iot |
136 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 136 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 | 144 | 0.05 | 8 | 0.02 |
Click for full report CSV
Board,examples/Central/LedControl<br>flash,%,examples/Central/LedControl<br>RAM for global variables,%,examples/Central/PeripheralExplorer<br>flash,%,examples/Central/PeripheralExplorer<br>RAM for global variables,%,examples/Central/Scan<br>flash,%,examples/Central/Scan<br>RAM for global variables,%,examples/Central/ScanCallback<br>flash,%,examples/Central/ScanCallback<br>RAM for global variables,%,examples/Central/SensorTagButton<br>flash,%,examples/Central/SensorTagButton<br>RAM for global variables,%,examples/Peripheral/Advertising/EnhancedAdvertising<br>flash,%,examples/Peripheral/Advertising/EnhancedAdvertising<br>RAM for global variables,%,examples/Peripheral/Advertising/RawDataAdvertising<br>flash,%,examples/Peripheral/Advertising/RawDataAdvertising<br>RAM for global variables,%,examples/Peripheral/BatteryMonitor<br>flash,%,examples/Peripheral/BatteryMonitor<br>RAM for global variables,%,examples/Peripheral/ButtonLED<br>flash,%,examples/Peripheral/ButtonLED<br>RAM for global variables,%,examples/Peripheral/CallbackLED<br>flash,%,examples/Peripheral/CallbackLED<br>RAM for global variables,%,examples/Peripheral/EncryptedBatteryMonitor<br>flash,%,examples/Peripheral/EncryptedBatteryMonitor<br>RAM for global variables,%,examples/Peripheral/LED<br>flash,%,examples/Peripheral/LED<br>RAM for global variables,%
arduino:mbed_nano:nano33ble,136,0.01,8,0.0,136,0.01,8,0.0,136,0.01,8,0.0,136,0.01,8,0.0,136,0.01,8,0.0,136,0.01,8,0.0,136,0.01,8,0.0,136,0.01,8,0.0,136,0.01,8,0.0,136,0.01,8,0.0,136,0.01,8,0.0,136,0.01,8,0.0
arduino:mbed_nano:nanorp2040connect,140,0.0,8,0.0,140,0.0,8,0.0,140,0.0,8,0.0,140,0.0,8,0.0,140,0.0,8,0.0,140,0.0,8,0.0,140,0.0,8,0.0,140,0.0,8,0.0,140,0.0,8,0.0,140,0.0,8,0.0,140,0.0,8,0.0,140,0.0,8,0.0
arduino:megaavr:uno2018:mode=on,180,0.37,4,0.07,180,0.37,4,0.07,180,0.37,4,0.07,180,0.37,4,0.07,180,0.37,4,0.07,180,0.37,4,0.07,180,0.37,4,0.07,180,0.37,4,0.07,180,0.37,4,0.07,180,0.37,4,0.07,180,0.37,4,0.07,180,0.37,4,0.07
arduino:renesas_uno:unor4wifi,136,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,120,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02
arduino:samd:mkrwifi1010,136,0.05,8,0.02,144,0.05,8,0.02,144,0.05,8,0.02,144,0.05,8,0.02,136,0.05,8,0.02,144,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,144,0.05,8,0.02,144,0.05,8,0.02
arduino:samd:nano_33_iot,136,0.05,8,0.02,144,0.05,8,0.02,144,0.05,8,0.02,144,0.05,8,0.02,136,0.05,8,0.02,144,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,136,0.05,8,0.02,144,0.05,8,0.02,144,0.05,8,0.02