arduino-managed-serial-device icon indicating copy to clipboard operation
arduino-managed-serial-device copied to clipboard

Command delays in execute chain do not delay

Open barbiani opened this issue 9 months ago • 0 comments

Hello,

I am investigating the command delay feature in the chained execution and in does not seem to respect these delays.

I did not see its test in the tests suite. Is there any trick to make it work?

Thank you.

Delaying Occasionally, especially when chaining commands, you may need to ensure that a subsequent command isn't executed immediately; in these cases, you are able to set a delay:

#include <ManagedSerialDevice.h>
#include <Regexp.h>

ManagedSerialDevice handler = ManagedSerialDevice();

void setup() {
    handler.begin(&Serial);

    ManagedSerialDevice::Command commands[] = {
        ManagedSerialDevice::Command(
            "AT+CIPSTART=\"TCP\",\"mywebsite.com\",\"80\"", // Command
            "OK\r\n",  // Expectation regex
            [](MatchState ms){
                Serial.println("Connected");
            }
        ),
        ManagedSerialDevice::Command(
            "AT+CIPSEND",
            ">",
            NULL,
            NULL,
            COMMAND_TIMEOUT,
            1000  // Wait for 1s before running this command 
        ),
        ManagedSerialDevice::Command(
            "abc\r\n\x1a"
            "SEND OK\r\n"
        )
    }
    handler.executeChain(commands, 3);
}

void loop() {
    handler.loop();
}

barbiani avatar Feb 24 '25 00:02 barbiani