arduino-libraries / ArduinoBLE

ArduinoBLE library for Arduino
GNU Lesser General Public License v2.1
315 stars 205 forks source link

Write method for returning the number of bytes transferred #371

Open fabik111 opened 1 month ago

fabik111 commented 1 month ago

The current writeValue method, used for writing the value of a characteristic, returns an integer value. This value is used as a Boolean to indicate the success or the failure of the writing operation, without giving any indication about the amount of bytes actually transferred (in case of subscription) or "loaded" into the characteristic (in case of a readable characteristic). Considering that the MTU, the amount of transferable data, is decided by the central and varies device by device, it is impossible for the user to determinate how many bytes are transferred and upon that to take an action. In this PR a write method is added for the generic BLECharacteristic returning the number of bytes transferred.

It works both when the device is in peripheral and central mode.

github-actions[bot] commented 1 month ago

Memory usage change @ e358f2d4ed9baaf13d032c11cb9ab17ed7392280

Board flash % RAM for global variables %
arduino:mbed_nano:nano33ble :small_red_triangle: 0 - +64 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect :small_red_triangle: +8 - +8 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:megaavr:uno2018:mode=on :small_red_triangle: +52 - +52 +0.11 - +0.11 0 - 0 0.0 - 0.0
arduino:renesas_uno:unor4wifi :small_red_triangle: +16 - +32 +0.01 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 :small_red_triangle: +8 - +8 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:nano_33_iot :small_red_triangle: +8 - +8 0.0 - 0.0 0 - 0 0.0 - 0.0
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`|0|0.0|0|0.0|64|0.01|0|0.0|64|0.01|0|0.0|64|0.01|0|0.0|64|0.01|0|0.0|64|0.01|0|0.0|0|0.0|0|0.0|64|0.01|0|0.0|64|0.01|0|0.0|64|0.01|0|0.0|0|0.0|0|0.0|64|0.01|0|0.0 `arduino:mbed_nano:nanorp2040connect`|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0 `arduino:megaavr:uno2018:mode=on`|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0 `arduino:renesas_uno:unor4wifi`|32|0.01|0|0.0|16|0.01|0|0.0|16|0.01|0|0.0|16|0.01|0|0.0|32|0.01|0|0.0|16|0.01|0|0.0|16|0.01|0|0.0|16|0.01|0|0.0|32|0.01|0|0.0|16|0.01|0|0.0|16|0.01|0|0.0|32|0.01|0|0.0 `arduino:samd:mkrwifi1010`|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0 `arduino:samd:nano_33_iot`|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0
Click for full report CSV ``` 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,0,0.0,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0,0,0.0,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0,0,0.0,0,0.0,64,0.01,0,0.0 arduino:mbed_nano:nanorp2040connect,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0 arduino:megaavr:uno2018:mode=on,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0 arduino:renesas_uno:unor4wifi,32,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,32,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,32,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,32,0.01,0,0.0 arduino:samd:mkrwifi1010,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0 arduino:samd:nano_33_iot,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0 ```
github-actions[bot] commented 3 weeks ago

Memory usage change @ ac8ab197cd183b7ddbd2a3eb35ac210a10bbaa51

Board flash % RAM for global variables %
arduino:mbed_nano:nano33ble :small_red_triangle: 0 - +64 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect :small_red_triangle: +8 - +8 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:megaavr:uno2018:mode=on :small_red_triangle: +52 - +52 +0.11 - +0.11 0 - 0 0.0 - 0.0
arduino:renesas_uno:unor4wifi :small_red_triangle: +16 - +32 +0.01 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 :small_red_triangle: +8 - +8 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:nano_33_iot :small_red_triangle: +8 - +8 0.0 - 0.0 0 - 0 0.0 - 0.0
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`|0|0.0|0|0.0|64|0.01|0|0.0|64|0.01|0|0.0|64|0.01|0|0.0|64|0.01|0|0.0|0|0.0|0|0.0|64|0.01|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|64|0.01|0|0.0|64|0.01|0|0.0|64|0.01|0|0.0 `arduino:mbed_nano:nanorp2040connect`|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0 `arduino:megaavr:uno2018:mode=on`|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0|52|0.11|0|0.0 `arduino:renesas_uno:unor4wifi`|32|0.01|0|0.0|16|0.01|0|0.0|16|0.01|0|0.0|16|0.01|0|0.0|32|0.01|0|0.0|32|0.01|0|0.0|16|0.01|0|0.0|16|0.01|0|0.0|32|0.01|0|0.0|16|0.01|0|0.0|16|0.01|0|0.0|32|0.01|0|0.0 `arduino:samd:mkrwifi1010`|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0 `arduino:samd:nano_33_iot`|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0|8|0.0|0|0.0
Click for full report CSV ``` 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,0,0.0,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0,0,0.0,0,0.0,64,0.01,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0 arduino:mbed_nano:nanorp2040connect,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0 arduino:megaavr:uno2018:mode=on,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0,52,0.11,0,0.0 arduino:renesas_uno:unor4wifi,32,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,32,0.01,0,0.0,32,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,32,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,32,0.01,0,0.0 arduino:samd:mkrwifi1010,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0 arduino:samd:nano_33_iot,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0 ```