system optimization & k18 sleep feather
author@CHENG <2393524978@qq.com>
Fri, 25 Oct 2024 08:50:06 +0000 (16:50 +0800)
committer@CHENG <2393524978@qq.com>
Fri, 25 Oct 2024 08:50:06 +0000 (16:50 +0800)
2.sdk/project/Z5_HA_K18/gui/lv_watch/mmi_default_CUSTOM.h
2.sdk/sdk/gui/lv_watch/app_adaptor/app_adaptor_timing_control.c
2.sdk/sdk/gui/lv_watch/include/ui_nvm_interface.h
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_http_protocol.c
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_sleep_activation.c
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_sleep_k18.c
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_sleep_k18.h
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.c
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_api.h
2.sdk/sdk/gui/lv_watch/modem/mmi_modem_tcp/mmi_modem_tcp_net.c
2.sdk/sdk/gui/lv_watch/modem/mmi_modem_tcp/mmi_modem_tcp_net.h

index b1cfe08..231ac3e 100644 (file)
@@ -91,7 +91,7 @@
 #define MMI_CUSTOMER_SLEEP_SETTING_TIME_SWITCH         (MMI_WATCH_SWITCH_ON) // 0-close; 1-open
 #define MMI_CUSTOMER_SLEEP_SETTING_TIME_BHOUR          (20) // 0-23
 #define MMI_CUSTOMER_SLEEP_SETTING_TIME_BMIN           (0) // 0-59
-#define MMI_CUSTOMER_SLEEP_SETTING_TIME_EHOUR          (9) // 0-23
+#define MMI_CUSTOMER_SLEEP_SETTING_TIME_EHOUR          (10) // 0-23
 #define MMI_CUSTOMER_SLEEP_SETTING_TIME_EMIN           (0) // 0-59
 
 
