Skip to content

Commit

Permalink
drivers: modem: hl7800: fix COPS handler
Browse files Browse the repository at this point in the history
Add support for handling the +COPS=? response
to the +COPS command handler.

Signed-off-by: Ryan Erickson <[email protected]>
  • Loading branch information
rerickson1 authored and nashif committed Sep 1, 2021
1 parent fde0b96 commit 7cfedb9
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions drivers/modem/hl7800.c
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,13 @@ static bool on_cmd_atcmdinfo_ipaddr(struct net_buf **buf, uint16_t len)
return true;
}

/* Handler: +COPS: <mode>[,<format>,<oper>[,<AcT>]] */
/* Handler1: +COPS: <mode>[,<format>,<oper>[,<AcT>]]
*
* Handler2:
* +COPS: [list of supported (<stat>, long alphanumeric <oper>, short
* alphanumeric <oper>, numeric <oper>[,< AcT>])s][,,
* (list of supported <mode>s),(list of supported <format>s)]
*/
static bool on_cmd_atcmdinfo_operator_status(struct net_buf **buf, uint16_t len)
{
size_t out_len;
Expand All @@ -1761,8 +1767,16 @@ static bool on_cmd_atcmdinfo_operator_status(struct net_buf **buf, uint16_t len)

out_len = net_buf_linearize(value, sizeof(value), *buf, 0, len);
value[out_len] = 0;
LOG_INF("Operator: %s", log_strdup(value));

/* For AT+COPS=?, result is most likely longer than size of log string */
if (strchr(value, '(') != NULL) {
LOG_HEXDUMP_DBG(value, out_len, "Operator: ");
goto done;
} else {
LOG_INF("Operator: %s", log_strdup(value));
}

/* Process AT+COPS? */
if (len == 1) {
/* only mode was returned, there is no operator info */
ictx.operator_status = NO_OPERATOR;
Expand All @@ -1775,8 +1789,7 @@ static bool on_cmd_atcmdinfo_operator_status(struct net_buf **buf, uint16_t len)
for (i = 0; i < num_delims; i++) {
delims[i] = strchr(search_start, ',');
if (!delims[i]) {
LOG_ERR("Could not find delim %d, val: %s", i,
log_strdup(value));
LOG_ERR("Could not find delim %d, val: %s", i, log_strdup(value));
goto done;
}
/* Start next search after current delim location */
Expand Down

0 comments on commit 7cfedb9

Please sign in to comment.