From 72bc4cda76156aeaa26ecb63d77de2806bfb7147 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Fri, 28 Jun 2024 19:18:16 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E7=9B=98=E5=8D=8F?= =?utf8?q?=E8=AE=AEBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/set_dial/src/SetDialModel.cpp | 8 +++-- .../service/ble_service/bleservice/bleEvent.c | 34 +++++++++---------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp index d001a6d91..b9d56647b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp @@ -136,11 +136,15 @@ namespace OHOS /* 注册表盘map */ void SetDialModel::RegisterDial(uint16_t ID, const char *dialname) { - std::string *dialname_ = new std::string(dialname); - registeredDials[ID] = *dialname_; // 唯一性 + registeredDials[ID] = std::string(dialname); // 唯一性 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RegisterDial %s is ok!", dialname); + + LoadAllDial(); + + saveDialfile(); + } /* 打印map */ void SetDialModel::PrintRegisteredDials(const std::unordered_map &dials) 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 bda04bfce..ff7c50de0 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -2500,7 +2500,7 @@ static void switchDialCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *total } else { - value[17] = 3;//切换成功 + value[17] = 3;//切换失败 } value[18] = Calculate_CRC(value,18); @@ -3806,20 +3806,22 @@ static void GetAllDialUidCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *to if(Check_CRC(data,len,crcvalue)) { int dial_num=ble_get_dial_num(); - - uint8_t data_size=1+dial_num*2; + + uint16_t data_size=1+dial_num*2; + uint32_t temp_data_size=data_size; char *dail_uid_buf=(char *)ym_malloc(data_size); dail_uid_buf[0]=(uint8_t)dial_num; + if(dial_num *2 !=get_all_dial_id(dail_uid_buf+1)) { - printf( "GetAllDialUidCmd dial_num % err\r\n",dial_num); + printf( "GetAllDialUidCmd dial_num %d err\r\n",dial_num); } else { printf( "GetAllDialUidCmd yes\r\n"); } - send_big_data(0,dail_uid_buf,data_size,data_size,1,1,0x2a,1); + send_big_data(0,dail_uid_buf,data_size,temp_data_size,1,1,0x2a,1); free(dail_uid_buf); @@ -4802,23 +4804,17 @@ bool Read_Health_BIN_file_buf_send_bin_Data(uint8_t day, uint16_t num,uint16_t i // send_big_data(1,NULL,0,0,1,1,id,1); // return; - char *buf=NULL; char path[128]; - uint8_t timeBit = 4;//默认是4个字节的时间戳 - uint8_t dataBit = 1;//默认是1个字节的数据 switch (id) { case 0x40://同步心率历史数据 get_health_HEART_data_path(path,day,128); - dataBit = 1;//心率数据字节1个字节 uint8_t break; case 0x41://同步血氧历史数据 get_health_OXYGEN_data_path(path,day,128); - dataBit = 1;//血氧数据字节1个字节 uint8_t break; } - uint32_t file_size=0; FILE *fp= fopen(path,"r+"); if(fp==NULL) @@ -5814,6 +5810,7 @@ static errcode_t install_dial(void) //安装完后删除表盘 printf("remove %s\r\n",lzma_filepath); + if(0!=remove(lzma_filepath)) return ERRCODE_FAIL; @@ -5928,6 +5925,7 @@ void decode_file_checksum(ble_read_data *buffer_handle) //0504 ble_reply_cmd(DIAL_INSTALL_REPY_CMD,1); + // ble_reply_cmd(GET_TRANS_END_CMD,1); } @@ -5939,7 +5937,6 @@ void decode_file_checksum(ble_read_data *buffer_handle) ble_reply_cmd(DIAL_INSTALL_REPY_CMD,0); } - break; default: break; @@ -5974,7 +5971,6 @@ void decode_file_checksum(ble_read_data *buffer_handle) CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); break; case 2://mp3 - break; case 3://dial TRANSMIT_DATA= TRANS_DIAL_FAIL; @@ -5984,16 +5980,18 @@ void decode_file_checksum(ble_read_data *buffer_handle) break; } } + buffer_handle->file_recv_stat.recv_file_stat=0; } void type2AE0Data(ble_read_data *buffer_handle) { uint16_t typeID = buffer_handle->cmd_header.cmdtype*256 + buffer_handle->cmd_header.cmdid; - #ifdef BLE_LOG - printf("type2AE0Data typeID:0x%04X datalen %d\r\n",typeID,buffer_handle->totalDataLen); - #endif + + printf("type2AE0Data typeID:0x%04X datalen %d\r\n",typeID,buffer_handle->totalDataLen); + bool checkcrc = (get_crc_from_lrc(buffer_handle->lrcvalue) == buffer_handle->crcvalue); + uint32_t num; if ( (checkcrc == true ) || (buffer_handle->cmd_header.direction == MSG_DIRECTION_RECV_ANDROID)) @@ -6164,7 +6162,7 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t printf("handle_recv_file %d\n",event_size); //第一帧要创建文件 - if(buffer_handle->file_recv_stat.recv_file_stat <= 0 && buffer_handle->file_recv_stat.file == NULL) + if((buffer_handle->file_recv_stat.recv_file_stat <= 0) && buffer_handle->file_recv_stat.file == NULL ) { buffer_handle->file_recv_stat.lrcvalue = 0; if (buffer_handle->file_recv_stat.file_type == 1) @@ -6184,6 +6182,7 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t } if (buffer_handle->file_recv_stat.file == NULL) { + printf("6185 buffer_handle->file_recv_stat.file \n"); return ERRCODE_FAIL; } buffer_handle->file_recv_stat.recv_file_stat = 1; @@ -6192,6 +6191,7 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t if (buffer_handle->file_recv_stat.file == NULL) { + printf("6194 buffer_handle->file_recv_stat.file \n"); return ERRCODE_FAIL; } //写入文件 -- 2.17.1