hengai
authorCCC <2393524978@qq.com>
Mon, 20 Nov 2023 08:27:25 +0000 (16:27 +0800)
committerCCC <2393524978@qq.com>
Mon, 20 Nov 2023 08:27:25 +0000 (16:27 +0800)
19 files changed:
2.sdk/sdk/gui/lv_watch/app_adaptor/app_adaptor_timing_control.c
2.sdk/sdk/gui/lv_watch/framework/nvm/ui_nvm.h
2.sdk/sdk/gui/lv_watch/framework/nvm/ui_nvm_api.c
2.sdk/sdk/gui/lv_watch/include/ui_nvm_interface.h
2.sdk/sdk/gui/lv_watch/lv_apps/alarm_remind/alarm_remind.c
2.sdk/sdk/gui/lv_watch/lv_apps/alarm_remind/alarm_remind.h
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/custom_function.c
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/custom_function.h
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_sleep_activation.c [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_sleep_activation.h [new file with mode: 0644]
2.sdk/sdk/gui/lv_watch/lv_watch.c
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.c
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd.h
2.sdk/sdk/gui/lv_watch/mmi_protocol/mmi_protocol_fzd_content.c
2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_sundry.c
2.sdk/sdk/gui/lv_watch/mmi_sundry/mmi_sundry.h
2.sdk/sdk/product/craneg_modem/CMakeLists.txt
2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/inc/lib_sleep.h [new file with mode: 0644]
2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/lib/lib_sleep_yll_v0.2.6.111623.a [new file with mode: 0644]

index c3d2b12..05cc676 100644 (file)
@@ -11,7 +11,7 @@
 #include <stdbool.h>
 #include "app_adaptor_timing_control.h"
 
-#ifdef __MMI_ZHSX_SUPPORT__
+#if 1 // def __MMI_ZHSX_SUPPORT__
 
 static void * s_timing_control_timer = NULL;
 static int8_t s_timing_control_last_min = -1;
@@ -39,9 +39,15 @@ static void timing_timer_callback(uint32_t param)
                s_timing_control_last_min = cur_time.tm_min;
                
                // check remind
-               mmi_remind_mission(cur_time);
+               mmi_remind_mission_check(cur_time);
 
+               // check sleep time
+               mmi_watch_sleep_time_mission_check();
 
+
+
+
+               
        }
 }
 
