Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. Henrik Nielsen
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Henrik Nielsen

    • RE: SmartSleep wake up message always get NACK

      @berkseo Great 🙂 I am currently trying to figure out what my employers policy for open source contributions made in their employees spare time is, so I could make the pull request myself, but you beat me to it 😞

      posted in Development
      Henrik Nielsen
      Henrik Nielsen
    • RE: SmartSleep wake up message always get NACK

      @berkseo I just started wondering if "everyone" uses cheap chinese radios, should this fix be part of the official code base?

      Maybe just as something that could be enabled if needed.

      posted in Development
      Henrik Nielsen
      Henrik Nielsen
    • RE: SmartSleep wake up message always get NACK

      It works 😄 You're a wizard @berkseo 🙂

      I do infact use the cheap radio modules from china, so I think you're right about the possible lacking of quality in the hardware 😕

      I guess there is not a way I can change these settings somewhere local to my sketch, so they do not get overwritten the next time I update the MySensors lib?

      Anyway, it's great that it works now, and I will just bookmark this topic for future reference.

      Thank again for your assistance 🙂

      posted in Development
      Henrik Nielsen
      Henrik Nielsen
    • RE: SmartSleep wake up message always get NACK

      I guess if I could just turn off the wake up / post-sleep message, everything would still kinda work. MyController will react to the pre-sleep message and send any pending messages, so the problem is just the 2 seconds of wasted battery everytime it try to send the wake up messages.

      There might of course be other implications that I am not aware of 🙂

      posted in Development
      Henrik Nielsen
      Henrik Nielsen
    • RE: SmartSleep wake up message always get NACK

      @berkseo Thank you for your suggestions, I have tried both.

      • I moved the node up right next to the gateway, so there are no repeaters in between. I still get NACK on the wake up message. And I can see in the gateway log that the wake up message are not received by the gateway. The other message still shows up just fine. In the output below you can see it sends directly to node 0

      • I also added a wait(200) after the sleep, still get the same error, but I guess it is because the wake up message are sent before the sleep method returns?

      • Using sleep(1000, true) instead of smartSleep, same result, but I'll start using sleep(nnn, true) instead anyway 🙂

      New code:

      #define MY_DEBUG
      #define MY_RADIO_NRF24
      #define MY_RF24_CHANNEL 0x44
      #define MY_RF24_BASE_RADIO_ID 0x00,0xf6,0x4d,0x89,0xc0
      #include <MySensors.h>
      
      void presentation() {
        sendSketchInfo("SmartSleepTest", "1.0");
        present(1, S_INFO, "Info");
      }
      
      void loop() {
        sleep(1000, true);
        wait(200);
      }
      

      Output:

      16 MCO:BGN:INIT NODE,CP=RNNNA---,VER=2.3.0
      26 TSM:INIT
      28 TSF:WUR:MS=0
      34 TSM:INIT:TSP OK
      36 TSF:SID:OK,ID=204
      38 TSM:FPAR
      75 TSF:MSG:SEND,204-204-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      686 TSF:MSG:READ,0-0-204,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      692 TSF:MSG:FPAR OK,ID=0,D=1
      708 TSF:MSG:READ,0-201-204,s=255,c=3,t=25,pt=1,l=1,sg=0:2
      714 !TSF:MSG:PONG RECV,INACTIVE
      854 TSF:MSG:READ,202-202-204,s=255,c=3,t=8,pt=1,l=1,sg=0:1
      880 TSF:MSG:READ,203-203-204,s=255,c=3,t=8,pt=1,l=1,sg=0:1
      2084 TSM:FPAR:OK
      2084 TSM:ID
      2086 TSM:ID:OK
      2088 TSM:UPL
      2093 TSF:MSG:SEND,204-204-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      2101 TSF:MSG:READ,0-0-204,s=255,c=3,t=25,pt=1,l=1,sg=0:1
      2107 TSF:MSG:PONG RECV,HP=1
      2109 TSM:UPL:OK
      2111 TSM:READY:ID=204,PAR=0,DIS=1
      2117 TSF:MSG:SEND,204-204-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
      2127 TSF:MSG:READ,0-0-204,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      2136 TSF:MSG:SEND,204-204-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.0
      2146 TSF:MSG:SEND,204-204-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
      2242 TSF:MSG:READ,0-0-204,s=255,c=3,t=6,pt=0,l=1,sg=0:M
      2254 TSF:MSG:SEND,204-204-0-0,s=255,c=3,t=11,pt=0,l=14,sg=0,ft=0,st=OK:SmartSleepTest
      2265 TSF:MSG:SEND,204-204-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
      2275 TSF:MSG:SEND,204-204-0-0,s=1,c=0,t=36,pt=0,l=4,sg=0,ft=0,st=OK:Info
      2283 MCO:REG:REQ
      2289 TSF:MSG:SEND,204-204-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      2297 TSF:MSG:READ,0-0-204,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      2304 MCO:PIM:NODE REG=1
      2308 MCO:BGN:INIT OK,TSP=1
      2310 MCO:SLP:MS=1000,SMS=1,I1=255,M1=255,I2=255,M2=255
      2318 TSF:MSG:SEND,204-204-0-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=0,st=OK:500
      2826 TSF:TDI:TSL
      2828 MCO:SLP:WUP=-1
      2830 TSF:TRI:TSB
      4513 !TSF:MSG:SEND,204-204-0-0,s=255,c=3,t=33,pt=5,l=4,sg=0,ft=0,st=NACK:1000
      4722 MCO:SLP:MS=1000,SMS=1,I1=255,M1=255,I2=255,M2=255
      4728 TSF:MSG:SEND,204-204-0-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=1,st=OK:500
      5238 TSF:TDI:TSL
      5240 MCO:SLP:WUP=-1
      5242 TSF:TRI:TSB
      6926 !TSF:MSG:SEND,204-204-0-0,s=255,c=3,t=33,pt=5,l=4,sg=0,ft=0,st=NACK:1000
      
      posted in Development
      Henrik Nielsen
      Henrik Nielsen
    • RE: SmartSleep wake up message always get NACK

      @Yveaux I checked, and no, the gateway does not receive the wake up message with payload 1000. It does receive the pre-sleep message with 500 ms, so I'm pretty sure I'm looking the right place 🙂

      posted in Development
      Henrik Nielsen
      Henrik Nielsen
    • SmartSleep wake up message always get NACK

      Hi

      I'm struggling a bit with the smartSleep functionality in MySensors.

      I know it should be straight forward, since it appears that the usage of sleep and smartSleep methods are basically the same from a developers perspective, but for some reason, the "wake up" message the node sends when the smart sleep is over, never gets sent. I almost never see messages that I manually send with sensor data etc. getting NACK'ed, and this happens on every single wake.

      Below is a tiny PoC test I have made. I kept it as simple as possible so I could hopefully get something working, and build on to that. But this simple example also fails 😞

      #define MY_DEBUG
      #define MY_RADIO_NRF24
      #define MY_RF24_CHANNEL 0x44
      #define MY_RF24_BASE_RADIO_ID 0x00, 0xf6, 0x4d,0x89, 0xc0
      #include <MySensors.h>
      
      void presentation() {
        sendSketchInfo("SmartSleepTest", "1.0");
        present(1, S_INFO, "Info");
      }
      
      void loop() {
        smartSleep(1000);
      }
      

      When running, the output looks like this:

      6 MCO:BGN:INIT NODE,CP=RNNNA---,VER=2.3.0
      26 TSM:INIT
      28 TSF:WUR:MS=0
      36 TSM:INIT:TSP OK
      38 TSF:SID:OK,ID=204
      40 TSM:FPAR
      77 TSF:MSG:SEND,204-204-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      446 TSF:MSG:READ,202-202-204,s=255,c=3,t=8,pt=1,l=1,sg=0:2
      452 TSF:MSG:FPAR OK,ID=202,D=3
      573 TSF:MSG:READ,201-201-204,s=255,c=3,t=8,pt=1,l=1,sg=0:1
      579 TSF:MSG:FPAR OK,ID=201,D=2
      2084 TSM:FPAR:OK
      2084 TSM:ID
      2086 TSM:ID:OK
      2088 TSM:UPL
      2095 TSF:MSG:SEND,204-204-201-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      2140 TSF:MSG:READ,0-201-204,s=255,c=3,t=25,pt=1,l=1,sg=0:2
      2148 TSF:MSG:PONG RECV,HP=2
      2150 TSM:UPL:OK
      2152 TSM:READY:ID=204,PAR=201,DIS=2
      2160 TSF:MSG:SEND,204-204-201-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
      2191 TSF:MSG:READ,0-201-204,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      2201 TSF:MSG:SEND,204-204-201-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.0
      2211 TSF:MSG:SEND,204-204-201-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:201
      2355 TSF:MSG:READ,0-201-204,s=255,c=3,t=6,pt=0,l=1,sg=0:M
      2363 TSF:MSG:SEND,204-204-201-0,s=255,c=3,t=11,pt=0,l=14,sg=0,ft=0,st=OK:SmartSleepTest
      2410 !TSF:MSG:SEND,204-204-201-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=NACK:1.0
      2420 TSF:MSG:SEND,204-204-201-0,s=1,c=0,t=36,pt=0,l=4,sg=0,ft=1,st=OK:Info
      2428 MCO:REG:REQ
      2441 TSF:MSG:SEND,204-204-201-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      2506 TSF:MSG:READ,0-201-204,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      2512 MCO:PIM:NODE REG=1
      2514 MCO:BGN:INIT OK,TSP=1
      2519 MCO:SLP:MS=1000,SMS=1,I1=255,M1=255,I2=255,M2=255
      2529 TSF:MSG:SEND,204-204-201-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=0,st=OK:500
      3037 TSF:TDI:TSL
      3039 MCO:SLP:WUP=-1
      3041 TSF:TRI:TSB
      5457 !TSF:MSG:SEND,204-204-201-0,s=255,c=3,t=33,pt=5,l=4,sg=0,ft=0,st=NACK:1000
      5466 MCO:SLP:MS=1000,SMS=1,I1=255,M1=255,I2=255,M2=255
      5476 TSF:MSG:SEND,204-204-201-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=1,st=OK:500
      5984 TSF:TDI:TSL
      5986 MCO:SLP:WUP=-1
      5988 TSF:TRI:TSB
      8404 !TSF:MSG:SEND,204-204-201-0,s=255,c=3,t=33,pt=5,l=4,sg=0,ft=0,st=NACK:1000
      8413 MCO:SLP:MS=1000,SMS=1,I1=255,M1=255,I2=255,M2=255
      8423 TSF:MSG:SEND,204-204-201-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=1,st=OK:500
      8931 TSF:TDI:TSL
      8933 MCO:SLP:WUP=-1
      

      The PRE-SLEEP message at 2529 gets sent correct, but the POST-SLEEP message gets NACK'ed at 5457.

      I have tried the following, without any luck:

      1. Longer and shorter smart sleep durations, with the same result.

      2. Attempts has been made both with a Raspberry Pi gateway and an ESP8266 gateway, but I doubt the gateway type matter, since it looks like something locally on the node.

      3. Two types of hardware for the node, both a home-designed mini-pcb which run great for other nodes (without smart sleep), and the Easy/Newbie PCB from openhardware.io.

      4. Looking for examples that use smartSleep, but the ones I found only use sleep.

      ANY help or push in the right direction will be greatly appreciated. 🙂

      /Henrik

      posted in Development
      Henrik Nielsen
      Henrik Nielsen
    • RE: Make node look for new/better parent without restarting

      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 🙂

      posted in Development
      Henrik Nielsen
      Henrik Nielsen
    • RE: Make node look for new/better parent without restarting

      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 😉

      posted in Development
      Henrik Nielsen
      Henrik Nielsen
    • RE: Make node look for new/better parent without restarting

      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.

      posted in Development
      Henrik Nielsen
      Henrik Nielsen
    • Make node look for new/better parent without restarting

      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 🙂

      posted in Development
      Henrik Nielsen
      Henrik Nielsen