From: dxy <1731678236@qq.com> Date: Thu, 28 Mar 2024 02:34:02 +0000 (+0800) Subject: ble服务接入ui界面 X-Git-Tag: release_V1.2.70_20241020_135402~1241^2~25 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=c098b435110657a06aa609c61c1459bac0b31712;p=mirrors%2FFD230.git ble服务接入ui界面 --- diff --git a/code/sdk/application/wearable/alipay/driver_adapt/vendor_product.c b/code/sdk/application/wearable/alipay/driver_adapt/vendor_product.c index fbf289d8e..14528886e 100755 --- a/code/sdk/application/wearable/alipay/driver_adapt/vendor_product.c +++ b/code/sdk/application/wearable/alipay/driver_adapt/vendor_product.c @@ -155,7 +155,9 @@ csi_error_t csi_ble_write(uint8_t *data, uint16_t len) #ifdef ALIPAY_CSI_LOG_EXT_ON MyPrintf("csi_ble_write in %s,len:%u.", data, len); #endif +#ifdef SUPPORT_BLE_SERVICE svr_alipay_bt_gatts_noyify(data, len); +#endif return CSI_OK; } diff --git a/code/sdk/application/wearable/alipay/service/alipay_bluetooth.c b/code/sdk/application/wearable/alipay/service/alipay_bluetooth.c index e3f490738..101e021db 100644 --- a/code/sdk/application/wearable/alipay/service/alipay_bluetooth.c +++ b/code/sdk/application/wearable/alipay/service/alipay_bluetooth.c @@ -16,7 +16,7 @@ #include "securec.h" #include "wearable_log.h" -#ifdef SUPPORT_BLE_SERVICE +#ifdef SUPPORT_ALIPAY_SEC #include "bleService.h" #include "alipay_bluetooth.h" @@ -351,10 +351,15 @@ void alipay_unregist_server(void) gatts_unregister_server(g_alipay_server_id); svr_alipay_ble_adv_stop(); } +#ifdef SUPPORT_BLE_SERVICE extern void ble_unregist_server(void); +#endif + void svr_alipay_bluetooth_init(void) { + #ifdef SUPPORT_BLE_SERVICE ble_unregist_server(); + #endif disable_bt_stack(); svr_alipay_ble_adv_stop(); osDelay(100); @@ -373,7 +378,9 @@ void svr_alipay_bluetooth_init(void) } void svr_alipay_reset_init(void)//重新启动alipa的服务 { + #ifdef SUPPORT_BLE_SERVICE ble_unregist_server(); + #endif osDelay(100); svr_alipay_btcallback_reg(); svr_alipay_bt_init_gatts(); diff --git a/code/sdk/application/wearable/alipay/service/alipay_bluetooth.h b/code/sdk/application/wearable/alipay/service/alipay_bluetooth.h index 47f080e39..ec8367a2e 100644 --- a/code/sdk/application/wearable/alipay/service/alipay_bluetooth.h +++ b/code/sdk/application/wearable/alipay/service/alipay_bluetooth.h @@ -25,6 +25,7 @@ #define ALIPAY_BLE_DEFAULT_NAME_LEN 9 #define ALIPAY_BLE_MAC_MAX_LEN 6 +void svr_alipay_bluetooth_init(void); void ble_alipay_add_characters_input_report_cbk(uint16_t srvc_handle); void alipay_add_chart_decr_cb(uint8_t server_id,uint16_t srv_handle); #endif diff --git a/code/sdk/application/wearable/alipay/service/alipay_feature.c b/code/sdk/application/wearable/alipay/service/alipay_feature.c index df31aa8d5..f22d366a9 100755 --- a/code/sdk/application/wearable/alipay/service/alipay_feature.c +++ b/code/sdk/application/wearable/alipay/service/alipay_feature.c @@ -23,6 +23,7 @@ #include "thread_init.h" #include "alipay_transit.h" #include "bleService.h" +#include "alipay_bluetooth.h" #include "vendor_file.h" #if defined(__FREERTOS__) #include "FreeRTOS.h" @@ -76,7 +77,9 @@ static int32_t svr_alipay_notify_bt(bool value) svr_alipay_bluetooth_init(); } else { printf("svr_alipay_notify_bt false:%d",value); + #ifdef SUPPORT_BLE_SERVICE svr_bluetooth_init(); + #endif // svr_alipay_ble_adv_stop(); } return 0; diff --git a/code/sdk/application/wearable/service/ble_service/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleEvent.c index a01c1c093..d6292648e 100644 --- a/code/sdk/application/wearable/service/ble_service/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleEvent.c @@ -25,6 +25,8 @@ #include "bts_a2dp_sink.h" #include "osal_timer.h" #include "bleEvent.h" +#include "ppg_service.h" +#include "broadcast_feature.h" #ifdef SUPPORT_BLE_SERVICE #include "app_common_api.h" #include "hidService.h" @@ -263,11 +265,11 @@ void sendConfirmParieSucess(void) sendBleData(value,19); } -static void jsonCheck_phoneinfor(uint8_t *buf,uint8_t *mac_data)//解析手机信息json +static uint8_t jsonCheck_phoneinfor(uint8_t *buf,uint8_t *mac_data,char *devname)//解析手机信息json { + uint8_t len = 0; uint8_t mac_tmp[6]; memset(mac_tmp,0,6); - char *devname;//手机设备名称 uint8_t type = 0; uint8_t count1 = 0; uint8_t count2 = 0; @@ -276,13 +278,16 @@ static void jsonCheck_phoneinfor(uint8_t *buf,uint8_t *mac_data)//解析手机 cJSON* root = cJSON_Parse((const char *)json); if (root == NULL) { printf("JSON解析错误\n"); - return; + return 0; } cJSON* pn = cJSON_GetObjectItem(root, "pn"); if (cJSON_IsString(pn)) { - printf("设备名称: %s\n", pn->valuestring); + len = strlen(pn->valuestring)+1; + pn->valuestring[len-1]='\0'; + memcpy((uint8_t *)devname,(uint8_t *)pn->valuestring,strlen(pn->valuestring)); + printf("设备名称: %s\n", pn->valuestring); } cJSON* tp = cJSON_GetObjectItem(root, "tp"); @@ -313,6 +318,8 @@ static void jsonCheck_phoneinfor(uint8_t *buf,uint8_t *mac_data)//解析手机 memcpy(mac_data,mac_tmp,6); } cJSON_Delete(root); + return len; + } errcode_t bondSucessCmd(void)//发送解绑指令,解绑界面调用这个函数 如果点了✓调用这个函数 返回成功后延迟10s再重启设备 { @@ -389,19 +396,70 @@ void comfirmPaire(uint8_t flag) value[17] = flag; value[18] = Calculate_CRC(value,1+17); sendBleData(value,19); + if(flag == 1) + { + gap_ble_pair_remote_device(&phone_addr); + }else{ + if(Bleconnect == GAP_BLE_STATE_CONNECTED){//设备连接需要断开 + gap_ble_disconnect_remote_device(&phone_addr);//与固定的mac设置地址进行断开连接 + gap_ble_remove_pair(&phone_addr); + } + svr_ble_adv_start(); + + } } // l连接手表之后-app通过特征值2AE4读手表信息->手表会把相应的信息给app->app通过73 02 10下发手机信息给设备(第一次连接mac为空)->设备返回73 02 10状态1才能和手机app第一次连接->设备会回发配对指令72 05 11给app,同时设备会对手机发起配对->手机点了配对后,配对成功手表会发配对成功指令72 05 10,这条指令包含手机的mac地址也会传给app->app校验解析成功之后->app下发时间指令72 02 02给设备->设备回复解析成功->完成连接 void alarmData(void) { } - -uint8_t firts_bond = 0;//是否和手机app绑定过已经绑定就不需要配对指令给app,直接发起配对 +void getPhoneMac(uint8_t *phonemac) +{ + uint8_t mac[6]; + memset(mac,0,6); + uint8_t count = 0; + FILE *jsfile = fopen(PHONE_WATCH_CONFIG_PATH, "r"); + if (jsfile != NULL) { + printf("succes opening file\n"); + fseek(jsfile, 0, SEEK_END); + long fileSize = ftell(jsfile); + fseek(jsfile, 0, SEEK_SET); + + char *jsonData = (char *)malloc(fileSize + 1); + fread(jsonData, 1, fileSize, jsfile); + jsonData[fileSize] = '\0'; + fclose(jsfile); + + // 解析JSON数据 + cJSON *root = cJSON_Parse(jsonData); + free(jsonData); + + if (root != NULL) { + cJSON *modifiedJson = cJSON_GetObjectItem(root,"mac"); + if (cJSON_IsArray(modifiedJson)) { + printf("MAC地址: "); + cJSON* macElement = NULL; + cJSON_ArrayForEach(macElement, modifiedJson) { + if (cJSON_IsNumber(macElement)) { + if ((macElement->prev != NULL)) { + mac[count] = macElement->valueint; + count++; + } + + } + } + printf("\n"); + } + } + // 释放资源 + cJSON_Delete(root); + } + memcpy(phonemac,mac,6); +} +uint8_t firts_bond = 0;//是否第一次绑定 第一次绑定保存配对mac地址 void getPhoneInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取手机信息 { - //static void * next_tmp; uint8_t value[20]; - // uint8_t crcvalue = 0; memset(value,0,20); uint32_t tmp = 1; uint16_t tmp_fen= 1; @@ -420,61 +478,29 @@ void getPhoneInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,u tmp_data = crcnum; uint8_t copare_mac[6]; memset(copare_mac,0,6); - jsonCheck_phoneinfor(tmp_data,&copare_mac); - gap_ble_pair_state_t status; - gap_ble_get_pair_state(&phone_addr,&status);//获取配对状态 + uint8_t datalen=0; + char devname[256]; + memset(devname,0,256); + datalen = jsonCheck_phoneinfor(tmp_data,&copare_mac,&devname); uint8_t bond = 1;//未与任何手机绑定过 errcode_t ret = 0; firts_bond = 0; uint8_t save_mac[6]; - uint8_t save_mac_t[6]; - uint8_t count = 0; - uint8_t count_t = 0; - FILE *jsfile = fopen(PHONE_WATCH_CONFIG_PATH, "r"); - if (jsfile != NULL) { - printf("succes opening file\n"); - fseek(jsfile, 0, SEEK_END); - long fileSize = ftell(jsfile); - fseek(jsfile, 0, SEEK_SET); - - char *jsonData = (char *)malloc(fileSize + 1); - fread(jsonData, 1, fileSize, jsfile); - jsonData[fileSize] = '\0'; - fclose(jsfile); - - // 解析JSON数据 - cJSON *root = cJSON_Parse(jsonData); - free(jsonData); - - if (root != NULL) { - cJSON *modifiedJson = cJSON_GetObjectItem(root,"mac"); - if (cJSON_IsArray(modifiedJson)) { - printf("MAC地址: "); - cJSON* macElement = NULL; - cJSON_ArrayForEach(macElement, modifiedJson) { - if (cJSON_IsNumber(macElement)) { - if ((macElement->prev != NULL)) { - save_mac[count] = macElement->valueint; - count++; - } - - } - } - printf("\n"); - } - // printf("success parsing JSON :save_mac :%d %d %d %d %d %d\n",save_mac[0],save_mac[1],save_mac[2],save_mac[3],save_mac[4],save_mac[5]); - } - // 释放资源 - cJSON_Delete(root); - } - if(save_mac[0] == 0 && save_mac[1] == 0 && save_mac[2] == 0)//只要手表本地存储没有mac地址就走连接流程重新绑定 + getPhoneMac(&save_mac); + memset(save_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;//手表未和任何手机绑定过 - if(strlen((char *)copare_mac) == 0)//只要app没有下发mac就开启弹窗 + 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)//只要app没有下发mac就开启弹窗 { - comfirmPaire(1); - gap_ble_pair_remote_device(&phone_addr); + #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION + if(datalen == 0){ + CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,NULL,0); + }else{ + CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,(uint8_t *)devname,datalen); + } + #endif }else{ ret = gap_ble_pair_remote_device(&phone_addr); } @@ -483,7 +509,7 @@ void getPhoneInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,u }else { - if(copare_mac[0] != 0 && copare_mac[1] != 0 && copare_mac[2] != 0 ) + 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) { printf("success parsing JSON :save_mac :%d %d %d %d %d %d copare_mac %d %d %d %d %d %d;\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]); @@ -521,7 +547,6 @@ void sendParieSuccess(uint8_t flag,uint8_t *mac)//发送配对成功指令to app { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sendParieSuccess:0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\r\n",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]); if(firts_bond != 1 && phoneDataFlag == 1){//和该手机绑定过并且是连接app之后下发的数据 正常系统配对是不需要保存的 - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sendParieSuccess:0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\r\n",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]); uint8_t value[25]; uint8_t length = 0; memset(value,0,25); diff --git a/code/sdk/application/wearable/service/ble_service/bleEvent.h b/code/sdk/application/wearable/service/ble_service/bleEvent.h index 933b7a499..bbfa121b7 100644 --- a/code/sdk/application/wearable/service/ble_service/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleEvent.h @@ -4,6 +4,9 @@ #include #include "stdbool.h" #include "errcode.h" +#ifdef __cplusplus +extern "C" { +#endif #define READ_FLASH_DATA 0x01 //读flash数据 #define WRITE_FLASH_DATA 0x02 //写flash数据 typedef struct { @@ -574,5 +577,10 @@ void getPhoneInfo_test(void); void setFindWatchFlag(uint8_t flag);//查找手表标识 errcode_t bondSucessCmd(void);//发送解绑指令,解绑界面调用这个函数 如果点了✓调用这个函数 返回成功后延迟10s再重启设备 void getDeviceState(void); + +void comfirmPaire(uint8_t flag);//发送确认配对指令 1确认配对 0取消配对 +#ifdef __cplusplus +} +#endif #endif diff --git a/code/sdk/application/wearable/service/ble_service/bleService.c b/code/sdk/application/wearable/service/ble_service/bleService.c index 61e5a34eb..9d9f8ab8d 100644 --- a/code/sdk/application/wearable/service/ble_service/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleService.c @@ -27,7 +27,6 @@ #include "osal_timer.h" #include "bleEvent.h" #include "hidService.h" - // #include "ble_hid_take_photo_server.h" /* Gatt service UUID */ #define BLE_SERVICE_UUID 0x18e0 @@ -89,7 +88,7 @@ static osal_timer g_a2dp_stream_accept_timer = {NULL, NULL, 0, 0}; uint8_t data2ae3Cmd = 0;//2ae3短指令特征值 uint8_t data2ae4Cmd = 0; - +#ifdef SUPPORT_BLE_SERVICE static void set_phone_info(bd_addr_t *addr)//保存手机信息 包含手机mac地址 { @@ -138,7 +137,7 @@ static void svr_ble_adv_data_set(int adv_id) 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 set_mac[6] = {0x61,0x22,0x33,0x44,0x09,0x14}; + unsigned char set_mac[6] = {0x61,0x22,0x33,0x44,0x09,0x15}; bluetooth_set_local_addr(set_mac,6); bd_addr_t addr_info; int32_t ret= 0; @@ -164,11 +163,6 @@ static void svr_ble_adv_data_set(int adv_id) } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_get_local_name name:%s,len:%u,ret:%u.", ble_name, ble_name_len, ret); - ret = gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 60); // start scan - if (ret == false) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectPhonePresenter bt gap_br_set_bt_scan_mode ret = 0x%x", ret); - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_get_local_addr, ret:%u.", ret); memcpy_s(adv_data, sizeof(ble_adv_type), ble_adv_type, sizeof(ble_adv_type)); adv_data_len = sizeof(ble_adv_type); @@ -194,8 +188,8 @@ static void svr_ble_adv_data_set(int adv_id) ble_data_mac_switch[2], ble_data_mac_switch[3], ble_data_mac_switch[4], ble_data_mac_switch[5]); memcpy_s(adv_mac_head + BLE_ADV_MAC_HEAD_LENTH, BD_ADDR_LEN, ble_data_mac_switch, BD_ADDR_LEN); - memcpy_s(adv_data + adv_data_len, sizeof(adv_mac_head), adv_mac_head, sizeof(adv_mac_head)); - adv_data_len = adv_data_len + sizeof(adv_mac_head); + // memcpy_s(adv_data + adv_data_len, sizeof(adv_mac_head), adv_mac_head, sizeof(adv_mac_head)); + // adv_data_len = adv_data_len + sizeof(adv_mac_head); scan_data[0] = 0x0f;//长度 scan_data[1] = 0xff;//数据类型 manufactory data @@ -738,13 +732,6 @@ static void svr_ble_bt_gatts_req_write_cb(uint8_t server_id, uint16_t conn_id, g } revBleOldData(write_cb_para->value,write_cb_para->length,write_cb_para->handle); - // if(write_cb_para->handle == g_alipay_server_handle) - // { - // printf("g_alipay_server_handle:%d",g_alipay_server_handle); - // uint8_t *msg_data = write_cb_para->value; - // svr_alipay_msg_write(ALIPAY_MSG_BT, msg_data, write_cb_para->length, false); - // } - } static void svr_ble_mtu_exchange(uint8_t server_id, uint16_t conn_id, uint16_t mtu_size, errcode_t status) { @@ -1162,14 +1149,17 @@ void svr_bluetooth_init(void) { bool ret = enable_bt_stack(); if (ret != ERRCODE_SUCC) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "svr_bluetooth_init enable_bt_stack ret:%u.\r\n", ret); + // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "svr_bluetooth_init enable_bt_stack ret:%u.\r\n", ret); } // osDelay(100); svr_ble_btcallback_reg(); + #ifdef SUPPORT_BLE_SERVICE svr_ble_bt_init_gatts(); + #endif + #ifdef SUPPORT_HID_SERVICE ble_hid_server_init(); + #endif svr_ble_adv_start_param(); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "svr_bluetooth_init22222222222\r\n"); ble_recv_register_msg_callback(ble_recv_msg_callback);//注册驱动回调 return; } @@ -1187,7 +1177,7 @@ void closeBle(void) memcpy(bd_addr.addr,addr,BLE_MAC_MAX_LEN); errcode_t ret = 0; if(Bleconnect == GAP_BLE_STATE_CONNECTED){//设备连接需要断开 - ret = gap_ble_disconnect_remote_device((const bd_addr_t *)&bd_addr);//与固定的mac设置地址进行断开连接 + ret = gap_ble_disconnect_remote_device((const bd_addr_t *)&phone_addr);//与固定的mac设置地址进行断开连接 } // ret = gap_ble_remove_all_pairs();//删除和所有配对的手机app // gap_remove_all_pairs(); @@ -1205,4 +1195,5 @@ void openBle(void) AdverFlag = true; svr_bluetooth_init(); } -} \ No newline at end of file +} +#endif \ No newline at end of file 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 b41c00f25..e309f7aee 100755 --- a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c +++ b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c @@ -45,6 +45,11 @@ static const TopicToCore topicToCoreArray[] = { {TOPIC_EVENT_CHARGE_PLUG, A_CORE_MASK, 1}, {TOPIC_EVENT_CHARGE_UNPLUG, A_CORE_MASK, 1}, #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}, +#endif #ifdef SUPPORT_CAT1_MODEM {TOPIC_EVENT_CAT1_INCOMMING, A_CORE_MASK, 1}, {TOPIC_EVENT_CAT1_CALLCONNTED, A_CORE_MASK, 1}, diff --git a/code/sdk/application/wearable/service/hid_service/hidService.c b/code/sdk/application/wearable/service/hid_service/hidService.c index 427830f41..96af29732 100644 --- a/code/sdk/application/wearable/service/hid_service/hidService.c +++ b/code/sdk/application/wearable/service/hid_service/hidService.c @@ -3,16 +3,14 @@ * Description: BT HID Service Server Module. */ #include "hidService.h" -#ifdef SUPPORT_BLE_SERVICE #include "bleService.h" -#endif #include "bts_gatt_stru.h" #include "bts_a2dp_source.h" #include "bts_gatt_server.h" #include "securec.h" #include "wearable_log.h" -#if 1 +#ifdef SUPPORT_HID_SERVICE /* HID information flag remote wakeup */ #define BLE_HID_INFO_FLAG_REMOTE_WAKE_UP_MSK 0x01 /* HID information flag normally connectable */ diff --git a/code/sdk/application/wearable/service/hid_service/hidService.h b/code/sdk/application/wearable/service/hid_service/hidService.h index bf17ceed5..83cd36a89 100644 --- a/code/sdk/application/wearable/service/hid_service/hidService.h +++ b/code/sdk/application/wearable/service/hid_service/hidService.h @@ -41,7 +41,7 @@ extern "C" { #define BLE_UUID_REPORT_REFERENCE 0x2908 /* HID character value handle offset */ #define BLE_HID_CHARACTER_INPUT_REPORT_VALUE_HANDLE_OFFSET 8 -#if 1 +#if 1 /** * @if Eng * @brief Use this funtion to register callback function of framework. 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 5ca4bd98c..c8a410a75 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 @@ -12,6 +12,11 @@ #include "components/ui_button.h" #include "components/ui_image_view.h" #include "components/ui_scroll_view.h" +#ifdef SUPPORT_BLE_SERVICE +#include "bleEvent.h" + +#endif + namespace OHOS { @@ -72,6 +77,9 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceBindingButtonCancel OnClick"); // 终止当前的绑定流程并关闭相关的通知界面。 + #ifdef SUPPORT_BLE_SERVICE + comfirmPaire(0); + #endif NotificationManager::GetInstance()->StopNotify(); } else if (&view == DeviceBindingButtonOK) // 设备绑定确认按钮 @@ -85,6 +93,9 @@ namespace OHOS */ // 关闭通知界面 + #ifdef SUPPORT_BLE_SERVICE + comfirmPaire(1); + #endif NotificationManager::GetInstance()->StopNotify(); } else if (&view == DeviceUnBindingButtonCancel) // 设备解绑取消按钮 diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index 70f33da11..3fa78e21b 100755 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -136,7 +136,8 @@ target = { 'SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION', 'SUPPORT_AT_CUSTOMUTILS', 'SUPPORT_ALIPAY_SEC', - 'SUPPORT_BLE_SERVICE' + 'SUPPORT_BLE_SERVICE', + 'SUPPORT_HID_SERVICE' ], 'ram_component': ["algorithm", "dfx_port_brandy", "dfx_update", 'dfx_nv', "osal", "arch_port", "-:testsuite", "liteos_port", 'lcd', 'qspi_display', 'dfx_file_operation', diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp index 3ed64b31f..0bd66300b 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp @@ -81,10 +81,13 @@ void CustomEventPublish(uint16_t topic, uint8_t *data , uint32_t size) return; } request->msgId = topic; - ret = memcpy_s(request->data, size, (const void *)data, size); - if (ret != EOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChargerEventPublish memcpy_s rateDataTmp fail! ret = %d", ret); - return; + if(size > 0) + { + ret = memcpy_s(request->data, size, (const void *)data, size); + if (ret != EOK) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChargerEventPublish memcpy_s rateDataTmp fail! ret = %d", ret); + return; + } } request->len = size; request->msgValue = 0;