I have a string: String outputValue = ""
that I then append to to build a JSON-like structure to send to a remote device. This code runs on an ATMEGA328P using the Arduino bootloader. I append values by doing outputValue += "hello"
.
The library I am using to send the values needs a uint8_t *
for it's payload with the associated length of that payload. Is there any way to cast/convert this String to a uint8_t array or is there a preferred way to do a builder rather than using String? I'm open to any suggestions
My working code that I used to test the library has the following. Note, this is just the result of me copying the raw outputValue to Notepad, enclosing each character in single quotes, then hardcoding this new array to test:
uint8_t testCmd[] = { '{', '"', 'T', '"', ':', '"', 'A', '1', '"', ',', '"', 'E', '"', ':', '-', '1', ',', '"', 'I', '"', ':', '[', '[', '1', ',', '[', '[', '[', '[', '2', '5', '0', ',', '2', ']', ',', '[', '0', ',', '4', ']', ']', ']', ']', ']', ']', '}' };
ZBTxRequest txReq = ZBTxRequest(coordinatorAddr64, testCmd, sizeof(testCmd));
ZBTxStatusResponse txResp = ZBTxStatusResponse();
xbee.send(txReq);