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:
-
Longer and shorter smart sleep durations, with the same result.
-
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.
-
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.
-
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
-
-
@henrik-nielsen do you know if the message is received by the gateway? This is possible although the node reports 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
-
@henrik-nielsen
Hello, there may be a problem with the repeater. ACK and NOACK are confirmation of sending to the first node in the chain(that is, in your case to the repeater). Try turning off this repeater so that the sender receives a new route. I also recommend using the sleep function with the attribute of smart sleep mode activation -- sleep(1000, true);
-
@henrik-nielsen
Try adding a little wait after the line with sleep, it will slow down the sketch but the framework will continue to work wait(200); ...not sure.
-
@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
-
-
The problem is deeper, you came across an interesting point, I did not notice it before... left to dig the problem
-
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
-
@henrik-nielsen
I banished your sketch. Faced the same problem, have not seen before. As it turned out, this is a problem of quality of radio modules and radio driver settings. The solution is described below.Was before:
__ __ ____ | \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___ | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __| | | | | |_| |___| | __/ | | \__ \ _ | | \__ \ |_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/ |___/ 2.3.1-alpha 18 MCO:BGN:INIT NODE,CP=RNNNA---,VER=2.3.1-alpha 28 TSM:INIT 28 TSF:WUR:MS=0 36 TSM:INIT:TSP OK 38 TSF:SID:OK,ID=100 40 TSM:FPAR 77 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 600 TSF:MSG:READ,0-0-100,s=255,c=3,t=8,pt=1,l=1,sg=0:0 606 TSF:MSG:FPAR OK,ID=0,D=1 2088 TSM:FPAR:OK 2088 TSM:ID 2091 TSM:ID:OK 2093 TSM:UPL 2099 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 2205 TSF:MSG:READ,0-0-100,s=255,c=3,t=25,pt=1,l=1,sg=0:1 2211 TSF:MSG:PONG RECV,HP=1 2215 TSM:UPL:OK 2217 TSM:READY:ID=100,PAR=0,DIS=1 2222 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 2357 TSF:MSG:READ,0-0-100,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 2365 TSF:MSG:SEND,100-100-0-0,s=255,c=0,t=17,pt=0,l=11,sg=0,ft=0,st=OK:2.3.1-alpha 2375 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0 2838 TSF:MSG:READ,0-0-100,s=255,c=3,t=6,pt=0,l=1,sg=0:M 2846 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=11,pt=0,l=14,sg=0,ft=0,st=OK:SmartSleepTest 2856 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0 2867 TSF:MSG:SEND,100-100-0-0,s=1,c=0,t=36,pt=0,l=4,sg=0,ft=0,st=OK:Info 2875 MCO:REG:REQ 2912 !TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=NACK:2 4923 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=OK:2 4995 TSF:MSG:READ,0-0-100,s=255,c=3,t=27,pt=1,l=1,sg=0:1 5001 MCO:PIM:NODE REG=1 5003 MCO:BGN:STP 5005 MCO:BGN:INIT OK,TSP=1 6008 MCO:SLP:MS=3000,SMS=1,I1=0,M1=3,I2=255,M2=255 6017 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=0,st=OK:600 6625 TSF:TDI:TSL 6627 MCO:SLP:WUP=-1 6629 TSF:TRI:TSB 8312 !TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=33,pt=5,l=4,sg=0,ft=0,st=NACK:3000 10524 MCO:SLP:MS=3000,SMS=1,I1=0,M1=3,I2=255,M2=255 10532 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=1,st=OK:600 11141 TSF:TDI:TSL 11143 MCO:SLP:WUP=-1 11145 TSF:TRI:TSB 12828 !TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=33,pt=5,l=4,sg=0,ft=0,st=NACK:3000 15036 MCO:SLP:MS=3000,SMS=1,I1=0,M1=3,I2=255,M2=255 15044 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=1,st=OK:600 15652 TSF:TDI:TSL
1.Go to the folder - C:\Users\Andrey\Documents\Arduino\libraries\MySensors-development
2.Next, go to the folder - \drivers\RF24
3.Open the file - RF24registers.h
4.Change the parameters to these:
...lines 42-47.// ARD, auto retry delay
#define RF24_SET_ARD (10)
// ARD, auto retry count#define RF24_SET_ARC (15)
5.Next, open the file-RF24.ccp
Change the parameters to these:
...line 67
...line 114delayMicroseconds(100);
The problem in radio driver, in his settings, apparently all wrote according to the Datasheet, but in life a bit otherwise)))
Has now become:
__ __ ____ | \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___ | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __| | | | | |_| |___| | __/ | | \__ \ _ | | \__ \ |_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/ |___/ 2.3.1-alpha 18 MCO:BGN:INIT NODE,CP=RNNNA---,VER=2.3.1-alpha 28 TSM:INIT 28 TSF:WUR:MS=0 38 TSM:INIT:TSP OK 43 TSF:SID:OK,ID=100 45 TSM:FPAR 102 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 2111 !TSM:FPAR:NO REPLY 2113 TSM:FPAR 2170 TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 2736 TSF:MSG:READ,0-0-100,s=255,c=3,t=8,pt=1,l=1,sg=0:0 2742 TSF:MSG:FPAR OK,ID=0,D=1 4182 TSM:FPAR:OK 4182 TSM:ID 4184 TSM:ID:OK 4186 TSM:UPL 4194 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 4300 TSF:MSG:READ,0-0-100,s=255,c=3,t=25,pt=1,l=1,sg=0:1 4306 TSF:MSG:PONG RECV,HP=1 4311 TSM:UPL:OK 4311 TSM:READY:ID=100,PAR=0,DIS=1 4319 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 4450 TSF:MSG:READ,0-0-100,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 4462 TSF:MSG:SEND,100-100-0-0,s=255,c=0,t=17,pt=0,l=11,sg=0,ft=0,st=OK:2.3.1-alpha 4474 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0 4939 TSF:MSG:READ,0-0-100,s=255,c=3,t=6,pt=0,l=1,sg=0:M 4950 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=11,pt=0,l=14,sg=0,ft=0,st=OK:SmartSleepTest 4966 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0 4976 TSF:MSG:SEND,100-100-0-0,s=1,c=0,t=36,pt=0,l=4,sg=0,ft=0,st=OK:Info 4984 MCO:REG:REQ 5021 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2 5308 TSF:MSG:READ,0-0-100,s=255,c=3,t=27,pt=1,l=1,sg=0:1 5314 MCO:PIM:NODE REG=1 5316 MCO:BGN:STP 5318 MCO:BGN:INIT OK,TSP=1 6322 MCO:SLP:MS=3000,SMS=1,I1=0,M1=3,I2=255,M2=255 6334 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=0,st=OK:600 6942 TSF:TDI:TSL 6944 MCO:SLP:WUP=-1 6946 TSF:TRI:TSB 6952 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=33,pt=5,l=4,sg=0,ft=0,st=OK:3000 9164 MCO:SLP:MS=3000,SMS=1,I1=0,M1=3,I2=255,M2=255 9177 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=0,st=OK:600 9785 TSF:TDI:TSL 9787 MCO:SLP:WUP=-1 9789 TSF:TRI:TSB 9797 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=33,pt=5,l=4,sg=0,ft=0,st=OK:3000 12005 MCO:SLP:MS=3000,SMS=1,I1=0,M1=3,I2=255,M2=255 12017 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=0,st=OK:600 12625 TSF:TDI:TSL
use..
-
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
-
@henrik-nielsen
Everyone uses cheap radio modules, it's a reality. One thing is technical specifications, the other is real network on real equipment. Although I think if you take a very original radios, it will be the same in 99%)). ....Glad to help, it's called a community.
-
@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.
-
@henrik-nielsen said in SmartSleep wake up message always get NACK:
if "everyone" uses cheap chinese radios, should this fix be part of the official code base?
simple! add issue or pull request to mysensors github. that's the easiest way when there's issue to fix
because the team can't follow all forum topics and make todolist, in this way this is not handy.
-
@scalz said in SmartSleep wake up message always get NACK:
pull request
I made a pull request. I think that this will accept. Apparently the next version will already be. ...I'm not sure this is absolutely perfect, a mistake in the first message after sleeping mostly. Perhaps later it is better to modify startListening, although, of course, now it is a good solution, but not ideal.
-
@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
-
@berkseo Hi, could you post the link to your pull request ? I don't see any traces of it in MySensors Github repository.
BTW with my setup (genuine/good quality NRF24L01) increase lines 67 & 114 of RF24.ccp to 50 do the trick.
Thanks.
-
@memphis007 berseo's pull requests (link 1, link 2) were closed in favor of this pull request.
-
@mfalkvidd I have applied Tekka007 pull request successfully, all is working correctly now. Thanks !