From a939e8e4ea7d25fe4e5a6d94055015377e6f68bf Mon Sep 17 00:00:00 2001 From: yangpeng Date: Mon, 4 Nov 2024 15:57:11 +0800 Subject: [PATCH] =?UTF-8?q?[components/net/at]=E4=BF=AE=E5=A4=8Dat=20socke?= =?UTF-8?q?t=E4=BF=A1=E5=8F=B7=E9=87=8F=E9=87=8A=E6=94=BE=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/net/at/at_socket/at_socket.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index d84875be3a..2973120205 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -439,12 +439,14 @@ static struct at_socket *alloc_socket_by_device(struct at_device *device, enum a #endif rt_snprintf(name, RT_NAME_MAX, "%s%d", "at_skt", idx); - /* create AT socket receive mailbox */ + /* create AT socket receive semaphore */ if ((sock->recv_notice = rt_sem_create(name, 0, RT_IPC_FLAG_FIFO)) == RT_NULL) { LOG_E("No memory socket receive notic semaphore create."); goto __err; } + /* set AT socket receive semaphore 'max_value' to 1 */ + rt_sem_control(sock->recv_notice, RT_IPC_CMD_SET_VLIMIT, (void *)1); rt_snprintf(name, RT_NAME_MAX, "%s%d", "at_skt", idx); /* create AT socket receive ring buffer lock */ @@ -823,7 +825,7 @@ static void at_recv_notice_cb(struct at_socket *sock, at_socket_evt_t event, con } rt_mutex_release(sock->recv_lock); - rt_sem_control(sock->recv_notice, RT_IPC_CMD_RESET, (void*)1); + rt_sem_release(sock->recv_notice); at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE); } @@ -842,7 +844,7 @@ static void at_closed_notice_cb(struct at_socket *sock, at_socket_evt_t event, c at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE); sock->state = AT_SOCKET_CLOSED; - rt_sem_control(sock->recv_notice, RT_IPC_CMD_RESET, (void*)1); + rt_sem_release(sock->recv_notice); } #ifdef AT_USING_SOCKET_SERVER