drivers: modem: gsm: Fix to COPS cmd parse info

drivers: modem: gsm: Quectel EC21 and BG9x act as a gsm modem without
problem, but COPS commands can returns just one value with 'mode'.

Format and oper are not mandatory. This modification reads 'mode'.
Also a modification on modem_cmd_read_cops_cmd is needed.

Signed-off-by: Jair Jack <jack@icatorze.com.br>
This commit is contained in:
Jair Jack 2021-11-01 08:20:33 -03:00 committed by Anas Nashif
commit 8e95b95bb4

View file

@ -181,11 +181,13 @@ static int unquoted_atoi(const char *s, int base)
*/ */
MODEM_CMD_DEFINE(on_cmd_atcmdinfo_cops) MODEM_CMD_DEFINE(on_cmd_atcmdinfo_cops)
{ {
if (argc >= 3) { if (argc >= 1) {
#if defined(CONFIG_MODEM_CELL_INFO) #if defined(CONFIG_MODEM_CELL_INFO)
gsm.context.data_operator = unquoted_atoi(argv[2], 10); if (argc >= 3) {
LOG_INF("operator: %u", gsm.context.data_operator = unquoted_atoi(argv[2], 10);
gsm.context.data_operator); LOG_INF("operator: %u",
gsm.context.data_operator);
}
#endif #endif
if (unquoted_atoi(argv[0], 10) == 0) { if (unquoted_atoi(argv[0], 10) == 0) {
gsm.context.is_automatic_oper = true; gsm.context.is_automatic_oper = true;
@ -445,7 +447,7 @@ MODEM_CMD_DEFINE(on_cmd_atcmdinfo_attached)
static const struct modem_cmd read_cops_cmd = static const struct modem_cmd read_cops_cmd =
MODEM_CMD("+COPS", on_cmd_atcmdinfo_cops, 3U, ","); MODEM_CMD_ARGS_MAX("+COPS:", on_cmd_atcmdinfo_cops, 1U, 4U, ",");
static const struct modem_cmd check_attached_cmd = static const struct modem_cmd check_attached_cmd =
MODEM_CMD("+CGATT:", on_cmd_atcmdinfo_attached, 1U, ","); MODEM_CMD("+CGATT:", on_cmd_atcmdinfo_attached, 1U, ",");