void receive not work with RelayActuator.ino ?



  • Hi all,
    I don't understand a problem,
    My receive function is not working in the sktech relayActuator.ino
    If I simply add the following code :

    ....
    void receive(const MyMessage &message)
    {
       Serial.print("--- Incoming Message ---");
      // We only expect one type of message from controller. But we better check anyway.
      if (message.getType()==V_STATUS) {
    ....
    

    I never have anything.
    But in the node logs I do receive the information:
    Relay OFF :

    345110 TSF:MSG:READ,0-180-162,s=180,c=3,t=6,pt=0,l=1,sg=0:0
    

    Relay ON:

    355655 TSF:MSG:READ,0-180-162,s=180,c=3,t=6,pt=0,l=1,sg=0:1
    

    For information I use a gateway+W5100 in MQTT.

    An idea why the receive function is not working here ?

    Thank you all



  • @yourry Don't use serial print inside the receive function.

    instead set a variable in receive and test for that in the main loop and then send serial from the main loop.

    This is probably all the problem is........ probably....... 😉



  • Thanks for the answer, I keep the advice.
    Finally I looked for a while and the problem was with the MQTT publish syntax.
    It works perfectly, the difficulty is to find the right publish MQTT request.
    Thank you.


  • Mod

    @skywatch said in void receive not work with RelayActuator.ino ?:

    Don't use serial print inside the receive function

    Why not? Receive doesn't run in interrupt context, so it should be safe to serial print from it...



  • @Yveaux I'm sure it's in the forum posts somewhere but I don't have time to look for it.

    Maybe you could do a list of what is and isn't possible in void receive to mitigate further confusions?


Log in to reply
 

Suggested Topics

  • 3
  • 4
  • 2
  • 2
  • 15
  • 3

16
Online

11.2k
Users

11.1k
Topics

112.5k
Posts