tldr; I am writing a mesh network software using arduinos. I need to wirelessly receive, process, and transmit data, all simultaneously. I am aware of protothreads library, and the other software solutions, such as using interrupts, however, I am using relatively high baud rates. Thus each nanosecond is of the essence. Does anyone have any other ideas for me to achieve this? my initial thought is to have 2 Arduinos functioning as a single node in the mesh. One will receive while the other transmits.
I am currently using these antennas to receive and send messages. I want to create a mesh network of Arduinos using these modules. I found several mesh libraries for Arduino, but none seem to quite do the task I need. So here is my plan which I will work through using an example. (This is a very naive explanation, and has flaws in it's implementation. This is just to give off the general idea).
Each Arduino will be connected to a receiver and a transmitter. Let's say I have just 4 nodes in the mesh.
- Node #1 -> Address = 0xA031
- Node #2 -> Address = 0xB042
- Node #3 -> Address = 0xC053
- Node #4 -> Address = 0xD064
I send a message to node A through USB. Let's say the message is "SOS!" Node A will reconstruct the message in the following way so that the new message is "0xA031_SOS!"
Now, Node A will begin transmitting this message continually. Let's say only Node C picks up the message. Node C will pick up the message and perform the following checks. (I will have 2 queues. A receiving queue and a transmitting queue. So as soon as a node receives a message, it will be placed in the receiving queue. And then it will run the following checks before sending it to the transmitting queue.)
- Is the address a recognized/valid address? Handle appropriately
Is the address of the received message the same as the node's own address?
If address is same, check if the message received is the same message being transmitted currently by itself. If so, discard the message and tell transmitter to stop transmitting that message(This means that the message was originally transmitted to another node and came back, which means, it doesn't need to be re-transmitted any more). If the address is not the same, then send the message to the transmission queue.
Now the transmission will be handled the following way.
- Check if there is anything in the transmission queue. If there is, transmit this message continually until told not to.
- If the transmitter is told to not transmit that message any longer, that message will be popped of the queue.
So what happens? Node A continually sends a message. Node C receives the message and re-transmits. Because Node C was able to pick up Node A's message, it is in range and Node A will pick up Node C's message. Now, Node A will check the address, and say "oh, this is the same address as me." Then it will check if the message being transmitted is the same as what was received. If so, then it will tell the transmission queue to no longer transmit that message. (This almost like a form of back propagation).
Now I realize there are a million ways to have collisions and infinite loops. I will be eventually writing a software to resolve these things. But I hope I am giving off the general idea of how the network will work.
- As is clear from my explanation, because I am receiving and transmitting simultaneously, is there a way for me to do multi-threading? I am aware of protothreads and the other things mentioned in this post. However, all of them only offer a software solution, and not a hardware solution. So does anyone have any ideas of how I'd work around this? My initial thought is to have each node be composed of 2 Arduinos. Any one have any other ideas?
- Also, does anyone have a better idea of implementing the mesh to do what I want it to?
I know this is a very convoluted, hefty post. Please let me know what I should clarify. Thank you.