ArduinoBLE icon indicating copy to clipboard operation
ArduinoBLE copied to clipboard

Allow valueSize changes after initialization to adjust to MTU size

Open matpowel opened this issue 10 months ago • 3 comments

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.

matpowel avatar Apr 09 '25 16:04 matpowel

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 09 '25 16:04 CLAassistant

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.

Files with missing lines Patch % Lines
src/local/BLELocalCharacteristic.cpp 0.00% 8 Missing :warning:
src/local/BLELocalDevice.cpp 0.00% 6 Missing :warning:
src/BLECharacteristic.cpp 0.00% 5 Missing :warning:
src/BLEDevice.cpp 0.00% 2 Missing :warning:
src/utility/ATT.cpp 0.00% 2 Missing :warning:
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.

codecov[bot] avatar Apr 09 '25 16:04 codecov[bot]

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/LedControl
flash
% examples/Central/LedControl
RAM for global variables
% examples/Central/PeripheralExplorer
flash
% examples/Central/PeripheralExplorer
RAM for global variables
% examples/Central/Scan
flash
% examples/Central/Scan
RAM for global variables
% examples/Central/ScanCallback
flash
% examples/Central/ScanCallback
RAM for global variables
% examples/Central/SensorTagButton
flash
% examples/Central/SensorTagButton
RAM for global variables
% examples/Peripheral/Advertising/EnhancedAdvertising
flash
% examples/Peripheral/Advertising/EnhancedAdvertising
RAM for global variables
% examples/Peripheral/Advertising/RawDataAdvertising
flash
% examples/Peripheral/Advertising/RawDataAdvertising
RAM for global variables
% examples/Peripheral/BatteryMonitor
flash
% examples/Peripheral/BatteryMonitor
RAM for global variables
% examples/Peripheral/ButtonLED
flash
% examples/Peripheral/ButtonLED
RAM for global variables
% examples/Peripheral/CallbackLED
flash
% examples/Peripheral/CallbackLED
RAM for global variables
% examples/Peripheral/EncryptedBatteryMonitor
flash
% examples/Peripheral/EncryptedBatteryMonitor
RAM for global variables
% examples/Peripheral/LED
flash
% examples/Peripheral/LED
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
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

github-actions[bot] avatar Apr 09 '25 16:04 github-actions[bot]