I am using Arduino. I have the following code which converts binary data to its ASCII equivalent. It uses the String object.
static uint16_t index = 0;
static char buffer[1600]; //contains binary data 0x11, 0x22, 0x1, 0xa ...
String msg;
index = strlen(buffer);
for (i=0; i < index; i++)
{
//Produce a zero in front for single digits. Examples, 0x5 transforms into 05, 0xa transforms into 0a
if (buffer[i] <= 0x0F)
{
msg += "0";
}
msg += String(buffer[i], HEX); //msg contains the ASCII equivalent of buffer
}
How can the code be modified such that the String object is not used but the same objective is accomplished?
static uint16_t index = 0;andfor (i=0; i < index; i++)are you sure that's correct?