BugID:17384074: handle mico wifi module input socket data, should read the
postfix data
@@ -234,7 +234,7 @@ static void handle_socket_data()
uint32_t len = 0;
char reader[16] = {0};
char *recvdata = NULL;
- char single;
+
/* Eat the "OCKET," */
at.read(reader, 6);
@@ -284,7 +284,7 @@ static void handle_socket_data()
return;
}
/* Prepare socket data */
- recvdata = (char *)aos_malloc(len + 1);
+ recvdata = (char *)aos_malloc(len);
if (!recvdata) {
LOGE(TAG, "Error: %s %d out of memory, len is %d. \r\n", __func__, __LINE__, len);
return;
@@ -296,15 +296,13 @@ static void handle_socket_data()
goto err;
}
- at.read(&single, 1);
- if (single != '\r') {
- LOGE(TAG, "at fail to read delimiter %d after data %d!\n", '\r', single);
+ memset(reader, 0, sizeof(reader));
+ at.read(reader, 2);
+ if (strncmp(reader, AT_RECV_PREFIX, 2) != 0) {
+ LOGE(TAG, "at fail to read delimiter %s after data %s!\n", AT_RECV_PREFIX, reader);
goto err;
}
- recvdata[len] = '\0';
- LOGD(TAG, "The socket data is %s", recvdata);
-
if (g_netconn_data_input_cb && (g_link[link_id].fd >= 0)) {
/* TODO get recv data src ip and port*/
if (g_netconn_data_input_cb(g_link[link_id].fd, recvdata, len, NULL, 0)) {