index 201eb34..05152e4 100644 (file)
@@ -51,6 +51,7 @@ extern "C" {
 #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
 #define NV_SECTION_UI_DO_NOT_DISTURB_LEN                       (sizeof(nv_watch_do_not_disturb_t))
 #endif
+#define NV_SECTION_UI_SLEEP_TIME_DATA_LEN                      (sizeof(nv_watch_sleep_time_t))
 #define NV_SECTION_UI_DIAL_PAD_SWITCH_LEN                      (sizeof(nv_watch_switch_t))
 #define NV_SECTION_UI_WHITE_LIST_SWITCH_LEN                    (sizeof(nv_watch_switch_t))
 #define NV_SECTION_UI_MAIN_MENU_STYLE_LEN                      (sizeof(nv_watch_main_menu_style_t))
@@ -64,6 +65,7 @@ extern "C" {
 #endif
 #ifdef __MMI_CUSTOM_HENG_AI__
 #define NV_SECTION_UI_HENG_AI_WAKE_RING_TYPE_LEN       (sizeof(nv_watch_switch_t))
+#define NV_SECTION_UI_HENG_AI_SLEEP_ACTIVATION_LEN     (sizeof(nv_watch_heng_ai_sleep_activation_t))
 #endif
 
 #endif
@@ -162,6 +164,7 @@ typedef lv_fs_dir_t  ui_dir_t;
 #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
 #define NV_SECTION_UI_DO_NOT_DISTURB_FILE                      "ui_do_not_disturb.nv"
 #endif
+#define NV_SECTION_UI_SLEEP_TIME_DATA_FILE                     "ui_sleep_time_data.nv"
 #define NV_SECTION_UI_DIAL_PAD_SWITCH_FILE                     "ui_dial_pad_switch.nv"
 #define NV_SECTION_UI_WHITE_LIST_SWITCH_FILE           "ui_white_list_switch.nv"
 #define NV_SECTION_UI_MAIN_MENU_STYLE_FILE                     "ui_main_menu_style.nv"
@@ -175,6 +178,7 @@ typedef lv_fs_dir_t  ui_dir_t;
 #endif
 #ifdef __MMI_CUSTOM_HENG_AI__
 #define NV_SECTION_UI_HENG_AI_WAKE_RING_TYPE_FILE      "ui_heng_ai_wake_ring_type.nv"
+#define NV_SECTION_UI_HENG_AI_SLEEP_ACTIVATION_FILE    "ui_heng_ai_sleep_activation.nv"
 #endif
 
 
index 25dc49c..66e469b 100644 (file)
@@ -96,6 +96,8 @@ uint32_t UI_NV_Get_Section_Len(NV_UI_SECTION_ID SectionId)
                case NV_SECTION_UI_DO_NOT_DISTURB:
                        return (NV_SECTION_LEN(NV_SECTION_UI_DO_NOT_DISTURB));
        #endif
+               case NV_SECTION_UI_SLEEP_TIME_DATA:
+                       return (NV_SECTION_LEN(NV_SECTION_UI_SLEEP_TIME_DATA));
                case NV_SECTION_UI_DIAL_PAD_SWITCH:
                        return (NV_SECTION_LEN(NV_SECTION_UI_DIAL_PAD_SWITCH));
                case NV_SECTION_UI_WHITE_LIST_SWITCH:
@@ -117,6 +119,8 @@ uint32_t UI_NV_Get_Section_Len(NV_UI_SECTION_ID SectionId)
        #ifdef __MMI_CUSTOM_HENG_AI__
                case NV_SECTION_UI_HENG_AI_WAKE_RING_TYPE:
                        return (NV_SECTION_LEN(NV_SECTION_UI_HENG_AI_WAKE_RING_TYPE));
+               case NV_SECTION_UI_HENG_AI_SLEEP_ACTIVATION:
+                       return (NV_SECTION_LEN(NV_SECTION_UI_HENG_AI_SLEEP_ACTIVATION));
        #endif
                                
                        
@@ -215,6 +219,8 @@ char * UI_NV_Get_Section_path(NV_UI_SECTION_ID SectionId)
                case NV_SECTION_UI_DO_NOT_DISTURB:
                        return (NV_SECTION_FILE_PATH(NV_SECTION_UI_DO_NOT_DISTURB));
        #endif
+               case NV_SECTION_UI_SLEEP_TIME_DATA:
+                       return (NV_SECTION_FILE_PATH(NV_SECTION_UI_SLEEP_TIME_DATA));
                case NV_SECTION_UI_DIAL_PAD_SWITCH:
                        return (NV_SECTION_FILE_PATH(NV_SECTION_UI_DIAL_PAD_SWITCH));
                case NV_SECTION_UI_WHITE_LIST_SWITCH:
@@ -236,6 +242,8 @@ char * UI_NV_Get_Section_path(NV_UI_SECTION_ID SectionId)
        #ifdef __MMI_CUSTOM_HENG_AI__
                case NV_SECTION_UI_HENG_AI_WAKE_RING_TYPE:
                        return (NV_SECTION_FILE_PATH(NV_SECTION_UI_HENG_AI_WAKE_RING_TYPE));
+               case NV_SECTION_UI_HENG_AI_SLEEP_ACTIVATION:
+                       return (NV_SECTION_FILE_PATH(NV_SECTION_UI_HENG_AI_SLEEP_ACTIVATION));
        #endif
 
                        
@@ -294,6 +302,7 @@ uint8_t UI_NV_Reset_Default(NV_UI_SECTION_ID SectionId)
 #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
        nv_watch_do_not_disturb_t * do_not_disturb;
 #endif
+       nv_watch_sleep_time_t * sleep_time_data;
        nv_watch_switch_t * mmi_switch_data;
        nv_watch_main_menu_style_t * main_menu_style;
 #ifdef __MMI_ZHSX_SUPPORT_CHECK_SIM_UNBIND__
@@ -303,6 +312,9 @@ uint8_t UI_NV_Reset_Default(NV_UI_SECTION_ID SectionId)
 #ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
        nv_watch_remind_wake_up_t * remind_wake_up_data;
 #endif
+#ifdef __MMI_CUSTOM_HENG_AI__
+       nv_watch_heng_ai_sleep_activation_t * heng_ai_sleep_activation;
+#endif
 
 #endif
 
@@ -514,6 +526,12 @@ uint8_t UI_NV_Reset_Default(NV_UI_SECTION_ID SectionId)
                        break;
        #endif
 
+               case NV_SECTION_UI_SLEEP_TIME_DATA:
+                       sleep_time_data = lv_mem_alloc(SectionLen);
+                       memset(sleep_time_data, 0x0, SectionLen);
+                       TempData = (char *)sleep_time_data;
+                       break;
+                       
                case NV_SECTION_UI_DIAL_PAD_SWITCH:
                        mmi_switch_data = lv_mem_alloc(SectionLen);
                        memset(mmi_switch_data, 0x0, SectionLen);
@@ -571,6 +589,11 @@ uint8_t UI_NV_Reset_Default(NV_UI_SECTION_ID SectionId)
                        memset(mmi_switch_data, 0x0, SectionLen);
                        TempData = (char *)mmi_switch_data;
                        break;
+               case NV_SECTION_UI_HENG_AI_SLEEP_ACTIVATION:
+                       heng_ai_sleep_activation = lv_mem_alloc(SectionLen);
+                       memset(heng_ai_sleep_activation, 0x0, SectionLen);
+                       TempData = (char *)heng_ai_sleep_activation;
+                       break;
        #endif
                        
                        
index 627abaa..439e048 100644 (file)
@@ -278,6 +278,14 @@ typedef struct
 } __packed nv_watch_do_not_disturb_t;
 #endif
 
+typedef struct
+{
+    uint8_t on_off;                                               // 1: on, 0: off
+    uint8_t begin_hour;                                           // [0, 23]
+    uint8_t begin_min;                                            // [0, 59]
+    uint8_t end_hour;                                             // [0, 23]
+    uint8_t end_min;                                              // [0, 59]
+} __packed nv_watch_sleep_time_t;
 
 typedef struct
 {
@@ -305,6 +313,14 @@ typedef struct
 } __packed nv_watch_not_clean_data_t;
 
 
+#ifdef __MMI_CUSTOM_HENG_AI__
+typedef struct
+{
+    uint8_t is_activated; // 0-not activated; 1-activated
+    char req_code[128];
+       char act_code[128];
+} __packed nv_watch_heng_ai_sleep_activation_t;
+#endif
 
 #endif
 
@@ -502,6 +518,7 @@ enum
 #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
        NV_SECTION_UI_DO_NOT_DISTURB,                                   // nv_watch_do_not_disturb_t
 #endif
+       NV_SECTION_UI_SLEEP_TIME_DATA,                                  // nv_watch_sleep_time_t
        NV_SECTION_UI_DIAL_PAD_SWITCH,                                  // nv_watch_switch_t
        NV_SECTION_UI_WHITE_LIST_SWITCH,                                // nv_watch_switch_t
        NV_SECTION_UI_MAIN_MENU_STYLE,                                  // nv_watch_main_menu_style_t
@@ -515,6 +532,7 @@ enum
 #endif
 #ifdef __MMI_CUSTOM_HENG_AI__
        NV_SECTION_UI_HENG_AI_WAKE_RING_TYPE,                   // nv_watch_switch_t
+       NV_SECTION_UI_HENG_AI_SLEEP_ACTIVATION,                 // nv_watch_heng_ai_sleep_activation_t
 #endif
 
 #endif
index ebdd6dd..d7fb4bf 100644 (file)
@@ -344,7 +344,7 @@ void mmi_remind_screen_active(void)
        mmi_ui_msg_action_remind();
 }
 
