Skip to content

Allow valueSize changes after initialization to adjust to MTU size #391

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

matpowel
Copy link

@matpowel matpowel commented Apr 9, 2025

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.

@CLAassistant
Copy link

CLAassistant commented Apr 9, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

codecov bot commented Apr 9, 2025

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 ⚠️
src/local/BLELocalDevice.cpp 0.00% 6 Missing ⚠️
src/BLECharacteristic.cpp 0.00% 5 Missing ⚠️
src/BLEDevice.cpp 0.00% 2 Missing ⚠️
src/utility/ATT.cpp 0.00% 2 Missing ⚠️
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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

github-actions bot commented Apr 9, 2025

Memory usage change @ d22a91c

Board flash % RAM for global variables %
arduino:mbed_nano:nano33ble 🔺 +136 - +136 +0.01 - +0.01 🔺 +8 - +8 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect 🔺 +140 - +140 0.0 - 0.0 🔺 +8 - +8 0.0 - 0.0
arduino:megaavr:uno2018:mode=on 🔺 +180 - +180 +0.37 - +0.37 🔺 +4 - +4 +0.07 - +0.07
arduino:renesas_uno:unor4wifi 🔺 +120 - +136 +0.05 - +0.05 🔺 +8 - +8 +0.02 - +0.02
arduino:samd:mkrwifi1010 🔺 +136 - +144 +0.05 - +0.05 🔺 +8 - +8 +0.02 - +0.02
arduino:samd:nano_33_iot 🔺 +136 - +144 +0.05 - +0.05 🔺 +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

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants