I agree with you that the situation is unclear. For a better understanding of what's going on I would add some informations in the debug message in case of incorrect message: the length of the received buffer and its raw content, using a function like this one that outputs the array of bytes in the string in hex format:
Fmt (msg, "0x%*d[zb1w2p0r16j1] ", strlen (receivedMsg), receivedMsg);
It could probably be a good thing to also print the time value with milliseconds in Terminal_Writeline () function.