esp-modem: prefix the crash issue both bg96 and sim800l in OVERALL mode

This commit is contained in:
Liu Han
2020-12-22 20:22:27 +08:00
committed by bot
parent 935edc9e09
commit 7f3bcc13d7
3 changed files with 17 additions and 12 deletions

View File

@@ -160,7 +160,7 @@ static esp_err_t bg96_handle_cimi(modem_dce_t *dce, const char *line)
* @brief Handle response from AT+COPS?
*/
static esp_err_t bg96_handle_cops(modem_dce_t *dce, const char *line)
{
{
esp_err_t err = ESP_FAIL;
if (strstr(line, MODEM_RESULT_CODE_SUCCESS)) {
err = esp_modem_process_command_done(dce, MODEM_STATE_SUCCESS);
@@ -172,7 +172,7 @@ static esp_err_t bg96_handle_cops(modem_dce_t *dce, const char *line)
size_t len = strlen(line);
char *line_copy = malloc(len + 1);
strcpy(line_copy, line);
/* +COPS: <mode>[, <format>[, <oper>][, <Act>]] */
/* +COPS: <mode>[, <format>[, <oper>[, <Act>]]] */
char *str_ptr = NULL;
char *p[5];
uint8_t i = 0;
@@ -190,9 +190,7 @@ static esp_err_t bg96_handle_cops(modem_dce_t *dce, const char *line)
}
}
if (i >= 4) {
char act_str[3] = {0};
int len = snprintf(act_str, 3, "%s", p[3]);
dce->act = (uint8_t)atoi(act_str);
dce->act = (uint8_t)strtol(p[3], NULL, 0);
}
free(line_copy);
}
@@ -469,6 +467,8 @@ modem_dce_t *bg96_init(modem_dte_t *dte)
DCE_CHECK(bg96_get_imei_number(bg96_dce) == ESP_OK, "get imei failed", err_io);
/* Get IMSI number */
DCE_CHECK(bg96_get_imsi_number(bg96_dce) == ESP_OK, "get imsi failed", err_io);
/* Get operator name */
DCE_CHECK(bg96_get_operator_name(&(bg96_dce->parent)) == ESP_OK, "get operator name failed", err_io);
return &(bg96_dce->parent);
err_io:
free(bg96_dce);