Description
Related area
BLE API
Hardware specification
Shouldn't depend on specific hardware
Is your feature request related to a problem?
API is harder to use than it needs to be. E.g. cannot write:
BLECharacteristic myCharacteristic(...);
// ...
myCharacteristic.setValue(2.5F); // Error here
Error: no instance of overloaded function "BLECharacteristic::setValue" matches the argument list
This is because the function requires a reference to a value, which cannot be created from the temporary 2.5F
value.
You instead have to do:
BLECharacteristic myCharacteristic(...);
// ...
float tempFloat = 2.5F;
myCharacteristic.setValue(tempFloat; // OK
This is OK for a couple of calls, but if you're setting lots of values it gets very messy.
Describe the solution you'd like
Change the function signatures to either take arguments by value or by const reference:
// old
void setValue(uint32_t &data32);
// new - value
void setValue(uint32_t data32);
// new - const reference
void setValue(const uint32_t &data32);
This should apply to all the overloads: uint16_t
, uint32_t
, int
, float
, double
.
Since the code already just immediately copies everything into a uint8_t[]
or other temporary value I don't think this will affect how it works. It also shouldn't break any existing use of the API.
As such, cost of implementing this should be minimal.
Describe alternatives you've considered
Workaround with temporary variables. Works OK but gets messy as number of variables increases.
Additional context
No response
I have checked existing list of Feature requests and the Contribution Guide
- I confirm I have checked existing list of Feature requests and Contribution Guide.
Metadata
Metadata
Assignees
Type
Projects
Status