-void mmi_remind_mission(hal_rtc_t cur_time)
+void mmi_remind_mission_check(hal_rtc_t cur_time)
 {
        printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
 #ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
index 2dd0877..0ccdf21 100644 (file)
@@ -59,7 +59,7 @@ void mmi_remind_sleep_screen_active(void);
 bool mmi_remind_screen_is_active(void);
 void mmi_ui_msg_update_remind(void);
 void mmi_remind_screen_active(void);
-void mmi_remind_mission(hal_rtc_t cur_time);
+void mmi_remind_mission_check(hal_rtc_t cur_time);
 void mmi_remind_data_init(void);
 
 
index 4471f5b..74082a6 100644 (file)
@@ -7,6 +7,7 @@
 
 #ifdef __MMI_CUSTOM_HENG_AI__
 #include "heng_ai.c"
+#include "heng_ai_sleep_activation.c"
 #endif
 
 #ifdef __MMI_CUSTOM_BEI_KE_RUI_SHENG__
index 05fa888..0b70bb3 100644 (file)
@@ -21,6 +21,7 @@ extern "C" {
 
 #ifdef __MMI_CUSTOM_HENG_AI__
 #include "heng_ai.h"
+#include "heng_ai_sleep_activation.h"
 #endif
 
 #ifdef __MMI_CUSTOM_BEI_KE_RUI_SHENG__
diff --git a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_sleep_activation.c b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_sleep_activation.c
new file mode 100644 (file)
index 0000000..f5372a7
--- /dev/null
@@ -0,0 +1,346 @@
+
+
+
+#include "lv_watch.h"
+
+#ifdef __MMI_CUSTOM_HENG_AI__
+
+#include "../../../../product/craneg_modem/cust/heng_ai_sleep/inc/lib_sleep.h"
+
+#define HENGAI_SLEEP_DATA_FILE "C:/hengai_sleep_data.txt"
+
+static nv_watch_heng_ai_sleep_activation_t s_hengai_sleep_activation = {0};
+
+#define HENGAI_SLEEP_GSENSOR_DATA_MAX (3000) // 50hz
+
+static void * s_hengai_sleep_gsensor_timer_id = NULL;
+static gsensor_data_t s_hengai_sleep_gsensor_data[HENGAI_SLEEP_GSENSOR_DATA_MAX] = {0};
+static uint8_t s_hengai_sleep_gsensor_counter = 0;
+
+static void mmi_hengai_gsensor_data_get(uint32_t para);
+
+
+void mmi_hengai_sleep_activation_nv_read(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_heng_ai_sleep_activation_t);
+       
+       if(nv_data_length != UI_NV_Read_Req(NV_SECTION_UI_HENG_AI_SLEEP_ACTIVATION, 0, nv_data_length, (uint8_t *)&s_hengai_sleep_activation))
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+void mmi_hengai_sleep_activation_nv_write(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_heng_ai_sleep_activation_t);
+       
+       if(nv_data_length != UI_NV_Write_Req(NV_SECTION_UI_HENG_AI_SLEEP_ACTIVATION, 0, nv_data_length, (uint8_t *)&s_hengai_sleep_activation))
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+void mmi_hengai_sleep_activation_act_code_set(char * act_code, uint32_t act_code_len)
+{
+       s_hengai_sleep_activation.is_activated = 1;
+       _lv_memcpy(s_hengai_sleep_activation.act_code, act_code, act_code_len);
+       mmi_hengai_sleep_activation_nv_write();
+
+       int result = 0;
+       result = activate_algorithm(s_hengai_sleep_activation.req_code,
+                                                                       strlen(s_hengai_sleep_activation.req_code),
+                                                                       s_hengai_sleep_activation.act_code,
+                                                                       strlen(s_hengai_sleep_activation.act_code)
+                                                                       );  //result=1±íʾËã·¨¼¤»î
+
+       printf("[@CHENG_DEBUG][%s][%d]: result=%d\n", __FUNCTION__, __LINE__, result);
+       if(1 == result)
+       {
+               mmi_protocol_fzd_action_hengai_activation_feedback();
+       }       
+}
+
+void mmi_hengai_sleep_activation_check_action(void)
+{
+       printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       if(0 == s_hengai_sleep_activation.is_activated)
+       {
+           unsigned char* fact = "hengaigaoke";                // »ñÈ¡³§ÉÌÃû×Ö£¨²»³¬¹ý32¸ö×Ö½ÚµÄ×Ö·û´®£©
+
+               char imei[16 + 1] = {0};
+               app_adp_get_imei_req(imei);
+
+           unsigned char req_code[128];
+           unsigned int req_code_len = 0;
+               
+               request_validation(fact, strlen(fact), imei, strlen(imei), req_code, &req_code_len);
+
+               _lv_memcpy(s_hengai_sleep_activation.req_code, req_code, req_code_len);
+
+               mmi_protocol_fzd_action_hengai_activation(req_code);
+       }
+}
+
+void mmi_hengai_sleep_data_save_to_file(void * data_buf, uint32_t data_size)
+{
+       lv_fs_file_t file_p;
+       lv_fs_res_t res;
+       uint32_t bytes_write = 0;
+
+       res = lv_fs_open(&file_p, HENGAI_SLEEP_DATA_FILE, LV_FS_MODE_WR | LV_FS_MODE_APPEND);
+       if(LV_FS_RES_OK != res) 
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               lv_fs_close(&file_p);
+               return false;
+       }
+
+       res = lv_fs_write(&file_p, data_buf, data_size, &bytes_write);
+       lv_fs_close(&file_p);
+       if(LV_FS_RES_OK != res)
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               return false;
+       }
+       printf("[@CHENG_DEBUG][%s][%d]: file_size=%d,write_size=%d\n", __FUNCTION__, __LINE__, data_size, bytes_write);
+
+       return true;
+}
+
+void mmi_hengai_sleep_data_get(void)
+{
+       sleep_data_t sdata = {0};
+       
+    init_sleep_data(&sdata);        //³õʼ»¯sdata
+
+       sleep_time_t curtime = {0};
+       hal_rtc_t cur_time = {0};
+
+    Hal_Rtc_Gettime(&cur_time);
+       curtime.year = cur_time.tm_year;
+       curtime.month = cur_time.tm_mon;
+       curtime.day = cur_time.tm_mday;
+       curtime.hour = cur_time.tm_hour;
+       curtime.minute = cur_time.tm_min;
+
+       int result = 0;
+       result = get_sleep_time(s_hengai_sleep_gsensor_data, HENGAI_SLEEP_GSENSOR_DATA_MAX, curtime, &sdata);
+       if(1 == result)
+       {
+               mmi_hengai_sleep_data_save_to_file(&sdata, sizeof(sdata));
+       }
+
+       _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)
+{
+       int16_t t_mems_data[32 * 3] = {0};
+       uint8_t i = 0;
+       
+       get_Gsensor_fifo_xyz(t_mems_data);
+       for(i = 0; i < 25; i++) // 25 sets data per 500ms
+       {
+               uint16_t index = s_hengai_sleep_gsensor_counter * 25 + i;
+               
+               s_hengai_sleep_gsensor_data[index].x = *(t_mems_data + i);
+               s_hengai_sleep_gsensor_data[index].y = *(t_mems_data + 32 + i);
+               s_hengai_sleep_gsensor_data[index].z = *(t_mems_data + 64 + i);
+       }
+       
+       s_hengai_sleep_gsensor_counter++;
+       if((60 * 2) <= s_hengai_sleep_gsensor_counter) // 1 minute:500ms*2*60
+       {
+               uos_timer_stop(s_hengai_sleep_gsensor_timer_id);
+               s_hengai_sleep_gsensor_counter = 0;
+               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(500), 0, mmi_hengai_gsensor_data_get, NULL);
+       }
+}
+
+bool mmi_hengai_sleep_data_send(void)
+{
+       char * file_buf = NULL;
+       uint32_t file_size = 0;
+       lv_fs_file_t file_p;
+       lv_fs_res_t res;
+       uint32_t bytes_read = 0;
+
+       res = lv_fs_open(&file_p, HENGAI_SLEEP_DATA_FILE, LV_FS_MODE_RD);
+       if(LV_FS_RES_OK != res) 
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               goto exit_free_res;
+       }
+
+       lv_fs_size(&file_p, &file_size);
+       file_buf = (char *)lv_mem_alloc(file_size + 1);
+       if(NULL == file_buf)
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: memory alloce fail\n", __FUNCTION__, __LINE__);
+               goto exit_free_res;
+       }
+       _lv_memset_00(file_buf, file_size + 1);
+       res = lv_fs_read(&file_p, file_buf, file_size, &bytes_read);
+       if(LV_FS_RES_OK != res)
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               goto exit_free_res;
+       }
+       printf("[@CHENG_DEBUG][%s][%d]: file_size=%d,bytes_read=%d,file_buf=%p\n", __FUNCTION__, __LINE__, file_size, bytes_read, file_buf);
+
+       mmi_protocol_fzd_action_hengai_sleep_data(file_buf, file_size);
+
+exit_free_res:
+       lv_fs_close(&file_p);
+       if(NULL != file_buf)
+       {
+               lv_mem_free(file_buf);
+               file_buf = NULL;
+       }
+}
+
+void mmi_hengai_get_sleep_data_start(void)
+{
+       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);
+       else
+               uos_timer_create(&s_hengai_sleep_gsensor_timer_id);
+
+       //mmi_hengai_gsensor_data_get(0);
+       uos_timer_start(s_hengai_sleep_gsensor_timer_id, MS_TO_TICKS(500), 0, mmi_hengai_gsensor_data_get, NULL);
+}
+
+void mmi_hengai_get_sleep_data_stop(void)
+{
+       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);
+       }
+
+       mmi_hengai_sleep_data_send();
+
+       lv_fs_remove(HENGAI_SLEEP_DATA_FILE);
+}
+#endif
+
+
+
+#if 0
+bool mmi_debug_0(void)
+{
+       lv_fs_file_t file_p;
+       lv_fs_res_t res;
+       uint32_t bytes_write = 0;
+       char * info_buf = s_hengai_sleep_gsensor_data;
+       uint32_t info_size = sizeof(s_hengai_sleep_gsensor_data);
+
+       res = lv_fs_open(&file_p, MMI_DEBUG_LOG_FILE, LV_FS_MODE_WR | LV_FS_MODE_APPEND);
+       if(LV_FS_RES_OK != res) 
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               lv_fs_close(&file_p);
+               return false;
+       }
+
+       hal_rtc_t cur_time = {0};
+       char str_time[24] = {0};
+       
+       Hal_Rtc_Gettime(&cur_time);
+       sprintf(str_time, "\n[%04d%02d%02d_%02d%02d%02d]", 
+                       cur_time.tm_year,
+                       cur_time.tm_mon,
+                       cur_time.tm_mday,
+                       cur_time.tm_hour,
+                       cur_time.tm_min,
+                       cur_time.tm_sec);
+
+       //lv_fs_seek
+       res = lv_fs_write(&file_p, str_time, strlen(str_time), &bytes_write);
+       if(LV_FS_RES_OK != res)
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               lv_fs_close(&file_p);
+               return false;
+       }
+       
+       res = lv_fs_write(&file_p, info_buf, info_size, &bytes_write);
+       lv_fs_close(&file_p);
+       if(LV_FS_RES_OK != res)
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+               return false;
+       }
+       printf("[@CHENG_DEBUG][%s][%d]: file_size=%d,write_size=%d\n", __FUNCTION__, __LINE__, info_size, bytes_write);
+
+       return true;
+}
+
+static void mmi_debug_1(uint32_t para)
+{
+       int16_t t_mems_data[32 * 3] = {0};
+       uint8_t i = 0;
+       
+       get_Gsensor_fifo_xyz(t_mems_data);
+       for(i = 0; i < 25; i++)
+       {
+               s_hengai_sleep_gsensor_data[s_hengai_sleep_gsensor_counter * 25 + i].x = *(t_mems_data + i);
+               s_hengai_sleep_gsensor_data[s_hengai_sleep_gsensor_counter * 25 + i].y = *(t_mems_data + 32 + i);
+               s_hengai_sleep_gsensor_data[s_hengai_sleep_gsensor_counter * 25 + i].z = *(t_mems_data + 64 + i);
+       }
+
+       printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       for(i = 0; i < 25; i++)
+       {
+               printf("[%d]:x=%d,y=%d,z=%d",
+                                       s_hengai_sleep_gsensor_counter * 25 + i,
+                                       s_hengai_sleep_gsensor_data[s_hengai_sleep_gsensor_counter * 25 + i].x,
+                                       s_hengai_sleep_gsensor_data[s_hengai_sleep_gsensor_counter * 25 + i].y,
+                                       s_hengai_sleep_gsensor_data[s_hengai_sleep_gsensor_counter * 25 + i].z
+                                       );
+       }
+       
+       s_hengai_sleep_gsensor_counter++;
+       if((3) <= s_hengai_sleep_gsensor_counter) // 1 minute
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+               uos_timer_stop(s_hengai_sleep_gsensor_timer_id);
+               s_hengai_sleep_gsensor_counter = 0;
+               
+               mmi_debug_0();
+       }
+       else
+       {
+               printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               
+               uos_timer_stop(s_hengai_sleep_gsensor_timer_id);
+               uos_timer_start(s_hengai_sleep_gsensor_timer_id, MS_TO_TICKS(500), 0, mmi_debug_1, NULL);
+       }
+}
+
+void mmi_debug_sleep(void)
+{
+       if(NULL != s_hengai_sleep_gsensor_timer_id)
+               uos_timer_stop(s_hengai_sleep_gsensor_timer_id);
+       else
+               uos_timer_create(&s_hengai_sleep_gsensor_timer_id);
+
+       mmi_debug_1(0);
+}
+#endif
+
+
+
+
diff --git a/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_sleep_activation.h b/2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_sleep_activation.h
new file mode 100644 (file)
index 0000000..09e66e4
--- /dev/null
@@ -0,0 +1,38 @@
+
+
+
+#ifndef __HENG_AI_SLEEP_ACTIVATION_H__
+#define __HENG_AI_SLEEP_ACTIVATION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef LV_CONF_INCLUDE_SIMPLE
+#include "lvgl.h"
+#include "lv_ex_conf.h"
+#else
+#include "../../../lvgl/lvgl.h"
+#include "../../../lv_ex_conf.h"
+#endif
+
+#ifdef __MMI_CUSTOM_HENG_AI__
+
+
+void mmi_hengai_sleep_activation_nv_read(void);
+void mmi_hengai_sleep_activation_act_code_set(char * act_code, uint32_t act_code_len);
+void mmi_hengai_sleep_activation_check_action(void);
+
+void mmi_hengai_get_sleep_data_start(void);
+void mmi_hengai_get_sleep_data_stop(void);
+
+
+
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
+
index 0358ecc..ea597b2 100644 (file)
@@ -117,12 +117,16 @@ static void mmi_data_init_after_watch_create(void)
 #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
        mmi_watch_do_not_disturb_mission_check();
 #endif
