I am new to Arduino and think this might be easy but can't seem to solve it. I am getting an invalid conversion from 'int32_t {aka long int}' to 'const char*'
#include <BLEPeripheral.h>
constexpr int32_t file_maximum_byte_count = (50 * 1024);
BLECharacteristic file_maximum_length_characteristic = BLECharacteristic("3002", BLERead, sizeof(uint32_t));
In my setup I am doing this:
void setup() {
...
blePeripheral.addAttribute(file_maximum_length_characteristic);
file_maximum_length_characteristic.setValue(file_maximum_byte_count);
...
}
I guess I need to convert the file_maximum_length_characteristic
to a const char*
and on the bluetooth app receives this as an array I believe.
The error is happening on this line:
file_maximum_length_characteristic.setValue(file_maximum_byte_count);
Here is the library function information:
instance-method setValue → bool Parameters:
const unsigned char * value unsigned char length // In BLECharacteristic public: virtual bool setValue(const unsigned char value[], unsigned char length)
Although this doesn't make sense as I can pass in 1 value and have, but it doesn't work when I am receiving the value from the app when I do that.
Here is the GitHub repo of the library.
This worked for me:
setValue((uint8_t*)&file_maximum_byte_count, sizeof(file_maximum_byte_count));