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
-
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; }BR,
Boozz -
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
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; startOperation(); } } } void startOperation() { delay(5000); state = false; } -
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; startOperation(); } } } void startOperation() { delay(5000); state = false; }
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