Error: invalid conversion from 'int32_t {aka long int}' to 'const char*' [-fpermissive]

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*'

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.

Error:

error: invalid conversion from 'int32_t {aka long int}' to 'const char*' [-fpermissive]
   file_maximum_length_characteristic.setValue(file_maximum_byte_count);

I have serious doubts that this is a tutorial. Topic moved.

I don't know what version of the ESP32 core you're using, but in v2.06 the only two overloads for the BLECharacteristic class's constructor are:

	BLECharacteristic(const char* uuid, uint32_t properties = 0);
	BLECharacteristic(BLEUUID uuid, uint32_t properties = 0);

Neither of those match what you're attempting to do.

The error is happening here:
file_maximum_length_characteristic.setValue(file_maximum_byte_count);

I'm using the library for nRF52.

Post the complete error message.

That link doesn't work.

It would have also been helpful for you to tell us you're using nRF52 in your first post.

Sorry. Fixed it.

How about?

For the characteristic you have chosen, the library has these ways to setValue.

setValue(const unsigned char value[], unsigned char length);
 setValue(const char* value);

Try
setValue((uint8_t*)&file_maximum_byte_count, sizeof(file_maximum_byte_count));

1 Like

Added the error message above

Thank you!!!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.