index fa016c2..296cd59 100644 (file)
@@ -112,6 +112,11 @@ static void mmi_gui_timing_task_entry(void * para)
 
 void mmi_gui_timing_task_create(void)
 {
+       if(NULL != s_gui_timing_task_id)
+       {               
+               return;
+       }
+       
        s_gui_timing_task_id = uos_create_task(mmi_gui_timing_task_entry,
                                                                                        NULL,
                                                                                        MMI_GUI_TIMING_MSG_QUEUE_SIZE,
@@ -253,9 +258,6 @@ static void mmi_gui_timing_timer_callback(uint32_t param)
     Hal_Rtc_Gettime(&cur_time);
        TIMING_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %02d:%02d:%02d\n", __FUNCTION__, __LINE__, cur_time.tm_hour, cur_time.tm_min, cur_time.tm_sec);
 
-       uos_timer_stop(s_timing_control_timer);
-       uos_timer_start(s_timing_control_timer, MS_TO_TICKS(MMI_GUI_TIMING_TIMER_INTERVAL), 0, mmi_gui_timing_timer_callback, NULL);
-
        s_timing_control_timer_counter++; // 3s per time
 
        mmi_gui_timing_task_msg_send(MMI_GUI_TIMING_MSG_3_SECOND, NULL); // 3 seconds
@@ -290,7 +292,11 @@ void app_adaptor_timing_control_init(void)
        mmi_gui_timing_task_create();
 
     uos_timer_create(&s_timing_control_timer);
-    uos_timer_start(s_timing_control_timer, MS_TO_TICKS(MMI_GUI_TIMING_TIMER_INTERVAL), 0, mmi_gui_timing_timer_callback, NULL);
+    uos_timer_start(s_timing_control_timer, 
+                                               MS_TO_TICKS(MMI_GUI_TIMING_TIMER_INTERVAL), 
+                                               MS_TO_TICKS(MMI_GUI_TIMING_TIMER_INTERVAL), 
+                                               mmi_gui_timing_timer_callback, 
+                                               NULL);
 }
 
 #else
index 6e5884c..b8d0298 100644 (file)
@@ -484,12 +484,12 @@ typedef struct
 #ifdef __MMI_CUSTOM_HENGAI_SLEEP_K18__
 #define NV_MAX_SLEEP_STATE 50
 
-typedef enum
-{
-       NV_LS_STATE = 11,                               // light sleep
-       NV_DS_STATE = 12,                               // deep sleep
-       NV_REM_STATE = 2,                               // rapid eye movement
-} NV_SLEEP_STATE_E;
+//typedef enum
+//{
+//     NV_LS_STATE = 11,                               // light sleep
+//     NV_DS_STATE = 12,                               // deep sleep
+//     NV_REM_STATE = 2,                               // rapid eye movement
+//} NV_SLEEP_STATE_E;
 
 typedef struct
 {
@@ -500,19 +500,19 @@ typedef struct
        uint8_t minute;
 } nv_sleep_time_t;
 
-typedef struct
-{
-       uint32_t duration;                      // the duration of corresponding state
-       NV_SLEEP_STATE_E state;         // state
-} nv_sleep_detail_data_t;
+//typedef struct
+//{
+//     uint32_t duration;                      // the duration of corresponding state
+//     NV_SLEEP_STATE_E state;         // state
+//} nv_sleep_detail_data_t;
 
 typedef struct
 {
        uint32_t total_sleep_time;                      // minutes
        nv_sleep_time_t begin_sleep_time;               // sleep_time_t
        nv_sleep_time_t end_sleep_time;
-       uint16_t state_count;                           // number of some sleep state
-       nv_sleep_detail_data_t data[NV_MAX_SLEEP_STATE];
+//     uint16_t state_count;                           // number of some sleep state
+//     nv_sleep_detail_data_t data[NV_MAX_SLEEP_STATE];
 } __packed nv_watch_hengai_sleep_data_t;
 #endif
 
index e6e2608..3253ec2 100644 (file)
@@ -1315,6 +1315,7 @@ static void mmi_hengai_tcp_algorithm_login_cb(uint32_t para)
        {
                uos_timer_stop(s_delay_timer_id);
                uos_timer_delete(s_delay_timer_id);
+               s_delay_timer_id = NULL;
        }
        
        mmi_hengai_tcp_algorithm_interface_login_action();
index b55b74f..ebb0846 100644 (file)
@@ -497,6 +497,7 @@ void mmi_hengai_get_sleep_data_stop(void)
        {
                uos_timer_stop(s_hengai_sleep_gsensor_timer_id);
                uos_timer_delete(s_hengai_sleep_gsensor_timer_id);
+               s_hengai_sleep_gsensor_timer_id = NULL;
        }
 
        s_hengai_sleep_gsensor_counter = 0;
index b2a1c00..fc5e86e 100644 (file)
@@ -18,8 +18,87 @@ static uint32_t s_hengai_sleep_gsensor_counter = 0;
 static sleep_data_t s_hengai_sdata = {0};
 static bool s_sleep_data_in_same_cycle = false;
 
-static void mmi_hengai_sleep_data_get(void);
-static void mmi_hengai_gsensor_data_get(uint32_t para);
+static TASK_HANDLE * s_hengai_k18_sleep_task_id = NULL;
+
+void mmi_hengai_k18_sleep_task_msg_send(MMI_WATCH_SLEEP_MSG_ID_E msg_id) //, void * msg_param)
+{
+       if(NULL == s_hengai_k18_sleep_task_id)
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: task not exist\n", __FUNCTION__, __LINE__);
+               return;
+       }
+       
+       if((MMI_WATCH_SLEEP_MSG_QUEUE_SIZE - 1) < Hal_Get_Message_Count(s_hengai_k18_sleep_task_id))
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: msg queue full\n", __FUNCTION__, __LINE__);
+               return;
+       }
+
+       printf("[@CHENG_DEBUG][%s][%d]: msg_id=%d\n", __FUNCTION__, __LINE__, msg_id);
+    mmi_watch_sleep_task_msg_t * msg = Hal_Mem_Alloc(sizeof(mmi_watch_sleep_task_msg_t));
+       if(NULL == msg)
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: memory alloc fail\n", __FUNCTION__, __LINE__);
+               return;
+       }
+       msg->msg_id = msg_id;
+       //msg->msg_param = msg_param;
+
+    Hal_Send_Message((TASK_ID)s_hengai_k18_sleep_task_id, (void *)msg);
+}
+
+static void mmi_hengai_k18_sleep_task_handle(void * param)
+{
+       mmi_watch_sleep_task_msg_t * msg = (mmi_watch_sleep_task_msg_t *)param;
+       MMI_WATCH_SLEEP_MSG_ID_E msg_id = msg->msg_id;
+       //void * msg_param = msg->msg_param;
+
+       printf("[@CHENG_DEBUG][%s][%d]: msg_id=%d\n", __FUNCTION__, __LINE__, msg_id);
+    switch(msg_id)
+       {
+               case MMI_WATCH_SLEEP_MSG_600MS:
+                       mmi_hengai_k18_gsensor_data_get();
+                       break;
+
+               default:
+                       break;
+    }
+}
+
+static void mmi_hengai_k18_sleep_task_entry(void * para)
+{
+    while(NULL == s_hengai_k18_sleep_task_id)
+       {
+        uos_sleep(10);
+    }
+
+    while(1)
+       {
+        mmi_watch_sleep_task_msg_t * msg = (mmi_watch_sleep_task_msg_t *)Hal_Receive_Message((TASK_ID)s_hengai_k18_sleep_task_id, TRUE);
+
+               mmi_hengai_k18_sleep_task_handle(msg);
+
+        //Hal_Mem_Free(msg->msg_param);
+        Hal_Mem_Free(msg);
+    }
+}
+
+void mmi_hengai_k18_sleep_task_create(void)
+{
+       if(NULL != s_hengai_k18_sleep_task_id)
+       {               
+               return;
+       }
+       
+       s_hengai_k18_sleep_task_id = uos_create_task(mmi_hengai_k18_sleep_task_entry,
+                                                                                                       NULL,
+                                                                                                       MMI_WATCH_SLEEP_MSG_QUEUE_SIZE,
+                                                                                                       MMI_WATCH_SLEEP_TASK_STACK_SIZE,
+                                                                                                       MMI_WATCH_SLEEP_TASK_PRIORITY,
+                                                                                                       "mmi_hengai_k18_sleep_task");
+
+       printf("[@CHENG_DEBUG][%s][%d]: task_id=0x%x\n", __FUNCTION__, __LINE__, s_hengai_k18_sleep_task_id);
+}
 
 
 
