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.


  • Admin

    @Magic-W Of course, a sleeping node is by definition not able to receive and process incoming messages.



  • @tekka Thank you for your reply.!


  • Admin

    @Magic-W if you substitute delay() and sleep() to wait(), the node will process incoming messages.


  • Hero Member

    @Magic-W When you have some control over what you want to receive and when you can trick it like:

    1. When you want to recieve information (possibly from the controller). use request(<sensor>)
    2. wait(<milliseconds>) (keep awake) for the sender to send the info.
    3. either receive the information or conclude that something went wrong (if you can expect there will allways be a value sent)
    4. 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.



  • @AWI thanks for your replay!
    in your way,the node can always sleep if it don't send mesage? When i want to wake it up,i can send request(<sensor>) from the controller? How do I deal with the request message in the sensor node?

    Look forward to your reply!



  • @tekka thank you for your reminding!


  • Hero Member

    @Magic-W the intention is that you send a Request from your node when you want to Receive a status update from the controller. The controller sends you a response with the requested status. You keep the node awake Wait 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.


Log in to reply
 

Suggested Topics

  • 3
  • 1
  • 1
  • 6
  • 2
  • 5

17
Online

11.4k
Users

11.1k
Topics

112.7k
Posts