From be2b875e40fba1ca88675aabf5f14a4b63f9c2fb Mon Sep 17 00:00:00 2001 From: chenyong <1521761801@qq.com> Date: Fri, 14 Sep 2018 19:54:11 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91at=5Fclient?= =?UTF-8?q?=5Frecv=20=E5=87=BD=E6=95=B0=E6=B7=BB=E5=8A=A0=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenyong <1521761801@qq.com> --- at_socket_ec20.c | 13 ++++++++++--- at_socket_esp8266.c | 11 +++++++---- at_socket_m26.c | 11 +++++++---- 3 files changed, 24 insertions(+), 11 deletions(-) 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);