MQTT over RS485
- Make use of standard MQTT topic, value, and QoS structure
- Miltidrop serial over RS485
- No master required
topic = network1/node2/device3/catagory4/key5 value = value QoS = 0, 1 or 2
MQTT Serial Structure
&network1/node2/device3/catagory4/key6=value (+newline \n)
Subscribe request, single reading:
Subscribe request, updates when reading varies by more than 0.5 since last post, at least every hour:
Subscribe request, with alias:
With wildcards (from every device).
Communication is at Node level.
Each node stores list of other nodes.
Queue order is last message age descending, based on an integer ticket derived from unix timestamp.
Each node stores message tickets going back 1000 max typically, as well as its own previous tickets.
A post contains the next ticket on the list, been the oldest on its list. The owner of that ticket then follows.
New Ticket, [Post], Next Ticket
Once post is made a node defers to the next oldest node on the list. This way each node is given equal share, and there is no need to delay between messages, with a clear order to follow in a loop. If a system is missed on one list it will turn on another, so registering a new device on a single existing device will pull newcomer into message loop.
No system sends until it is called to. The act of subscribing adds new entries to the lists, and places them at the oldest (first in queue) system.
If a system does not respond for more than 3 seconds then next on list is called for by the previous poster. Before long the problem unit will drop off all lists.
While a master is not required, initiation of communications loop is required, as well as registering new nodes.
If a node is called a second time within 1 seconds it will pause.
Every minute, a node will post a delay post, and delay 1s to allow broadcast from new nodes. A random delay on new node response reduces collisions.