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!
-
@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.
-
@Magic-W Of course, a sleeping node is by definition not able to receive and process incoming messages.
-
@tekka Thank you for your reply.!
-
@Magic-W if you substitute delay() and sleep() to wait(), the node will process incoming messages.
-
@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
receive
the information or conclude that something went wrong (if you can expect there will allways be a value sent) sleep
for 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
-
@AWI thanks for your replay!
in your way,the node can alwayssleep
if it don't send mesage? When i want to wake it up,i can sendrequest(<sensor>)
from the controller? How do I deal with therequest
message in the sensor node?Look forward to your reply!
-
@tekka thank you for your reminding!
-
@Magic-W the intention is that you send a
Request
from your node when you want toReceive
a status update from the controller. The controller sends you a response with the requested status. You keep the node awakeWait
until you receive the message from the controller.In fact you are polling for new messages every x time or whenever you need an update.
Suggested Topics
-
Day 1 - Status report
Announcements • 23 Mar 2014, 22:45 • hek 24 Mar 2014, 20:12 -
Can not compile MySensors on esp8266
Troubleshooting • 24 Aug 2024, 15:35 • TheoL 29 Aug 2024, 20:47 -
JSN-SR04T-V3.0 Coax cable extended
Troubleshooting • 19 Mar 2025, 21:00 • bocalexandru 21 Mar 2025, 12:05 -
Forum Search not working?
Troubleshooting • 4 Oct 2023, 23:33 • Gibber 2 Sept 2024, 20:28 -
Compiling Sensor code using BME280 and ESP8266
Troubleshooting • 26 Feb 2025, 00:32 • dpcons 26 Feb 2025, 06:22 -
Getting system time from the controller
Troubleshooting • 27 Feb 2025, 01:39 • dpcons 3 Mar 2025, 01:00