修复battery不能更新bug
authorSnickerSun <snickersun@163.com>
Tue, 23 Jan 2024 07:15:10 +0000 (15:15 +0800)
committerSnickerSun <snickersun@163.com>
Tue, 23 Jan 2024 07:15:10 +0000 (15:15 +0800)
code/sdk/application/battery/service/battery_service.c

index 4a58f84..bb088f4 100644 (file)
@@ -412,9 +412,7 @@ static void battery_check_task(void const *arg)
     int32_t ret;
     common_notify_mail_t mail;
     uint32_t msgsize = (uint32_t)sizeof(common_notify_mail_t);
-    //开始timer
-    battery_timer_start_check_released(CHARGE_CHECK_TIMER_CYCLE_MS);
-
+    
     while (1) {
         ret = osal_msg_queue_read_copy(g_app_queue, (void *)&mail, &msgsize,
                                        OSAL_MSGQ_WAIT_FOREVER);
@@ -431,28 +429,30 @@ static void battery_check_task(void const *arg)
 
         if (mail.comm.app == BATTERY_CMD_CHECK_VOLTAGE) {
 
-
             g_check_count++;
+            // PRINT("BATTERY_CMD_CHECK_VOLTAGE g_check_count %d\r\n",g_check_count);
             
             if(last_battery_charge_enable_status == true){
             
                 if (g_check_count*CHARGE_CHECK_TIMER_CYCLE_MS  >= ENABLE_CHARGE_TIMEOUT_MS)
                 {
+                    // PRINT("BATTERY_CMD_CHECK_VOLTAGE disable_charge \r\n");
+
                     g_check_count = 0 ;
                     //超时交换状态
                     disable_charge();
                     last_battery_charge_enable_status = false;
                 }
 
-                
-
             }else if (last_battery_charge_enable_status == false) {
                 if (g_check_count*CHARGE_CHECK_TIMER_CYCLE_MS  >= DISABLE_CHARGE_CHECK_MS)
                 {
+                    // PRINT("BATTERY_CMD_CHECK_VOLTAGE battery_check_and_enable_charge \r\n");
+
                     g_check_count = 0 ;
                     //超时交换状态
                     battery_check_and_enable_charge();
-                    last_battery_charge_enable_status = false;
+                    last_battery_charge_enable_status = true;
                 }
                 
             }
@@ -481,6 +481,9 @@ errcode_t uapi_battery_init(void)
     // osal_kthread_set_priority(task_handle, 10);
     g_battery_timer = osTimerNew((osTimerFunc_t)battery_check_timer_callback, osTimerPeriodic, NULL, NULL);
 
+    //开始timer
+    battery_timer_start_check_released(CHARGE_CHECK_TIMER_CYCLE_MS);
+
     return ERRCODE_SUCC;
 }