From: DXY <1731678236@qq.com> Date: Tue, 7 May 2024 09:31:07 +0000 (+0800) Subject: 解绑 绑定界面加名字显示: 修复解绑界面死机问题:补充用户数据协议增加字段 X-Git-Tag: release_V1.2.70_20241020_135402~1108^2~18 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a42236410170af201d6c2147913743964c0eed72;p=mirrors%2FFD230.git 解绑 绑定界面加名字显示: 修复解绑界面死机问题:补充用户数据协议增加字段 --- 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 62312513c..32f789c21 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -950,6 +950,7 @@ void sendBindInfor(uint8_t *crcnum) if (devname != NULL){ printf("phone devname is name!!!!!!!!!:"); uint8_t buf[devnamelen+2]; + memset(buf,0,devnamelen+2); buf[0] = DEVICEBIND ; buf[1] = devnamelen;//设备名称长度 0不显示 memcpy(buf+2,devname,devnamelen); @@ -961,6 +962,7 @@ void sendBindInfor(uint8_t *crcnum) }else{ printf("phone devname is no name11111!!!!!!!!!:"); uint8_t buf[2]; + memset(buf,0,2); buf[0] = DEVICEBIND; buf[1] = 0; CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2); @@ -968,6 +970,7 @@ void sendBindInfor(uint8_t *crcnum) } }else{ uint8_t buf[2]; + memset(buf,0,2); buf[0] = DEVICEBIND; buf[1] = 0 ; printf("phone devname is no name!!!!!!!!!:"); @@ -1001,12 +1004,10 @@ void sendBindInfor(uint8_t *crcnum) } } printf("bond flag:%d first_bond:%d\r\n",bond,first_bond); - value[17] = bond;// - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); + if(bond == 0x03) { - gap_ble_disconnect_remote_device(&disconect_addr);//与固定的mac设置地址进行断开连接 + // gap_ble_disconnect_remote_device(&disconect_addr);//与固定的mac设置地址进行断开连接 devnamelen = 0; GetwatchSaveNameLen(&devnamelen);//获取手表设备保存手机的设备名称长度 if(devnamelen > 0) @@ -1014,25 +1015,35 @@ void sendBindInfor(uint8_t *crcnum) devname = GetwatchSaveName(); if (devname != NULL){ uint8_t buf[devnamelen+2]; + memset(buf,0,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!!!!!"); + printf("devname:is no null!!!!!%s\r\n",devname); + CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,(uint8_t *)buf,devnamelen+2); + if(devname) + { + free(devname); + } }else{ uint8_t buf[2]; + memset(buf,0,2); buf[0] = DEVICEUNBIND; buf[1] = 0; printf("devname:is null!!!!!"); - CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,buf,2); + CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2); } }else{ uint8_t buf[2]; + memset(buf,0,2); buf[0] = DEVICEUNBIND; buf[1] = 0; - CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,buf,2); + CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2); } } + value[17] = bond;// + value[18] = Calculate_CRC(value,18); + sendBleData(value,19); } void getPhoneInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取手机信息 { @@ -1094,6 +1105,7 @@ void sendParieSuccess(uint8_t flag,bd_addr_t *addr)//发送配对成功指令to { cJSON_AddStringToObject(dataJSON,"pn",(char *)savephonename); free(savephonename); + savephonename = NULL; } cJSON_AddNumberToObject(dataJSON,"phoneType",phoneType); cJSON_AddNumberToObject(dataJSON,"mac_type",addr->type); @@ -1943,6 +1955,11 @@ void getUserInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,ui memcpy(&user_info.fat_time,crcnum+9,2); user_info.target_stand = crcnum[11]; user_info.timeformat = crcnum[12]; + uint16_t target_kcal = 0; + memcpy(&target_kcal,&crcnum[13],2); + set_goal_caloriescount(target_kcal); + uint8_t target_km = crcnum[15]; + set_goal_discount(target_km); if(func != NULL) { func(WRITE_FLASH_DATA,cmd,&user_info,sizeof(msg_user_info_t)); @@ -3889,9 +3906,9 @@ len 就是data的长度 *totaldata:总的数据内容 包含包头和校验预览做接口是用 如果要计算totaldata的长度直接是len+17+1 就是加上包头和校验和 crcvalue;数据的校验和 不包含包头和校验和的计算结果 */ -void type2AE3Data(uint16_t cmd ,uint8_t *data,uint16_t datalen,uint8_t *totaldata,uint8_t crcvalue) +void type2AE3Data(uint8_t *cmd_buf ,uint8_t *data,uint16_t datalen,uint8_t *totaldata,uint8_t crcvalue) { - // uint16_t typeID = cmd_buf[1]*256+cmd_buf[2]; + uint16_t cmd = cmd_buf[1]*256+cmd_buf[2]; printf("typeHexOneData:0x%x\r\n",cmd); // uint8_t typeID = cmd_buf[2]; switch (cmd) @@ -4376,6 +4393,12 @@ void bleLongRecvData(uint8_t *data, uint16_t data_size,uint8_t *buf_cmd,uint8_t case 0x02://获取手机信息 type2AE4Data(buf_cmd,data,data_size,totalData,crcvalue); break; + case 0x01: + type2AE3Data(buf_cmd,data,data_size,totalData,crcvalue); + break; + case 0x03:// + type2AE1Data(buf_cmd,data,data_size,totalData,crcvalue); + break; default: break; } @@ -4585,9 +4608,11 @@ uint8_t jscheck_ancs(uint8_t *data) message_data(uid_t,appid_t,titleBuf,msgBuf,hasCode_t); if(titleBuf != NULL){ free(titleBuf); + titleBuf = NULL; } if(msgBuf != NULL){ free(msgBuf); + msgBuf = NULL; } return 1; } @@ -4658,29 +4683,7 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) } uint8_t crcvalue= 0x00; - - if(data2ae3Cmd == handle)//短指令 - { - if(recvBigDataBufState == true)//在接收大数据时未接收完成时,不能被其他指令打断 - { - return; - } - if(event_size > 17) - { - uint16_t cmd = totalData[1]*256+totalData[2]; - crcvalue = totalData[event_size-1]; - - memcpy(&packdataLen,totalData+3,4); - recvData = malloc(packdataLen); - memcpy(recvData,totalData+17,packdataLen); - printf("recv crcvalue:%x packdataLen-1:%d\r\n",crcvalue,packdataLen); - type2AE3Data(cmd,recvData,packdataLen,totalData,crcvalue); - if(recvData != NULL) - { - free(recvData); - } - } - }else if(data2ae4Cmd == handle)//长数据接收 + if(1)//长数据接收 { while (1) { @@ -4688,8 +4691,16 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) { //每包的数据长度 如果当前报数的数据小于总的数据包数时认为就发送完成,没有就还有继续接收 // packdataLen = packdataLen+event_size-18;// 减掉18个数据 0+517 730总的数据长度 517还是小于730 说明还有数据没有接收完成 继续接收 - if(event_size >= 17) + if(event_size >= 17)//第一包的数据必须大于17个字节 { + if(bigDataBuf != NULL){ + free(bigDataBuf); + bigDataBuf = NULL; + } + if(recvData != NULL){ + free(recvData); + recvData = NULL; + } packdataLen = event_size;//第一包的数据大小 第二包不走这里 514-17 = 497 memcpy(&totalDataLen,totalData+7,4);//总的数据大小 printf("totalDataLen;%d totaldataLen:%d",totalDataLen,packdataLen); @@ -4710,7 +4721,7 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) memset(cmd_data,0,17); memcpy(cmd_data,totalData,17); printf("muilt totalDataLen11;%d packdataLen:%d",totalDataLen,packdataLen); - if(totalData == 0 && event_size == 18)//数据长度为0 没数据数据包 + if(totalDataLen == 0 && event_size == 18)//数据长度为0 没数据数据包 { crcvalue = totalData[event_size-1]; bleLongRecvData(NULL,0,cmd_data,totalData,crcvalue); @@ -4723,6 +4734,7 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) bleLongRecvData(recvData,packdataLen-1,cmd_data,totalData,crcvalue); if(recvData != NULL){ free(recvData); + recvData = NULL; } packdataLen = 0; } @@ -4749,9 +4761,11 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) totalpack = 0; if(bigDataBuf != NULL){ free(bigDataBuf); + bigDataBuf = NULL; } if(recvData != NULL){ free(recvData); + recvData = NULL; } break; }else{ @@ -4762,90 +4776,6 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) } } - else if(data2ae1Cmd == handle)//安卓消息特征Hhandle - { - - while (1) - { - printf("ancs!!!!!!!!!"); - if(ANCSBigBufFlag == 0) - { - if(event_size >= 17) - { - packdataLen = event_size;//第一包的数据大小 第二包不走这里 514-17 = 497 - memcpy(&totalDataLen,totalData+7,4);//总的数据大小 - printf("ancs totalDataLen;%d totaldataLen:%d",totalDataLen,packdataLen); - if(totalDataLen > event_size-18)//如果514-18 = 496 497 > 496 - { - printf("ancs totalDataLen;%d packdataLen:%d",totalDataLen,packdataLen); - - recvData = malloc(totalDataLen+18); - if(recvData == NULL)return; - ANCSBigBufFlag = 1;//表示有两包以上的数据 - memcpy(recvData,totalData,event_size);//从第十七个字节开始接收数据data - memset(cmd_data,0,17); - memcpy(cmd_data,totalData,17); - totalpack=1; - break; - }else{//直接发送数据解析 - printf("ancs totalDataLen11;%d packdataLen:%d",totalDataLen,packdataLen); - 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); - if(totalDataLen == 0){ - crcvalue = 0x00; - }else{ - crcvalue = totalData[event_size-1]; - } - - bleRecvANCSData(recvData,packdataLen-1,cmd_data,totalData,crcvalue); - if(recvData != NULL){ - free(recvData); - } - packdataLen = 0; - break; - } - } - break; - - }else//这是接收两包以上的数据 - { - totalpack+=1;//包数 - printf("ancs 122222;%d packdataLen:%d",totalDataLen,packdataLen); - memcpy(recvData+packdataLen,totalData,event_size); //先copy再加 - packdataLen = packdataLen+event_size; - printf("ancs 133333;%d packdataLen:%d",totalDataLen,packdataLen); - if(totalDataLen >= (packdataLen-18))//总的数据包 packdataLen-18把前面17个字节的包头和一个字节的校验和去掉得到数据部分和校验和部分 - { - bigDataBuf = malloc(totalDataLen); - crcvalue = totalData[event_size-1]; - memcpy(bigDataBuf,recvData+17,totalDataLen); - bleRecvANCSData(bigDataBuf,totalDataLen,cmd_data,recvData,crcvalue); - totalDataLen = 0; - packdataLen = 0; - ANCSBigBufFlag = 0; - totalpack = 0; - if(bigDataBuf != NULL){ - free(bigDataBuf); - } - if(recvData != NULL){ - free(recvData); - } - break; - }else{ - - break; - } - } - - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xhandle %d,%d %d",data2ae3Cmd,data2ae4Cmd,handle); - } if(Bleconnect == false)//断开蓝牙不接收数据 { totalpack = 0; @@ -4857,9 +4787,11 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) sendbigDataBufState = false; if(bigDataBuf != NULL){ free(bigDataBuf); + bigDataBuf = NULL; } if(recvData != NULL){ free(recvData); + recvData = NULL; } } } @@ -4874,9 +4806,11 @@ void free_ble_data(void)//以防断开蓝牙没有释放数据类型 sendbigDataBufState = false; if(bigDataBuf != NULL){ free(bigDataBuf); + bigDataBuf = NULL; } if(recvData != NULL){ free(recvData); + recvData = NULL; } } //接收app下发的原始数据 diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h index 8d818dc56..7a2cb60be 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -603,8 +603,8 @@ typedef struct void revBleOldData(uint8_t *buf, uint16_t event_size,uint16_t handle);//协议接收client下发的数据接口 //02类型的指令数据 -void typeHexTwoData(uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t crcvalue); -void type2AE3Data(uint16_t cmd ,uint8_t *data,uint16_t datalen,uint8_t *totaldata,uint8_t crcvalue);//对不同指令ID进行区分 +void type2AE3Data(uint8_t *cmd_buf ,uint8_t *data,uint16_t datalen,uint8_t *totaldata,uint8_t crcvalue);//对不同指令ID进行区分 +void type2AE1Data(uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *totalData,uint8_t crcvalue); errcode_t sendBleData(uint8_t *buf,uint16_t len); void sendParieSuccess(uint8_t flag,bd_addr_t *addr);//发送配对成功指令to app mac手机端的地址 void getPhoneInfo_test(void); diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index b27155032..b5b39249e 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -146,7 +146,7 @@ static void svr_ble_adv_data_set(int adv_id) uint8_t scan_data_len = 0; uint8_t ble_data_name[BLE_ADV_BLE_NAME_MAX_LENGTH + 1 ] = {0}; // +TYPE LENGTH uint8_t ble_data_mac_switch[BD_ADDR_LEN] = {0}; - uint8_t adv_mac_head[BLE_ADV_MAC_LENTH] = {0x9, 0x16, 0xe0, 0x18}; + uint8_t adv_mac_head[BLE_ADV_MAC_LENTH] = {0x9, 0x16, 0x02, 0x38}; 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)); unsigned char addr[BLE_MAC_MAX_LEN] = {0}; @@ -289,9 +289,9 @@ static void svr_ble_connstate_change_cb(unsigned short conn_id, bd_addr_t *addr, g_ble_conn_id = conn_id; if (GAP_BLE_STATE_DISCONNECTED == conn_state) { // restart ble adv when disconnected Bleconnect = GAP_BLE_STATE_DISCONNECTED;//蓝牙已断开 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_DISCONNECTED!!! svr_alipay_get_adv_start_state %d alipay_get_binding_status:%d\r\n",svr_alipay_get_adv_start_state(),alipay_get_binding_status()); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_DISCONNECTED!!! svr_alipay_get_adv_start_state %d alipay_get_binding_status:%d\r\n",svr_alipay_get_adv_start_state(),alipay_get_binding_status()); // if(AdverFlag == true){ - + free_ble_data(); #ifdef BLE_CHANGE_MODE svr_ble_adv_start(); #else @@ -304,7 +304,7 @@ static void svr_ble_connstate_change_cb(unsigned short conn_id, bd_addr_t *addr, } #endif - free_ble_data(); + // } } else { devpair_state = 0;// @@ -815,15 +815,25 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data1)) { - g_ble_server_handle = result->value_handle; - data2ae5Cmd = result->value_handle; + if(g_ble_server_handle == 0) + { + g_ble_server_handle = result->value_handle; + } + if(data2ae5Cmd == 0){ + data2ae5Cmd = result->value_handle; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " 2ae5 result->value_handle1 %d\r\n",result->value_handle); } if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data2)) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae3 result->value_handle2 %d\r\n",result->value_handle); - data2ae3Cmd = result->value_handle; + if(data2ae3Cmd == 0) + { + data2ae3Cmd = result->value_handle; + } + } if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data4)) @@ -833,7 +843,11 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t } if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data5)) { - data2ae1Cmd = result->value_handle; + if(data2ae3Cmd == 0) + { + data2ae1Cmd = result->value_handle; + } + // data2ae1Cmd = result->value_handle; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae1 result->value_handle5 %d\r\n",result->value_handle); // shortCmdChara = result->value_handle; } @@ -845,7 +859,11 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data3)) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae4 result->value_handle3 %d\r\n",result->value_handle); - data2ae4Cmd = result->value_handle; + if(data2ae4Cmd == 0) + { + data2ae4Cmd = result->value_handle; + } + // = result->value_handle; } if (ble_gatts_cmp_uuid(uuid, &hid_report_uuid) == true) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "result->hid_report_uuid %d\r\n",result->value_handle); diff --git a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c index 81f9b4c74..437b5a25c 100755 --- a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c +++ b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c @@ -53,8 +53,8 @@ static const TopicToCore topicToCoreArray[] = { #endif #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION {TOPIC_EVENT_DEVICE_BIND,A_CORE_MASK, 1}, - {TOPIC_EVENT_DEVICE_UNBIND,A_CORE_MASK, 1}, - {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST,A_CORE_MASK, 1}, + // {TOPIC_EVENT_DEVICE_UNBIND,A_CORE_MASK, 1}, + // {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST,A_CORE_MASK, 1}, #endif {TOPIC_EVENT_FIND_WATCH,A_CORE_MASK, 1},//查找手表 {TOPIC_EVENT_CANCEL_FIND_WATCH,A_CORE_MASK, 1}, diff --git a/code/sdk/application/wearable/service/factorytest_service/factorytestService.c b/code/sdk/application/wearable/service/factorytest_service/factorytestService.c index e54ec84d0..b5fa022ad 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytestService.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytestService.c @@ -172,12 +172,18 @@ errcode_t ble_factorytest_server_send_ota_report(const uint8_t *data, uint8_t le void ble_factorytest_store_report_handle(uint16_t srvc_handle) { printf("g_factory_notify_report_att_hdl: 0x%X\r\n",srvc_handle); - g_factory_notify_report_att_hdl = srvc_handle; + if(g_factory_notify_report_att_hdl == 0){ + g_factory_notify_report_att_hdl = srvc_handle; + } } void ble_factorytest_store_recv_handle(uint16_t srvc_handle) { printf("factory_ate_write_handl : 0x%X\r\n",srvc_handle); - factory_ate_write_handl = srvc_handle; + if(factory_ate_write_handl == 0) + { + factory_ate_write_handl = srvc_handle; + } + } uint32_t get_factory_ate_write_handl(void) @@ -188,12 +194,19 @@ uint32_t get_factory_ate_write_handl(void) void ble_factorytest_store_ota_report_handle(uint16_t srvc_handle) { printf("g_factory_ota_report_hdl: 0x%X\r\n",srvc_handle); - g_factory_ota_report_hdl = srvc_handle; + if(g_factory_ota_report_hdl == 0) + { + g_factory_ota_report_hdl = srvc_handle; + } } void ble_factorytest_store_ota_recv_handle(uint16_t srvc_handle) { printf("factory_ota_write_handl : 0x%X\r\n",srvc_handle); - factory_ota_write_handl = srvc_handle; + if(factory_ota_write_handl == 0) + { + factory_ota_write_handl = srvc_handle; + } + } uint32_t get_factory_ota_write_handl(void) { diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h index 13093c1f1..df9c58b4f 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h @@ -26,16 +26,17 @@ namespace OHOS const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages); void FreeImagePathsArray(const char **imagePaths, const int numImages); bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override; - void SetDeviceName(const char *Name); - const char *GetDeviceName(); + void SetDeviceName(char *Name); + char *GetDeviceName(); void Pairing_StartTimer(uint32_t interval = 1000*30); void Pairing_StopTimer(void); + char DeviceName[50]; private: PairingViewEventListener(); ~PairingViewEventListener(); PairingViewEventListener(const PairingViewEventListener &) = delete; const PairingViewEventListener &operator=(const PairingViewEventListener &) = delete; - const char *DeviceName{nullptr}; + }; } diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 476463ee1..cb4a651b0 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -91,8 +91,8 @@ const PriorityMapper g_pri_mapper[] = { #endif #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION //如果支持设备配对通知 {TOPIC_EVENT_DEVICE_BIND, PRIORITY_TWO}, - {TOPIC_EVENT_DEVICE_UNBIND, PRIORITY_TWO}, - {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, PRIORITY_TWO}, + // {TOPIC_EVENT_DEVICE_UNBIND, PRIORITY_TWO}, + // {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, PRIORITY_TWO}, #endif {TOPIC_EVENT_FIND_WATCH,PRIORITY_TWO}, {TOPIC_EVENT_CANCEL_FIND_WATCH,PRIORITY_TWO}, @@ -158,8 +158,8 @@ void MsgCenterSubscribe() #endif #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION //如果支持设备配对通知 MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_BIND); - MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_UNBIND); - MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_UNBINDING_REQUEST); + // MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_UNBIND); + // MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_UNBINDING_REQUEST); #endif MsgCenterSubscribeTopic(TOPIC_EVENT_FIND_WATCH); MsgCenterSubscribeTopic(TOPIC_EVENT_CANCEL_FIND_WATCH); @@ -684,46 +684,67 @@ void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req) display_api->turn_on_screen(); } uint8_t* data=(uint8_t*)req->data; - + uint8_t len_name = req->len; + char devname[len_name]; if(data!=NULL && req->len>=2) { - switch (data[0]) + switch(data[0]) { - case DEVICEBIND: - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); - NotificationManager::GetInstance()->ShowNotify(showDeviceBindingNotify, (uint16_t)topic, true); - break; - case DEVICEUNBIND: - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); - NotificationManager::GetInstance()->ShowNotify(showDeviceUnBindingNotify, (uint16_t)topic, true); - break; - case DeviceUnBindingRequest: - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); - NotificationManager::GetInstance()->ShowNotify(showDeviceUnbindingRequestNotify, (uint16_t)topic, true); - break; - case SHUTDOWN: - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, " SHUTDOWN"); - set_lowpower_falg(3); - if (NotificationManager::GetInstance()->hasNotifyShowing()) - NotificationManager::GetInstance()->StopNotify(); - - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); - - NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); - //low_power_paly(true); - break; - case REBOOT: - set_lowpower_falg(4); - if (NotificationManager::GetInstance()->hasNotifyShowing()) - NotificationManager::GetInstance()->StopNotify(); - - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); - NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); - //low_power_paly(false); - break; - - default: - break; + case DEVICEBIND: + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + len_name = req->len-2; + memset(devname,0,len_name); + if(len_name > 0) + { + memcpy(devname,(char *)req->data+2,len_name); + PairingViewEventListener::GetInstance().SetDeviceName(devname); + }else{ + PairingViewEventListener::GetInstance().SetDeviceName(NULL); + } + NotificationManager::GetInstance()->ShowNotify(showDeviceBindingNotify, (uint16_t)topic, true); + break; + case DEVICEUNBIND: + + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + len_name = req->len-2; + memset(devname,0,len_name); + if(len_name > 0) + { + memcpy(devname,(char *)req->data+2,len_name); + // printf("devname:%s\r\n",devname); + PairingViewEventListener::GetInstance().SetDeviceName(devname); + }else{ + PairingViewEventListener::GetInstance().SetDeviceName(NULL); + } + NotificationManager::GetInstance()->ShowNotify(showDeviceUnBindingNotify, (uint16_t)topic, true); + break; + case DeviceUnBindingRequest: + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + NotificationManager::GetInstance()->ShowNotify(showDeviceUnbindingRequestNotify, (uint16_t)topic, true); + break; + case SHUTDOWN: + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, " SHUTDOWN"); + set_lowpower_falg(3); + if (NotificationManager::GetInstance()->hasNotifyShowing()) + NotificationManager::GetInstance()->StopNotify(); + + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + + NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); + //low_power_paly(true); + break; + case REBOOT: + set_lowpower_falg(4); + if (NotificationManager::GetInstance()->hasNotifyShowing()) + NotificationManager::GetInstance()->StopNotify(); + + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); + //low_power_paly(false); + break; + + default: + break; } } @@ -733,6 +754,7 @@ void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req) //设备解绑通知 void MsgCenterNotifyDeviceUnBindProc(const Topic topic, Request* req) { + return; unused(req); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyUnBindProc Unbind !"); const power_display_svr_api_t *display_api = power_display_svr_get_api(); @@ -747,6 +769,7 @@ void MsgCenterNotifyDeviceUnBindProc(const Topic topic, Request* req) //设备解绑请求(与新设备连接)通知 void MsgCenterNotifyDeviceUnBindingRequestProc(const Topic topic, Request* req) { + return; unused(req); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyUnBindProc Unbind !"); const power_display_svr_api_t *display_api = power_display_svr_get_api(); @@ -864,8 +887,8 @@ static msg_center_notify_table_t g_msg_center_notify_table[] = { #endif #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION {TOPIC_EVENT_DEVICE_BIND, MsgCenterNotifyDeviceBindProc}, - {TOPIC_EVENT_DEVICE_UNBIND, MsgCenterNotifyDeviceUnBindProc}, - {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, MsgCenterNotifyDeviceUnBindingRequestProc}, + // {TOPIC_EVENT_DEVICE_UNBIND, MsgCenterNotifyDeviceUnBindProc}, + // {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, MsgCenterNotifyDeviceUnBindingRequestProc}, #endif {TOPIC_EVENT_FIND_WATCH,MsgCenterNotifyFindWatchProc}, {TOPIC_EVENT_CANCEL_FIND_WATCH,MsgCenterNotifyCanCelFindWatchProc}, 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 9226f709b..24ba5cf77 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 @@ -83,6 +83,7 @@ namespace OHOS UNUSED(event); if (&view == DeviceBindingButtonCancel) // 设备绑定取消按钮 { + PairingViewEventListener::GetInstance().Pairing_StopTimer(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceBindingButtonCancel OnClick"); // 终止当前的绑定流程并关闭相关的通知界面。 #ifdef SUPPORT_BLE_SERVICE @@ -99,7 +100,7 @@ namespace OHOS * 2.更新设备绑定状态. * 3.发送绑定请求到设备或服务器等. */ - + PairingViewEventListener::GetInstance().Pairing_StopTimer(); // 关闭通知界面 #ifdef SUPPORT_BLE_SERVICE comfirmPaire(1); @@ -187,14 +188,24 @@ namespace OHOS return button; } - void PairingViewEventListener::SetDeviceName(const char *Name) + void PairingViewEventListener::SetDeviceName( char *Name) { - DeviceName = Name; + + //DeviceName = Name; + int len = strlen(Name); + if(len > sizeof(DeviceName)) + len = sizeof(DeviceName); + Name[len]='\0'; + memset(DeviceName,0,sizeof(DeviceName)); + memcpy(DeviceName,Name,len); + // PRINT("set DeviceName:%x\r\n",DeviceName); } + /*获取设备名称*/ - const char *PairingViewEventListener::GetDeviceName(void) + char *PairingViewEventListener::GetDeviceName(void) { - return "Iphone 13 pro"; //先用固定字符串测试 + // PRINT("get DeviceName:%x\r\n",DeviceName); + return DeviceName; //先用固定字符串测试 } /* @@ -225,6 +236,7 @@ namespace OHOS DeviceBindingViewTitleLabel->SetPosition(173, 52, 120, 35); DeviceBindingViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); DeviceBindingViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceBindingViewTitleLabel->SetText("设备绑定"); DeviceBindingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); DeviceBindingViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); @@ -236,10 +248,19 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingName new fail!!"); return nullptr; } + + const char *devanme = PairingViewEventListener::GetInstance().GetDeviceName(); DeviceBindingName->SetPosition(33, 180, 400, 40); DeviceBindingName->SetStyle(STYLE_TEXT_FONT, 30); DeviceBindingName->SetStyle(STYLE_LINE_HEIGHT, 35); - DeviceBindingName->SetText("Iphone 14 Pro\n"); + + if(devanme != NULL){ + DeviceBindingName->SetText(devanme); + }else + { + DeviceBindingName->SetText(" "); + } + DeviceBindingName->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); DeviceBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); DeviceBindingName->SetRollSpeed(60); @@ -355,7 +376,18 @@ namespace OHOS DeviceUnBindingName->SetPosition(33, 200, 400, 40); DeviceUnBindingName->SetStyle(STYLE_TEXT_FONT, 30); DeviceUnBindingName->SetStyle(STYLE_LINE_HEIGHT, 35); - DeviceUnBindingName->SetText("小米5\n"); + + + const char *devanme = PairingViewEventListener::GetInstance().GetDeviceName(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName devanme :%s",devanme); + + if(devanme != NULL){ + DeviceUnBindingName->SetText(devanme); + }else + { + DeviceUnBindingName->SetText(" "); + } + // DeviceUnBindingName->SetText("小米5\n"); DeviceUnBindingName->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); DeviceUnBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); DeviceUnBindingName->SetRollSpeed(60); @@ -402,6 +434,7 @@ namespace OHOS DeviceUnBindingView->Add(DeviceUnBindingButtonOK); } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingView new success!!"); return DeviceUnBindingView; } @@ -581,19 +614,24 @@ namespace OHOS DeviceUnBindingViewTitleLabel = nullptr; PairingViewEventListener::GetInstance().FreeImagePathsArray(UnBindPathsArray, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); - + + DeviceUnBindingAnimatorView->Stop(); delete DeviceUnBindingAnimatorView; DeviceUnBindingAnimatorView = nullptr; + delete DeviceUnBindingName; DeviceUnBindingName = nullptr; + delete DeviceUnBindingViewLabel; DeviceUnBindingViewLabel = nullptr; + delete DeviceUnBindingButtonCancel; DeviceUnBindingButtonCancel = nullptr; + delete DeviceUnBindingButtonOK; DeviceUnBindingButtonOK = nullptr; diff --git a/code/sdk/drivers/peripheral/ppg/ppgBleService/ppgBleService.c b/code/sdk/drivers/peripheral/ppg/ppgBleService/ppgBleService.c index 105d8b8c6..7c15265c2 100644 --- a/code/sdk/drivers/peripheral/ppg/ppgBleService/ppgBleService.c +++ b/code/sdk/drivers/peripheral/ppg/ppgBleService/ppgBleService.c @@ -129,7 +129,11 @@ errcode_t ble_ppgtest_server_send_input_report(const uint8_t *data, uint8_t len) void ble_ppgtest_store_report_handle(uint16_t srvc_handle) { printf("g_ppgtest_notify_report_att_hdl: 0x%X\r\n",srvc_handle); - g_ppgtest_notify_report_att_hdl = srvc_handle; + if(g_ppgtest_notify_report_att_hdl == 0) + { + g_ppgtest_notify_report_att_hdl = srvc_handle; + } + } void ble_ppgtest_add_characters_and_descriptors(uint8_t server_id, uint16_t srvc_handle)