From: hcj <1224667075@qq.com> Date: Tue, 11 Jun 2024 07:49:45 +0000 (+0800) Subject: 站立次数同步 X-Git-Tag: release_V1.2.70_20241020_135402~1020^2~1 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=8a5912e380f085a43c69bea4f9e759494375134c;p=mirrors%2FFD230.git 站立次数同步 --- diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index 8b6c4f149..54ee72788 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -100,8 +100,50 @@ char * ble_step_history(uint8_t day,uint16_t *len) } *len=size; return buf; +} + +#define CWM_HISTORY_STAND_DATA_PATH "/user/userdata/stand_" +char * ble_stand_history(uint8_t day,uint16_t *len) +{ + char path_[64]={0}; + char timeday[12] = {0}; + uapi_get_YYMMDD_Time(timeday, '_'); + sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_STAND_DATA_PATH,timeday); + + FILE * fp = fopen(path_,"rb+"); + if(fp==NULL) + { + printf("fopen fail\r\n"); + return NULL; + } + uint32_t size; + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + size = ftell(fp); // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + } + printf("size %d \r\n",size); + + char * buf=(char *)malloc(size); + if(buf==NULL) + { + printf("malloc fail\r\n"); + return buf; + } + uint32_t ret= fread(buf,1,size,fp); + + printf("fread %d \r\n",ret); + for(int i=0;i482) + { + num=482; + } + Read_BIN_file_buf_send_bin_Data(num,0x45); + break; case 0x46://同步卡路里历史数据 EACH_DATA_LEN = KCAL_DATA_LEN; diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index d4830a4ba..3c4d271de 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -272,6 +272,8 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req) // cywee_save_data(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时步数"); step_history_save(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时站立数据"); + stand_history_save(); } @@ -912,9 +914,16 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s cywee_inactivity_result_t failed, ret = %d", rets); return; } - + + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "cywee_Inactivity_Info->sedentary_status = %d, stand_freq = %d", cywee_Inactivity_Info->sedentary_status, cywee_Inactivity_Info->stand_freq); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "cywee_Inactivity_Info->output_number = %d", cywee_Inactivity_Info->output_number); + if(cywee_Inactivity_Info->sedentary_status==9) + { + set_stand_falg(); + } + + static int interval = 0;//久坐间隔时间 switch (cywee_Inactivity_Info->output_number) diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h index ab3599704..2eaf1ddef 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h @@ -33,6 +33,7 @@ extern void* CWM_OS_malloc(int size); extern void CWM_OS_free(void *ptr); extern void CWM_OS_saveData(int* data, uint32_t len); extern void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len); +extern void CWM_OS_saveData_STAND_history(uint8_t *falg,uint32_t len); extern void CWM_OS_restoreData(int* data, uint32_t len); /********************CYWEE LIB*************************/ @@ -507,6 +508,8 @@ void cywee_time_sync(void); void cywee_hand_updown_switch(int cmd); void cywee_ar_alert_switch(int cmd); void step_history_save(void); +void stand_history_save(void); +void set_stand_falg(void); void cywee_get_chipinfo(char *databuf,uint8_t len); void cywee_get_acc_switch(uint8_t cmd); void cywee_set_sedentary_interval(int time); diff --git a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c index df7fe1ba2..cda4297ca 100644 --- a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c +++ b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c @@ -332,32 +332,48 @@ void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len){ } #define CWM_HISTORY_STAND_DATA_PATH "/user/userdata/stand_" -void CWM_OS_saveData_STAND_history(int *time ,uint32_t len){ - char path_[64]={0}; - char timeday[12] = {0}; - uapi_get_YYMMDD_Time(timeday, '_'); +void CWM_OS_saveData_STAND_history(uint8_t *falg,uint32_t len){ + if(*falg) + { + char path_[64]={0}; + char timeday[12] = {0}; + uapi_get_YYMMDD_Time(timeday, '_'); + + sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_STAND_DATA_PATH,timeday); + CWM_OS_dbgPrintf(" save path %s \n",path_); + + FILE * fp = fopen(path_,"ab+"); + if(fp==NULL) + { + CWM_OS_dbgPrintf("open fail\n"); + return; + } + uint32_t creationTime; + int ret =uapi_get_timestampe_ss(&creationTime); + + creationTime=creationTime-60*60; + CWM_OS_dbgPrintf("uapi_get_timestampe_ss %d\n",ret); + + ret =fwrite(&creationTime,1,len,fp); + if(ret==0) + { + CWM_OS_dbgPrintf("fwrite failed %d\n",ret); + } - sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_STAND_DATA_PATH,timeday); - CWM_OS_dbgPrintf(" save path %s \n",path_); + fclose(fp); - FILE * fp = fopen(path_,"ab+"); - if(fp==NULL) - { - CWM_OS_dbgPrintf("open fail\n"); - return; + *falg=0; } - - int ret =fwrite(time,1,len,fp); - if(ret==0) + else { - CWM_OS_dbgPrintf("fwrite failed %d\n",ret); + return; } - //CWM_OS_dbgPrintf("fwrite data %d\n",data); - - *time=0; - fclose(fp); } + + //CWM_OS_dbgPrintf("fwrite data %d\n",data); + + diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index f6b61b235..17ac1f209 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -46,6 +46,8 @@ static int stepcount = 0; int history_step_=0;//存一个小时前的步数数据,每次保存步数时会更新改数据 +uint8_t stand_falg=0;//站立falg,如果发生站立,一个小时内会被置1; + static char chipInfo[64] = {0}; static int get_acc_swtich = 0; @@ -82,6 +84,16 @@ void step_history_save(void) CWM_OS_saveData_history(&stepcount,&history_step_,sizeof(int)); } +void set_stand_falg(void) +{ + stand_falg=1; +} +void stand_history_save(void) +{ + CWM_OS_saveData_STAND_history(&stand_falg,sizeof(int)); +} + + void cywee_ar_alert_switch(int cmd) { memset(&scl, 0, sizeof(scl));