修复cat1默认关闭时,开机状态不正确问题。
authorSnickerSun <snickersun@163.com>
Wed, 8 May 2024 13:36:55 +0000 (21:36 +0800)
committerSnickerSun <snickersun@163.com>
Wed, 8 May 2024 13:36:55 +0000 (21:36 +0800)
优化cat1休眠投票处理机制

code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp
code/sdk/drivers/peripheral/utils/custom_cmd_service.c

index f509a1a..1bc182c 100644 (file)
@@ -103,7 +103,9 @@ struct tcp_msg_t {
 static int g_listen_sock = 0;
 struct sockaddr_in sourceAddr = {0};
 static osTimerId_t g_timer_time_sync = NULL;
+#if USE_CAT1_SLEEP_TIMER
 static osTimerId_t g_timer_cat1_sleep = NULL;
+#endif
 static uint8_t g_time_synced = 0;
 #define MAX_TIME_SYNC_RETRY_TIME 5
 static uint8_t g_time_sync_retry_time = 0;
@@ -575,6 +577,8 @@ int cat1_handle_timesync(struct tcp_msg_t *msg)
 
     return 1;
 }
+
+#if USE_CAT1_SLEEP_TIMER
 void mcu_remove_sleepvote_and_stoptimer(void)
 {
     // uapi_cat1_wakeup_cat1(0);// 反馈给cat1,它也可以自己睡
@@ -590,6 +594,7 @@ static void timeout_handler_sleep_cat1(void)
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,"sleep mcu\n");
     do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_REMOVE_CAT1VOTE,NULL,0);
 }
+
 //目前只在 被cat1唤醒的中断函数里执行,
 void restart_sleep_cat1_timer(void)
 {
@@ -610,12 +615,27 @@ void restart_sleep_cat1_timer(void)
         // WEARABLE_LOGI(WEARABLE_LOG_MODULE_MAIN_SERVICE,"osTimerStart g_timer_cat1_sleep ret %d\n",ret);
     }
 }
-
+#endif
 
 static void time_sync_func(void)
 {
     
     PRINT("time_sync_func\n");
+
+    runtime_status_t * runtime = get_device_runtime_status();
+    if (uapi_cat1_get_power_stat() == false )
+    {
+        //开关是关的 则cat1所有状态清空
+         runtime->cat1_runtime.cat1_powerOn = 0;
+         runtime->cat1_runtime.network_on = 0;
+         runtime->cat1_runtime.signal = 99;
+         runtime->cat1_runtime.sim = 0;
+         runtime->cat1_runtime.volte = 0;
+         return ;
+    }else{
+         runtime->cat1_runtime.cat1_powerOn = 1;
+
+    }
     cat1_getsignal();
     
     if(osTimerIsRunning(g_timer_time_sync)==1 && g_time_synced == 1 )
@@ -807,8 +827,10 @@ void cat1_server_task(void *pvParameters)
             // if( index >= 0 ) {
             //     udp_send_response(tx_buffer, rx_buffer, "OK"/* msg_wifi_resp[index]*/);
             // }
+
+            #ifndef USE_CAT1_SLEEP_TIMER
             uapi_cat1_remove_cat1_vote(); //中断会添加休眠投票,此处代表已经收到cat1的消息,可以移除投票进入休眠了。
-  
+            #endif
         }
        }
        
@@ -859,12 +881,15 @@ errcode_t cat1_server_init(void)
     if (g_timer_time_sync == NULL)
         PRINT("g_timer_time_sync create failed\n");
 
+    restart_time_sync();
+
+#if USE_CAT1_SLEEP_TIMER
     g_timer_cat1_sleep = osTimerNew((osTimerFunc_t)timeout_handler_sleep_cat1, osTimerPeriodic, NULL, NULL);
     if (g_timer_cat1_sleep == NULL)
         PRINT("g_timer_cat1_sleep create failed\n");
     //第一次启动,要确保去除已经添加过的cat1 Vote
     restart_sleep_cat1_timer();
-    
+#endif
     return ERRCODE_SUCC;
 }
 
index a25933e..c805abb 100644 (file)
@@ -96,10 +96,14 @@ static void custom_cmd_service_check_task(void const *arg)
             uapi_cat1_add_cat1_vote();
             //中断会在此添加休眠投票,在收到cat1的消息后,会移除投票进入休眠。
             //之前的5秒后移除投票延迟太久,与5秒更新一次信号强度
-            // restart_sleep_cat1_timer();
+            #if USE_CAT1_SLEEP_TIMER
+                restart_sleep_cat1_timer();
+            #endif
             break;
         case CUSTOM_CMD_MSG_TYPE_REMOVE_CAT1VOTE:
-            mcu_remove_sleepvote_and_stoptimer();
+            #if USE_CAT1_SLEEP_TIMER
+                mcu_remove_sleepvote_and_stoptimer();
+            #endif
             break;
         case CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME:
             {