Skip to content

How to handle different responses? #3

@tomy983

Description

@tomy983

@prampec

Hello, I have an issue.. I've added a command ad handlers to shut gprs. The AT response is "SHUT OK", on the same line.

void handleSHUT(char* result);
GsmHandler SHUTHandler = {"SHUT ", handleSHUT};  // gprs shut
gsmAsync.registerHandler(&SHUTHandler);
gsmAsync.addCommand("AT+CIPSHUT");  // CIPSHUT will close *all* open connections

my handle function is as follows:

void handleSHUT(char* result) {
    if (strcmp(result, "OK") == 0) {
        Serial.println("GPRS IS : SHUT");
    } else {
        Serial.println("GPRS IS : NOT SHUT");
    }
}

and it gets called as expected. Here is the debug output:

132.66 GSM CMD: AT+CIPSHUT

SHUT 
132.67 Calling handler for 'SHUT ' with argument 'OK'.
GPRS IS : SHUT

134.66 Timeout for 'AT+CIPSHUT' (2000 ms).
134.67 GSM CMD: AT+CIPSHUT

which shows that even if the response is handled, triggers the timeout and eventually the

Retries exceeded.
GSM not responding

I suspect it is because it treats the OK in the "SHUT OK" response as an argument and expects another OK, but I am not able to correct this in the code. Can I please have some help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions