How does the mesh network work with MySensors ?
jmd last edited by jmd
I didn't use MySensors yet, but I'm trying to understand how it works, especially the mesh network auto-linking.
I tried to find answers in the source code of the version 2.0, but finding answers isn't easy.
Could someone explain me the message exchanges allowing the mesh network to exist ?
I found few things:
And specific questions:
- How are circular links avoided ?
- How the nearest repeater is chosen as a parent ?
- Does it works if two gateways are nearby (for example, my neighbor and I are both using MySensors)
- How does the sensor find the shortest way to the gateway ?
Mesh is probably the wrong word. I would rather say if forms a mesh tree.
When a node is losing "connection" with its parent (that is, doesn't receive any inter-node-ack when sending a message) it will send out a broadcast message that will be picked up by all repeaters and the gateway in range.
The repeater/gateway will answer the request, including how many hops it has to the gateway. So it's not physical distance we're talking about here. The NRF radio does not provide any RSSI value either so it is impossible to take that into account. RFM69 on the other hand does have RSSI so we might use that in the future to determine best path when the number of hops are the same.
So you must include enough repeaters to avoid "islands" in the radio network (without any path to the gateway). Circular links won't happen because of the rules of choosing parent.
jmd last edited by
Thank you for your answer.
Do you have any documentation on the messages exchanges to determine the parent ? The number of hops ?
But the state machine code has inlined comments here:
A conceptual drawing of the network is available at https://www.mysensors.org/about/network in case you haven't found it already.