Discover network topology?
https://forum.mysensors.org/topic/2680/data-stored-in-the-eeprom/1 has some example code how to extract the routing information (from EEPROM on a node)
The parent node number comes from the payload in the I_CONFIG request that the node sends at startup (or when you send I_PRESENT request to the node).
@sundberg84 Thanks! Unfortunately, the API does not tell me anything about the contents of the payload of internal messages like
Init complete, id=0, parent=0, distance=0, registration=1 TSP:MSG:READ 3-3-0 s=1,c=1,t=1,pt=7,l=5,sg=0:62.00 TSP:SANCHK:OK
I can guess what some of these things mean, but I would really like to read some documentation to make sure that my interpretations are correct.
@mfalkvidd Thanks. It might be the case that I can find each node's parent in the EEPROM, but I would like to be able to read the topology "run time". I.e., while the system is in production.
@hek This might be what I was looking for, thanks, I'll try it out!
@darkhorse - check this then: https://forum.mysensors.org/topic/2579/about-serial-api-1-5/2
@sundberg84 Great, thanks!
(pity that there is no official doc, however, but this should suffice for now)
@darkhorse - check debug/faq/how to ask for help in the forum, its kind of official and you find it there as well.
@hek After a week, I've found some time to test your advice and tried to send the I_PRESENT-message to some of my nodes. The reply that I get unfortunately is not totally clear to me. Can you help me out some more? I've tried sending the message to nodes 1 (being closest to the gateway) and 4 (being far from the gateway and with some nodes in between). I got the following response:
Sent to module 1:
Received from module 1 (duplicate lines removed):
1;255;0;0;18;2.0.0 1;255;3;0;6;0 1;255;3;0;6;M 1;0;0;0;6; 1;1;0;0;7; 1;2;0;0;1;
Sent to module 4:
Received from module 4 (duplicate lines removed):
4;255;3;0;6;3 4;255;3;0;6;M 4;255;0;0;18;2.0.0 4;255;3;0;6;3 4;2;0;0;3;
If I had to guess, I'd say that the lines '1;255;3;0;6;0' and '4;255;3;0;6;3' are the ones that I am looking for. They seem to tell me that
- the parent of node 1 is node 0 (the gateway) and
- the parent of node 4 is node 3 (a node that is physically somewhere in between the gateway and node 4).
Before I draw conclusions, however, I'd really like to know if I'm correct. Can you confirm this? And if so, can I safely assume that any I_CONFIG-message received not containing an 'M' or 'I' in the payload tells me the parent-node?
Thank you very much!
Yes, you are right..
It's a little weird that you receive a message with the payload "M"... Are you sure that it isn't the outgoing reply we're seeing here? Node should not send in anything else with the config request.
@hek You are right, I forgot that I configured my controller to respond to a I_CONFIG request by sending an 'M'. Apparently, a config request and an answer to I_PRESENT are the same message, so my controller does not differentiate its behaviour.
Anyway, thanks for your fast reply, this really helps me out!