From ac7253e4bc391715572ea001b2cfd600eeb3a2e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=AD=99=E6=98=A5=E9=98=B3?= Date: Tue, 9 Dec 2025 00:26:41 +0800 Subject: [PATCH] =?utf8?q?1=E3=80=81=E9=9B=B7=E9=B8=9F=E7=A6=81=E7=94=A8S?= =?utf8?q?=5FMGPIO22=20=E8=BE=93=E5=85=A5=E5=94=A4=E9=86=92=EF=BC=8C?= =?utf8?q?=E6=94=B9=E4=B8=BAuart=E4=B8=AD=E6=96=AD=E5=94=A4=E9=86=92?= =?utf8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=20PM=5FID=5FCAT1=E7=9A=84=E6=8A=95?= =?utf8?q?=E7=A5=A8=E5=8E=BB=E9=99=A4=E4=B8=8D=E4=BA=86=E7=9A=84=E9=97=AE?= =?utf8?q?=E9=A2=98=E3=80=82=202=E3=80=81=E6=81=A2=E5=A4=8DLWIP=5FLOWPOWER?= =?utf8?q?=200=20=EF=BC=88=3D1=EF=BC=8C=3D0=20=E4=BC=BC=E4=B9=8E=E5=8F=98?= =?utf8?q?=E5=8C=96=E4=B8=8D=E5=A4=A7=EF=BC=8C=E5=BE=85=E9=AA=8C=E8=AF=81?= =?utf8?q?=EF=BC=89=203=E3=80=81tcp=20thread=E4=BC=98=E5=85=88=E7=BA=A7?= =?utf8?q?=E8=B0=83=E9=AB=98=EF=BC=8C=E5=87=8F=E5=B0=91=E9=94=81=E5=AE=9A?= =?utf8?q?=E6=97=B6=E9=97=B4=EF=BC=8C=E5=87=8F=E5=B0=91=E6=97=B6=E9=97=B4?= =?utf8?q?=E7=89=87=E5=8D=A0=E7=94=A8=EF=BC=8C=E9=87=8A=E6=94=BE=E8=B5=84?= =?utf8?q?=E6=BA=90=E7=BB=99=E5=85=B6=E4=BB=96=E7=BA=BF=E7=A8=8B=EF=BC=88?= =?utf8?q?=E6=9C=AA=E9=AA=8C=E8=AF=81=EF=BC=89=204=E3=80=81=E5=BB=B6?= =?utf8?q?=E9=95=BF=20cat1=5Fserver=E7=9A=84=20=E4=BF=A1=E5=8F=B7=E6=9B=B4?= =?utf8?q?=E6=96=B0=E5=90=8C=E6=AD=A5=E6=97=B6=E9=97=B4=E4=B8=BA10?= =?utf8?q?=E7=A7=92=205=E3=80=81=E7=A6=81=E7=94=A8uapi=5Fws=5Fsuspend,?= =?utf8?q?=E5=8A=A0=E5=BF=ABws=E7=9A=84=E9=87=8D=E8=BF=9E=E6=95=88?= =?utf8?q?=E7=8E=87=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../lwip/lwip_adapter/liteos/src/arch/sio.c | 34 +++++++++++++++++-- .../src/include/lwip/lwipopts_default.h | 2 +- .../lwip/lwip_v2.1.3/src/api/tcpip.c | 2 +- .../4g/cat1Service/Service/cat1_server.c | 13 +++---- code/sdk/zhihui/4gTest/cat1_porting.c | 2 +- .../zhihui/websocket/os_ws/haisi_websocket.c | 4 +-- 6 files changed, 44 insertions(+), 13 deletions(-) diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c index 912acfc48..3fb708d62 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c @@ -48,6 +48,10 @@ #include #include #include "pmu_interrupt.h" +#ifdef SUPPORT_CAT1_SERVICE +#include "cat1_porting.h" +#include "pm_definition.h" +#endif /* 乒乓缓冲区配置 */ #ifndef SIO_PING_PONG_BUFFER_SIZE @@ -167,6 +171,13 @@ static sio_stats_t g_sio_stats = {0}; /* 数据处理回调函数指针 - 用于将数据传递给SLIP */ static void (*g_sio_data_callback)(const uint8_t *data, uint32_t len) = NULL; +#ifdef SUPPORT_CAT1_SERVICE +/* CAT1投票管理:记录最后接收数据的时间,用于idle检测 */ +static uint32_t g_sio_last_rx_time_ms = 0; +static bool g_sio_cat1_vote_added = false; +#define SIO_CAT1_VOTE_IDLE_MS 10000 // 10秒idle后移除投票 +#endif + /* 内部函数声明 */ @@ -320,7 +331,19 @@ static void sio_timeout_timer_callback(unsigned long arg) // ⚠️ 更新全局时间戳(供ISR使用,ISR中不能调用时间函数) g_sio_timer_timestamp_ms = current_time; - +#ifdef SUPPORT_CAT1_SERVICE + // ✅ CAT1投票管理:检测idle状态,超过10秒后移除投票 + if (g_sio_cat1_vote_added && g_sio_last_rx_time_ms > 0) { + uint32_t idle_time = current_time - g_sio_last_rx_time_ms; + if (idle_time >= SIO_CAT1_VOTE_IDLE_MS) { + // 空闲时间超过10秒,移除投票允许CAT1休眠 + cat1_api_remove_cat1_vote(); + g_sio_cat1_vote_added = false; + g_sio_last_rx_time_ms = 0; + printf("[SIO] Removed CAT1 vote after %ums idle\n", idle_time); + } + } +#endif if (g_sio_ping_pong_buffers == NULL) { goto restart_timer; @@ -415,7 +438,14 @@ static void sio_uart_rx_interrupt_handler(const void *buffer, uint16_t length, b g_sio_stats.total_interrupts++; g_sio_stats.total_bytes_received += length; - +#ifdef SUPPORT_CAT1_SERVICE + // ✅ CAT1投票管理:收到数据时,更新接收时间并添加投票 + g_sio_last_rx_time_ms = g_sio_timer_timestamp_ms; + if (!g_sio_cat1_vote_added) { + cat1_api_add_cat1_vote(); + g_sio_cat1_vote_added = true; + } +#endif uint8_t current_idx = g_sio_current_buffer_index; sio_ping_pong_buffer_t *current_buffer = &g_sio_ping_pong_buffers[current_idx]; diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h index 4ce9a9d1f..0bee4e3f5 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h @@ -44,7 +44,7 @@ extern "C" { #define LWIP_DEFINE_SWITCH 0 #define LOSCFG_CONFIG_MQTT 1 -#define LWIP_LOWPOWER 1 +#define LWIP_LOWPOWER 0 /* time unit */ #define MS_PER_SECOND 1000 diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c index 7324632f8..18d74a7ae 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c @@ -724,7 +724,7 @@ tcpip_init(tcpip_init_done_fn initfunc, void *arg) // tcpip_thread_id = sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO); taskcfg.create_queue_handle = NULL; taskcfg.attr.name=TCPIP_THREAD_NAME; - taskcfg.attr.priority = osPriorityBelowNormal;// osPriorityBelowNormal; + taskcfg.attr.priority = osPriorityNormal;// osPriorityBelowNormal; taskcfg.attr.stack_size = TCPIP_THREAD_STACKSIZE; taskcfg.func = tcpip_thread; taskcfg.use_mem = USE_EXTEND_MEM; diff --git a/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c b/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c index d97f195c4..f1becd361 100644 --- a/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c +++ b/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c @@ -74,7 +74,8 @@ static f_cat1_msg_callback g_cat1_msg_callback_func=NULL; #define PEER_IP "172.16.1.2" #define PEER_PORT 5000 #define SERVER_IP "172.16.1.5" -#define PORT 1000 +#define PORT 1000 +#define TIME_SYNC_INTERVAL 10000 // 时间同步定时器间隔,单位:毫秒 //"F"UDP_COMMAND_HEAD , len ,data enum UDP_COMMAND_HEAD { UDP_CMD_GET_CAT1VER = 0x00, // 获取 Cat1 版本号 @@ -1499,8 +1500,8 @@ void restart_time_sync(void) if(osTimerIsRunning(g_timer_time_sync)==0 ) { // cat1_print_info("cat1 restart_time_sync timer \n"); - // uint32_t tick = (uint32_t )osMs2Tick(5000); // 60000: seconds of a minute - osStatus_t ret = osTimerStart(g_timer_time_sync,5000); //5秒后重试同步时间 + // uint32_t tick = (uint32_t )osMs2Tick(TIME_SYNC_INTERVAL); // 60000: seconds of a minute + osStatus_t ret = osTimerStart(g_timer_time_sync, TIME_SYNC_INTERVAL); // 时间同步定时器启动 cat1_print_info("cat1 restart_time_sync timer ret %d\n",ret); } @@ -1983,11 +1984,11 @@ errcode_t cat1_server_init(void) g_timer_time_Dial = osTimerNew((osTimerFunc_t)time_dial_func, osTimerPeriodic, NULL, NULL); if (g_timer_time_Dial == NULL) - cat1_print_err("g_timer_time_sync create failed\n"); + cat1_print_err("g_timer_time_Dial create failed\n"); g_timer_time_answer = osTimerNew((osTimerFunc_t)time_answer_func, osTimerPeriodic, NULL, NULL); if (g_timer_time_answer == NULL) - cat1_print_err("g_timer_time_sync create failed\n"); + cat1_print_err("g_timer_time_answer create failed\n"); #ifdef USE_CAT1_SLEEP_TIMER @@ -2015,7 +2016,7 @@ void cat_sync_timer_control(int cmd) } else if(cmd == 1 && !osTimerIsRunning(g_timer_time_sync)) { - osTimerStart(g_timer_time_sync,5000); + osTimerStart(g_timer_time_sync, TIME_SYNC_INTERVAL); } } diff --git a/code/sdk/zhihui/4gTest/cat1_porting.c b/code/sdk/zhihui/4gTest/cat1_porting.c index 28f94cf4e..7012b4ea3 100644 --- a/code/sdk/zhihui/4gTest/cat1_porting.c +++ b/code/sdk/zhihui/4gTest/cat1_porting.c @@ -376,7 +376,7 @@ errcode_t cat1_api_porting_init(void) 1, S_AGPIO_L24,//reset_pin 1, - S_MGPIO22,//ring_pin + PIN_NONE,//S_MGPIO22,//ring_pin 0, S_MGPIO21,//wakemodem_pin 0, diff --git a/code/sdk/zhihui/websocket/os_ws/haisi_websocket.c b/code/sdk/zhihui/websocket/os_ws/haisi_websocket.c index fdc2d3e62..1634cf38f 100644 --- a/code/sdk/zhihui/websocket/os_ws/haisi_websocket.c +++ b/code/sdk/zhihui/websocket/os_ws/haisi_websocket.c @@ -560,13 +560,13 @@ static void uapi_ws_main_thread(void *arg) // 检测到idle且未suspend,执行suspend if (g_ws_is_suspended == 0) { HAISI_WS_DEBUG("Idle detected, suspending WebSocket\n"); - uapi_ws_suspend(); + // uapi_ws_suspend(); } } else { // 检测到busy且已suspend,执行resume if (g_ws_is_suspended != 0) { HAISI_WS_DEBUG("Busy detected, resuming WebSocket\n"); - uapi_ws_resume(); + // uapi_ws_resume(); } } } -- 2.17.1