void mmi_hengai_tcp_health_lib_activation_check_action(void)
{
HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
if(0 == mmi_hengai_health_lib_activated_flag_get())
{
data_ptr = NULL;
}
}
+ else
+ {
+ HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ #ifdef __MMI_CUSTOM_HENGAI_SLEEP_K18__
+ mmi_hengai_health_sleep_activation_check();
+ #endif
+ }
}
void mmi_hengai_tcp_algorithm_interface_login_action(void)
{
HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
char * token = mmi_hengai_health_token_get();
if(0 == strlen(token))
}
}
+static void * s_delay_timer_id = NULL;
+static void mmi_hengai_tcp_algorithm_login_cb(uint32_t para)
+{
+ if(NULL != s_delay_timer_id)
+ {
+ uos_timer_stop(s_delay_timer_id);
+ uos_timer_delete(s_delay_timer_id);
+ }
+
+ mmi_hengai_tcp_algorithm_interface_login_action();
+}
+
+void mmi_hengai_tcp_algorithm_login_action(void)
+{
+ HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ if(NULL == s_delay_timer_id)
+ {
+ uos_timer_create(&s_delay_timer_id);
+ }
+ uos_timer_stop(s_delay_timer_id);
+ uos_timer_start(s_delay_timer_id, MS_TO_TICKS(1000*10), 0, mmi_hengai_tcp_algorithm_login_cb, NULL);
+}
+
bool mmi_hengai_health_data_parse(unsigned char * next_buff, unsigned int next_buff_len)
{
if(NULL == next_buff || 0 == next_buff_len)
return false;
}
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, next_buff_len);
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", next_buff);
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", next_buff + 90);
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", next_buff + 180);
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", next_buff + 270);
+ //HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, next_buff_len);
+ //HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", next_buff);
+ //HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", next_buff + 90);
+ //HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", next_buff + 180);
+ //HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", next_buff + 270);
uint32_t output_len = 0;
char * t_decode_str = lv_mem_alloc(next_buff_len);
return false;
}
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(t_decode_str));
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", t_decode_str);
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", t_decode_str + 90);
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", t_decode_str + 180);
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", t_decode_str + 270);
+ //HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, strlen(t_decode_str));
+ HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, t_decode_str);
+ //HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", t_decode_str + 90);
+ //HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", t_decode_str + 180);
+ //HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", t_decode_str + 270);
+ //mmi_debug_info_write_to_file("C:/data_parse.txt", t_decode_str, strlen(t_decode_str));
+ UART_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, t_decode_str);
cJSON * json_recv = cJSON_Parse(t_decode_str);
if(NULL != json_recv)
return flag;
}
-void mmi_hengai_health_activated_flag_set(uint8_t flag)
-{
-/*
- s_hengai_health_data.is_activated = flag;
- mmi_hengai_health_data_nv_write();
-*/
-}
-
char * mmi_hengai_health_lib_req_code_get(void)
{
- //return (s_hengai_health_data.req_code);
char * req_code = get_HA_req_code();
HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: req_code=\n", __FUNCTION__, __LINE__);
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", req_code);
+ HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, req_code);
return req_code;
}
-void mmi_hengai_health_req_code_set(char * req_code)
+char * mmi_hengai_health_lib_act_code_get(void)
{
-/*
- if(NULL == req_code)
- return;
+ char * act_code = get_HA_key_code();
+ HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: act_code=\n", __FUNCTION__, __LINE__);
+ HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%d]: %s\n", __LINE__, act_code);
- if(NV_HENGAI_HEALTH_REQ_CODE_LEN < strlen(req_code))
- return;
-
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", req_code);
- _lv_memcpy(s_hengai_health_data.req_code, req_code, strlen(req_code));
- mmi_hengai_health_data_nv_write();
-*/
-}
-
-char * mmi_hengai_health_act_code_get(void)
-{
- //return (s_hengai_health_data.act_code);
+ return act_code;
}
void mmi_hengai_health_lib_act_code_set(char * act_code)
{
- HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: act_code=\n", __FUNCTION__, __LINE__);
+ HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,act_code=\n", __FUNCTION__, __LINE__, strlen(act_code));
HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG]: %s\n", act_code);
/*
if(NULL == act_code)
*/
int ret = HA_lib_activate(act_code);
HENGAI_HEALTH_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: ret=%d\n", __FUNCTION__, __LINE__, ret);
+ UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: ret=%d\n", __FUNCTION__, __LINE__, ret);
if(ret)
{
#ifdef __MMI_CUSTOM_HENGAI_HEALTH_UPLOAD_USE_TCP__
#else
mmi_hengai_health_lib_activation_feedback();
#endif
- #ifdef __MMI_CUSTOM_HENGAI_SLEEP_K18__
- char * req_code = mmi_hengai_health_lib_req_code_get();
- mmi_hengai_health_sleep_lib_active(req_code, act_code);
- #endif
}
+
+#ifdef __MMI_CUSTOM_HENGAI_SLEEP_K18__
+ mmi_hengai_health_sleep_lib_active();
+#endif
}
char * mmi_hengai_health_token_get(void)
_lv_memcpy(time_ptr, &(s_hengai_health_data.calibrate_time), sizeof(hal_rtc_t));
}
+#ifdef __MMI_CUSTOM_HENGAI_SLEEP_K18__
+void mmi_hengai_health_sleep_activated_flag_set(uint8_t flag)
+{
+ s_hengai_health_data.is_sleep_activated = flag;
+ mmi_hengai_health_data_nv_write();
+}
+
+uint8_t mmi_hengai_health_sleep_activated_flag_get(void)
+{
+ return (s_hengai_health_data.is_sleep_activated);
+}
+
+void mmi_hengai_health_sleep_activation_check(void)
+{
+ if(0 == mmi_hengai_health_sleep_activated_flag_get())
+ {
+ mmi_hengai_health_sleep_lib_active();
+ }
+}
+#endif
+
+
#endif
static void mmi_hengai_gsensor_data_get(uint32_t para);
-
-#ifdef __MMI_HENG_AI_DEBUG__
-static uint8_t s_gsensor_upload_switch = 0; // 0-off; 1-on
-static char s_gsensor_buff_send[45000] = {0}; // 3000 * 3 * (4 + 1)
-
-#define HENGAI_SLEEP_RESULT_FILE "C:/hengai_sleep_result.txt"
-
-
-void mmi_heng_ai_gsensor_upload_action(void)
+static bool mmi_hengai_sleep_data_send(void)
{
- if(0 == s_gsensor_upload_switch)
- return;
-
- _lv_memset_00(s_gsensor_buff_send, sizeof(s_gsensor_buff_send));
-
- char * temp_ptr = s_gsensor_buff_send;
- uint32_t counter = 0;
- uint32_t index = 0;
- for(index = 0; index < (HENGAI_SLEEP_GSENSOR_DATA_MAX / 3); index++)
- {
- temp_ptr += counter;
- sprintf(temp_ptr, "%d,%d,%d,%d,%d,%d,%d,%d,%d,",
- s_hengai_sleep_gsensor_data[index].x,
- s_hengai_sleep_gsensor_data[index].y,
- s_hengai_sleep_gsensor_data[index].z,
- s_hengai_sleep_gsensor_data[index + 1].x,
- s_hengai_sleep_gsensor_data[index + 1].y,
- s_hengai_sleep_gsensor_data[index + 1].z,
- s_hengai_sleep_gsensor_data[index + 2].x,
- s_hengai_sleep_gsensor_data[index + 2].y,
- s_hengai_sleep_gsensor_data[index + 2].z);
- counter = strlen(temp_ptr);
- }
+ PROTOCOL_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
- mmi_protocol_fzd_action_hengai_gsensor_data(s_gsensor_buff_send, strlen(s_gsensor_buff_send));
-}
-
-void mmi_heng_ai_gsensor_upload_switch_set(uint8_t value)
-{
- s_gsensor_upload_switch = value;
-}
-
-void mmi_hengai_data_save_to_file(char * path, 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, path, 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;
-}
-
-#define HENGAI_SLEEP_RESULT_FILE "C:/hengai_sleep_result.txt"
-
-void mmi_hengai_sleep_result_save(sleep_time_t * curtime, int result)
-{
- char * temp_buff = NULL;
- uint32_t buff_size = 64;
-
- temp_buff = lv_mem_alloc(buff_size + 1);
- if(NULL == temp_buff)
- {
- printf("[@CHENG_DEBUG][%s][%d]: memory alloc failed\n", __FUNCTION__, __LINE__);
- return;
- }
- _lv_memset_00(temp_buff, buff_size + 1);
-
- sprintf(temp_buff, "%d,%d,%d,%d,%d:%d;",
- curtime->year,
- curtime->month,
- curtime->day,
- curtime->hour,
- curtime->minute,
- result);
-
- mmi_hengai_data_save_to_file(HENGAI_SLEEP_RESULT_FILE, temp_buff, strlen(temp_buff));
-
- if(NULL != temp_buff)
- {
- lv_mem_free(temp_buff);
- temp_buff = NULL;
- }
-}
-
-bool mmi_hengai_sleep_result_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_RESULT_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_sleep_result(file_buf, file_size);
- mmi_protocol_fzd_action_hengai_sleep_data_test(file_buf, file_size);
-
-
-exit_free_res:
- lv_fs_close(&file_p);
- if(NULL != file_buf)
- {
- lv_mem_free(file_buf);
- file_buf = NULL;
- }
-}
-
-bool mmi_hengai_sleep_data_test_send(void)
-{
char * temp_buff = NULL;
uint32_t buff_size = sizeof(sleep_data_t);
char * temp_ptr = NULL;
uint32_t temp_count = 0;
uint8_t i = 0;
- temp_buff = lv_mem_alloc(buff_size + 1);
+ temp_buff = lv_mem_alloc(buff_size+ 32 + 1);
if(NULL == temp_buff)
{
printf("[@CHENG_DEBUG][%s][%d]: memory alloc failed\n", __FUNCTION__, __LINE__);
return;
}
- _lv_memset_00(temp_buff, buff_size + 1);
+ _lv_memset_00(temp_buff, buff_size + 32 + 1);
temp_count = 0;
temp_ptr = temp_buff + temp_count;
- sprintf(temp_ptr, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
- s_hengai_sdata.total_sleep_time,
- s_hengai_sdata.begin_sleep_time.year,
- s_hengai_sdata.begin_sleep_time.month,
- s_hengai_sdata.begin_sleep_time.day,
- s_hengai_sdata.begin_sleep_time.hour,
- s_hengai_sdata.begin_sleep_time.minute,
- s_hengai_sdata.end_sleep_time.year,
- s_hengai_sdata.end_sleep_time.month,
- s_hengai_sdata.end_sleep_time.day,
- s_hengai_sdata.end_sleep_time.hour,
- s_hengai_sdata.end_sleep_time.minute);
- temp_count = strlen(temp_ptr);
- temp_ptr += temp_count;
- sprintf(temp_ptr, ",%d", s_hengai_sdata.state_count);
+ sprintf(temp_ptr, ",HENGAI_SLEEP_DATA,");
temp_count = strlen(temp_ptr);
-
- for(i = 0; i < s_hengai_sdata.state_count; i++)
- {
- temp_ptr += temp_count;
- sprintf(temp_ptr, ",%d,%d", s_hengai_sdata.data[i].duration, s_hengai_sdata.data[i].state);
- temp_count = strlen(temp_ptr);
- }
-
- mmi_protocol_fzd_action_hengai_sleep_data_test(temp_buff, strlen(temp_buff));
-
- if(NULL != temp_buff)
- {
- lv_mem_free(temp_buff);
- temp_buff = NULL;
- }
-}
-
-
-//#ifndef __MMI_HENG_AI_DEBUG__
-//#define __MMI_HENG_AI_DEBUG__
-//#endif
-
-static uint32_t __sleep_gsensor_counter = 0;
-
-void mmi_hengai_sleep_data_get(void);
-
-void __gsensor_data_set(unsigned char * next_buff, unsigned int next_buff_len)
-{
-#ifdef __MMI_HENG_AI_DEBUG__
- // 300 set datas per 3 seconds
- uint32_t index = 0;
- char * temp_ptr = NULL;
- uint32_t i = 0;
-
- for(i = 0; i < 300; i++)
- {
- index = __sleep_gsensor_counter + i;
-
- temp_ptr = km_strtok_r(NULL, ",", &next_buff);
- s_hengai_sleep_gsensor_data[index].x = atoi(temp_ptr);
-
- temp_ptr = km_strtok_r(NULL, ",", &next_buff);
- s_hengai_sleep_gsensor_data[index].y = atoi(temp_ptr);
-
- temp_ptr = km_strtok_r(NULL, ",", &next_buff);
- s_hengai_sleep_gsensor_data[index].z = atoi(temp_ptr);
- }
-
- __sleep_gsensor_counter += 300;
- printf("[@CHENG_DEBUG][%s][%d]: %d\n", __FUNCTION__, __LINE__, __sleep_gsensor_counter);
- if(HENGAI_SLEEP_GSENSOR_DATA_MAX <= __sleep_gsensor_counter)
- {
- printf("[@CHENG_DEBUG][%d]: %d,%d,%d,%d,%d,%d\n", __LINE__,
- s_hengai_sleep_gsensor_data[0].x,
- s_hengai_sleep_gsensor_data[0].y,
- s_hengai_sleep_gsensor_data[0].z,
- s_hengai_sleep_gsensor_data[1].x,
- s_hengai_sleep_gsensor_data[1].y,
- s_hengai_sleep_gsensor_data[1].z
- );
-
- __sleep_gsensor_counter = 0;
- mmi_hengai_sleep_data_get();
- }
-#endif
-}
-
-#endif
-
-bool mmi_hengai_sleep_data_send(void)
-{
- char * temp_buff = NULL;
- uint32_t buff_size = sizeof(sleep_data_t);
- char * temp_ptr = NULL;
- uint32_t temp_count = 0;
- uint8_t i = 0;
-
- temp_buff = lv_mem_alloc(buff_size + 1);
- if(NULL == temp_buff)
- {
- printf("[@CHENG_DEBUG][%s][%d]: memory alloc failed\n", __FUNCTION__, __LINE__);
- return;
- }
- _lv_memset_00(temp_buff, buff_size + 1);
-
- temp_count = 0;
- temp_ptr = temp_buff + temp_count;
+ temp_ptr += temp_count;
sprintf(temp_ptr, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
s_hengai_sdata.total_sleep_time,
s_hengai_sdata.begin_sleep_time.year,
temp_count = strlen(temp_ptr);
}
- mmi_protocol_fzd_action_hengai_sleep_data(temp_buff, strlen(temp_buff));
+ //mmi_protocol_fzd_action_hengai_sleep_data(temp_buff, strlen(temp_buff));
+ mmi_protocol_fzd_action_tcp_http(temp_buff, strlen(temp_buff));
if(NULL != temp_buff)
{
}
}
-void mmi_hengai_sleep_data_get(void)
+static void mmi_hengai_sleep_data_get(void)
{
sleep_time_t curtime = {0};
hal_rtc_t cur_time = {0};
int result = 0;
result = get_sleep_time(s_hengai_sleep_gsensor_data, HENGAI_SLEEP_GSENSOR_DATA_MAX, curtime, &s_hengai_sdata);
printf("[@CHENG_DEBUG][%s][%d]: result=%d\n", __FUNCTION__, __LINE__, result);
+ UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: result=%d\n", __FUNCTION__, __LINE__, result);
if(1 == result)
{
mmi_hengai_sleep_data_send();
}
-#ifdef __MMI_HENG_AI_DEBUG__
- else
- {
- mmi_hengai_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)
{
-#ifndef __MMI_HENG_AI_DEBUG__
int16_t t_mems_data[32 * 3] = {0};
uint8_t i = 0;
{
uos_timer_stop(s_hengai_sleep_gsensor_timer_id);
s_hengai_sleep_gsensor_counter = 0;
- #ifdef __MMI_HENG_AI_DEBUG__
- mmi_heng_ai_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);
}
-#endif
}
void mmi_hengai_get_sleep_data_start(void)
{
-#ifndef __MMI_HENG_AI_DEBUG__
printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ UART_DEBUG_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);
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);
-#endif
}
void mmi_hengai_get_sleep_data_stop(void)
{
-#ifndef __MMI_HENG_AI_DEBUG__
printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
if(NULL != s_hengai_sleep_gsensor_timer_id)
s_hengai_sleep_gsensor_counter = 0;
_lv_memset_00(s_hengai_sleep_gsensor_data, sizeof(s_hengai_sleep_gsensor_data));
-#else
- mmi_hengai_sleep_result_send();
- lv_fs_remove(HENGAI_SLEEP_RESULT_FILE);
-#endif
}
-void mmi_hengai_health_sleep_lib_active(char * req_code, char * act_code)
+/*
+static unsigned char s_sleep_req_code[128 + 1] = {0};
+static char * mmi_hengai_health_sleep_req_code_get(void)
{
- if(NULL == req_code || NULL == act_code)
- return;
-
+ if(0 == strlen(s_sleep_req_code))
+ {
+ char imei[16 + 1] = {0};
+ app_adp_get_imei_req(imei);
+
+ unsigned int* req_len = 0;
+ //UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ request_validation((unsigned char *)"ZHSX", 4, (unsigned char *)imei, strlen(imei), (unsigned char *)s_sleep_req_code, &req_len);
+ }
+
+ return s_sleep_req_code;
+}
+*/
+
+void mmi_hengai_health_sleep_lib_active(void)
+{
+ char * req_code = mmi_hengai_health_lib_req_code_get();
printf("[@CHENG_DEBUG][%s][%d]: req_code=%s\n", __FUNCTION__, __LINE__, req_code);
+ UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: req_code=%s\n", __FUNCTION__, __LINE__, req_code);
+ if(NULL == req_code)
+ return;
+
+ char * act_code = mmi_hengai_health_lib_act_code_get();
printf("[@CHENG_DEBUG][%s][%d]: act_code=%s\n", __FUNCTION__, __LINE__, act_code);
+ UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: act_code=%s\n", __FUNCTION__, __LINE__, act_code);
+ if(NULL == act_code)
+ return;
+
int ret = activate_algorithm((unsigned char *)req_code, strlen(req_code), (unsigned char *)act_code, strlen(act_code));
printf("[@CHENG_DEBUG][%s][%d]: ret=%d\n", __FUNCTION__, __LINE__, ret);
+ UART_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: ret=%d\n", __FUNCTION__, __LINE__, ret);
+ if(ret)
+ {
+ mmi_hengai_health_sleep_activated_flag_set(1);
+ }
}
#endif