@@ -262,11 +341,12 @@ void __gsensor_data_set(unsigned char * next_buff, unsigned int next_buff_len)
 #endif
 
 
-static bool mmi_hengai_sleep_data_send(void)
+static bool mmi_hengai_k18_sleep_data_send(void)
 {
        char * temp_buff = NULL;
        uint32_t buff_size = sizeof(sleep_data_t);
        char * temp_ptr = NULL;
+       uint32_t temp_len = 0;
        uint32_t temp_count = 0;
        uint8_t i = 0;
 
@@ -304,7 +384,9 @@ static bool mmi_hengai_sleep_data_send(void)
                temp_count = strlen(temp_ptr);
        }
        
-       mmi_protocol_fzd_action_sleep_data(temp_buff, strlen(temp_buff));
+       temp_len = strlen(temp_buff);
+       UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: buff_size=%d,temp_len=%d\n", __FUNCTION__, __LINE__, buff_size, temp_len);
+       mmi_protocol_fzd_action_sleep_data(temp_buff, temp_len);
 
        if(NULL != temp_buff)
        {
@@ -313,7 +395,7 @@ static bool mmi_hengai_sleep_data_send(void)
        }
 }
 
-static void mmi_hengai_sleep_data_get(void)
+static void mmi_hengai_k18_sleep_data_get(void)
 {
        //if(0 != mmi_hsensor_measure_get_wear_status())
        {
@@ -333,29 +415,20 @@ static void mmi_hengai_sleep_data_get(void)
                UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: result=%d\n", __FUNCTION__, __LINE__, result);
                if(1 == result)
                {
-                       mmi_hengai_sleep_data_send();           
+                       mmi_hengai_k18_sleep_data_send();               
                        mmi_hengai_sleep_data_set(&s_hengai_sdata);
                }
                else if(-1 == result)
                {
                        mmi_hengai_health_sleep_lib_active();
                }
-       #ifdef __hengai_sleep_test__
-               mmi_hengai_k18_sleep_data_test_send();
-               mmi_hengai_sleep_result_save(&curtime, result);
-       #endif
        }
 
        _lv_memset_00(s_hengai_sleep_gsensor_data, sizeof(s_hengai_sleep_gsensor_data));
-       mmi_hengai_gsensor_data_get(0);
 }
 
