From: 孙春阳 Date: Mon, 8 Dec 2025 16:26:41 +0000 (+0800) Subject: 1、雷鸟禁用S_MGPIO22 输入唤醒,改为uart中断唤醒,修复 PM_ID_CAT1的投票去除不了的问题。 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F2897%2Ftarget%2F1;p=mirrors%2FFD230.git 1、雷鸟禁用S_MGPIO22 输入唤醒,改为uart中断唤醒,修复 PM_ID_CAT1的投票去除不了的问题。 2、恢复LWIP_LOWPOWER 0 (=1,=0 似乎变化不大,待验证) 3、tcp thread优先级调高,减少锁定时间,减少时间片占用,释放资源给其他线程(未验证) 4、延长 cat1_server的 信号更新同步时间为10秒 5、禁用uapi_ws_suspend,加快ws的重连效率。 --- 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(); } } }