+       mmi_watch_sleep_time_nv_read();
        mmi_dial_pad_switch_nv_read();
        mmi_white_list_switch_nv_read();
 #ifdef __MMI_ZHSX_SUPPORT_CHECK_SIM_UNBIND__
        mmi_watch_sim_unbind_switch_nv_read();
 #endif
        mmi_remind_data_init();
+#ifdef __MMI_CUSTOM_HENG_AI__
+       mmi_hengai_sleep_activation_nv_read();
+#endif
 
 
 
@@ -457,7 +461,9 @@ static void main_task(lv_task_t * task)
         //printf("set AudioHAL_SetResBufCnt 20\n");
         AudioHAL_SetResBufCnt(20);
 
+       #ifndef __MMI_POWER_ON_OFF_NO_RING__
         Hal_NFFS_File_Play_Onetime(AUDIO_POWER_ON, (HAL_SPEAKER_GAIN)query_current_volume(), poweron_play_callback, 0);
+       #endif
     }
 
     if(power_on_gif->once_done) {
index 06069ff..b104407 100644 (file)
@@ -590,10 +590,10 @@ bool mmi_protocol_fzd_parse_ACTION_BIND(unsigned char * next_buff, unsigned int
                        mmi_watch_sim_unbind_check();
                #endif
 
-                       //heartbeat
+                       // socket heartbeat
                        mmi_protocol_watch_heartbeat_action();
                        
-                       // timing
+                       // timing mission
                        mmi_protocol_watch_timed_mission_action();
 
                        //video call
@@ -601,6 +601,12 @@ bool mmi_protocol_fzd_parse_ACTION_BIND(unsigned char * next_buff, unsigned int
                        mmi_protocol_fzd_action_get_vc_config();
                #endif
 
+                       // hengai
+               #ifdef __MMI_CUSTOM_HENG_AI__
+                       mmi_hengai_sleep_activation_check_action();
+               #endif
+               
+
                }
        }
 
@@ -2698,6 +2704,43 @@ bool mmi_protocol_fzd_parse_SERVER_SET_NOT_DISTURB(unsigned char * next_buff, un
 }
 #endif
 
+// [*SLEEPTIME,21:30-6:10] [*SLEEPTIME,]
+bool mmi_protocol_fzd_parse_SERVER_SET_SLEEPTIME(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_SERVER_SET_SLEEPTIME;
+
+       result = true;
+       mmi_protocol_fzd_send_without_data(action);
+       
+       nv_watch_sleep_time_t data = {0};
+       char * temp_ptr = NULL;
+       
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       }
+       else
+       {
+               data.on_off = 1;
+               
+               temp_ptr = km_strtok_r(NULL, ":", &next_buff);
+               data.begin_hour = atoi(temp_ptr);
+
+               temp_ptr = km_strtok_r(NULL, "-", &next_buff);
+               data.begin_min = atoi(temp_ptr);
+
+               temp_ptr = km_strtok_r(NULL, ":", &next_buff);
+               data.end_hour = atoi(temp_ptr);
+
+               data.end_min = atoi(next_buff);
+       }
+       
+       mmi_watch_sleep_time_data_set(&data);
+
+       return result;
+}
+
 bool mmi_protocol_fzd_parse_SERVER_SET_DIAL_PAD_SWITCH(unsigned char * next_buff, unsigned int next_buff_len)
 {
        bool result = false;
@@ -2885,6 +2928,88 @@ bool mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WARNING(unsigned char * next_buff
        
        return result;
 }
+
+
+// [*HENGAI_ACTIVATION, name, model, firm, sensor,fs, sinklib_version, request_code] 
+bool mmi_protocol_fzd_action_hengai_activation(char * req_code)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_HENGAI_ACTIVATION;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 256;
+
+       char * name = "Z5_HA_K7"; // É豸Ãû³Æ
+       char * model = "Z5_HA_K7"; // É豸ÐͺÅ
+       char * firm = "zh"; // É豸³§ÉÌ
+       char * sensor = "whale"; // ´«¸ÐÆ÷ÐͺÅ
+       uint16_t fs = 50; // ²ÉÑùÂÊ
+       char * sinklib_version = "v0.3.2.101122"; // Ï³Á¿â°æ±¾ºÅ
+
+       content_buff = (unsigned char *)lv_mem_alloc(content_lenth);
+       if(NULL == content_buff)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       _lv_memset_00(content_buff, content_lenth);
+       
+       sprintf(content_buff, ",%s,%s,%s,%s,%d,%s,%s", name, model, firm, sensor, fs, sinklib_version, req_code);
+       content_lenth = strlen(content_buff);
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_parse_ACTION_HENGAI_ACTIVATION(unsigned char * next_buff, unsigned int next_buff_len)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_HENGAI_ACTIVATION;
+
+       if(NULL == next_buff || 0 == next_buff_len)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       
+       result = true;
+       //mmi_protocol_fzd_send_without_data(action);
+
+       PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+       
+       mmi_hengai_sleep_activation_act_code_set(next_buff, next_buff_len);
+       
+       return result;
+}
+
+bool mmi_protocol_fzd_action_hengai_activation_feedback(void)
+{
+       return mmi_protocol_fzd_send_without_data(MMI_FZD_ACTION_HENGAI_ACTIVATION_FEEDBACK);
+}
+
+bool mmi_protocol_fzd_action_hengai_sleep_data(char * file_buf, uint32_t file_size)
+{
+       bool result = false;
+       MMI_PROTOCOL_FZD_ACTION_ENUM action = MMI_FZD_ACTION_HENGAI_SLEEP_DATA;
+       unsigned char * content_buff = NULL;
+       unsigned int content_lenth = 0;
+
+       content_buff = (unsigned char *)lv_mem_alloc(file_size + 1);
+       if(NULL == content_buff)
+       {
+               PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               return false;
+       }
+       _lv_memset_00(content_buff, file_size + 1);
+       _lv_memcpy(content_buff, file_buf, file_size);
+       content_lenth = file_size;
+       
+       result = mmi_protocol_fzd_send_with_data(action, content_buff, content_lenth);
+       lv_mem_free(content_buff);
+       
+       return result;
+}
 #endif
 
 
