GSMV1_STATE_GUESS_MULTILINE_RESPONSE,
GSMV1_STATE_MULTILINE_RESPONSE,
GSMV1_STATE_MULTILINE_TERMINATOR_CR,
+ GSMV1_STATE_PDU_CHECK_EXTRA_CR,
+ GSMV1_STATE_PDU_CHECK_EXTRA_LF,
GSMV1_STATE_PDU,
GSMV1_STATE_PDU_CR,
GSMV1_STATE_PROMPT,
{
switch (hint) {
case G_AT_SYNTAX_EXPECT_PDU:
- syntax->state = GSMV1_STATE_PDU;
+ syntax->state = GSMV1_STATE_PDU_CHECK_EXTRA_CR;
break;
case G_AT_SYNTAX_EXPECT_MULTILINE:
syntax->state = GSMV1_STATE_GUESS_MULTILINE_RESPONSE;
goto out;
+ /* Some 27.007 compliant modems still get this wrong. They
+ * insert an extra CRLF between the command and he PDU,
+ * in effect making them two separate lines. We try to
+ * handle this case gracefully
+ */
+ case GSMV1_STATE_PDU_CHECK_EXTRA_CR:
+ if (byte == '\r')
+ syntax->state = GSMV1_STATE_PDU_CHECK_EXTRA_LF;
+ else
+ syntax->state = GSMV1_STATE_PDU;
+ break;
+
+ case GSMV1_STATE_PDU_CHECK_EXTRA_LF:
+ res = G_AT_SYNTAX_RESULT_UNRECOGNIZED;
+ syntax->state = GSMV1_STATE_PDU;
+
+ if (byte == '\n')
+ i += 1;
+
+ goto out;
+
case GSMV1_STATE_PDU:
if (byte == '\r')
syntax->state = GSMV1_STATE_PDU_CR;