Lately I’ve been working on a way to make the communication between the STM and the ESP more reliable.
While searching on the subject, I came across two methods.
The first one made me reminisce some of the lessons we had in first year about information theory. The idea is to use a Hamming code for the messages of the protocol. This will make the communication more robust because of the properties of such a code. We plan to use a Hamming code (7,4) which means that the words will be 7 bits wide, with 4 bits of information (meaning we can go up to 16 different words, including the words with only bits at 0) and 3 bits of parity. This code also has the property of having a Hamming distance of 3 which is most interesting property for us. This means that to mistake a message for another, 3 errors must occur in the same word which makes it way more robust than the previous coding we intended to use (some words had a Hamming distance of only 1).
Another interesting property of this code is the ability to correct messages where a unique error occurred, but we choose not to implement this property for the moment.
The second method we will use to increase communication reliability is to add a checksum and append the data payload with the computed result.
We choose to use a CRC mostly because of what’s pointed out in this article : MAXINO, Theresa C. The effectiveness of checksums for embedded networks. Department of Electrical and Computer Engineering, Carnegie Mellon University, Pittsburgh, Pennsylvania, USA, 2006.
The receiver of the data message will strip and store the CRC value transmitted, compute its own value and then check if it matches the received CRC value. If it does, there is a good chance that the communication went as intended.
After this research phase, I’m currently trying to add a dummy CRC behavior that justs add a constant byte at the end of the data payload. This implies going through the code already written by Ilan, and adapting it to implement the desired feature. I must admit I’ve taken more time than expected to understand the code to a good point.