Indeed, though twice for each run. Should probably be something like:
for (int i = 0; i < messageLength; i++) {
Serial1.print(message.charAt(i), HEX);
}
Serial1.write("\r\n");
Also, uncnf
does not seem to allow for a confirmation from your server:
Serial1.write("mac tx uncnf 1 ");
And I'm confused now: for the above message as sent by the node, are you receiving the same JSON you get after making your server respond to the message?
(Finally, not to spoil the fun: on The Things Network sending a message every 20 seconds, even when only a single byte, will hit the Fair Access Policy quite soon, even more so if every message is a confirmed message. See Limitations: data rate, packet size, 30 seconds/day Fair Access Policy, nodes per gateway and Spreadsheet for LoRa airtime calculation. When sending 1 byte all day long, in best conditions, you can only send one unconfirmed message every 2 minutes.)