if use sleep() the node can't receive message?
-
If i use sleep(3000) function in loop(),It can't recieve message from controller?
the log is:
2016/7/27 0:29:20 RX 0;255;3;0;9;!TSP:MSG:SEND 0-0-1-1 s=5,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=fail:5 (i test it on MYSCtroller).if remove the sleep() function,and use delay() funtion the node can receive the message!
-
If i use sleep(3000) function in loop(),It can't recieve message from controller?
the log is:
2016/7/27 0:29:20 RX 0;255;3;0;9;!TSP:MSG:SEND 0-0-1-1 s=5,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=fail:5 (i test it on MYSCtroller).if remove the sleep() function,and use delay() funtion the node can receive the message!
@Magic-W
sleep() function is powering down both rf radio and arduino, therefore no way to get messages during that time. Maybe you can wake frequently and wait a brief time to check if any messages coming while gw sending messages for a few times repeatedly. I read this kind of thing on forum I guess it was about battery actuator.Meanwhile using delay() isn't that good since it is a blocking function, prefer wait() since it runs process() on background.
-
If i use sleep(3000) function in loop(),It can't recieve message from controller?
the log is:
2016/7/27 0:29:20 RX 0;255;3;0;9;!TSP:MSG:SEND 0-0-1-1 s=5,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=fail:5 (i test it on MYSCtroller).if remove the sleep() function,and use delay() funtion the node can receive the message!
-
@Magic-W Of course, a sleeping node is by definition not able to receive and process incoming messages.
-
If i use sleep(3000) function in loop(),It can't recieve message from controller?
the log is:
2016/7/27 0:29:20 RX 0;255;3;0;9;!TSP:MSG:SEND 0-0-1-1 s=5,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=fail:5 (i test it on MYSCtroller).if remove the sleep() function,and use delay() funtion the node can receive the message!
@Magic-W When you have some control over what you want to receive and when you can trick it like:
- When you want to recieve information (possibly from the controller). use
request(<sensor>) wait(<milliseconds>)(keep awake) for the sender to send the info.- either
receivethe information or conclude that something went wrong (if you can expect there will allways be a value sent) sleepfor as long as you want.
It will depend on your controller if and how it reacts to
request. For Domoticz V_STATUS and V_TEXT do work.You can also build a "broker" node (or integrate it in your gateway). Thise is very flexible and independent of your controller (but not very user friendly). I you need any how to's just let me know.
- When you want to recieve information (possibly from the controller). use
-
@Magic-W When you have some control over what you want to receive and when you can trick it like:
- When you want to recieve information (possibly from the controller). use
request(<sensor>) wait(<milliseconds>)(keep awake) for the sender to send the info.- either
receivethe information or conclude that something went wrong (if you can expect there will allways be a value sent) sleepfor as long as you want.
It will depend on your controller if and how it reacts to
request. For Domoticz V_STATUS and V_TEXT do work.You can also build a "broker" node (or integrate it in your gateway). Thise is very flexible and independent of your controller (but not very user friendly). I you need any how to's just let me know.
- When you want to recieve information (possibly from the controller). use
-
@Magic-W if you substitute delay() and sleep() to wait(), the node will process incoming messages.
-
@AWI thanks for your replay!
in your way,the node can alwayssleepif it don't send mesage? When i want to wake it up,i can sendrequest(<sensor>)from the controller? How do I deal with therequestmessage in the sensor node?Look forward to your reply!
@Magic-W the intention is that you send a
Requestfrom your node when you want toReceivea status update from the controller. The controller sends you a response with the requested status. You keep the node awakeWaituntil you receive the message from the controller.In fact you are polling for new messages every x time or whenever you need an update.
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