I need to parse a response from a device (SIM900) like this:
\r\n+CIPRXGET:1
+CIPRXGET: 2,1,3
DATA COMPOSED BY A WHITESPACE AND MAYBE OTHER
OK
so i use sscanf twice: first to remove the final string "OK" and second to parse data.
char buffer[256] = sim900.getResponse();
char data[256];
int bytesRead, bytesToRead;
sscanf(buffer, "%[^OK]", buffer);
sscanf(buffer, "%*s,%d,%d\r\n%[^\\0]", &bytesRead, &bytesToRead, data);
my response start with a whitespace (character 0x20) and i got a dirty output, that is "\r\n \r\n" (or in hex representation "0x0D 0x0A 0x20 0x0D 0x0A").
I tried everything but i can't parse correctly only the whitespace character into the output buffer.