From: Caisking <3449750381@qq.com> Date: Mon, 6 May 2024 01:17:06 +0000 (+0800) Subject: 修复解绑bug X-Git-Tag: release_V1.2.70_20241020_135402~1025^2~41 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=2d9ce455d2b079f5d754f9a518d9a0640b7a2e2a;p=mirrors%2FFD230.git 修复解绑bug --- 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 ac0ba9816..3b755fe8a 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -302,8 +302,8 @@ void send_big_data(uint8_t flag, char *data, int datalen, int total, uint32_t Pa // 处理数据和计算CRC if (data == NULL) { - data = "\0"; // 数据为空时处理 - buf[17 + datalen] = Calculate_CRC_Big((uint8_t *)data, datalen); // 计算CRC + //数据为空 按照18个字节总长度发送给app + buf[17] = 0x00; // 直接写0x00的校验和 } else { memcpy(buf + 17, data, datalen); // 复制数据到缓冲区 buf[17 + datalen] = Calculate_CRC_Big((uint8_t *)data, datalen); // 计算CRC @@ -952,7 +952,7 @@ void sendBindInfor(uint8_t *crcnum) if (devname != NULL){ printf("phone devname is name!!!!!!!!!:"); uint8_t buf[devnamelen+2]; - buf[0] = DEVICEBIND; + buf[0] = DEVICEBIND ; buf[1] = devnamelen;//设备名称长度 0不显示 memcpy(buf+2,devname,devnamelen); CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,(uint8_t *)buf,devnamelen+2); @@ -971,7 +971,7 @@ void sendBindInfor(uint8_t *crcnum) }else{ uint8_t buf[2]; buf[0] = DEVICEBIND; - buf[1] = 0; + buf[1] = 0 ; printf("phone devname is no name!!!!!!!!!:"); CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2); } @@ -1015,9 +1015,9 @@ void sendBindInfor(uint8_t *crcnum) { devname = GetwatchSaveName(); if (devname != NULL){ - uint8_t buf[devnamelen+1]; - buf[0] = devnamelen; - buf[1] = DEVICEUNBIND; + uint8_t buf[devnamelen+2]; + buf[0] = DEVICEUNBIND ; + buf[1] = devnamelen; memcpy(buf+2,devname,devnamelen); CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,(uint8_t *)buf,devnamelen+2); printf("devname:is no null!!!!!"); @@ -2152,28 +2152,28 @@ static void aboutDeviceCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *to char *json_format = cJSON_PrintUnformatted(dataJSON); cJSON_Delete(dataJSON); uint32_t data_len = strlen(json_format); - uint8_t value[data_len+18]; + uint8_t value[data_len+19]; + memset(value,0,data_len+19); uint32_t tmp = 1; - uint16_t tmp_data = 1; + uint16_t tmp_data = (uint16_t)data_len; value[0] = 0x72; value[1] = 0x01; value[2] = 0x03; memcpy(value+3,&tmp,4); - memcpy(value+7,&tmp,4); + memcpy(value+7,&data_len,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); if(Check_CRC(crcnum,len,crcvalue)) { - memcpy(value+17,(uint8_t *)json_format,data_len); + memcpy(value+17,(uint8_t *)json_format,data_len);//17+69 = 86 free(json_format); - unsigned char lrc = Calculate_CRC(value,data_len+17); - printf("lrc:%d",lrc); - value[data_len+18] = lrc; + value[data_len+17] = Calculate_CRC(value,data_len+17);// + printf("data_len:%d %x %d!!!!!\r\n",data_len,value[data_len+17],data_len+17); sendBleData(value,data_len+18); }else { value[17] = 0; - unsigned char lrc = Calculate_CRC(value,18); + uint8_t lrc = Calculate_CRC(value,18); value[18] = lrc; sendBleData(value,19); } @@ -2200,10 +2200,9 @@ void setFindWatchFlag(uint8_t flag) } static void findWatchCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { - - uint8_t findFlag = crcnum[0]; if(Check_CRC(crcnum,len,crcvalue)) { + uint8_t findFlag = crcnum[0]; //弹窗界面 if(findFlag)//查找手表弹窗界面 { @@ -2615,9 +2614,9 @@ void sendRealTimeDataToAPP(uint8_t flag) { if(flag == 0)//校验失败 { - send_big_data(0,NULL,1,data_len,1,1,0x0f,1); + send_big_data(0,NULL,0,0,1,1,0x0f,1); - }else + }else { training_ble_data.sportType= 4;//运动类型 0 健走 1跑步 2骑行 3 training_ble_data.controlmd= SENDDATA; @@ -2895,7 +2894,7 @@ static void GetWatchAuxFuncCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t memcpy(value+15,&tmp_data,2); if(Check_CRC(crcnum,len,crcvalue)) { - uint8_t paramCmt = 0;//辅助功能 0 + uint8_t paramCmt = crcnum[0];//辅助功能 0 value[17] = paramCmt;// value[18] = Calculate_CRC(value,18); @@ -4004,7 +4003,7 @@ void Read_file_buf_send_bin_Data(uint8_t num,uint16_t id,char *data_item) } if(path==NULL) { - send_big_data(1,NULL,1,1,1,1,id,1); + send_big_data(1,NULL,0,0,1,1,id,1); sendbigDataBufState = false;//分包同步数据不允许打断 free(buf); return; @@ -4013,7 +4012,7 @@ void Read_file_buf_send_bin_Data(uint8_t num,uint16_t id,char *data_item) FILE *fp= fopen(path,"r+"); if(fp==NULL) { - send_big_data(1,NULL,1,1,1,1,id,1); + send_big_data(1,NULL,0,0,1,1,id,1); printf("打开文件失败%s\r\n",path); free(buf); sendbigDataBufState = false;//分包同步数据不允许打断 diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp index 8def5babe..3f841720b 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp @@ -472,7 +472,7 @@ namespace OHOS DeviceUnbindingRequestViewLabel[0]->SetStyle(STYLE_TEXT_FONT, 30); DeviceUnbindingRequestViewLabel[0]->SetStyle(STYLE_LINE_HEIGHT, 40); char str[512]; - memcpy(str, 0, 512); + memset(str, 0, 512); sprintf(str, "当前设备已经与 %s 绑定", PairingViewEventListener::GetInstance().GetDeviceName()); DeviceUnbindingRequestViewLabel[0]->SetText(str); DeviceUnbindingRequestViewLabel[0]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); @@ -491,7 +491,7 @@ namespace OHOS DeviceUnbindingRequestViewLabel[1]->SetPosition(33, y, 400, 300); DeviceUnbindingRequestViewLabel[1]->SetStyle(STYLE_TEXT_FONT, 30); DeviceUnbindingRequestViewLabel[1]->SetStyle(STYLE_LINE_HEIGHT, 40); - memcpy(str, 0, 512); + memset(str, 0, 512); sprintf(str, "继续连接操作会解除与%s的绑定并将手表恢复出厂设置(会清空手表数据)\n\n是否继续此操作\n", PairingViewEventListener::GetInstance().GetDeviceName()); // str = "继续连接操作会解除与 " + GetDeviceName() + " 的绑定并将手表恢复出厂设置(会清空手表数据)\n\n是否继续此操作\n"; DeviceUnbindingRequestViewLabel[1]->SetText(str);