Skip to content

Commit 83f86d0

Browse files
gbakkerlubos
authored andcommitted
drivers/at_cmd: Correct detection of CME / CMS errors
Reorder presedence of error detection and correct pattern to match. Signed-off-by: Glenn Ruben Bakke <[email protected]>
1 parent 7b162b1 commit 83f86d0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/at_cmd/at_cmd.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ LOG_MODULE_REGISTER(at_cmd, CONFIG_AT_CMD_LOG_LEVEL);
1919

2020
#define AT_CMD_OK_STR "OK"
2121
#define AT_CMD_ERROR_STR "ERROR"
22-
#define AT_CMD_CMS_STR "+CMS:"
23-
#define AT_CMD_CME_STR "+CME:"
22+
#define AT_CMD_CMS_STR "+CMS ERROR:"
23+
#define AT_CMD_CME_STR "+CME ERROR:"
2424

2525
static K_THREAD_STACK_DEFINE(socket_thread_stack, \
2626
CONFIG_AT_CMD_THREAD_STACK_SIZE);
@@ -77,13 +77,6 @@ static int get_return_code(char *buf, struct return_state_object *ret)
7777
break;
7878
}
7979

80-
tmpstr = strstr(buf, AT_CMD_ERROR_STR);
81-
if (tmpstr) {
82-
ret->state = AT_CMD_ERROR;
83-
ret->code = -ENOEXEC;
84-
break;
85-
}
86-
8780
tmpstr = strstr(buf, AT_CMD_CMS_STR);
8881
if (tmpstr) {
8982
ret->state = AT_CMD_ERROR_CMS;
@@ -97,6 +90,13 @@ static int get_return_code(char *buf, struct return_state_object *ret)
9790
ret->code = atoi(&buf[ARRAY_SIZE(AT_CMD_CMS_STR) - 1]);
9891
break;
9992
}
93+
94+
tmpstr = strstr(buf, AT_CMD_ERROR_STR);
95+
if (tmpstr) {
96+
ret->state = AT_CMD_ERROR;
97+
ret->code = -ENOEXEC;
98+
break;
99+
}
100100
} while (0);
101101

102102
if (tmpstr) {

0 commit comments

Comments
 (0)