How does the mesh network work with MySensors ?



  • Hi,

    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:

    • DISCOVERY
    • PING
    • FIND_PARENT

    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 ?

    Thanks !

    JM


  • Admin

    Mesh is probably the wrong word. I would rather say if forms a mesh tree.

    Simplified:
    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.

    More info

    If you and your neighbour is using MySensors, one of you would have to change channel or base radio id. The same applies when you have multiple gateways.



  • Thank you for your answer.
    Do you have any documentation on the messages exchanges to determine the parent ? The number of hops ?


  • Admin

    Unfortunately, no.

    But the state machine code has inlined comments here:
    https://github.com/mysensors/MySensors/blob/development/core/MyTransport.cpp


  • Mod

    A conceptual drawing of the network is available at https://www.mysensors.org/about/network in case you haven't found it already.


Log in to reply
 

Suggested Topics

  • 1
  • 2
  • 198
  • 5
  • 2
  • 1

24
Online

11.2k
Users

11.1k
Topics

112.5k
Posts