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. Make node look for new/better parent without restarting

Make node look for new/better parent without restarting

Scheduled Pinned Locked Moved Development
8 Posts 4 Posters 2.1k Views 4 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 Offline
    H Offline
    Henrik Nielsen
    wrote on last edited by
    #1

    Hi

    In my MySensors network I have a ESP8288 MQTT gateway and two repeaters and a number of sensor nodes. One of these are a button-node that I like to move around in my house. This means that sometimes I move it from one end of the house to the other, so it can no longer connect to the parent node it used to use. I know how to request an acknowledgement in the send method so I can resend the button-press-message, but is there a way to "give up" a parent node after a number of failed transmissions, and broadcast for a new one?

    I know I can do this by pulling the battery and restarting the node, but I'd rather it just do it by itself :)

    mfalkviddM berkseoB 2 Replies Last reply
    0
    • H Henrik Nielsen

      Hi

      In my MySensors network I have a ESP8288 MQTT gateway and two repeaters and a number of sensor nodes. One of these are a button-node that I like to move around in my house. This means that sometimes I move it from one end of the house to the other, so it can no longer connect to the parent node it used to use. I know how to request an acknowledgement in the send method so I can resend the button-press-message, but is there a way to "give up" a parent node after a number of failed transmissions, and broadcast for a new one?

      I know I can do this by pulling the battery and restarting the node, but I'd rather it just do it by itself :)

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

      @henrik-nielsen welcome to the forum!
      I am not sure, but I think calling transportCheckUplink(true) before sending the message will verify connection to the gateway, and establish new parent if needed. Could you try it?

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Henrik Nielsen
        wrote on last edited by
        #3

        It sort of works, I get a ping and a missing pong:

        (254 is button node, 252 is repeater I turned off after the button node was started up)

        64442 TSF:PNG:SEND,TO=252
        64479 !TSF:MSG:SEND,254-254-252-252,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1
        66488 TSF:CKU:FAIL
        

        But no looking for a new parent.

        I tried calling some functions I thought sounded like they would help me, without really knowing. I guess it is not functions that a user like me really should use?:

        if ( !transportCheckUplink() ) {
          stParentTransition();
          while ( isTransportSearchingParent() ) {
            stParentUpdate();
          }
        }
        

        This starts what appears to be a new parent search, but it never completes:

        151171 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
        153180 !TSM:FPAR:NO REPLY
        153182 TSM:FPAR
        153219 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
        155228 !TSM:FPAR:NO REPLY
        155230 TSM:FPAR
        155267 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
        157276 !TSM:FPAR:NO REPLY
        157278 TSM:FPAR
        157315 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
        159324 !TSM:FPAR:FAIL
        159326 TSM:FAIL:CNT=7
        159328 TSM:FAIL:DIS
        159330 TSF:TDI:TSL
        161333 !TSM:FPAR:NO REPLY
        161335 TSM:FPAR
        

        At this point I have started my repeater again, and I think it should also find either the gateway or another node.

        mfalkviddM 1 Reply Last reply
        1
        • H Henrik Nielsen

          It sort of works, I get a ping and a missing pong:

          (254 is button node, 252 is repeater I turned off after the button node was started up)

          64442 TSF:PNG:SEND,TO=252
          64479 !TSF:MSG:SEND,254-254-252-252,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1
          66488 TSF:CKU:FAIL
          

          But no looking for a new parent.

          I tried calling some functions I thought sounded like they would help me, without really knowing. I guess it is not functions that a user like me really should use?:

          if ( !transportCheckUplink() ) {
            stParentTransition();
            while ( isTransportSearchingParent() ) {
              stParentUpdate();
            }
          }
          

          This starts what appears to be a new parent search, but it never completes:

          151171 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
          153180 !TSM:FPAR:NO REPLY
          153182 TSM:FPAR
          153219 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
          155228 !TSM:FPAR:NO REPLY
          155230 TSM:FPAR
          155267 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
          157276 !TSM:FPAR:NO REPLY
          157278 TSM:FPAR
          157315 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
          159324 !TSM:FPAR:FAIL
          159326 TSM:FAIL:CNT=7
          159328 TSM:FAIL:DIS
          159330 TSF:TDI:TSL
          161333 !TSM:FPAR:NO REPLY
          161335 TSM:FPAR
          

          At this point I have started my repeater again, and I think it should also find either the gateway or another node.

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

          @henrik-nielsen nice work. I am not sure about the internal functions. Pinging @tekka, maybe he can assist.

          1 Reply Last reply
          0
          • H Offline
            H Offline
            Henrik Nielsen
            wrote on last edited by
            #5

            I guess another way would be like this:

            if ( !transportCheckUplink() ) {
               asm volatile ("  jmp 0"); // CRASH, BURN AND RESET
             }
            

            It does the trick ... though it really bothers my developer-heart ;)

            T 1 Reply Last reply
            1
            • H Henrik Nielsen

              I guess another way would be like this:

              if ( !transportCheckUplink() ) {
                 asm volatile ("  jmp 0"); // CRASH, BURN AND RESET
               }
              

              It does the trick ... though it really bothers my developer-heart ;)

              T Offline
              T Offline
              tekka
              Admin
              wrote on last edited by
              #6

              @henrik-nielsen By default, a new parent it searched after 5 (regular node) or 10 (repeater) failed uplink transmissions - alternatively, you can be more restrictive, by setting MY_TRANSPORT_MAX_TX_FAILURES to anything smaller.

              1 Reply Last reply
              1
              • H Henrik Nielsen

                Hi

                In my MySensors network I have a ESP8288 MQTT gateway and two repeaters and a number of sensor nodes. One of these are a button-node that I like to move around in my house. This means that sometimes I move it from one end of the house to the other, so it can no longer connect to the parent node it used to use. I know how to request an acknowledgement in the send method so I can resend the button-press-message, but is there a way to "give up" a parent node after a number of failed transmissions, and broadcast for a new one?

                I know I can do this by pulling the battery and restarting the node, but I'd rather it just do it by itself :)

                berkseoB Offline
                berkseoB Offline
                berkseo
                wrote on last edited by berkseo
                #7

                @henrik-nielsen said in Make node look for new/better parent without restarting:

                n my MySensors network I have a ESP8288 MQTT gateway and two repeaters and a number of sensor nodes. One of these are a button-node that I like to move around in my house. This means that sometimes I move it from one end of the house to the other, so it can no longer connect to the parent node it used to use. I know how to request an acknowledgement in the send method so I can resend the button-press-message, but is there a way to "give up" a parent node after a number of failed transmissions, and broadcast for a new one?
                I know I can do this by pulling the battery and restarting the node, but I'd rather it just do it by itself

                It's part of my code, ... roughly so

                void check_parent() {
                  _transportSM.findingParentNode = true;
                  CORE_DEBUG(PSTR("MyS: SEND FIND PARENT REQUEST, WAIT RESPONSE\n"));
                  tx_led ();
                  _sendRoute(build(_msg, 255, NODE_SENSOR_ID, 3, 7).set(""));
                  wait(2000, 3, 8);
                  if (_msg.sensor == 255) {
                    if (mGetCommand(_msg) == 3) {
                      if (_msg.type == 8) {
                        Ack_FP = 1;
                        CORE_DEBUG(PSTR("MyS: PARENT RESPONSE FOUND\n"));
                      }
                    }
                  }
                  if (Ack_FP == 1) {
                    CORE_DEBUG(PSTR("MyS: FIND PARENT PROCESS\n"));
                    rx_led ();
                    Ack_FP = 0;
                    transportSwitchSM(stParent);
                    flag_nogateway_mode = 0;
                    flag_find_parent_process = 1;
                    CORE_DEBUG(PSTR("MyS: STANDART TRANSPORT MODE IS RESTORED\n"));
                  } else {
                    bc_led ();
                    _transportSM.findingParentNode = false;
                    CORE_DEBUG(PSTR("MyS: PARENT RESPONSE NOT FOUND\n"));
                    _transportSM.failedUplinkTransmissions = 0;
                    fp_timer = millis();
                  }
                }
                
                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  Henrik Nielsen
                  wrote on last edited by
                  #8

                  Sorry I haven't gotten back to you, been a busy week.

                  The MY_TRANSPORT_MAX_TX_FAILURES seems to do the job perfectly, I adjusted it down to 1 for the node, and resend the message a couple of times if it fails.

                  Thank you for your support :)

                  Also thanks to berkseo, your code also works for me, but I do prefer the built in way now that I know of it. Less code for me to write and maintain :)

                  1 Reply Last reply
                  1

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  17

                  Online

                  12.0k

                  Users

                  11.2k

                  Topics

                  113.4k

                  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