Two-way error-free RF messaging : avoiding concurrent retry failure


So we have our RF nodes happily talking to one another, and most often we have one talking, one listening. This is very easy, and facilitated even in poor reception by our built in SendWithRetry function (we’re speaking of the RFM69 library here, of course). This is what a unidirectional communication structure often looks lke:

A typical RF (or otherwise) communication structure. One talks, one listens

The Problem : The Retry Loop

The problem arises when we want to have two nodes talk to each other that sometimes have other stuff to do. The following situation arises, which results in failure of at least one of the communication attempts. Essentially, they get stuck in a a retry loop:

The retry loop. The boon of two-way communication.

The Solution : The State Machine

The solution is rather simple: tell one node to stop retrying until it’s had a chance to listen. In pseudocode, this looks like this:

The state machine: savior of two-way retry communication.

In Real Life

In real life, this is pretty easily coded using a switch statement, with a delay afterwards to allow enough time for radio messages to show up and complete. 100ms is more than sufficient.

Leave a Reply

Your email address will not be published. Required fields are marked *