A serial input is taken from a python script on a PC, where the values of the ASCII string are 4x 0-255 with colon as end of line. The Pro Micro then takes a String from serial.read, I hear it is better to use char arrays so converts to this. To best optimise radio link it is wise to send minimum amount of data, in my case ASCII is not required as all values are supplied in the range of 0 - 255 the range of a byte.
Therefore I need to split the char array, I have tried and failed miserably with following thoughts.
- Slice into 4 ints then convert ints, just using byte = integer value of XXX
- Direct interperation of char values [0 to 2],[3 to 5]... to bytes
Simply put: How best to take char array (123123123123) of 4x 0-255 values into bytes to be transmitted over the RF24 library.
serialIN = Serial.readStringUntil(':'); //This is blocking serialIN = "123123123123:"; //For testing XXXYYYZZZTTT
Which then is converted to char array:
serialIN.toCharArray(txOUT,13); //Char array - 12(+1) bytes
Which once coverted needs to be sent using:
ack_rec = radio.write(SEND_BYTES_HERE, sizeof(SEND_BYTES_HERE)); //Sends PPPRRRYYYTTT
I've also seen structs while trying to search for an answer for this, I'm assuming that 4x byte values will be better placed in some sort of byte array?
Many thanks! (And apologies for what seems like a simple question)