Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Is there a way to check presence of a MySensors network, and proceed without if not found ?

Is there a way to check presence of a MySensors network, and proceed without if not found ?

Scheduled Pinned Locked Moved Development
22 Posts 7 Posters 2.4k Views 7 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Heizelmann

    @dbemowsk Search for node to node communication, you will find e.g.
    https://forum.mysensors.org/topic/8716/direct-pairing-of-two-nodes-implementation
    https://forum.mysensors.org/topic/826/node-to-node-communication and maybe some more.

    dbemowskD Offline
    dbemowskD Offline
    dbemowsk
    wrote on last edited by
    #6

    @heizelmann I just asked because I figured that was where the OP was going with the question. Good to know though.

    Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
    Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

    GertSandersG 1 Reply Last reply
    0
    • dbemowskD dbemowsk

      @heizelmann I just asked because I figured that was where the OP was going with the question. Good to know though.

      GertSandersG Offline
      GertSandersG Offline
      GertSanders
      Hardware Contributor
      wrote on last edited by
      #7

      I'm now using this define MY_TRANSPORT_WAIT_READY_MS to get a "timeout" and I also use isTransportReady() to check if my device needs to work in stand-alone mode or if it is connected to the MySensors network once I exit the setup() fase.

      I do not need to do node to node signalling without GW, but the info provided is nice to know :-)

      PetjepetP 1 Reply Last reply
      0
      • GertSandersG GertSanders

        I'm now using this define MY_TRANSPORT_WAIT_READY_MS to get a "timeout" and I also use isTransportReady() to check if my device needs to work in stand-alone mode or if it is connected to the MySensors network once I exit the setup() fase.

        I do not need to do node to node signalling without GW, but the info provided is nice to know :-)

        PetjepetP Offline
        PetjepetP Offline
        Petjepet
        wrote on last edited by
        #8

        @gertsanders Can you show your script on this with the define MY_TRANSPORT_WAIT_READY_MS to get a "timeout" and using the TransportReady() ?

        I would like to do the same with my BBQ-temp node since it has it's own display (node is for convenience to check temps on iPhone but not always needed).

        GertSandersG 1 Reply Last reply
        0
        • gohanG Offline
          gohanG Offline
          gohan
          Mod
          wrote on last edited by
          #9

          just put " if TransportReady()" condition at beginning of loop and then execute code you want executed only if node is connected

          1 Reply Last reply
          0
          • PetjepetP Petjepet

            @gertsanders Can you show your script on this with the define MY_TRANSPORT_WAIT_READY_MS to get a "timeout" and using the TransportReady() ?

            I would like to do the same with my BBQ-temp node since it has it's own display (node is for convenience to check temps on iPhone but not always needed).

            GertSandersG Offline
            GertSandersG Offline
            GertSanders
            Hardware Contributor
            wrote on last edited by
            #10

            @petjepet

            As @gohan mentioned, you need to add the test in the loop. But you can also add it to the setup() function. I did find that sometimes the link with the network is not yet active at the start of setup(). But by the end of the setup() (in my case I need to start several objects), it is usually OK.

            The define is just so that a timout is limited. I found 5 seconds a bit long, so I set it to 2 seconds

            #define MY_TRANSPORT_WAIT_READY_MS 2000
            

            and then in code I test:

            void loop() {
            if (isTransportReady())
            {
            // do stuff with network in place
            }
            else
            {
            // do stuff without network in place
            }
            
            } // end of loop()
            
            1 Reply Last reply
            0
            • PetjepetP Offline
              PetjepetP Offline
              Petjepet
              wrote on last edited by Petjepet
              #11

              @GertSanders The define was sufficient in my case:

              #define MY_TRANSPORT_WAIT_READY_MS 2000
              

              The sketch continues on startup when not able to connect (my BBQ-temp node is working stand alone) but will keep on trying to connect. When the gateway is found it will connect and the data is available on iPhone.

              Thanks!

              1 Reply Last reply
              0
              • GertSandersG GertSanders

                I have a question I could not answer based on the documentation:

                Is there a way to check presence of a MySensors network, and proceed without if not found ?

                I would like to make a device that connects to a MySensors network if there is one, but can go into "standalone" mode if no network is present.

                Right now it seems the node keeps trying to connect and never reaches the setup() function. It does pass the before() function.

                NeverDieN Offline
                NeverDieN Offline
                NeverDie
                Hero Member
                wrote on last edited by NeverDie
                #12

                @gertsanders said in Is there a way to check presence of a MySensors network, and proceed without if not found ?:

                I have a question I could not answer based on the documentation:

                Is there a way to check presence of a MySensors network, and proceed without if not found ?

                I would like to make a device that connects to a MySensors network if there is one, but can go into "standalone" mode if no network is present.

                Right now it seems the node keeps trying to connect and never reaches the setup() function. It does pass the before() function.

                This should be the default behavior IMHO. Otherwise, your node just hangs and is a nightmare to troubleshoot for new users.

                mfalkviddM 1 Reply Last reply
                0
                • NeverDieN NeverDie

                  @gertsanders said in Is there a way to check presence of a MySensors network, and proceed without if not found ?:

                  I have a question I could not answer based on the documentation:

                  Is there a way to check presence of a MySensors network, and proceed without if not found ?

                  I would like to make a device that connects to a MySensors network if there is one, but can go into "standalone" mode if no network is present.

                  Right now it seems the node keeps trying to connect and never reaches the setup() function. It does pass the before() function.

                  This should be the default behavior IMHO. Otherwise, your node just hangs and is a nightmare to troubleshoot for new users.

                  mfalkviddM Offline
                  mfalkviddM Offline
                  mfalkvidd
                  Mod
                  wrote on last edited by
                  #13

                  @neverdie by "this", do you mean the current MySensors behavior, or the behavior suggested by gertsanders?

                  GertSandersG NeverDieN 2 Replies Last reply
                  0
                  • mfalkviddM mfalkvidd

                    @neverdie by "this", do you mean the current MySensors behavior, or the behavior suggested by gertsanders?

                    GertSandersG Offline
                    GertSandersG Offline
                    GertSanders
                    Hardware Contributor
                    wrote on last edited by
                    #14

                    @mfalkvidd

                    I'm not sure if the current default behaviour of MySensors is to wait for 5 seconds before giving up and moving on. I was under the impression that a node would try to find a network until my hair grows back.

                    When the define is included in the sketch, it clearly does it's job.

                    @NeverDie probably meant that we should not need to set the define, unless we want to change the default 5sec wait time, or if we explicitly want to have the node hang until a network is found.

                    So the question is, is the default behaviour to keep looking for a network, or does the library stop after 5sec and move on with the setup() ?

                    mfalkviddM 1 Reply Last reply
                    0
                    • GertSandersG GertSanders

                      @mfalkvidd

                      I'm not sure if the current default behaviour of MySensors is to wait for 5 seconds before giving up and moving on. I was under the impression that a node would try to find a network until my hair grows back.

                      When the define is included in the sketch, it clearly does it's job.

                      @NeverDie probably meant that we should not need to set the define, unless we want to change the default 5sec wait time, or if we explicitly want to have the node hang until a network is found.

                      So the question is, is the default behaviour to keep looking for a network, or does the library stop after 5sec and move on with the setup() ?

                      mfalkviddM Offline
                      mfalkviddM Offline
                      mfalkvidd
                      Mod
                      wrote on last edited by mfalkvidd
                      #15

                      @gertsanders according to the documentation, the default value is 0 which means to wait forever.

                      Where did you get the 5 seconds from?

                      GertSandersG 1 Reply Last reply
                      0
                      • mfalkviddM mfalkvidd

                        @gertsanders according to the documentation, the default value is 0 which means to wait forever.

                        Where did you get the 5 seconds from?

                        GertSandersG Offline
                        GertSandersG Offline
                        GertSanders
                        Hardware Contributor
                        wrote on last edited by GertSanders
                        #16

                        @mfalkvidd from an example where it mentioned

                        #define MY_TRANSPORT_WAIT_READY_MS 5000
                        

                        I would expect this to be the default, and not '0'

                        mfalkviddM 1 Reply Last reply
                        0
                        • GertSandersG GertSanders

                          @mfalkvidd from an example where it mentioned

                          #define MY_TRANSPORT_WAIT_READY_MS 5000
                          

                          I would expect this to be the default, and not '0'

                          mfalkviddM Offline
                          mfalkviddM Offline
                          mfalkvidd
                          Mod
                          wrote on last edited by mfalkvidd
                          #17

                          @gertsanders I see. To me, providing an example that sets the value to its default value would make little sense since setting it would not change anything. But everyone interprets things based on prior experiences, and everyone's experiences are different.

                          I am unable to find an example that sets MY_TRANSPORT_WAIT_READY_MS in the MySensors git repo. Do you remember where you saw it?

                          GertSandersG 1 Reply Last reply
                          0
                          • mfalkviddM mfalkvidd

                            @neverdie by "this", do you mean the current MySensors behavior, or the behavior suggested by gertsanders?

                            NeverDieN Offline
                            NeverDieN Offline
                            NeverDie
                            Hero Member
                            wrote on last edited by
                            #18

                            @mfalkvidd said in Is there a way to check presence of a MySensors network, and proceed without if not found ?:

                            the behavior suggested by gertsanders

                            the behavior suggested by gertsanders

                            1 Reply Last reply
                            1
                            • mfalkviddM mfalkvidd

                              @gertsanders I see. To me, providing an example that sets the value to its default value would make little sense since setting it would not change anything. But everyone interprets things based on prior experiences, and everyone's experiences are different.

                              I am unable to find an example that sets MY_TRANSPORT_WAIT_READY_MS in the MySensors git repo. Do you remember where you saw it?

                              GertSandersG Offline
                              GertSandersG Offline
                              GertSanders
                              Hardware Contributor
                              wrote on last edited by
                              #19

                              @mfalkvidd
                              Nope, I probably got this from a forum message somewhere. I’m not sure where I got the suggestion to use the define.
                              The thing is, it is very nice to have this #define, but as @Neverdie said, it would be nice to avoid that a node “hangs” if the gateway is unavailable. As far as I can see, there is no DEBUG message if the network is not reachable. And for a new MySensors user a hanging node is really confusing (it is sometimes for me as well). So this #define will now be part of me ‘default’ template until the standard behaviour is adapted.

                              mfalkviddM 1 Reply Last reply
                              0
                              • GertSandersG GertSanders

                                @mfalkvidd
                                Nope, I probably got this from a forum message somewhere. I’m not sure where I got the suggestion to use the define.
                                The thing is, it is very nice to have this #define, but as @Neverdie said, it would be nice to avoid that a node “hangs” if the gateway is unavailable. As far as I can see, there is no DEBUG message if the network is not reachable. And for a new MySensors user a hanging node is really confusing (it is sometimes for me as well). So this #define will now be part of me ‘default’ template until the standard behaviour is adapted.

                                mfalkviddM Offline
                                mfalkviddM Offline
                                mfalkvidd
                                Mod
                                wrote on last edited by
                                #20

                                @gertsanders I think people have posted debug messages like this that indicate that the transport is not ready:

                                !TSP:SEND:TNR
                                

                                But that probably only happens when the node is trying to send. If the node is not trying to send, there is no way to determine if transport is available.

                                1 Reply Last reply
                                0
                                • PetjepetP Offline
                                  PetjepetP Offline
                                  Petjepet
                                  wrote on last edited by
                                  #21

                                  I think it is logical to have sensors try indefinitely since this is the concept of sensors in a network.
                                  Otherwise you would not know (when not debugging) all is ok in your network.
                                  A network sensor not being one in an usual way, just for convenience (like my BBQ-temp sensor), has to be defined otherwise.

                                  1 Reply Last reply
                                  0
                                  • gohanG Offline
                                    gohanG Offline
                                    gohan
                                    Mod
                                    wrote on last edited by
                                    #22

                                    If you configure the controller to send notifications when nodes don't report anything after 1 or 2 hours, you know that something is wrong without draining the battery in the process.

                                    1 Reply Last reply
                                    0
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    14

                                    Online

                                    11.7k

                                    Users

                                    11.2k

                                    Topics

                                    113.1k

                                    Posts


                                    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • MySensors
                                    • OpenHardware.io
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular