Update ec20.c

if (!str) 
    {
        return -1;
    }
This commit is contained in:
David Lin
2020-08-10 18:27:38 +08:00
committed by GitHub
parent ad5f75d4a3
commit cf59033304

View File

@@ -66,7 +66,6 @@ static int ec20_sim_card_check(void)
return 0; return 0;
} }
} }
return -1; return -1;
} }
@@ -87,6 +86,10 @@ static int ec20_signal_quality_check(void)
} }
str = strstr(echo.buffer, "+CSQ:"); str = strstr(echo.buffer, "+CSQ:");
if (!str)
{
return -1;
}
sscanf(str, "+CSQ:%d,%d", &rssi, &ber); sscanf(str, "+CSQ:%d,%d", &rssi, &ber);
if (rssi != 99) { if (rssi != 99) {
return 0; return 0;
@@ -111,6 +114,10 @@ static int ec20_gsm_network_check(void)
} }
str = strstr(echo.buffer, "+CREG:"); str = strstr(echo.buffer, "+CREG:");
if (!str)
{
return -1;
}
sscanf(str, "+CREG:%d,%d", &n, &stat); sscanf(str, "+CREG:%d,%d", &n, &stat);
if (stat == 1) { if (stat == 1) {
return 0; return 0;
@@ -137,6 +144,10 @@ static int ec20_gprs_network_check(void)
} }
str = strstr(echo.buffer, "+CGREG:"); str = strstr(echo.buffer, "+CGREG:");
if (!str)
{
return -1;
}
sscanf(str, "+CGREG:%d,%d", &n, &stat); sscanf(str, "+CGREG:%d,%d", &n, &stat);
if (stat == 1) if (stat == 1)
{ {
@@ -172,7 +183,6 @@ static int ec20_set_apn(void)
return -1; return -1;
} }
tos_at_cmd_exec_until(&echo, 3000, "AT+QIACT=1\r\n"); tos_at_cmd_exec_until(&echo, 3000, "AT+QIACT=1\r\n");
if (echo.status != AT_ECHO_STATUS_OK) if (echo.status != AT_ECHO_STATUS_OK)
{ {