From: hcj <1224667075@qq.com> Date: Wed, 10 Jul 2024 10:59:41 +0000 (+0800) Subject: 传输实时数据bug修复 X-Git-Tag: release_V1.2.70_20241020_135402~831^2~5 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=1339531f5167253c67741841ebd83d5cd92a1030;p=mirrors%2FFD230.git 传输实时数据bug修复 --- 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 876e958f6..900283abc 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -666,28 +666,41 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) day_now_data_size=0; } FILE * fp = fopen(path_,"rb+"); + uint32_t size=0; if(fp==NULL) { - printf(" fopen type %d %s fail\r\n",type,path_); + printf(" fopen type %d %s fail\r\n",type,path_); + if(day==0) + { + goto DAY_IS_0; + } + //printf(" fopen type %d %s fail\r\n",type,path_); 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); + + + DAY_IS_0: + printf("size %d \r\n",size); char * buf=(char *)malloc(size+day_now_data_size); if(buf==NULL) { printf("malloc fail\r\n"); return buf; } - uint32_t ret= fread(buf,1,size,fp); - + if(fp) + { + uint32_t ret= fread(buf,1,size,fp); + fclose(fp); + } + if(day==0) { time_t currtime; @@ -699,7 +712,7 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) struct tm *timeinfo; time(&currtime); timeinfo = localtime(&currtime); - //printf("localtime %d",timeinfo->tm_min); + printf("localtime %d",timeinfo->tm_min); creationTime-=(timeinfo->tm_min*60); switch (type) @@ -731,6 +744,7 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) memcpy(buf+size,&creationTime,4); size+=4; } + break; case 0x46://同步卡路里历史数据 value=get_now_hour_data(CYWEE_SAVE_DATA_CALORIES); @@ -752,20 +766,24 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) size+=4; } break; - break; default: break; } } - printf("fread %d \r\n",ret); - for(int i=0;i