How to stop receiving messages temporarily?

  • Is there a neat way to stop receiving messages temporarily in mysensors node? I have a node which must perform a routine of sequence of actions of roughly 5 seconds upon receiving a command. If another command comes when the routine is performed it produces unwanted side effects.

    So I am looking for a method or workaround, which would allow when command is received to stop listening to radio, after the routine is completed - restart listening again.

    Any advice?

    regards, rimantas

  • @rzylius
    maybe too simple, but can't you put your specific code within a 'while' loop?
    Something like:

    unsigned long Wait_time;
    unsigned long Start_time;
    Start_time = millis();
    Wait_time = millis() - Start_time;
    while (Wait_time < 5000){
    //insert your code for the routine of actions of roughly 5000 ms here
    Wait_time = millis() - Start_time;


  • Admin


    Can't you do this with a state variable? something like:

    boolean state = false;
    void receive(const MyMessage &message) {
      if (!state) {
        if (message.cmd = xxx) {
          state = true;
    void startOperation() {
       state = false;

  • @tbowmo works like a charm, thank you.

Log in to reply

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.