index 978329c..b0d0092 100644 (file)
@@ -149,6 +149,7 @@ typedef enum
 #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
        MMI_FZD_SERVER_SET_NOT_DISTURB, 
 #endif
+       MMI_FZD_SERVER_SET_SLEEPTIME,
        MMI_FZD_SERVER_SET_DIAL_PAD_SWITCH, 
        MMI_FZD_SERVER_SET_WHITE_LIST_SWITCH, 
 #ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
@@ -159,6 +160,9 @@ typedef enum
        MMI_FZD_SERVER_SET_HENG_AI_WAKE_NOW,
        MMI_FZD_SERVER_SET_HENG_AI_WAKE_RING_TYPE,
        MMI_FZD_SERVER_SET_HENG_AI_WARNING,
+       MMI_FZD_ACTION_HENGAI_ACTIVATION,
+       MMI_FZD_ACTION_HENGAI_ACTIVATION_FEEDBACK,
+       MMI_FZD_ACTION_HENGAI_SLEEP_DATA,
 #endif
 
 
@@ -281,6 +285,10 @@ bool mmi_protocol_fzd_parse_SERVER_SET_REMIND_WAKE_UP(unsigned char * next_buff,
 bool mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WAKE_NOW(unsigned char * next_buff, unsigned int next_buff_len);                
 bool mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WAKE_RING_TYPE(unsigned char * next_buff, unsigned int next_buff_len);
 bool mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WARNING(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_action_hengai_activation(char * req_code);
+bool mmi_protocol_fzd_parse_ACTION_HENGAI_ACTIVATION(unsigned char * next_buff, unsigned int next_buff_len);
+bool mmi_protocol_fzd_action_hengai_activation_feedback(void);
+bool mmi_protocol_fzd_action_hengai_sleep_data(char * file_buf, uint32_t file_size);
 #endif
 
 
index d01e2d9..e9f2561 100644 (file)
@@ -81,6 +81,7 @@ static unsigned char * mmi_protocol_fzd_action_string_get(MMI_PROTOCOL_FZD_ACTIO
                #ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
                        {MMI_FZD_SERVER_SET_NOT_DISTURB, "SILENCETIME2"},
                #endif
+                       {MMI_FZD_SERVER_SET_SLEEPTIME, "SLEEPTIME"},
                        {MMI_FZD_SERVER_SET_DIAL_PAD_SWITCH, "KEYBRD"},
                        {MMI_FZD_SERVER_SET_WHITE_LIST_SWITCH, "WLKEY"}, 
                #ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
@@ -90,6 +91,9 @@ static unsigned char * mmi_protocol_fzd_action_string_get(MMI_PROTOCOL_FZD_ACTIO
                        {MMI_FZD_SERVER_SET_HENG_AI_WAKE_NOW, "HENG_AI_WAKE_NOW"},
                        {MMI_FZD_SERVER_SET_HENG_AI_WAKE_RING_TYPE, "HENG_AI_WAKE_RING_TYPE"},
                        {MMI_FZD_SERVER_SET_HENG_AI_WARNING, "HENGAI_WARNING"},
+                       {MMI_FZD_ACTION_HENGAI_ACTIVATION, "HENGAI_ACTIVATION"},
+                       {MMI_FZD_ACTION_HENGAI_ACTIVATION_FEEDBACK, "HENGAI_ACTIVATION_FEEDBACK"},
+                       {MMI_FZD_ACTION_HENGAI_SLEEP_DATA, "HENGAI_SLEEP_DATA"},
                #endif
 
                
@@ -295,6 +299,10 @@ static bool mmi_protocol_fzd_content_parse(unsigned char * content_ptr, unsigned
                        break;
        #endif
 
+               case MMI_FZD_SERVER_SET_SLEEPTIME:
+                       mmi_protocol_fzd_parse_SERVER_SET_SLEEPTIME(next_buff, next_buff_len);
+                       break;
+                       
                case MMI_FZD_SERVER_SET_DIAL_PAD_SWITCH:
                        mmi_protocol_fzd_parse_SERVER_SET_DIAL_PAD_SWITCH(next_buff, next_buff_len);
                        break;
@@ -321,6 +329,15 @@ static bool mmi_protocol_fzd_content_parse(unsigned char * content_ptr, unsigned
                case MMI_FZD_SERVER_SET_HENG_AI_WARNING:
                        mmi_protocol_fzd_parse_SERVER_SET_HENG_AI_WARNING(next_buff, next_buff_len);
                        break;
+
+               case MMI_FZD_ACTION_HENGAI_ACTIVATION:
+                       mmi_protocol_fzd_parse_ACTION_HENGAI_ACTIVATION(next_buff, next_buff_len);
+                       break;
+
+               case MMI_FZD_ACTION_HENGAI_ACTIVATION_FEEDBACK:
+                       break;
+               case MMI_FZD_ACTION_HENGAI_SLEEP_DATA:
+                       break;
        #endif
 
                         
index f572711..1211351 100644 (file)
@@ -943,6 +943,109 @@ void mmi_watch_do_not_disturb_mission_check(void)
 #endif
 
 
+static nv_watch_sleep_time_t s_sleep_time_data = {0};
+static uint8_t s_sleep_mission_in_progress = 0;
+
+void mmi_watch_sleep_time_nv_write(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_sleep_time_t);
+       
+       if(nv_data_length != UI_NV_Write_Req(NV_SECTION_UI_SLEEP_TIME_DATA, 0, nv_data_length, (uint8_t *)&s_sleep_time_data))
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv write fail\n", __FUNCTION__, __LINE__);
+       }
+}
+
+void mmi_watch_sleep_time_nv_read(void)
+{
+       uint32_t nv_data_length = sizeof(nv_watch_sleep_time_t);
+       
+       if(nv_data_length != UI_NV_Read_Req(NV_SECTION_UI_SLEEP_TIME_DATA, 0, nv_data_length, (uint8_t *)&s_sleep_time_data))
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: nv read fail\n", __FUNCTION__, __LINE__);
+               _lv_memset_00(&s_sleep_time_data, sizeof(nv_watch_sleep_time_t));
+       }
+}
+
+void mmi_watch_sleep_time_data_set(nv_watch_sleep_time_t * data)
+{
+       if(NULL != data)
+       {
+               _lv_memcpy(&s_sleep_time_data, data, sizeof(nv_watch_sleep_time_t));
+               mmi_watch_sleep_time_nv_write();
+       }
+}
+
+bool mmi_watch_time_is_in_sleep_time(void)
+{
+       hal_rtc_t cur_time = {0};
+       uint16_t t_cur_mins = 0;
+
+       if(false == watch_modem_sim_present_check_req())
+       {
+               return false;
+       }
+
+       Hal_Rtc_Gettime(&cur_time);
+       t_cur_mins = cur_time.tm_hour * 60 + cur_time.tm_min;
+       
+       if(1 == s_sleep_time_data.on_off)
+       {
+               // begin_time -- 00:00 -- end_time
+               uint16_t t_begin_mins = s_sleep_time_data.begin_hour * 60 + s_sleep_time_data.begin_min;
+               uint16_t t_end_mins = s_sleep_time_data.end_hour * 60 + s_sleep_time_data.end_min;
+
+               if((t_begin_mins > t_end_mins) && (t_cur_mins >= t_begin_mins || t_cur_mins <= t_end_mins)
+                       || (t_begin_mins < t_end_mins) && (t_cur_mins >= t_begin_mins && t_cur_mins <= t_end_mins)
+                       )
+               {
+                       SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+static void mmi_watch_get_sleep_data_start(void)
+{
+#ifdef __MMI_CUSTOM_HENG_AI__
+       mmi_hengai_get_sleep_data_start();
+#endif
+
+}
+
+static void mmi_watch_get_sleep_data_stop(void)
+{
+#ifdef __MMI_CUSTOM_HENG_AI__
+       mmi_hengai_get_sleep_data_stop();
+#endif
+
+}
+
+void mmi_watch_sleep_time_mission_check(void)
+{
+       if(true == mmi_watch_time_is_in_sleep_time())
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               if(0 == s_sleep_mission_in_progress)
+               {
+                       s_sleep_mission_in_progress = 1;
+                       mmi_watch_get_sleep_data_start();
+               }
+       }
+       else
+       {
+               SUNDRY_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+               if(1 == s_sleep_mission_in_progress)
+               {
+                       s_sleep_mission_in_progress = 0;
+                       mmi_watch_get_sleep_data_stop();
+               }
+       }
+}
+
+
 #ifdef __MMI_ZHSX_SUPPORT_CHECK_SIM_UNBIND__
 
 static nv_watch_switch_t s_sim_unbind_switch = {0};
index 0ef467f..95852db 100644 (file)
@@ -91,6 +91,9 @@ void mmi_ui_msg_update_do_not_disturb(uint8_t flag);
 void mmi_watch_do_not_disturb_mission_check(void);
 #endif
 
+void mmi_watch_sleep_time_nv_read(void);
+void mmi_watch_sleep_time_data_set(nv_watch_sleep_time_t * data);
+void mmi_watch_sleep_time_mission_check(void);
 
 #ifdef __MMI_ZHSX_SUPPORT_CHECK_SIM_UNBIND__
 void mmi_watch_sim_unbind_switch_nv_read(void);
index 45a5670..f07b23b 100644 (file)
@@ -543,6 +543,7 @@ set_property(TARGET modem PROPERTY IMPORTED_OBJECTS
   cust/rt_ringbuffer/lib/rt_ringbuffer.a
   softutil/fotadm/lib/lib_fotadm.a
   softutil/rsfota/redstone/lib/librsdl.a
+  cust/heng_ai_sleep/lib/lib_sleep_yll_v0.2.6.111623.a
   # MODEM_LIB_ALIOS_LTEGSM_END
 )
 endif() # if($ENV{PS_MODE} STREQUAL "LTEGSM")
diff --git a/2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/inc/lib_sleep.h b/2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/inc/lib_sleep.h
new file mode 100644 (file)
index 0000000..092ced7
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * lib_sleep.h
+ *
+ *  Created on: 2023Äê11ÔÂ7ÈÕ
+ *      Author: HA-RD01
+ */
+
+#ifndef __LIB_SLEEP_H__
+#define __LIB_SLEEP_H__
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+// #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+#define SAMPLERATE 81          // sampling rate
+#define SAMPLETIME 10          // sampling time (seconds) data of which will be processed every time
+#define EMOTIONTIME 60
+#define SINGLETIME 10
+#define MAX_SLEEP_STATE 50
+
+
+/* Integer data types */
+#if ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) && \
+     (!defined(__ICC8051__) || (__ICC8051__ == 0)))
+#include <stdint.h>
+#else
+       typedef signed char int8_t;
+       typedef unsigned char uint8_t;
+       typedef signed short int16_t;
+       typedef unsigned short uint16_t;
+       typedef signed long int32_t;
+       typedef unsigned long uint32_t;
+       typedef unsigned long long uint64_t;
+#endif
+
+
+typedef struct
+{
+       short int x;
+       short int y;
+       short int z;
+} gsensor_data_t;
+
+typedef enum
+{
+       LS_STATE = 11,                          // light sleep
+       DS_STATE = 12,                          // deep sleep
+       REM_STATE = 2,                          // rapid eye movement
+} SLEEP_STATE_E;
+
+typedef struct
+{
+       uint16_t year;
+       uint8_t month;
+       uint8_t day;
+       uint8_t hour;
+       uint8_t minute;
+} sleep_time_t;
+
+typedef struct
+{
+       uint32_t duration;                      // the duration of corresponding state
+       SLEEP_STATE_E state;            // state
+} sleep_detail_data_t;
+
+typedef struct
+{
+       uint32_t total_sleep_time;                      // minutes
+       sleep_time_t begin_sleep_time;          // sleep_time_t
+       sleep_time_t end_sleep_time;
+       uint16_t state_count;                           // number of some sleep state
+       sleep_detail_data_t data[MAX_SLEEP_STATE];
+} sleep_data_t;
+
+
+void init_sleep_data(sleep_data_t* sdata);
+int get_sleep_time(gsensor_data_t gdata[], const int datalen, const sleep_time_t curtime, sleep_data_t *sdata);
+
+void request_validation(
+       const unsigned char fact[], const unsigned int fact_len,
+       const unsigned char imei[], const unsigned int imei_len,
+       unsigned char req_code[], unsigned int* req_code_len);
+
+int activate_algorithm(
+       const unsigned char req_code[], const unsigned int req_code_len,
+       const unsigned char key_code[], const unsigned int key_code_len);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
+
diff --git a/2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/lib/lib_sleep_yll_v0.2.6.111623.a b/2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/lib/lib_sleep_yll_v0.2.6.111623.a
new file mode 100644 (file)
index 0000000..e5700b6
Binary files /dev/null and b/2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/lib/lib_sleep_yll_v0.2.6.111623.a differ