I am working on a project where I first need to build up the payload as a string then later on convert it to byte when sending the payload. I am having issues with conversion.
Reson why payload build-up is in string is due to the way it generates each single string, "02", "12", "31", "03" and "36" are the result after diffrent methods of calculations.
String lockHexString[5];
lockHexString[0] = "02";
lockHexString[1] = "12";
lockHexString[2] = "31";
lockHexString[3] = "03";
lockHexString[4] = "36"
Now when I have lockHexString, I need convert the lockHexString to byteArray, so It looks like
byte lockByte[5] = {0x02, 0x12, 0x31, 0x03, 0x36};
std. stackoverflow.com/questions/17261798/…char*strings, thenatoi()would be a simple solution. or Maybe if you could store your string as decString instead of hexString, then at least you could easily convert it to a byte with(uint8_t) String.toInt().