From: hcj <1224667075@qq.com> Date: Wed, 10 Jul 2024 01:41:33 +0000 (+0800) Subject: 增加实时数据同步 X-Git-Tag: release_V1.2.70_20241020_135402~833^2~1 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=63e1dc144a46a6fbf3848f3cb2209fcd15e04a91;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 f963ffb69..386f03112 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -632,27 +632,36 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) char path_[64]={0}; char timeday[12] = {0}; uapi_get_YYMMDD_Time_extend(timeday, '_',day); - + uint8_t day_now_data_size=0; switch (type) { case 0x43: //同步步数历史数据 sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_PATH,timeday); + day_now_data_size=8; break; case 0x44://同步燃脂时间数据 - sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_FAT_PATH,timeday); + sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_FAT_PATH,timeday); + day_now_data_size=6; break; case 0x45://同步站立历史数据 sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_STAND_DATA_PATH,timeday); + day_now_data_size=4; break; case 0x46://同步卡路里历史数据 sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_CALORIES_PATH,timeday); + day_now_data_size=8; break; case 0x47://同步距离历史数据 sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_DISTANCE_PATH,timeday); + day_now_data_size=8; break; default: break; } + if(day!=0) + { + day_now_data_size=0; + } FILE * fp = fopen(path_,"rb+"); if(fp==NULL) { @@ -668,7 +677,7 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) } printf("size %d \r\n",size); - char * buf=(char *)malloc(size); + char * buf=(char *)malloc(size+day_now_data_size); if(buf==NULL) { printf("malloc fail\r\n"); @@ -676,6 +685,68 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) } uint32_t ret= fread(buf,1,size,fp); + if(day==0) + { + uint32_t creationTime=0; + int ret = uapi_get_timestampe_ss(&creationTime); + uint32_t value=0; + switch (type) + { + case 0x43: //同步步数历史数据 + value=get_now_hour_data(CYWEE_SAVE_DATA_STEP); + if(value) + { + memcpy(buf+size,&creationTime,4); + size+=4; + memcpy(buf+size,&value,4); + size+=4; + } + break; + case 0x44://同步燃脂时间数据 + value=get_now_hour_data(CYWEE_SAVE_DATA_FAT); + if(value) + { + memcpy(buf+size,&creationTime,4); + size+=4; + uint16 temp_value= value; + memcpy(buf+size,&(temp_value),2); + size+=2; + } + break; + case 0x45://同步站立历史数据 + if(get_stand_falg()) + { + memcpy(buf+size,&creationTime,4); + size+=4; + } + break; + case 0x46://同步卡路里历史数据 + value=get_now_hour_data(CYWEE_SAVE_DATA_CALORIES); + if(value) + { + memcpy(buf+size,&creationTime,4); + size+=4; + memcpy(buf+size,&value,4); + size+=4; + } + break; + case 0x47://同步距离历史数据 + value=get_now_hour_data(CYWEE_SAVE_DATA_DISTANCE); + if(value) + { + memcpy(buf+size,&creationTime,4); + size+=4; + memcpy(buf+size,&value,4); + size+=4; + } + break; + break; + default: + break; + } + + } + printf("fread %d \r\n",ret); for(int i=0;i=10) + //当前时间戳减去订阅通知时间戳3s以上的通知,才要求数据(过滤ios将所有未查看消息发过来) + if(creationTime-subscribe_notify_creationTime>=3) ble_ancs_client_at_cmd_get_notify_att(conn_id, notify_src->notification_uid); // diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h index 43db0c2e8..2f26ccb92 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h @@ -532,11 +532,13 @@ void stand_history_save(void); void calories_history_save(void); void distances_history_save(void); void fat_history_save(void); +int32_t get_now_hour_data(uint8_t type); void cywee_goal_history_save(void); void set_stand_falg(void); +uint8_t get_stand_falg(void); void set_calories_data(uint32_t data); int get_calories_data(void); diff --git a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c index 4ad3ad15f..d0f960092 100644 --- a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c +++ b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c @@ -373,15 +373,15 @@ void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len,uint8_t ty CWM_OS_dbgPrintf(" save path %s \n",path_); - // int data= *new_data-*history;//新数据减去旧数据,作为这一个小时的步数值 - // if(data<=0) - // { - // data=0; - // *history=0; - // CWM_OS_dbgPrintf("异常 清除步数数据\n"); - // return; + int data= *new_data-*history;//新数据减去旧数据,作为这一个小时的步数值 + if(data<0) + { + data=0; + *history=0; + CWM_OS_dbgPrintf("异常 清除步数数据\n"); + return; - // } + } FILE * fp = fopen(path_,"ab+"); if(fp==NULL) @@ -412,7 +412,7 @@ void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len,uint8_t ty } CWM_OS_dbgPrintf("fwrite data %d\n",*new_data); - //*history=*new_data; + *history=*new_data; fclose(fp); } diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 9e208581a..97a2d85c7 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -112,6 +112,7 @@ void cywee_save_data(void) CWM_OS_saveData(&(new_calories),sizeof(int),CYWEE_SAVE_DATA_CALORIES); new_distance+=history_distances; CWM_OS_saveData(&(new_distance),sizeof(int),CYWEE_SAVE_DATA_DISTANCE); + //new_fat+=history_fat; CWM_OS_saveData(&new_fat,sizeof(int),CYWEE_SAVE_DATA_FAT); } @@ -134,10 +135,6 @@ uint32_t get_step_data(void) { return stepcount; } -void step_history_save(void) -{ - CWM_OS_saveData_history(&stepcount,&history_step_,sizeof(int),CYWEE_SAVE_DATA_STEP); -} int get_calories_data(void) { @@ -175,11 +172,24 @@ void set_stand_falg(void) { stand_falg=1; } + +uint8_t get_stand_falg(void) +{ + return stand_falg; +} + void stand_history_save(void) { CWM_OS_saveData_STAND_history(&stand_falg,sizeof(int)); } +void step_history_save(void) +{ + CWM_OS_saveData_history(&stepcount,&history_step_,sizeof(int),CYWEE_SAVE_DATA_STEP); +} + + + void calories_history_save(void) { @@ -190,7 +200,7 @@ void calories_history_save(void) void distances_history_save(void) { int data= get_distance_data(); - CWM_OS_saveData_history(&data,&history_calories_,sizeof(int),CYWEE_SAVE_DATA_DISTANCE); + CWM_OS_saveData_history(&data,&history_distances_,sizeof(int),CYWEE_SAVE_DATA_DISTANCE); } void fat_history_save(void) @@ -199,6 +209,28 @@ void fat_history_save(void) CWM_OS_saveData_history(&data,&history_fat_,sizeof(uint16_t),CYWEE_SAVE_DATA_FAT); } +int32_t get_now_hour_data(uint8_t type) +{ + switch (type) + { + case CYWEE_SAVE_DATA_STEP: + return stepcount-history_step_; + break; + case CYWEE_SAVE_DATA_CALORIES: + return get_calories_data()-history_calories_; + break; + case CYWEE_SAVE_DATA_DISTANCE: + return get_distance_data()-history_calories_; + break; + case CYWEE_SAVE_DATA_FAT: + return get_fat_time_data()-history_calories_; + break; + default: + break; + } + return 0; +} + void cywee_goal_history_save(void) { stand_history_save();