From 2643aeb42ed2c12dfcbff0f6e36aa59dc33b708e Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Tue, 8 Oct 2024 17:17:11 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E5=B0=8F=E7=9D=A1=E6=AD=BB?= =?utf8?q?=E6=9C=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../service/ble_service/blemoder/bletest.cpp | 5 +- .../service/ble_service/bleservice/bleEvent.c | 286 +----------------- 2 files changed, 5 insertions(+), 286 deletions(-) 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 01559db79..b4337a2b4 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -689,8 +689,8 @@ uint8_t ble_get_sleep_data(uint32_t file_size,uint8_t day_,uint8_t *data) uint16_t read_size_status =fread(data+offset+3+read_size,1,sleep_file_size,fp); read_size+=read_size_status; memcpy(data+offset,&read_size,2); - - offset+=read_size_status; + fclose(fp); + } offset+=read_size; offset+=3; @@ -699,6 +699,7 @@ uint8_t ble_get_sleep_data(uint32_t file_size,uint8_t day_,uint8_t *data) } else if(fileName!="sleep_status.bin") { + printf("offset %d\r\n",offset); char file_path[128]={0}; sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 767adb925..c24b4b9f8 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -5471,132 +5471,7 @@ static void GetSynDataEndCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *to sendBleData(value,19); } } -//同步历史步数 -static void stepDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) -{ - uint8_t value[58]; - memset(value,0,58); - uint32_t tmp = 1; - uint32_t tmpToall = 40; - uint16_t tmp_data = 40; - value[0] = 0x72; - value[1] = 0x01; - value[2] = 0x43; - memcpy(value+3,&tmp,4); - memcpy(value+7,&tmpToall,4); - memcpy(value+11,&tmp,4); - memcpy(value+15,&tmp_data,2); - if(Check_CRC(data,len,crcvalue)) - { - uint8_t data_buf[40]; // - uint8_t data_len = 0; - uint32_t time = 1704090976; - uint32_t step = 0; - int ret = uapi_get_timestampe_ss(&time); - - for(uint16_t i = 0;i<5;i++) - { - time = time+i*3600; - memcpy(data_buf+data_len,&time,4); - data_len=data_len+4; - step = i*100; - memcpy(data_buf+data_len,&step,4);//1 3 5 7 9 - data_len = data_len+4; - - } - memcpy(&value[17],data_buf,40); - // value[17] = 1;// - value[17+40] = Calculate_CRC(value,57); - sendBleData(value,58); - }else - { - value[17] = 0; - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); - } -} -//同步卡路里历史数据 -static void kcalDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) -{ - uint8_t value[58]; - memset(value,0,58); - uint32_t tmp = 1; - uint32_t tmpToall = 40; - uint16_t tmp_data = 40; - value[0] = 0x72; - value[1] = 0x01; - value[2] = 0x46; - memcpy(value+3,&tmp,4); - memcpy(value+7,&tmpToall,4); - memcpy(value+11,&tmp,4); - memcpy(value+15,&tmp_data,2); - if(Check_CRC(data,len,crcvalue)) - { - uint8_t data_buf[40]; // - uint8_t data_len = 4; - for(uint16_t i = 0;i<10;i++) - { - if( i % 2 == 0){ - uint32_t time = 1710484844+i*3600; - memcpy(&data_buf[4*i],&time,data_len); //0 2 4 6 8 - }else{ - float kcal = 189+i*20; - memcpy(&data_buf[4*i],&kcal,data_len);//1 3 5 7 9 - } - - } - memcpy(&value[17],data_buf,40); - // value[17] = 1;// - value[17+40] = Calculate_CRC(value,57); - sendBleData(value,58); - }else - { - value[17] = 0; - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); - } -} -//同步距离历史数据 -static void disDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) -{ - uint8_t value[58]; - memset(value,0,58); - uint32_t tmp = 1; - uint32_t tmpToall = 40; - uint16_t tmp_data = 40; - value[0] = 0x72; - value[1] = 0x01; - value[2] = 0x47; - memcpy(value+3,&tmp,4); - memcpy(value+7,&tmpToall,4); - memcpy(value+11,&tmp,4); - memcpy(value+15,&tmp_data,2); - if(Check_CRC(data,len,crcvalue)) - { - uint8_t data_buf[40]; // - uint8_t data_len = 4; - for(uint16_t i = 0;i<10;i++) - { - if( i % 2 == 0){ - uint32_t time = 1710484844+i*3600; - memcpy(&data_buf[4*i],&time,data_len); //0 2 4 6 8 - }else{ - float kcal = 189+i*20; - memcpy(&data_buf[4*i],&kcal,data_len);//1 3 5 7 9 - } - - } - memcpy(&value[17],data_buf,40); - // value[17] = 1;// - value[17+40] = Calculate_CRC(value,57); - sendBleData(value,58); - }else - { - value[17] = 0; - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); - } -} + //同步基础训练历史数据 training history data static void Send_json_Data_Cmd(uint8_t day,uint16_t pack_size,uint8_t id) { @@ -5658,35 +5533,8 @@ static void Send_json_Data_Cmd(uint8_t day,uint16_t pack_size,uint8_t id) pack_id++; } cJSON_free(json_format); - // ym_free(json_format); -} -//同步睡眠数据 -static void sleepDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) -{ - uint8_t value[18+1]; - memset(value,0,18+1); - uint32_t tmp = 1; - uint32_t tmpToall = 0; - uint16_t tmp_data = 0; - value[0] = 0x72; - value[1] = 0x01; - value[2] = 0x4b; - memcpy(value+3,&tmp,4); - memcpy(value+7,&tmpToall,4); - memcpy(value+11,&tmp,4); - memcpy(value+15,&tmp_data,2); - if(Check_CRC(data,len,crcvalue)) - { - value[17] = 0; - value[18] = 0xff; - sendBleData(value,19); - }else - { - value[17] = 0; - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); - } } + //同步数据结束完成 static void synEndDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { @@ -5714,134 +5562,8 @@ static void synEndDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *total sendBleData(value,19); } } -//同步站立历史数据 -static void standDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) -{ - uint8_t value[58]; - memset(value,0,58); - uint32_t tmp = 1; - uint32_t tmpToall = 40; - uint16_t tmp_data = 40; - value[0] = 0x72; - value[1] = 0x01; - value[2] = 0x45; - memcpy(value+3,&tmp,4); - memcpy(value+7,&tmpToall,4); - memcpy(value+11,&tmp,4); - memcpy(value+15,&tmp_data,2); - if(Check_CRC(data,len,crcvalue)) - { - uint8_t data_buf[40]; // - uint8_t data_len = 4; - for(uint16_t i = 0;i<10;i++) - { - if( i % 2 == 0){ - uint32_t time = 1710484844+i*3600; - memcpy(&data_buf[4*i],&time,data_len); //0 2 4 6 8 - }else{ - float kcal = 189+i*20; - memcpy(&data_buf[4*i],&kcal,data_len);//1 3 5 7 9 - } - - } - memcpy(&value[17],data_buf,40); - // value[17] = 1;// - value[17+40] = Calculate_CRC(value,57); - sendBleData(value,58); - }else - { - value[17] = 0; - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); - } -} -//同步燃脂时间数据 -static void burntimeDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) -{ - uint8_t value[48]; - memset(value,0,48); - uint32_t tmp = 1; - uint32_t tmpToall = 30; - uint16_t tmp_data = 30; - value[0] = 0x72; - value[1] = 0x01; - value[2] = 0x44; - memcpy(value+3,&tmp,4); - memcpy(value+7,&tmpToall,4); - memcpy(value+11,&tmp,4); - memcpy(value+15,&tmp_data,2); - if(Check_CRC(data,len,crcvalue)) - { - uint8_t data_buf[30]; // - uint32_t data_len = 0; - for(uint16_t i = 0;i<5;i++) - { - uint32_t time = 1710484844+i*3600; - uint16_t fatTime = 189+i*20;//1 - memcpy(value+17+data_len,&time,4); - data_len=data_len+4;//4 6 - memcpy(value+17+data_len,&fatTime,2);//1 3 5 7 9 - data_len=data_len+2;//6 - } - printf("data_len:%d",data_len); - // memcpy(&value[17],data_buf,30); - // value[17] = 1;// - value[17+data_len] = Calculate_CRC(value,data_len+17); - sendBleData(value,data_len+17+1); - }else - { - value[17] = 0; - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); - } -} -uint8 read_hart_jsondata(uint8 day) -{ - // char path[64]={0}; - // sprintf(path,"%s/%d",HEALTH_JSON_PATH,day); - // fopen(); - // { - return 0; - // } -} -//同步血氧历史数据 -static void spo2DataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) -{ - uint8_t value[43]; - memset(value,0,43); - uint32_t tmp = 1; - uint32_t tmpToall = 25; - uint16_t tmp_data = 25; - value[0] = 0x72; - value[1] = 0x01; - value[2] = 0x41; - memcpy(value+3,&tmp,4); - memcpy(value+7,&tmpToall,4); - memcpy(value+11,&tmp,4); - memcpy(value+15,&tmp_data,2); - if(Check_CRC(data,len,crcvalue)) - { - uint32_t data_len = 0; - for(uint16_t i = 0;i<5;i++) - { - uint32_t time = 1710484844+i*3600; - uint8_t spo2 = 90+i;//1 - memcpy(value+17+data_len,&time,4); - data_len=data_len+4;//4 6 - memcpy(value+17+data_len,&spo2,1);//1 3 5 7 9 - data_len=data_len+1;//6 - } - value[17+data_len] = Calculate_CRC(value,data_len+17); - sendBleData(value,data_len+17+1); - }else - { - value[17] = 0; - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); - } -} //01类型 @@ -6185,8 +5907,6 @@ void Send_Sleep_Bin_Data(uint8_t day, uint16_t num) ble_data_type type_={0x01,0x4b,file_size,pack,pack_id}; send_big_data(type_,data+offset,num); - - //send_big_data(1,data+offset,num,file_size,pack_id,pack,0x4b,1); offset+=num; } else @@ -6202,8 +5922,6 @@ void Send_Sleep_Bin_Data(uint8_t day, uint16_t num) printf("%02X ",(uint8_t)data[i]); } printf("结束\r\n"); - - //send_big_data(1,data+offset,surplus_len,file_size,pack_id,pack,0x4b,1); break; } pack_id++; -- 2.17.1