From: hcj <1224667075@qq.com> Date: Tue, 23 Apr 2024 02:32:13 +0000 (+0800) Subject: 蓝牙控制训练修改 X-Git-Tag: release_V1.2.70_20241020_135402~1137^2~4 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=d60a3dad91ca24bfa5aaefa7daf6d9dd16a85613;p=mirrors%2FFD230.git 蓝牙控制训练修改 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h index 2127beea7..9cfc72d8c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h @@ -14,6 +14,16 @@ namespace OHOS { + typedef enum { + IOT_CODE_0, + IOT_CODE_IS_NEW=20006,//已是最新版本 + IOT_CODE_SUCCESS=20007,//有新版本,唯一成功id,不是这个都表示没有升级版本data为NULL + IOT_CODE_FAIL_1=50000,//设备源版本不能为空 + IOT_CODE_FAIL_2=50012,//设备未注册 + SAMPLE_RATE_MAX + } iot_code; + + class SystemupgradeView { diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp index fd5a50755..857f20702 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp @@ -17,8 +17,22 @@ #include "tcxo.h" #include "cat1_server.h" #include "linux/delay.h" + +#define HTTP_JSON_SERVER_NAME "test.iot.api.thisiot.com"//"test.app.api.thisiot.com" +#define HTTP_FWPGK_SERVER_NAME "r-oss.thisiot.com"//" +#define PORT (80)//(443) +#define UPDATAJSONPATH "/update/ota_start_.json" + +#define UPDATAREPORT "/update/ota_start_reported_.json" + +#define UPDATAFWPKGPATH "/update/update.fwpkg" + +//https://test.app.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion + +//http://test.iot.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion namespace OHOS { + static SystemupgradeView *g_pSystemFactoryResetView{nullptr}; static osThreadId_t g_alipay_task_handle = NULL; @@ -26,32 +40,87 @@ namespace OHOS // osThreadAttr_t g_alipay_attr = { // "alipay_task", 0, NULL, 0, NULL, ALIPAT_MSG_STACK_SIZE, TASK_PRIORITY_ALIPAY_APP, 0, 0 // }; - static char *Path= "/update/ota_start_3.json"; + static char *Path=UPDATAJSONPATH; static httpc_connection_t settings = {0}; static uint8_t uri[256] ={0};// (uint8_t*) //"http://icfota.snicker.com.cn:8089/fd230ota.jsp?product=FD230&pkgver=V1.1_20240316_115535&imei=864430010001091"; - static char *Path_ota_package= "/update/update.fwpkg"; - static uint8_t uri_ota_package[124] ={0}; + static char *Path_ota_package= UPDATAFWPKGPATH; + static uint8_t uri_ota_package[256] ={0}; + + void upgrade_reported_data(void) + { + FILE * fp = fopen(UPDATAREPORT,"rb+"); + if(fp==NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "open_UPDATAREPORT_fail"); + fclose(fp); + return; + } + + char *buf=(char *)malloc(512); + memset((void*)buf,0,512); + int ret =fread(buf,1,512,fp); + int offset=512; + while (ret==512) + { + buf=(char *)realloc(buf,offset+512); + ret=fread(buf+offset,1,512,fp); + offset+=512; + } + if(ret==0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fread %d",ret); + fclose(fp); + free(buf); + return; + } + cJSON *data = cJSON_Parse(buf); + + if(data!=NULL) + { + char *targetVersion=cJSON_GetObjectItem(data, "targetVersion")->valuestring; + char version_buf[128]={0}; + uint32_t version_len=128; + uapi_get_buildversion((uint8_t*)version_buf,version_len); + if(strcmp(targetVersion,version_buf)==0) + { + //HTTP_send_data + } + } + cJSON_Delete(data); + } + //#define UP_TEST static void upgrade_task(void *arg) { msleep(3000); //uapi_tcxo_delay_ms(3000); - char buf[1024]={0}; - FILE * fp = fopen(Path,"rb"); + + + FILE * fp = fopen(Path,"rb+"); if(fp==NULL) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "open fail"); SystemupgradeView::GetInstance()->set_string_value(NULL,false); return; } - int ret =fread(buf,1,1024,fp); + char *buf=(char *)malloc(512); + memset((void*)buf,0,512); + int ret =fread(buf,1,512,fp); + int offset=512; + while (ret==512) + { + buf=(char *)realloc(buf,offset+512); + ret=fread(buf+offset,1,512,fp); + offset+=512; + } if(ret==0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fread %d",ret); fclose(fp); + free(buf); SystemupgradeView::GetInstance()->set_string_value(NULL,false); return; } @@ -59,35 +128,78 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui %d",ret); // std::string jsonDataString((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); // const char *jsonData = jsonDataString.c_str(); - cJSON *root = cJSON_Parse(buf); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui"); - if(root!=NULL) + char *new_buf=NULL; + new_buf=strstr(buf,"{\"success\":");//移到json的头的位置 + cJSON *root = cJSON_Parse(new_buf); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " %s",new_buf); + free(buf); + if(root==NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui JSON_parse_fail"); + } + else if(root!=NULL) { - int falg=cJSON_GetObjectItem(root, "UptoDate")->valueint; - char *uri = cJSON_GetObjectItem(root, "url")->valuestring; - sprintf((char *)uri_ota_package,"%s",uri); - char *OtaPackageVersion = cJSON_GetObjectItem(root, "OtaPackageVersion")->valuestring; - char *description = cJSON_GetObjectItem(root, "description")->valuestring; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s,%s",uri,OtaPackageVersion); - //SystemupgradeView::GetInstance()->newVersion->SetText(OtaPackageVersion); - cJSON_Delete(root); - char buf[1024]={0}; - sprintf(buf,"%s\n%s",OtaPackageVersion,description); - #ifdef UP_TEST - SystemupgradeView::GetInstance()->set_string_value(buf,true); - #else - if(falg==0) + int code=cJSON_GetObjectItem(root, "code")->valueint; + + //char *uri = cJSON_GetObjectItem(root, "url")->valuestring; + // + //char *OtaPackageVersion = cJSON_GetObjectItem(root, "OtaPackageVersion")->valuestring; + char *msg = cJSON_GetObjectItem(root, "msg")->valuestring; + // if(msg==NULL) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "msg????????????????"); + // } + // else + // //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",msg); + int success=cJSON_GetObjectItem(root, "success")->valueint; + + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s,%s",uri,OtaPackageVersion); + // //SystemupgradeView::GetInstance()->newVersion->SetText(OtaPackageVersion); + // cJSON_Delete(root); + char msg_buf[256]={0}; + bool falg=false; + + if(code==IOT_CODE_SUCCESS) { - SystemupgradeView::GetInstance()->set_string_value(buf,true); + falg=true; + cJSON *data=cJSON_GetObjectItem(root, "data"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, ""); + + char *jsonString = cJSON_PrintUnformatted(data); + uint32_t data_len=strlen(jsonString); + FILE *FP_= fopen(UPDATAREPORT,"w+"); + fwrite(jsonString,1,data_len,FP_); + fclose(FP_); + printf("data%d %s\r\n",data_len,jsonString); + + if(data!=NULL) + { + cJSON *downloadFileVo=cJSON_GetObjectItem(data, "downloadFileVo"); + + if(downloadFileVo!=NULL) + { + + //"https://r-oss.thisiot.com/device-ota/2024_04_22/1782329689464958978.fwpkg?Expires=1713780167&OSSAccessKeyId=LTAI5tJa2arDBmqSUsSTQJ1T&Signature=OlbdNsfnz9Zje6ypFgXINQPXVE0%3D" + char *uri = cJSON_GetObjectItem(downloadFileVo, "url")->valuestring; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uri %s",uri); + sprintf((char *)uri_ota_package,"%s",uri); + } + } } else { - SystemupgradeView::GetInstance()->set_string_value(NULL,false); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "code!=IOT_CODE_SUCCESS"); } - #endif + + sprintf(msg_buf,"%s",msg); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",msg); + + SystemupgradeView::GetInstance()->set_string_value(msg_buf,falg); + //RootView::GetInstance()->Invalidate(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui"); + cJSON_Delete(root); } fclose(fp); @@ -109,7 +221,6 @@ namespace OHOS if(ret!=ERRCODE_SUCC) { SystemupgradeView::GetInstance()->init_fail(0); - } //开始升级 @@ -133,7 +244,7 @@ namespace OHOS taskcfg.create_queue_handle = NULL; taskcfg.attr.name="upgrade_service"; taskcfg.attr.priority = TASK_PRIORITY_APP; - taskcfg.attr.stack_size = 1024*8; + taskcfg.attr.stack_size = 1024*10; taskcfg.func = upgrade_task; taskcfg.use_mem = USE_EXTEND_MEM; @@ -208,9 +319,8 @@ namespace OHOS return 0; } - - static uint32_t custom_start_ota_download_ui_1( uint8_t *uri_str,uint8_t *Path,bool falg) + static uint32_t custom_start_ota_download_ui_1( uint8_t *uri_str,uint8_t *Path,bool falg,const char *server_name) { //(uint8_t*)argv[0]; @@ -226,6 +336,7 @@ namespace OHOS { settings.result_fn=httpc_download_result_ui_packpage; } + FILE * fp= fopen((char *)Path,"rb"); if(fp!=NULL) { @@ -235,10 +346,11 @@ namespace OHOS } settings.headers_done_fn=httpc_download_headers_done_ui; + settings.use_post=0; httpc_state_t* connection=NULL; err_t rett = httpc_get_file_dns_to_disk( - (const char*) "icfota.snicker.com.cn", - 8089, + server_name, + PORT, (const char*) uri_str, (const httpc_connection_t *)&settings, NULL, @@ -392,17 +504,18 @@ namespace OHOS } void SystemupgradeView::statr_down_fwpkg(void) { - if(is_new_cat1_version) - { - char *imei_str= const_cast(ConfigModel::GetInstance()->Getimei().c_str()); - char * version_buf=const_cast(ConfigModel::GetInstance()->GetmoderVer().c_str()); - sprintf((char *)uri,"http://icfota.snicker.com.cn:8089/fd230ota.jsp?product=FD230&pkgver=%s&imei=%s",version_buf,imei_str); - cat1_ota_update((char *)"0"); - container_updating->SetVisible(true); - scrollView->SetTouchable(false); - scrollView->SetDraggable(false); - } - else if(is_new_version) + // if(is_new_cat1_version) + // { + // char *imei_str= const_cast(ConfigModel::GetInstance()->Getimei().c_str()); + // char * version_buf=const_cast(ConfigModel::GetInstance()->GetmoderVer().c_str()); + // sprintf((char *)uri,"http://test.iot.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s",imei_str,version_buf); + // cat1_ota_update((char *)"0"); + // container_updating->SetVisible(true); + // scrollView->SetTouchable(false); + // scrollView->SetDraggable(false); + // } + // else + if(is_new_version) { //下载差分包 //********** @@ -410,7 +523,7 @@ namespace OHOS scrollView->SetTouchable(false); scrollView->SetDraggable(false); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "custom_start_ota_download_ui_1"); - custom_start_ota_download_ui_1(uri_ota_package,(uint8_t*)Path_ota_package,false); + custom_start_ota_download_ui_1(uri_ota_package,(uint8_t*)Path_ota_package,false,HTTP_FWPGK_SERVER_NAME); } } @@ -436,7 +549,10 @@ namespace OHOS { if(falg) { - newVersion->SetText(str); + if(str!=NULL) + { + newVersion->SetText(str); + } newVersionTitle->SetText("有最新固件版本"); newVersion->SetVisible(true); @@ -447,19 +563,25 @@ namespace OHOS } else { - newVersionTitle->SetText("已是最新固件版本"); + if(str!=NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "str %s",str); + newVersion->SetText(str); + newVersion->SetVisible(true); + } + + + newVersionTitle->SetText("获取升级失败"); newVersionTitle->SetVisible(true); is_new_version=false; } - char *imei_str= const_cast(ConfigModel::GetInstance()->Getimei().c_str()); - char * version_buf=const_cast(ConfigModel::GetInstance()->GetmoderVer().c_str()); - sprintf((char *)uri, - "http://icfota.snicker.com.cn:8089/fd230ota.jsp?product=FD230&pkgver=%s&imei=%s", - version_buf,imei_str); - custom_start_ota_download_ui_1(uri,(uint8_t*)Path,true); - falg_dwon_json++; + // char *imei_str= const_cast(ConfigModel::GetInstance()->Getimei().c_str()); + // char * version_buf=const_cast(ConfigModel::GetInstance()->GetmoderVer().c_str()); + // sprintf((char *)uri,"https://test.app.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s",imei_str,version_buf); + // custom_start_ota_download_ui_1(uri,(uint8_t*)Path,true); + // falg_dwon_json++; } else if (falg_dwon_json==1) { @@ -811,8 +933,11 @@ namespace OHOS display_api->set_screen_set_keepon_timeout(-1); memset(uri,0,256); char *imei_str= const_cast(ConfigModel::GetInstance()->Getimei().c_str()); - sprintf((char *)uri,"http://icfota.snicker.com.cn:8089/fd230ota.jsp?product=FD230&pkgver=%s&imei=%s",version_buf,imei_str); - custom_start_ota_download_ui_1(uri,(uint8_t*)Path,true); + //https://test.app.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion + // 860132060347507 + // v1.1_20240419_152549 + sprintf((char *)uri,"http://test.iot.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s",imei_str,"V1.1_20240422_161728");//version_buf); + custom_start_ota_download_ui_1(uri,(uint8_t*)Path,true,HTTP_JSON_SERVER_NAME); falg_dwon_json=0; //uograde_service_service_init(); diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h index 134204bbe..fa3f6c74d 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -45,20 +45,28 @@ enum PAIRING REBOOT, SHUTDOWN }; - +// enum class ExerciseState +// { +// Start = 0, +// End, +// Pause, +// Continue, +// General, +// }; enum TRANING { START=0, + END, STOP, RECOVER, - END + SETGOAL, }; typedef struct { uint8_t sportType; //训练项目 uint8_t sportTagType; //训练目标类型 - uint8_t sportTag; //训练目标 + uint32_t sportTag; //训练目标 uint8_t controlmd; //训练控制md } training_ble; 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 bdc4bbe90..4397db94b 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -285,6 +285,7 @@ void send_big_data(uint8_t flag,char *data,int datalen,int total,uint32_t Packet memcpy(buf+15,&datalen,2); if(data==NULL) { + data="\0"; buf[17+datalen] = Calculate_CRC_Big((uint8_t *)data,datalen); if(flag) sendDataNow(buf,17+datalen+1); @@ -1246,7 +1247,7 @@ void GetUTCtime(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uin } } - +static training_ble training_ble_data; static uint8_t jsonCheck_targetparam(uint8_t *buf)//训练目标参数 { @@ -1264,26 +1265,39 @@ static uint8_t jsonCheck_targetparam(uint8_t *buf)//训练目标参数 cJSON* ty = cJSON_GetObjectItem(root, "ty");//目标类型 if (cJSON_IsNumber(ty)) { printf("ty: %d\n", ty->valueint); - + training_ble_data.sportTagType=ty->valueint; + training_ble_data.controlmd=SETGOAL; + //CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,sizeof(training_ble)); } + cJSON* di = cJSON_GetObjectItem(root, "di");//目标距离 if (cJSON_IsNumber(di)) { printf("di: %d\n", di->valueint); + training_ble_data.sportTag=di->valueint; + + CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,sizeof(training_ble)); + } cJSON* ca = cJSON_GetObjectItem(root, "ca");//目标卡路里 if (cJSON_IsNumber(di)) { printf("ca: %d\n", ca->valueint); + training_ble_data.sportTag=ca->valueint; + CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,sizeof(training_ble)); } cJSON* tm = cJSON_GetObjectItem(root, "tm");//目标时间 if (cJSON_IsNumber(tm)) { printf("tm: %d\n", tm->valueint); + training_ble_data.sportTag=tm->valueint; + CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,sizeof(training_ble)); } cJSON* st = cJSON_GetObjectItem(root, "st");//目标步数 if (cJSON_IsNumber(st)) { printf("st: %d\n", st->valueint); + training_ble_data.sportTag=st->valueint; + CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,sizeof(training_ble)); } cJSON_Delete(root); return 1; @@ -1514,7 +1528,7 @@ void GetHrSetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalDa } -void GetSpo2SetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取app下发的声音与振动参数 +void GetSpo2SetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue) { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1639,6 +1653,7 @@ void SetsteptargetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *to uint8_t vibration=crcnum[6]; uint8_t notify=crcnum[7]; printf("设置步数:%d\r\n",targetStep); + set_goal_stepcount(targetStep); set_vibrationremiander(vibration); @@ -2391,7 +2406,7 @@ static void DeleteFileTypeCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t } } //开启指定运动模式 -static training_ble training_ble_data; + static void OpenSportModeCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[19]; @@ -2410,7 +2425,7 @@ static void OpenSportModeCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * training_ble_data.sportType= crcnum[0];//运动类型 0 健走 1跑步 2骑行 3 training_ble_data.controlmd= START; printf("开启指定运动%d\r\n",crcnum[0]); - CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,2); + CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,sizeof(training_ble)); value[17] = 1; //1 操作成功 2 操作失败 value[18] = Calculate_CRC(value,18); sendBleData(value,19); @@ -2442,7 +2457,7 @@ static void StopSportModeCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * training_ble_data.controlmd= END; printf("结束运动\r\n"); - CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,2); + CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,sizeof(training_ble)); value[17] = 1; //1 操作成功 2 操作失败 value[18] = Calculate_CRC(value,18); sendBleData(value,19); @@ -2655,7 +2670,7 @@ static void GetSportPasueResetCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint training_ble_data.controlmd= STOP; printf("运动暂停\r\n"); - CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,2); + CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,sizeof(training_ble)); } else { @@ -2663,7 +2678,7 @@ static void GetSportPasueResetCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint training_ble_data.controlmd= RECOVER; printf("运动恢复\r\n"); - CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,2); + CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,sizeof(training_ble)); } value[17] = 1; @@ -3691,47 +3706,7 @@ uint8 read_hart_jsondata(uint8 day) return 0; // } } -//同步心率历史数据 -static void heartDataCmd(uint16_t cmd,uint8_t *crcnum,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] = 0x40; - memcpy(value+3,&tmp,4); - memcpy(value+7,&tmpToall,4); - memcpy(value+11,&tmp,4); - memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) - { - read_hart_jsondata(crcnum[17]); - - // uint32_t data_len = 0; - // for(uint16_t i = 0;i<5;i++) - // { - // uint32_t time = 1710484844+i*3600; - // uint8_t hr = 70+i*5;//1 - // memcpy(value+17+data_len,&time,4); - // data_len=data_len+4;//4 6 - // memcpy(value+17+data_len,&hr,1);//1 3 5 7 9 - // data_len=data_len+1;//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); - } -} + //同步血氧历史数据 static void spo2DataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { @@ -4008,7 +3983,7 @@ void Read_file_buf_send_bin_Data(uint8_t num,uint16_t id,uint8_t single_data_len } if(path==NULL) { - send_big_data(1,NULL,0,0,1,1,id); + send_big_data(1,NULL,1,1,1,1,id); sendbigDataBufState = false;//分包同步数据不允许打断 return; } @@ -4016,7 +3991,7 @@ void Read_file_buf_send_bin_Data(uint8_t num,uint16_t id,uint8_t single_data_len FILE *fp= fopen(path,"r+"); if(fp==NULL) { - send_big_data(1,NULL,0,0,1,1,id); + send_big_data(1,NULL,1,1,1,1,id); printf("打开文件失败%s\r\n",path); sendbigDataBufState = false;//分包同步数据不允许打断 return; @@ -4107,7 +4082,7 @@ void readDevDataBle(uint8_t *crcnum,uint16_t len,uint8_t crcvalue) printf("同步血氧数据\r\n"); EACH_DATA_LEN = SPO2_DATA_LEN; num=(ble_nus_max_data_len-18)/EACH_DATA_LEN; - Read_file_buf_send_bin_Data(num,0x41,EACH_DATA_LEN,"heart_data_list"); + Read_file_buf_send_bin_Data(num,0x41,EACH_DATA_LEN,"heart_data_list"); break; case 0x43: //同步步数历史数据 EACH_DATA_LEN = STEP_DATA_LEN;