BLE.SendData from char array to uint8_t


#1

Hi to all,
I need your help to solve this problem.
I have data in char[] format and I need to transform to uint8_t to send.
This is the sample code from Reference:

// Send a three byte array of data
uint8_t data[3] = {0x01, 0x02, 0x03};
BLE.sendData(data, sizeof(data));

BLE.registerNotifications(radioCallbackHandler);

Best regards,
Michele.


#2

You can just send the char data directly after casting it to an array of uint8_t, like this:

    char data[3] = {0x01, 0x02, 0x03};
    BLE.sendData((uint8_t*)data, sizeof(data));

Both are 8-bit data types, so they are interchangeable.


#3

Thanks a lot Eric!!
Best regards,

Michele.