-static void mmi_hengai_gsensor_data_get(uint32_t para)
+void mmi_hengai_k18_gsensor_data_get(void)
 {
-#ifdef __hengai_sleep_test_server_gsensor_data__
-       return;
-#endif
-
        int16_t t_mems_data[32 * 3] = {0};
        uint8_t i = 0;
        
@@ -363,6 +436,11 @@ static void mmi_hengai_gsensor_data_get(uint32_t para)
        for(i = 0; i < 30; i++) // 30 sets data per 600ms
        {
                uint16_t index = s_hengai_sleep_gsensor_counter * 30 + i;
+
+               if(HENGAI_SLEEP_GSENSOR_DATA_MAX <= index)
+               {
+                       break;
+               }
                
                s_hengai_sleep_gsensor_data[index].x = *(t_mems_data + i*3);
                s_hengai_sleep_gsensor_data[index].y = *(t_mems_data + i*3 + 1);
@@ -383,28 +461,22 @@ static void mmi_hengai_gsensor_data_get(uint32_t para)
        s_hengai_sleep_gsensor_counter++;
        if(100 <= s_hengai_sleep_gsensor_counter) // 1 minute:600ms*100
        {
-               uos_timer_stop(s_hengai_sleep_gsensor_timer_id);
                s_hengai_sleep_gsensor_counter = 0;
-       #ifdef __hengai_sleep_test__
-               mmi_hengai_k18_gsensor_upload_action();
-       #endif
-               mmi_hengai_sleep_data_get();
-       }
-       else
-       {
-               uos_timer_stop(s_hengai_sleep_gsensor_timer_id);
-               uos_timer_start(s_hengai_sleep_gsensor_timer_id, MS_TO_TICKS(600), 0, mmi_hengai_gsensor_data_get, NULL);
+               mmi_hengai_k18_sleep_data_get();
        }
 }
 
-void mmi_hengai_get_sleep_data_start(void)
+void mmi_hengai_k18_get_sleep_data_cb(uint32_t para)
 {
-#ifdef __hengai_sleep_test_server_gsensor_data__
-       return;
-#endif
+       mmi_hengai_k18_sleep_task_msg_send(MMI_WATCH_SLEEP_MSG_600MS); //, void * msg_param)
+}
 
+void mmi_hengai_get_sleep_data_start(void)
+{
        printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
+       mmi_hengai_k18_sleep_task_create();
        
        if(NULL != s_hengai_sleep_gsensor_timer_id)
                uos_timer_stop(s_hengai_sleep_gsensor_timer_id);
@@ -417,21 +489,22 @@ void mmi_hengai_get_sleep_data_start(void)
        //³õʼ»¯sdata
     init_sleep_data(&s_hengai_sdata);
     
-       uos_timer_start(s_hengai_sleep_gsensor_timer_id, MS_TO_TICKS(600), 0, mmi_hengai_gsensor_data_get, NULL);
+       uos_timer_start(s_hengai_sleep_gsensor_timer_id, 
+                                               MS_TO_TICKS(600), 
+                                               MS_TO_TICKS(600), 
+                                               mmi_hengai_k18_get_sleep_data_cb,
+                                               NULL);
 }
 
 void mmi_hengai_get_sleep_data_stop(void)
 {
-#ifdef __hengai_sleep_test_server_gsensor_data__
-       return;
-#endif
-
        printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
 
        if(NULL != s_hengai_sleep_gsensor_timer_id)
        {
                uos_timer_stop(s_hengai_sleep_gsensor_timer_id);
                uos_timer_delete(s_hengai_sleep_gsensor_timer_id);
+               s_hengai_sleep_gsensor_timer_id = NULL;
        }
 
        s_sleep_data_in_same_cycle = false;
@@ -473,7 +546,7 @@ void mmi_hengai_sleep_data_nv_write(void)
        
        if(nv_data_length != UI_NV_Write_Req(NV_SECTION_UI_HENGAI_SLEEP_DATA, 0, nv_data_length, (uint8_t *)&s_hengai_sleep_data))
        {
-               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
+               printf("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
        }
 }
 
@@ -483,35 +556,32 @@ void mmi_hengai_sleep_data_nv_read(void)
        
        if(nv_data_length != UI_NV_Read_Req(NV_SECTION_UI_HENGAI_SLEEP_DATA, 0, nv_data_length, (uint8_t *)&s_hengai_sleep_data))
        {
-               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
+               printf("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
                _lv_memset_00(&s_hengai_sleep_data, sizeof(nv_watch_hengai_sleep_data_t));
        }
 }
 
-void mmi_hengai_sleep_data_set(nv_watch_hengai_sleep_data_t * data)
+void mmi_hengai_sleep_data_set(sleep_data_t * data) // (nv_watch_hengai_sleep_data_t * data)
 {
        if(NULL == data)
                return;
 
        if(false == s_sleep_data_in_same_cycle)
        {
+               UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
                s_sleep_data_in_same_cycle = true;
-               _lv_memcpy(&s_hengai_sleep_data, data, sizeof(nv_watch_hengai_sleep_data_t));
+
+               s_hengai_sleep_data.total_sleep_time = data->total_sleep_time;
+               _lv_memcpy(&(s_hengai_sleep_data.begin_sleep_time), &(data->begin_sleep_time), sizeof(nv_sleep_time_t));
+               _lv_memcpy(&(s_hengai_sleep_data.end_sleep_time), &(data->end_sleep_time), sizeof(nv_sleep_time_t));
        }
        else
        {
+               UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
                s_hengai_sleep_data.total_sleep_time += data->total_sleep_time;
                _lv_memcpy(&(s_hengai_sleep_data.end_sleep_time), &(data->end_sleep_time), sizeof(nv_sleep_time_t));
-
-               if(NV_MAX_SLEEP_STATE > s_hengai_sleep_data.state_count)
-               {
-                       uint8_t count = s_hengai_sleep_data.state_count;
-                       s_hengai_sleep_data.state_count += data->state_count;
-                       if(NV_MAX_SLEEP_STATE < s_hengai_sleep_data.state_count)
-                               s_hengai_sleep_data.state_count = NV_MAX_SLEEP_STATE;
-
-                       _lv_memcpy(s_hengai_sleep_data.data + count, data->data, sizeof(nv_sleep_detail_data_t) * (s_hengai_sleep_data.state_count - count));
-               }
        }
        mmi_hengai_sleep_data_nv_write();
 }
@@ -701,8 +771,9 @@ static lv_obj_t * mmi_sleep_info_create(lv_obj_t * tileview, uint16_t id)
 
        // update time
        if(0 != s_hengai_sleep_data.total_sleep_time
-               && 0 != s_hengai_sleep_data.end_sleep_time.hour 
-               && 0 != s_hengai_sleep_data.end_sleep_time.minute
+               && (0 != s_hengai_sleep_data.end_sleep_time.hour 
+                       || 0 != s_hengai_sleep_data.end_sleep_time.minute
+                       )
                )
        {
                lv_obj_t * label_prompt = lv_label_create(cont, NULL);
@@ -868,6 +939,15 @@ void mmi_sleep_create_event_cb(lv_obj_t * btn, lv_event_t e)
 }
 #endif
 
+
+
+// [e9c46fe559102558fe099e794cd571a2oxLwDqcwJCtiPSRu*876226002021881*0067*SLEEP_DATA,2024-10-24 11:11,2024-10-24 13:48,157,10,11,0,2,109,12,2,11,3,12,2,11,1,12,24,2,10,12,2,11,4]
+// [34dd6188c1d1f31c95948171aad75c1boxLwDqcwJCtiPSRu*876226002021881*0063*SLEEP_DATA,2024-10-18 13:54,2024-10-18 15:39,107,10,11,0,2,24,12,9,2,5,12,7,2,5,12,7,2,46,12,2,11,2]
+// [26535ab1fed638806c9c532665c7bdd6oxLwDqcwJCtiPSRu*876226002021881*0054*SLEEP_DATA,2024-10-25 10:51,2024-10-25 12:06,75,7,11,1,12,3,2,16,12,7,2,38,12,7,11,3]
+// [3116327bf6a1a60db350f638f7b0bb69oxLwDqcwJCtiPSRu*876226002021881*0088*SLEEP_DATA,2024-10-25 12:10,2024-10-25 16:00,230,17,11,3,12,1,2,8,12,7,2,37,12,7,2,11,12,7,2,11,12,11,2,39,12,7,2,31,12,7,2,40,12,2,11,1]
+
+
+
 #endif
 
 
index f396619..5c1c103 100644 (file)
@@ -18,6 +18,26 @@ extern "C" {
 
 #ifdef __MMI_CUSTOM_HENGAI_SLEEP_K18__
 
+#define MMI_WATCH_SLEEP_TASK_PRIORITY 221
+#define MMI_WATCH_SLEEP_TASK_STACK_SIZE (1 * 1024)
+#define MMI_WATCH_SLEEP_MSG_QUEUE_SIZE (32) // (16)
+
+
+typedef enum
+{
+       MMI_WATCH_SLEEP_MSG_ID_START,
+
+    MMI_WATCH_SLEEP_MSG_600MS,
+
+    MMI_WATCH_SLEEP_MSG_ID_END
+}MMI_WATCH_SLEEP_MSG_ID_E;
+
+typedef struct
+{
+       uint16_t msg_id;
+       //void * msg_param;
+}mmi_watch_sleep_task_msg_t;
+
 
 void mmi_hengai_get_sleep_data_start(void);
 void mmi_hengai_get_sleep_data_stop(void);
index a880420..d529173 100644 (file)
@@ -321,7 +321,7 @@ void mmi_watch_authenticate_action(void)
                                }
 
                                mmi_watch_authenticate_flag_set(1);
-                               mmi_launcher_tcp_first_connect(0);
+                               mmi_launcher_tcp_first_connect_check_start();
                        }
                        else
                        {
@@ -480,10 +480,9 @@ static int16_t s_gsensor_chip_x = 0, s_gsensor_chip_y = 0, s_gsensor_chip_z = 0;
 
 #define PROTOCOL_LOCATION_MOVE_CHECK_TIMER_INTERVAL    (2 * 1000) // ms
 
-static void mmi_protocol_timing_timer_callback(uint32_t param);
+static void mmi_protocol_timing_timer_cb_action(void);
 static uint8_t mmi_protocol_location_move_state_get(void);
 static void mmi_protocol_location_move_state_set(uint8_t flag);
-static void mmi_protocol_location_move_state_check_cb(uint32_t param);
 
 static void mmi_protocol_timing_task_msg_send(MMI_PROTOCOL_TIMING_MSG_ID_E msg_id, void * msg_param)
 {
@@ -530,6 +529,10 @@ static void mmi_protocol_timing_task_handle(void * param)
        PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: msg_id=%d\n",__FUNCTION__,__LINE__, msg_id);
     switch(msg_id)
        {
+               case MMI_PROTOCOL_TIMING_MSG_TIMER_CB:
+                       mmi_protocol_timing_timer_cb_action();
+                       break;
+                       
                case MMI_PROTOCOL_TIMING_MSG_HEARTBEAT:
                        mmi_protocol_fzd_action_HEARTBEAT();
                        break;
@@ -591,16 +594,61 @@ static void mmi_protocol_timing_task_create(void)
        PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: task_id=0x%x\n",__FUNCTION__,__LINE__, s_protocol_timing_task_id);
 }
 
-static void mmi_protocol_timing_timer_callback(uint32_t param)
+static uint8_t mmi_protocol_location_move_state_get(void)
+{
+       return s_protocol_location_move_flag;
+}
+
+static void mmi_protocol_location_move_state_set(uint8_t flag)
+{
+       s_protocol_location_move_flag = flag;
+}
+
+static void mmi_protocol_location_move_state_check_cb(uint32_t param)
+{
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
+       if(0 == mmi_protocol_location_move_state_get())
+       {
+               int16_t chip_x = 0, chip_y = 0, chip_z = 0;
+               
+               xMotion_Chip_Read_XYZ(&chip_x, &chip_y, &chip_z);
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,%d,%d/%d,%d,%d\n", __FUNCTION__, __LINE__,
+                                                               chip_x, chip_y, chip_z, s_gsensor_chip_x, s_gsensor_chip_y, s_gsensor_chip_z);
+               if((100 < abs(s_gsensor_chip_x - chip_x)) || (100 < abs(s_gsensor_chip_y - chip_y)) || (100 < abs(s_gsensor_chip_z - chip_z)))
+               {
+                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       mmi_protocol_location_move_state_set(1);
+               }
+               s_gsensor_chip_x = chip_x;
+               s_gsensor_chip_y = chip_y;
+               s_gsensor_chip_z = chip_z;
+       }
+}
+
+void mmi_protocol_location_move_state_check(void)
+{
+       if(NULL == s_protocol_location_move_check_timer)
+           uos_timer_create(&s_protocol_location_move_check_timer);
+       else
+               uos_timer_stop(s_protocol_location_move_check_timer);
+
+       mmi_protocol_location_move_state_set(0);
+       xMotion_Chip_Read_XYZ(&s_gsensor_chip_x, &s_gsensor_chip_y, &s_gsensor_chip_z);
+    uos_timer_start(s_protocol_location_move_check_timer, 
+                                               MS_TO_TICKS(PROTOCOL_LOCATION_MOVE_CHECK_TIMER_INTERVAL), 
+                                               MS_TO_TICKS(PROTOCOL_LOCATION_MOVE_CHECK_TIMER_INTERVAL), 
+                                               mmi_protocol_location_move_state_check_cb, 
+                                               NULL);
+}
+
+static void mmi_protocol_timing_timer_cb_action(void)
 {
        uint32_t cur_time_stamp = 0;
 
        Hal_Rtc_Gettime_Count_Utc(&cur_time_stamp);
        PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: cur_time_stamp=%d\n", __FUNCTION__, __LINE__, cur_time_stamp);
 
-       uos_timer_stop(s_protocol_timing_timer);
-    uos_timer_start(s_protocol_timing_timer, MS_TO_TICKS(PROTOCOL_TIMING_TIMER_INTERVAL), 0, mmi_protocol_timing_timer_callback, NULL);
-
        // heartbeat
        if(mmi_protocol_watch_heartbeat_action_interval_get() <= (cur_time_stamp - s_protocol_heartbeat_time_stamp))
        {
@@ -636,51 +684,9 @@ static void mmi_protocol_timing_timer_callback(uint32_t param)
 
 }
 
-static uint8_t mmi_protocol_location_move_state_get(void)
-{
-       return s_protocol_location_move_flag;
-}
-
-static void mmi_protocol_location_move_state_set(uint8_t flag)
-{
-       s_protocol_location_move_flag = flag;
-}
-
-static void mmi_protocol_location_move_state_check_cb(uint32_t param)
-{
-       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
-
-       uos_timer_stop(s_protocol_location_move_check_timer);
-    uos_timer_start(s_protocol_location_move_check_timer, MS_TO_TICKS(PROTOCOL_LOCATION_MOVE_CHECK_TIMER_INTERVAL), 0, mmi_protocol_location_move_state_check_cb, NULL);
-
-       if(0 == mmi_protocol_location_move_state_get())
-       {
-               int16_t chip_x = 0, chip_y = 0, chip_z = 0;
-               
-               xMotion_Chip_Read_XYZ(&chip_x, &chip_y, &chip_z);
-               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,%d,%d/%d,%d,%d\n", __FUNCTION__, __LINE__,
-                                                               chip_x, chip_y, chip_z, s_gsensor_chip_x, s_gsensor_chip_y, s_gsensor_chip_z);
-               if((100 < abs(s_gsensor_chip_x - chip_x)) || (100 < abs(s_gsensor_chip_y - chip_y)) || (100 < abs(s_gsensor_chip_z - chip_z)))
-               {
-                       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
-                       mmi_protocol_location_move_state_set(1);
-               }
-               s_gsensor_chip_x = chip_x;
-               s_gsensor_chip_y = chip_y;
-               s_gsensor_chip_z = chip_z;
-       }
-}
-
-void mmi_protocol_location_move_state_check(void)
+static void mmi_protocol_timing_timer_callback(uint32_t param)
 {
-       if(NULL == s_protocol_location_move_check_timer)
-           uos_timer_create(&s_protocol_location_move_check_timer);
-       else
-               uos_timer_stop(s_protocol_location_move_check_timer);
-
-       mmi_protocol_location_move_state_set(0);
-       xMotion_Chip_Read_XYZ(&s_gsensor_chip_x, &s_gsensor_chip_y, &s_gsensor_chip_z);
-    uos_timer_start(s_protocol_location_move_check_timer, MS_TO_TICKS(PROTOCOL_LOCATION_MOVE_CHECK_TIMER_INTERVAL), 0, mmi_protocol_location_move_state_check_cb, NULL);
+       mmi_protocol_timing_task_msg_send(MMI_PROTOCOL_TIMING_MSG_TIMER_CB, NULL);
 }
 
 void mmi_protocol_timing_mission_action(void)
@@ -716,7 +722,11 @@ void mmi_protocol_timing_mission_action(void)
        else
                uos_timer_stop(s_protocol_timing_timer);
 
-    uos_timer_start(s_protocol_timing_timer, MS_TO_TICKS(PROTOCOL_TIMING_TIMER_INTERVAL), 0, mmi_protocol_timing_timer_callback, NULL);
+    uos_timer_start(s_protocol_timing_timer, 
+                                               MS_TO_TICKS(PROTOCOL_TIMING_TIMER_INTERVAL), 
+                                               MS_TO_TICKS(PROTOCOL_TIMING_TIMER_INTERVAL), 
+                                               mmi_protocol_timing_timer_callback, 
+                                               NULL);
 }
 
 void mmi_protocol_timing_mission_stop(void)
index 4fb5276..80aabdb 100644 (file)
@@ -39,6 +39,7 @@ typedef enum
 {
        MMI_PROTOCOL_TIMING_MSG_ID_START,
 
+    MMI_PROTOCOL_TIMING_MSG_TIMER_CB,
     MMI_PROTOCOL_TIMING_MSG_HEARTBEAT,
        MMI_PROTOCOL_TIMING_MSG_LOCATION_UPDATE,
     MMI_PROTOCOL_TIMING_MSG_WEATHER_UPDATE,
index b1d509d..03eed0f 100644 (file)
@@ -25,7 +25,7 @@ void tcp_connect_cb(int t)
 static void * s_tcp_first_connect_timer_id = NULL;
 static uint32_t s_tcp_first_connect_time = 0;
 
-void mmi_launcher_tcp_first_connect(uint32_t para)
+static void mmi_launcher_tcp_first_connect_check_cb(uint32_t para)
 {
        if((FALSE == watch_modem_sim_present_check_req())
                && (MMI_TCP_FIRST_CONNECT_TIMEOUT <= s_tcp_first_connect_time)
@@ -49,16 +49,6 @@ void mmi_launcher_tcp_first_connect(uint32_t para)
                {
                        printf("[@CHENG_DEBUG][%s][%d]: \n",__FUNCTION__,__LINE__);
 
-                       if(NULL == s_tcp_first_connect_timer_id)
-                       {
-                               uos_timer_create(&s_tcp_first_connect_timer_id);
-                       }
-                       uos_timer_stop(s_tcp_first_connect_timer_id);
-                       uos_timer_start(s_tcp_first_connect_timer_id, 
-                                                       MS_TO_TICKS(MMI_TCP_FIRST_CONNECT_TIME_INTERVAL), 
-                                                       MS_TO_TICKS(MMI_TCP_FIRST_CONNECT_TIME_INTERVAL),
-                                                       mmi_launcher_tcp_first_connect,
-                                                       NULL);
                        if(true == mmi_poweron_logo_is_finish())
                        {
                                s_tcp_first_connect_time += MMI_TCP_FIRST_CONNECT_TIME_INTERVAL;
@@ -85,6 +75,24 @@ void mmi_launcher_tcp_first_connect(uint32_t para)
        }
 }
 
+void mmi_launcher_tcp_first_connect_check_start(void)
+{
+       printf("[@CHENG_DEBUG][%s][%d]: \n",__FUNCTION__,__LINE__);
+
+       s_tcp_first_connect_time = 0;
+       
+       if(NULL == s_tcp_first_connect_timer_id)
+               uos_timer_create(&s_tcp_first_connect_timer_id);
+       else
+               uos_timer_stop(s_tcp_first_connect_timer_id);
+       
+       uos_timer_start(s_tcp_first_connect_timer_id, 
+                                       MS_TO_TICKS(MMI_TCP_FIRST_CONNECT_TIME_INTERVAL), 
+                                       MS_TO_TICKS(MMI_TCP_FIRST_CONNECT_TIME_INTERVAL),
+                                       mmi_launcher_tcp_first_connect_check_cb,
+                                       NULL);
+}
+
 #ifdef __MMI_ZHSX_SUPPORT_AUTHENTICATE__
 #define MMI_AUTHENTICATE_CONNECT_TIME_INTERVAL         (1000 * 5) // ms
 #define MMI_AUTHENTICATE_CONNECT_TIMEOUT               (1000 * 60 * 3) // ms
@@ -97,7 +105,7 @@ void mmi_watch_msg_authenticate(void)
        send_task_msg_authenticate_action();
 }
 
-void mmi_watch_authenticate_pre(uint32_t para)
+static void mmi_watch_authenticate_check_cb(uint32_t para)
 {
        if((FALSE == watch_modem_sim_present_check_req())
                && (MMI_AUTHENTICATE_CONNECT_TIMEOUT <= s_authenticate_connect_time)
@@ -121,16 +129,6 @@ void mmi_watch_authenticate_pre(uint32_t para)
                {
                        printf("[@CHENG_DEBUG][%s][%d]: \n",__FUNCTION__,__LINE__);
 
-                       if(NULL == s_authenticate_connect_timer_id)
-                       {
-                               uos_timer_create(&s_authenticate_connect_timer_id);
-                       }
-                       uos_timer_stop(s_authenticate_connect_timer_id);
-                       uos_timer_start(s_authenticate_connect_timer_id, 
-                                                       MS_TO_TICKS(MMI_AUTHENTICATE_CONNECT_TIME_INTERVAL), 
-                                                       MS_TO_TICKS(MMI_AUTHENTICATE_CONNECT_TIME_INTERVAL), 
-                                                       mmi_watch_authenticate_pre, 
-                                                       NULL);
                        if(true == mmi_poweron_logo_is_finish())
                        {
                                s_authenticate_connect_time += MMI_AUTHENTICATE_CONNECT_TIME_INTERVAL;
@@ -156,6 +154,24 @@ void mmi_watch_authenticate_pre(uint32_t para)
                }
        }
 }
+
+static void mmi_watch_authenticate_check_start(void)
+{
+       printf("[@CHENG_DEBUG][%s][%d]: \n",__FUNCTION__,__LINE__);
+
+       s_authenticate_connect_time = 0;
+       
+       if(NULL == s_authenticate_connect_timer_id)
+               uos_timer_create(&s_authenticate_connect_timer_id);
+       else
+               uos_timer_stop(s_authenticate_connect_timer_id);
+       
+       uos_timer_start(s_authenticate_connect_timer_id, 
+                                       MS_TO_TICKS(MMI_AUTHENTICATE_CONNECT_TIME_INTERVAL), 
+                                       MS_TO_TICKS(MMI_AUTHENTICATE_CONNECT_TIME_INTERVAL), 
+                                       mmi_watch_authenticate_check_cb, 
+                                       NULL);
+}
 #endif
 
 #endif
@@ -173,14 +189,14 @@ void mmi_modem_tcp_task_init(void)
 #ifdef __MMI_ZHSX_SUPPORT_AUTHENTICATE__
        if(0 == mmi_watch_authenticate_flag_get())
        {
-               mmi_watch_authenticate_pre(0);
+               mmi_watch_authenticate_check_start();
        }
        else
        {
-               mmi_launcher_tcp_first_connect(0);
+               mmi_launcher_tcp_first_connect_check_start();
        }
 #else
-       mmi_launcher_tcp_first_connect(0);
+       mmi_launcher_tcp_first_connect_check_start();
 #endif
        
 #else
index 3bc4031..dc5642a 100644 (file)
@@ -87,7 +87,7 @@ void shutdownc_tcp_connect(FUNC_CB tcp_callback);
 void send_tcp_cmdmsg(int cmd_type,void* cmd_param);
 
 #ifdef __MMI_ZHSX_SUPPORT__
-void mmi_launcher_tcp_first_connect(uint32_t para);
+void mmi_launcher_tcp_first_connect_check_start(void);
 #endif
 
 #ifdef __cplusplus