diff --git a/at_socket_ec20.c b/at_socket_ec20.c index 95b5df9..9ab1910 100644 --- a/at_socket_ec20.c +++ b/at_socket_ec20.c @@ -32,6 +32,10 @@ #include #include +#if !defined(AT_SW_VERSION_NUM) || AT_SW_VERSION_NUM < 0x10100 +#error "This AT Client version is older, please check and update latest AT Client!" +#endif + #ifndef AT_DEVICE_NOT_SELECTED #define EC20_MODULE_SEND_MAX_SIZE 1460 @@ -916,12 +920,15 @@ static void urc_recv_func(const char *data, rt_size_t size) { int socket = 0; rt_size_t bfsz = 0, temp_size = 0; + rt_int32_t timeout; char *recv_buf = RT_NULL, temp[8]; RT_ASSERT(data && size); /* get the current socket and receive buffer size by receive data */ sscanf(data, "+QIURC: \"recv\",%d,%d", &socket, (int *) &bfsz); + /* get receive timeout by receive buffer length */ + timeout = bfsz; if (socket < 0 || bfsz == 0) return; @@ -935,11 +942,11 @@ static void urc_recv_func(const char *data, rt_size_t size) { if (bfsz - temp_size > sizeof(temp)) { - at_client_recv(temp, sizeof(temp)); + at_client_recv(temp, sizeof(temp), timeout); } else { - at_client_recv(temp, bfsz - temp_size); + at_client_recv(temp, bfsz - temp_size, timeout); } temp_size += sizeof(temp); } @@ -947,7 +954,7 @@ static void urc_recv_func(const char *data, rt_size_t size) } /* sync receive data */ - if (at_client_recv(recv_buf, bfsz) != bfsz) + if (at_client_recv(recv_buf, bfsz, timeout) != bfsz) { LOG_E("receive size(%d) data failed!", bfsz); rt_free(recv_buf); diff --git a/at_socket_esp8266.c b/at_socket_esp8266.c index 593bf1a..38bce56 100644 --- a/at_socket_esp8266.c +++ b/at_socket_esp8266.c @@ -31,7 +31,7 @@ #include -#if !defined(AT_SW_VERSION_NUM) || AT_SW_VERSION_NUM < 0x10000 +#if !defined(AT_SW_VERSION_NUM) || AT_SW_VERSION_NUM < 0x10100 #error "This AT Client version is older, please check and update latest AT Client!" #endif @@ -441,12 +441,15 @@ static void urc_recv_func(const char *data, rt_size_t size) { int socket = 0; rt_size_t bfsz = 0, temp_size = 0; + rt_int32_t timeout; char *recv_buf = RT_NULL, temp[8]; RT_ASSERT(data && size); /* get the current socket and receive buffer size by receive data */ sscanf(data, "+IPD,%d,%d:", &socket, (int *) &bfsz); + /* get receive timeout by receive buffer length */ + timeout = bfsz; if (socket < 0 || bfsz == 0) return; @@ -460,11 +463,11 @@ static void urc_recv_func(const char *data, rt_size_t size) { if (bfsz - temp_size > sizeof(temp)) { - at_client_recv(temp, sizeof(temp)); + at_client_recv(temp, sizeof(temp), timeout); } else { - at_client_recv(temp, bfsz - temp_size); + at_client_recv(temp, bfsz - temp_size, timeout); } temp_size += sizeof(temp); } @@ -472,7 +475,7 @@ static void urc_recv_func(const char *data, rt_size_t size) } /* sync receive data */ - if (at_client_recv(recv_buf, bfsz) != bfsz) + if (at_client_recv(recv_buf, bfsz, timeout) != bfsz) { LOG_E("receive size(%d) data failed!", bfsz); rt_free(recv_buf); diff --git a/at_socket_m26.c b/at_socket_m26.c index bcdee9c..6d9c554 100644 --- a/at_socket_m26.c +++ b/at_socket_m26.c @@ -31,7 +31,7 @@ #include #include -#if !defined(AT_SW_VERSION_NUM) || AT_SW_VERSION_NUM < 0x10000 +#if !defined(AT_SW_VERSION_NUM) || AT_SW_VERSION_NUM < 0x10100 #error "This AT Client version is older, please check and update latest AT Client!" #endif @@ -516,12 +516,15 @@ static void urc_recv_func(const char *data, rt_size_t size) { int socket = 0; rt_size_t bfsz = 0, temp_size = 0; + rt_int32_t timeout; char *recv_buf = RT_NULL, temp[8]; RT_ASSERT(data && size); /* get the current socket and receive buffer size by receive data */ sscanf(data, "+RECEIVE: %d, %d", &socket, (int *) &bfsz); + /* get receive timeout by receive buffer length */ + timeout = bfsz; if (socket < 0 || bfsz == 0) return; @@ -535,11 +538,11 @@ static void urc_recv_func(const char *data, rt_size_t size) { if (bfsz - temp_size > sizeof(temp)) { - at_client_recv(temp, sizeof(temp)); + at_client_recv(temp, sizeof(temp), timeout); } else { - at_client_recv(temp, bfsz - temp_size); + at_client_recv(temp, bfsz - temp_size, timeout); } temp_size += sizeof(temp); } @@ -547,7 +550,7 @@ static void urc_recv_func(const char *data, rt_size_t size) } /* sync receive data */ - if (at_client_recv(recv_buf, bfsz) != bfsz) + if (at_client_recv(recv_buf, bfsz, timeout) != bfsz) { LOG_E("receive size(%d) data failed!", bfsz); rt_free(recv_buf);