From: dxy <1731678236@qq.com> Date: Sat, 13 Apr 2024 03:52:24 +0000 (+0800) Subject: 优化绑定流程加界面显示 X-Git-Tag: release_V1.2.70_20241020_135402~1200^2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a58e3d386ebf5f292e6261c22feae52753624801;p=mirrors%2FFD230.git 优化绑定流程加界面显示 --- a58e3d386ebf5f292e6261c22feae52753624801 diff --cc code/sdk/application/wearable/service/ble_service/blemoder/bletest.h index a89f9ffde,a89f9ffde..6b00d35ae --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@@ -18,7 -18,7 +18,12 @@@ extern "C" #include "stdint.h" #include "errcode.h" -- ++enum PAIRING ++{ ++ DEVICEBIND = 0,// ++ DEVICEUNBIND,//设备解绑通知 ++ DeviceUnBindingRequest//设备解绑请求(与新设备连接)通知 ++}; void set_weather_now_data(int humidity, char* windScale, char* textNight,int uvIndex,int temp,int iconNight); void set_weather_address_data(int lat, char* atm, char* city,char* subLocality,int lon); diff --cc code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 71d2c97dd,50a9af674..5790e44f5 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@@ -39,7 -39,7 +39,7 @@@ extern "C" #define PHONE_WATCH_CONFIG_PATH "/user/userdata/phone_watch.json" #define ALARM_DATA_CONFIG_PATH "/user/userdata/alarm_test.json" #include "bletest.h" -- ++#define DEBUG_TEST (0) uint8_t *bigDataBuf = NULL;//大数据buf uint8_t bigDataBufLen=0; @@@ -337,7 -337,7 +337,7 @@@ static uint8_t jsonCheck_phoneinfor(ui return len; } --errcode_t bondSucessCmd(void)//发送解绑指令,解绑界面调用这个函数 如果点了✓调用这个函数 返回成功后延迟10s再重启设备 ++errcode_t UnbindSucessCmd(void)//发送解绑指令,解绑界面调用这个函数 如果点了✓调用这个函数 返回成功后延迟10s再重启设备 { errcode_t sendok = ERRCODE_FAIL; uint32_t tmp = 1; @@@ -356,9 -356,9 +356,14 @@@ value[18] = Calculate_CRC(value,18); sendok = sendBleData(value,19); bool ret = bt_is_acl_connected(&phone_addr); ++ if(0!=remove(PHONE_WATCH_CONFIG_PATH)) ++ { ++ printf("json remove fail\r\n"); ++ } gap_ble_remove_all_pairs(); gap_remove_all_pairs(); -- closeBle(); ++ // uapi_reboot_device(); ++ return sendok; } void getDeviceState(void) @@@ -396,7 -396,7 +401,7 @@@ void clearPaireCmd(uint16_t cmd,uint8_ clearPaireFlag(0); } } --char *savephonename; ++uint8_t *savephonename; //确认配对指令 uint8_t first_bond = 0;//是否第一次绑定 第一次绑定保存配对mac地址 void comfirmPaire(uint8_t flag) @@@ -429,7 -429,7 +434,8 @@@ first_bond = 0; printf("gap_ble_pair_remote_device 444444444\r\n"); gap_ble_disconnect_remote_device(&disconect_addr);//与固定的mac设置地址进行断开连接 -- gap_ble_remove_pair(&disconect_addr);//清除配对信息 ++ gap_ble_remove_all_pairs(); ++ gap_remove_all_pairs(); if(savephonename != NULL) { free(savephonename); @@@ -535,17 -535,13 +541,17 @@@ void getPhoneNameLen(uint8_t *crcnum,ui } memcpy(datalen,&len,1); cJSON_Delete(root); - } + } else{ + len = 0; + + memcpy(datalen,&len,1); + } } --static char *getPhoneName(uint8_t *crcnum)//获取手机设备名称 ++static uint8_t *getPhoneName(uint8_t *crcnum)//获取手机设备名称 { uint8_t *json = crcnum; -- char *str = NULL; ++ uint8_t *str = NULL; cJSON* root = cJSON_Parse((const char *)json); if(root != NULL) { @@@ -556,8 -552,9 +562,10 @@@ pn->valuestring[datalen-1]='\0'; str = malloc(sizeof(char)*datalen); savephonename = malloc(sizeof(char)*datalen); -- strcpy(str,pn->valuestring); -- strcpy(savephonename,pn->valuestring); - free(str); ++ memcpy(str,(uint8_t *)pn->valuestring,datalen); ++ // strcpy(str,pn->valuestring); ++ memcpy(savephonename,(uint8_t *)pn->valuestring,datalen); ++ // strcpy(savephonename,pn->valuestring); printf("str:%s savephonename:%s\n",str,savephonename); } printf("设备名称: %s\n", pn->valuestring); @@@ -695,15 -682,12 +703,15 @@@ static void GetwatchSaveNameLen(uint8_ memcpy(datalen,&len,1); // 释放资源 cJSON_Delete(root); + }else{ + len = 0; + memcpy(datalen,&len,1); } } --static char *GetwatchSaveName(void)//获取手表本地保存的手机设备名称 ++static uint8_t *GetwatchSaveName(void)//获取手表本地保存的手机设备名称 { uint8_t count = 0; -- char *str = NULL; ++ uint8_t *str = NULL; FILE *jsfile = fopen(PHONE_WATCH_CONFIG_PATH, "r"); if (jsfile != NULL) { printf("succes opening file\n"); @@@ -728,7 -712,11 +736,9 @@@ if(showname_len-1 > 0){ str = malloc(sizeof(char)*showname_len); pn->valuestring[showname_len-1]='\0'; -- strcpy(str,pn->valuestring); - if(str) - { - free(str); - } ++ str[showname_len]=0; ++ memcpy(str,(uint8_t *)pn->valuestring,showname_len); ++ // strcpy(str,pn->valuestring); printf("GetwatchSaveName:%s",pn->valuestring); } } @@@ -736,61 -724,36 +746,49 @@@ // 释放资源 cJSON_Delete(root); } - return str; + if (str == NULL) + { + return NULL; + }else{ + return str; + } + } --void cleanUnbindInfor(void)//和旧手机解绑清除配对信息 ++void cleanUnbindInfor(uint8_t flag)//和旧手机解绑清除配对信息 { + uint8_t value[19]; + memset(value,0,19); + uint32_t tmp = 1; + uint16_t tmp_fen= 1; + value[0] =0x72; + value[1] =0x05; + value[2] =0x11; + memcpy(value+3,&tmp,4); + memcpy(value+7,&tmp,4); + memcpy(value+11,&tmp,4); + memcpy(value+15,&tmp_fen,2); + value[17] = 0x03;// + value[18] = Calculate_CRC(value,18); + sendBleData(value,19); + uint8_t MacType = 0; uint8_t mac_data[6]; memset(mac_data,0,6); GetwatchSaveMac(&mac_data,&MacType); + errcode_t ret1 = gap_disconnect_remote_device(&disconect_addr); - // printf("inforaddr:%x",ret1); gap_ble_disconnect_remote_device(&disconect_addr);//与固定的mac设置地址进行断开连接 -- bd_addr_t inforaddr; -- inforaddr.addr[0] = mac_data[0]; -- inforaddr.addr[1] = mac_data[1]; -- inforaddr.addr[2] = mac_data[2]; -- inforaddr.addr[3] = mac_data[3]; -- inforaddr.addr[4] = mac_data[4]; -- inforaddr.addr[5] = mac_data[5]; -- inforaddr.type = MacType; -- // printf("inforaddr:%x-%x-%x-%x-%x-%x",inforaddr.addr[0],inforaddr.addr[1],inforaddr.addr[2],inforaddr.addr[3],inforaddr.addr[4],inforaddr.addr[5]); - errcode_t ret= gap_ble_remove_pair(&disconect_addr);//清除配对信息 - gap_remove_pair(&disconect_addr); - // if(ret!=ERRCODE_SUCC) - // { - // printf("gap_ble_remove_pair : %X\r\n",ret); - // } - errcode_t ret= gap_ble_remove_pair(&inforaddr);//清除配对信息 - if(ret!=ERRCODE_SUCC) - { - printf("gap_ble_remove_pair : %X\r\n",ret); - } -- //清除保存的文件信息 -- if(0!=remove(PHONE_WATCH_CONFIG_PATH)) -- { -- printf("json remove fail\r\n"); ++ if (flag == 1){ ++ errcode_t ret= gap_ble_remove_pair(&disconect_addr);//清除配对信息 ++ gap_ble_remove_all_pairs(); ++ bool ret_flag = gap_remove_all_pairs(); ++ printf("ret_flag:%d ret:%x\r\n",ret_flag,ret); ++ if(0!=remove(PHONE_WATCH_CONFIG_PATH)) ++ { ++ printf("json remove fail\r\n"); ++ } ++ set_ble_falg(0); ++ uapi_reboot_device(); } -- set_ble_falg(0); - uapi_reboot_device(); -- } void sendBindInfor(uint8_t *crcnum) { @@@ -809,7 -772,7 +807,7 @@@ uint8_t copare_mac[6]; memset(copare_mac,0,6); uint8_t datalen=0; - char *devname = NULL; - char *devname; ++ uint8_t *devname = NULL; uint8_t devnamelen = 0; uint8_t mac_tmp[6]; memset(mac_tmp,0,6); @@@ -817,46 -780,37 +815,59 @@@ uint8_t bond = 1;//未与任何手机绑定过 errcode_t ret = 0; first_bond = 0; - - uint8_t save_mac[6]; memset(save_mac,0,6); - char *showname = NULL; - char *showname; -- uint8_t showname_len = 0; uint8_t MacType = 0; -- ++ GetwatchSaveMac(&save_mac,&MacType);//获取手表设备本地保存的mac地址和mac地址类型 getPhoneMac(crcnum,&copare_mac); - // save_mac[0] = 90; - // memset(copare_mac,0,6); - ++ save_mac[0] = 0; ++ memset(copare_mac,0,6); if(save_mac[0] == 0 && save_mac[1] == 0 && save_mac[2] == 0 && save_mac[3] == 0 && save_mac[4] == 0 && save_mac[5] == 0)//只要手表本地存储没有mac地址就走连接流程重新绑定 { + bond = 0x01;//手表未和任何手机绑定过 + value[17] = bond;// + value[18] = Calculate_CRC(value,18); + sendBleData(value,19); - comfirmPaire(1); - return; #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION devnamelen = 0; getPhoneNameLen(crcnum,&devnamelen);//获取手机下发的手机设备名称长度 ++ devnamelen = 0; if(devnamelen > 0 ) { devname = getPhoneName(crcnum); printf("devname!!!!!!!!!:%s devnamelen:%d",devname,devnamelen); - CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,NULL,0); - printf("bond flag:!!!!!!!!!\r\n"); + if (devname != NULL){ + printf("phone devname is name!!!!!!!!!:"); - CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,NULL,0); ++ uint8_t buf[devnamelen+2]; ++ buf[0] = DEVICEBIND; ++ buf[1] = devnamelen;//设备名称长度 0不显示 ++ memcpy(buf+2,devname,devnamelen); ++ CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,(uint8_t *)buf,devnamelen+2); ++ if(devname) ++ { ++ free(devname); ++ } + }else{ + printf("phone devname is no name11111!!!!!!!!!:"); - CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,NULL,0); ++ uint8_t buf[2]; ++ buf[0] = DEVICEBIND; ++ buf[1] = 0; ++ CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2); ++ + } }else{ - CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,NULL,0); ++ uint8_t buf[2]; ++ buf[0] = DEVICEBIND; ++ buf[1] = 0; + printf("phone devname is no name!!!!!!!!!:"); - CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,NULL,0); ++ CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2); } #endif - bond = 0x01;//手表未和任何手机绑定过 ++ return; + }else { - // printf("success parsing JSON :save_mac :%x %x %x %x %x %x copare_mac %x %x %x %x %x %x;\n",save_mac[0],save_mac[1],save_mac[2],save_mac[3],save_mac[4],save_mac[5], - // copare_mac[0],copare_mac[1],copare_mac[2],copare_mac[3],copare_mac[4],copare_mac[5]); if(copare_mac[0] == 0 && copare_mac[1] == 0 && copare_mac[2] == 0 && copare_mac[3] == 0 && copare_mac[4] == 0 && copare_mac[5] == 0) { bond = 0x03;//手表和其他手机绑定过 @@@ -885,40 -835,24 +896,38 @@@ sendBleData(value,19); if(bond == 0x03) { - cleanUnbindInfor(); - return; - errcode_t ret1 = gap_disconnect_remote_device(&disconect_addr); + gap_ble_disconnect_remote_device(&disconect_addr);//与固定的mac设置地址进行断开连接 devnamelen = 0; GetwatchSaveNameLen(&devnamelen);//获取手表设备保存手机的设备名称长度 if(devnamelen > 0) { devname = GetwatchSaveName(); -- printf("devname:%s showname_len:%d",devname,devnamelen); - // cleanUnbindInfor(); - CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,(uint8_t *)devname,devnamelen); - printf("cleanUnbindInfor!!!!!!!"); + if (devname != NULL){ ++ uint8_t buf[devnamelen+1]; ++ buf[0] = devnamelen; ++ buf[1] = DEVICEUNBIND; ++ memcpy(buf+2,devname,devnamelen); ++ CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,(uint8_t *)buf,devnamelen+2); + printf("devname:is no null!!!!!"); - CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,(uint8_t *)devname,devnamelen); + }else{ ++ uint8_t buf[2]; ++ buf[0] = DEVICEUNBIND; ++ buf[1] = 0; + printf("devname:is null!!!!!"); - CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,NULL,0); ++ CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,buf,2); + } - - printf("cleanUnbindInfor!!!!!!!"); }else{ - cleanUnbindInfor(); - return; - printf("devname:is no name!!!!!"); - // cleanUnbindInfor(); -- CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,NULL,0); ++ uint8_t buf[2]; ++ buf[0] = DEVICEUNBIND; ++ buf[1] = 0; ++ CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,buf,2); } -- //加解绑提示界面是否和旧的手机解绑app 弹窗提示 } } void getPhoneInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取手机信息 { -- uint8_t value[20]; -- memset(value,0,20); ++ uint8_t value[19]; ++ memset(value,0,19); uint32_t tmp = 1; uint16_t tmp_fen= 1; value[0] =0x72; @@@ -973,7 -907,7 +982,7 @@@ void sendParieSuccess(uint8_t flag,bd_a } if(savephonename != NULL) { -- cJSON_AddStringToObject(dataJSON,"pn",savephonename); ++ cJSON_AddStringToObject(dataJSON,"pn",(char *)savephonename); free(savephonename); } cJSON_AddNumberToObject(dataJSON,"phoneType",phoneType); @@@ -3957,7 -3895,7 +3966,7 @@@ void getPhoneInfo_test(void // memcpy(value+15,&tmp_data,2); // memcpy(&value[17],buf,strlen(buf)); -- comfirmPaire(0); ++ // comfirmPaire(0); } @@@ -3966,9 -3904,9 +3975,9 @@@ void bleLongRecvData(uint8_t *data, uin { uint8_t type=buf_cmd[1]; printf("type:%d %d data_size:%d data:%d crcvalue:%x",buf_cmd[0],type,data_size,data[0],crcvalue); -- FILE *fp= fopen("user/ble_test.json","w+"); -- fwrite((void *)data,1,data_size,fp); -- fclose(fp); ++ // FILE *fp= fopen("user/ble_test.json","w+"); ++ // fwrite((void *)data,1,data_size,fp); ++ // fclose(fp); switch (type) { case 0x02://获取手机信息 @@@ -3982,13 -3920,13 +3991,15 @@@ } } --uint8_t *recvData; ++ uint32_t packdataLen = 0; uint32_t totalDataLen = 0; uint8_t totalpack = 0; uint8_t cmd_data[17]; ++uint8_t *recvData; void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) { ++ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xhandle %d,%d %d",data2ae3Cmd,data2ae4Cmd,handle); if(sendbigDataBufState == true)//正在发送大数据不接收任何app指令下发的数据 { @@@ -4008,7 -3946,7 +4019,7 @@@ uint16_t cmd = totalData[1]*256+totalData[2]; crcvalue = totalData[event_size-1]; -- memcpy(&packdataLen,&totalData[3],4); ++ memcpy(&packdataLen,totalData+3,4); recvData = malloc(packdataLen); memcpy(recvData,totalData+17,packdataLen); printf("recv crcvalue:%x packdataLen-1:%d\r\n",crcvalue,packdataLen); @@@ -4018,7 -3956,7 +4029,7 @@@ free(recvData); } } -- }else if(handle) ++ }else if(data2ae4Cmd == handle) { while (1) { @@@ -4049,7 -3987,7 +4060,8 @@@ packdataLen = event_size-17; memset(cmd_data,0,17); memcpy(cmd_data,totalData,17); -- ++ ++ // 73 2 10 1 0 0 0 16 0 0 0 1 0 0 0 16 0 recvData = malloc(packdataLen-1); if(recvData == NULL)return; memcpy(recvData,totalData+17,packdataLen-1); @@@ -4058,7 -3996,7 +4070,8 @@@ }else{ crcvalue = totalData[event_size-1]; } -- bleLongRecvData(recvData,packdataLen-1,&cmd_data,totalData,crcvalue); ++ ++ bleLongRecvData(recvData,packdataLen-1,cmd_data,totalData,crcvalue); if(recvData != NULL){ free(recvData); } @@@ -4080,7 -4018,7 +4093,7 @@@ bigDataBuf = malloc(totalDataLen); crcvalue = totalData[event_size-1]; memcpy(bigDataBuf,recvData+17,totalDataLen); -- bleLongRecvData(bigDataBuf,totalDataLen,&cmd_data,recvData,crcvalue); ++ bleLongRecvData(bigDataBuf,totalDataLen,cmd_data,recvData,crcvalue); totalDataLen = 0; packdataLen = 0; muiltFlag = 0; @@@ -4106,9 -4044,9 +4119,9 @@@ if(bigDataBuf != NULL){ free(bigDataBuf); } -- if(recvData != NULL){ -- free(recvData); -- } ++ // if(recvData != NULL){ ++ // // free(recvData); ++ // } break; } } @@@ -4122,7 -4060,7 +4135,7 @@@ void revBleOldData(uint8_t *buf, uint16_t event_size,uint16_t handle)//每包的数据大小 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxxxxx"); -- printf("handle :%d data2ae3Cmd:%d data2ae4Cmd:%d buf:%d event_size %d\r\n",handle,data2ae3Cmd,data2ae4Cmd,buf,event_size); ++ printf("handle :%d data2ae3Cmd:%d data2ae4Cmd:%d event_size %d\r\n",handle,data2ae3Cmd,data2ae4Cmd,event_size); bleDataRecv(buf,event_size,handle); } #endif diff --cc code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h index 2ed5036d8,2ed5036d8..1e4f6b02e --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@@ -581,12 -581,12 +581,13 @@@ errcode_t sendBleData(uint8_t *buf,uint void sendParieSuccess(uint8_t flag,bd_addr_t *addr);//发送配对成功指令to app mac手机端的地址 void getPhoneInfo_test(void); void setFindWatchFlag(uint8_t flag);//查找手表标识 --errcode_t bondSucessCmd(void);//发送解绑指令,解绑界面调用这个函数 如果点了✓调用这个函数 返回成功后延迟10s再重启设备 ++errcode_t UnbindSucessCmd(void);//发送解绑指令,解绑界面调用这个函数 如果点了✓调用这个函数 返回成功后延迟10s再重启设备 void getDeviceState(void); --void cleanUnbindInfor(void);//和旧手机解绑清除配对信息 ++void cleanUnbindInfor(uint8_t flag);//和旧手机解绑清除配对信息 0不清除配对信息 1清除配对信息重启 void comfirmPaire(uint8_t flag);//发送确认配对指令 1确认配对 0取消配对 void cameraSend(void); void senfindphoneSend(uint8_t flag); ++void readDevDataBle(uint8_t *crcnum,uint16_t len,uint8_t crcvalue); #ifdef __cplusplus } #endif diff --cc code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index 2db8c9a5f,0088bc317..7923ce581 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@@ -105,13 -105,13 +105,9 @@@ uint8_t data2ae5Cmd = 0 #if 1//def SUPPORT_BLE_SERVICE static void set_phone_info(bd_addr_t *addr)//保存手机信息 包含手机mac地址 { -- printf("set_phone_info:addr.type %x-%x-%x-%x-%x-%x: new_addr.type->%d\r\n",addr->addr[5],addr->addr[4], -- addr->addr[3],addr->addr[2],addr->addr[1],addr->addr[0],addr->type); memcpy(&phone_addr,addr,sizeof(bd_addr_t)); memcpy(&disconect_addr,addr,sizeof(bd_addr_t)); -- // printf("phone_addr:%x-%x-%x-%x-%x-%x",phone_addr.addr[0],phone_addr.addr[1],phone_addr.addr[2],phone_addr.addr[3],phone_addr.addr[4],phone_addr.addr[5]); } -- enum{ BLE_CHARACTERISTIC_RECV_ID_PROPERTIES = GATT_CHARACTER_PROPERTY_BIT_NOTIFY|GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP|GATT_CHARACTER_PROPERTY_BIT_WRITE|GATT_CHARACTER_PROPERTY_BIT_READ, BLE_CHARACTERISTIC_SNED_SHORT_ID_PROPERTIES = GATT_CHARACTER_PROPERTY_BIT_WRITE|GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP, @@@ -147,15 -147,15 +143,19 @@@ static void svr_ble_adv_data_set(int ad uint8_t adv_mac_head[BLE_ADV_MAC_LENTH] = {0x9, 0x16, 0xe0, 0x18}; gap_ble_config_adv_data_t adv_data_info; memset_s(&adv_data_info, sizeof(gap_ble_config_adv_data_t), 0, sizeof(gap_ble_config_adv_data_t)); - - #if 0 - unsigned char set_mac[6] = {0x61,0x22,0x33,0x44,0x09,0x26}; - bluetooth_set_local_addr(set_mac,6); - bd_addr_t addr_info; - int32_t ret= 0; - unsigned int len = BLE_MAC_MAX_LEN; -- + unsigned char addr[BLE_MAC_MAX_LEN] = {0}; ++ unsigned int len = BLE_MAC_MAX_LEN; ++ errcode_t ret = 0; + #if 1 - unsigned char set_mac[6] = {0x61,0x22,0x33,0x44,0x09,0x26}; - bluetooth_set_local_addr(set_mac,6); ++ memset(addr,0,6); ++ bluetooth_get_local_addr(&addr[0],len); ++ if(addr[0] == 0 && addr[1] == 0 && addr[2] == 0 && addr[3] == 0 && addr[4] == 0 && addr[5] == 0) ++ { ++ unsigned char set_mac[6] = {0x61,0x22,0x33,0x44,0x09,0x26}; ++ bluetooth_set_local_addr(set_mac,6); ++ } + bd_addr_t addr_info; - int32_t ret= 0; - unsigned int len = BLE_MAC_MAX_LEN; - - unsigned char addr[BLE_MAC_MAX_LEN] = {0}; ++ memset(addr,0,6); bluetooth_get_local_addr(&addr[0],len); char watchName[32]; memset_s(watchName, sizeof(watchName), 0, sizeof(watchName)); @@@ -167,12 -167,12 +167,9 @@@ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bt SetLocalName ret = 0x%x", ret); } #else -- int32_t ret= 0; -- unsigned int len = BLE_MAC_MAX_LEN; -- unsigned char addr[BLE_MAC_MAX_LEN] = {0}; bluetooth_get_local_addr(&addr[0],len); #endif -- ++ ret = bluetooth_get_local_name(ble_name, &ble_name_len); if (ret != 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_get_local_name fail, name:%s,len:%u,ret:%u.", ble_name, ble_name_len, ret); diff --cc code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp index d77c55955,d36b2ed6f..8def5babe --- 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 @@@ -2,7 -2,7 +2,7 @@@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-22 10:04:36 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-12 11:37:28 - * @LastEditTime: 2024-04-13 11:32:36 ++ * @LastEditTime: 2024-03-30 09:28:18 * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp */ #include "notification_manager.h" @@@ -110,7 -110,7 +110,9 @@@ namespace OHO { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnBindingButtonCancel OnClick"); // 不想执行解绑动作,并关闭解绑的通知界面。 -- ++ #ifdef SUPPORT_BLE_SERVICE ++ cleanUnbindInfor(0); ++ #endif NotificationManager::GetInstance()->StopNotify(); } else if (&view == DeviceUnBindingButtonOK) // 设备解绑确认按钮 @@@ -125,7 -125,7 +127,7 @@@ // 关闭通知界面 #ifdef SUPPORT_BLE_SERVICE -- cleanUnbindInfor(); ++ cleanUnbindInfor(1); #endif NotificationManager::GetInstance()->StopNotify(); } @@@ -398,6 -401,6 +400,7 @@@ DeviceUnBindingView->Add(DeviceUnBindingViewLabel); DeviceUnBindingView->Add(DeviceUnBindingButtonCancel); DeviceUnBindingView->Add(DeviceUnBindingButtonOK); ++ } return DeviceUnBindingView; }