I was communicating with two RAK3172 modules in P2P mode without encryption. Then I wanted to do encryption and I encrypted the payload with commands. I wrote the same codes in the receiver and transmitter part. But after uploading the new codes, I decode the received data and verify that I solved it. The data I decode comes in HEX format correctly. After applying the HEX to ASCII process on an online site, I can read the data correctly. But the code below fails to translate correctly when converting to ASCII for me. Can you help?
Note: This issue arose when I started using AES128 encryption. Oddly enough, the decrypting is successful so I can read the decrypted HEX data properly.
@Kongduino@carlrowan Guys please help. As you can see below im getting a weird problem. As shown in comments, i explained the process.
+EVT:RXP2P:-22:7:9A1FCEF3CB64A39E20BC58BDD096AFE7 // IF YOU CONVERT HEX TO ASCII YOU'LL SEE = ÎóËd£ ¼X½Ð¯ç
11:54
Incoming message: 1,11,23 // BUT THIS LINE SHOWS CORRECT DATA
11:54
Sensor ID: 1
11:54
Match ID: 11
11:54
Data: 23
11:54
//AT HERE, WITH THE "AT+ENCRY=1" COMMAND ENCRYPTION ENABLED. AND THE ENCRYPTION KEY SET SAME IN DEVICES BEFORE.
11:55
+EVT:RXP2P:-23:6:312C31312C3234 // IF YOU CONVERT HEX TO ASCII YOU'LL SEE = 1,11,24
11:55
Incoming message: `�m�0f // BUT THIS LINE SHOWS FALSE DATA
11:55
Sensor ID: `�m�0f
11:55
Match ID:
11:55
Data:
11:55
void hex2array(uint8_t *src, uint8_t *dst, size_t sLen) {
size_t i, n = 0;
for (i = 0; i < sLen; i += 2) {
uint8_t x, c;
c = src[i];
if (c != '-') {
if (c > 0x39) c -= 55;
else c -= 0x30;
x = c << 4;
c = src[i + 1];
if (c > 0x39) c -= 55;
else c -= 0x30;
dst[n++] = (x + c);
}
}
}
Also, note that the encryption scheme in RUI3 is broken – has been for a while – and might get fixed in a release down the line. Use software AES code from my repositories.
I hope we have the encryption fixed with V4.0.2.
Right now the team is fixing a bug we found in V4.0.0 which is critical. V4.0.1 should be released within the next days, then they work on the encryption.