解绑 绑定界面加名字显示: 修复解绑界面死机问题:补充用户数据协议增加字段
authorDXY <1731678236@qq.com>
Tue, 7 May 2024 09:31:07 +0000 (17:31 +0800)
committerDXY <1731678236@qq.com>
Tue, 7 May 2024 09:31:07 +0000 (17:31 +0800)
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h
code/sdk/application/wearable/service/ble_service/bleservice/bleService.c
code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c
code/sdk/application/wearable/service/factorytest_service/factorytestService.c
code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp
code/sdk/drivers/peripheral/ppg/ppgBleService/ppgBleService.c

index 6231251..32f789c 100644 (file)
@@ -950,6 +950,7 @@ void sendBindInfor(uint8_t *crcnum)
             if (devname != NULL){\r
                 printf("phone devname is name!!!!!!!!!:");\r
                 uint8_t buf[devnamelen+2]; \r
+                memset(buf,0,devnamelen+2);\r
                 buf[0] = DEVICEBIND ;\r
                 buf[1] = devnamelen;//设备名称长度 0不显示\r
                 memcpy(buf+2,devname,devnamelen);\r
@@ -961,6 +962,7 @@ void sendBindInfor(uint8_t *crcnum)
             }else{\r
                 printf("phone devname is no name11111!!!!!!!!!:");\r
                 uint8_t buf[2]; \r
+                memset(buf,0,2);\r
                 buf[0] = DEVICEBIND;\r
                 buf[1] = 0;\r
                 CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2);\r
@@ -968,6 +970,7 @@ void sendBindInfor(uint8_t *crcnum)
             }\r
         }else{\r
             uint8_t buf[2]; \r
+            memset(buf,0,2);\r
             buf[0] = DEVICEBIND;\r
             buf[1] = 0 ;\r
             printf("phone devname is no name!!!!!!!!!:");\r
@@ -1001,12 +1004,10 @@ void sendBindInfor(uint8_t *crcnum)
         }\r
     }\r
     printf("bond flag:%d first_bond:%d\r\n",bond,first_bond);\r
-    value[17] = bond;//\r
-    value[18] = Calculate_CRC(value,18);\r
-    sendBleData(value,19);\r
+   \r
     if(bond == 0x03)\r
     {\r
-        gap_ble_disconnect_remote_device(&disconect_addr);//与固定的mac设置地址进行断开连接\r
+        // gap_ble_disconnect_remote_device(&disconect_addr);//与固定的mac设置地址进行断开连接\r
         devnamelen = 0;\r
         GetwatchSaveNameLen(&devnamelen);//获取手表设备保存手机的设备名称长度\r
         if(devnamelen > 0)\r
@@ -1014,25 +1015,35 @@ void sendBindInfor(uint8_t *crcnum)
             devname = GetwatchSaveName();\r
             if (devname != NULL){\r
                 uint8_t buf[devnamelen+2]; \r
+                memset(buf,0,devnamelen+2);\r
                 buf[0] = DEVICEUNBIND ;\r
                 buf[1] = devnamelen;\r
                 memcpy(buf+2,devname,devnamelen);\r
-                CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,(uint8_t *)buf,devnamelen+2);\r
-                printf("devname:is no null!!!!!");\r
+                printf("devname:is no null!!!!!%s\r\n",devname);\r
+                CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,(uint8_t *)buf,devnamelen+2);\r
+                if(devname)\r
+                {\r
+                    free(devname);\r
+                }\r
             }else{\r
                 uint8_t buf[2]; \r
+                memset(buf,0,2);\r
                 buf[0] = DEVICEUNBIND;\r
                 buf[1] = 0;\r
                 printf("devname:is  null!!!!!");\r
-                CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,buf,2);\r
+                CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2);\r
             }\r
         }else{\r
             uint8_t buf[2]; \r
+            memset(buf,0,2);\r
             buf[0] = DEVICEUNBIND;\r
             buf[1] = 0;\r
-            CustomEventPublish(TOPIC_EVENT_DEVICE_UNBIND,buf,2);\r
+            CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2);\r
         }\r
     }\r
+    value[17] = bond;//\r
+    value[18] = Calculate_CRC(value,18);\r
+    sendBleData(value,19);\r
 }\r
 void getPhoneInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取手机信息\r
 {\r
@@ -1094,6 +1105,7 @@ void sendParieSuccess(uint8_t flag,bd_addr_t *addr)//发送配对成功指令to
             {\r
                 cJSON_AddStringToObject(dataJSON,"pn",(char *)savephonename);\r
                 free(savephonename);\r
+                savephonename = NULL;\r
             }\r
             cJSON_AddNumberToObject(dataJSON,"phoneType",phoneType);\r
             cJSON_AddNumberToObject(dataJSON,"mac_type",addr->type);\r
@@ -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);\r
         user_info.target_stand = crcnum[11];\r
         user_info.timeformat = crcnum[12];\r
+        uint16_t target_kcal = 0;\r
+        memcpy(&target_kcal,&crcnum[13],2);\r
+        set_goal_caloriescount(target_kcal);\r
+        uint8_t target_km = crcnum[15];\r
+        set_goal_discount(target_km);\r
          if(func != NULL)\r
         {\r
             func(WRITE_FLASH_DATA,cmd,&user_info,sizeof(msg_user_info_t));\r
@@ -3889,9 +3906,9 @@ len 就是data的长度
 *totaldata:总的数据内容 包含包头和校验预览做接口是用  如果要计算totaldata的长度直接是len+17+1 就是加上包头和校验和\r
 crcvalue;数据的校验和 不包含包头和校验和的计算结果\r
 */\r
-void type2AE3Data(uint16_t cmd ,uint8_t *data,uint16_t datalen,uint8_t *totaldata,uint8_t crcvalue)\r
+void type2AE3Data(uint8_t *cmd_buf ,uint8_t *data,uint16_t datalen,uint8_t *totaldata,uint8_t crcvalue)\r
 {\r
-    // uint16_t typeID = cmd_buf[1]*256+cmd_buf[2];\r
+    uint16_t cmd = cmd_buf[1]*256+cmd_buf[2];\r
     printf("typeHexOneData:0x%x\r\n",cmd);\r
     // uint8_t typeID = cmd_buf[2];\r
     switch (cmd)\r
@@ -4376,6 +4393,12 @@ void bleLongRecvData(uint8_t *data, uint16_t data_size,uint8_t *buf_cmd,uint8_t
         case 0x02://获取手机信息\r
             type2AE4Data(buf_cmd,data,data_size,totalData,crcvalue);\r
             break;\r
+        case 0x01:\r
+            type2AE3Data(buf_cmd,data,data_size,totalData,crcvalue);\r
+            break;\r
+        case 0x03://\r
+            type2AE1Data(buf_cmd,data,data_size,totalData,crcvalue);\r
+            break;\r
         default:\r
             break;\r
     }\r
@@ -4585,9 +4608,11 @@ uint8_t jscheck_ancs(uint8_t *data)
     message_data(uid_t,appid_t,titleBuf,msgBuf,hasCode_t);\r
     if(titleBuf != NULL){\r
         free(titleBuf);\r
+        titleBuf = NULL;\r
     }\r
     if(msgBuf != NULL){\r
         free(msgBuf);\r
+        msgBuf = NULL;\r
     }\r
     return 1;\r
 }\r
@@ -4658,29 +4683,7 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle)
     }\r
     \r
     uint8_t crcvalue= 0x00;\r
-\r
-    if(data2ae3Cmd == handle)//短指令\r
-    {\r
-        if(recvBigDataBufState == true)//在接收大数据时未接收完成时,不能被其他指令打断\r
-        {\r
-            return;\r
-        }\r
-        if(event_size > 17)\r
-        {\r
-            uint16_t cmd = totalData[1]*256+totalData[2];\r
-            crcvalue = totalData[event_size-1];\r
-            \r
-            memcpy(&packdataLen,totalData+3,4);\r
-            recvData = malloc(packdataLen);\r
-            memcpy(recvData,totalData+17,packdataLen);\r
-            printf("recv crcvalue:%x packdataLen-1:%d\r\n",crcvalue,packdataLen);\r
-            type2AE3Data(cmd,recvData,packdataLen,totalData,crcvalue);\r
-            if(recvData != NULL)\r
-            {\r
-                free(recvData);\r
-            }\r
-        }\r
-    }else if(data2ae4Cmd == handle)//长数据接收\r
+    if(1)//长数据接收\r
     {\r
         while (1)\r
         {\r
@@ -4688,8 +4691,16 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle)
             {\r
                 //每包的数据长度 如果当前报数的数据小于总的数据包数时认为就发送完成,没有就还有继续接收\r
                 // packdataLen = packdataLen+event_size-18;//  减掉18个数据 0+517 730总的数据长度 517还是小于730 说明还有数据没有接收完成 继续接收\r
-                if(event_size >= 17)\r
+                if(event_size >= 17)//第一包的数据必须大于17个字节\r
                 {\r
+                    if(bigDataBuf != NULL){\r
+                        free(bigDataBuf);\r
+                        bigDataBuf = NULL;\r
+                    }\r
+                    if(recvData != NULL){\r
+                        free(recvData);\r
+                        recvData = NULL;\r
+                    }\r
                     packdataLen = event_size;//第一包的数据大小 第二包不走这里 514-17 = 497\r
                     memcpy(&totalDataLen,totalData+7,4);//总的数据大小\r
                     printf("totalDataLen;%d totaldataLen:%d",totalDataLen,packdataLen);\r
@@ -4710,7 +4721,7 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle)
                         memset(cmd_data,0,17);\r
                         memcpy(cmd_data,totalData,17);\r
                         printf("muilt totalDataLen11;%d packdataLen:%d",totalDataLen,packdataLen);\r
-                        if(totalData == 0 && event_size == 18)//数据长度为0 没数据数据包 \r
+                        if(totalDataLen == 0 && event_size == 18)//数据长度为0 没数据数据包 \r
                         {\r
                             crcvalue = totalData[event_size-1];\r
                             bleLongRecvData(NULL,0,cmd_data,totalData,crcvalue);\r
@@ -4723,6 +4734,7 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle)
                                 bleLongRecvData(recvData,packdataLen-1,cmd_data,totalData,crcvalue);\r
                                 if(recvData != NULL){\r
                                     free(recvData);\r
+                                    recvData = NULL;\r
                                 }\r
                                 packdataLen = 0;\r
                             }\r
@@ -4749,9 +4761,11 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle)
                     totalpack = 0; \r
                     if(bigDataBuf != NULL){\r
                         free(bigDataBuf);\r
+                        bigDataBuf = NULL;\r
                     }\r
                     if(recvData != NULL){\r
                         free(recvData);\r
+                        recvData = NULL;\r
                     }\r
                     break;\r
                 }else{\r
@@ -4762,90 +4776,6 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle)
             \r
         }\r
     }\r
-    else if(data2ae1Cmd == handle)//安卓消息特征Hhandle\r
-    {\r
-        \r
-        while (1)\r
-        {\r
-            printf("ancs!!!!!!!!!");\r
-            if(ANCSBigBufFlag == 0)\r
-            {\r
-                if(event_size >= 17)\r
-                {\r
-                    packdataLen = event_size;//第一包的数据大小 第二包不走这里 514-17 = 497\r
-                    memcpy(&totalDataLen,totalData+7,4);//总的数据大小\r
-                    printf("ancs totalDataLen;%d totaldataLen:%d",totalDataLen,packdataLen);\r
-                    if(totalDataLen > event_size-18)//如果514-18 = 496 497 > 496 \r
-                    {\r
-                        printf("ancs totalDataLen;%d packdataLen:%d",totalDataLen,packdataLen);\r
-\r
-                        recvData = malloc(totalDataLen+18);\r
-                        if(recvData == NULL)return;\r
-                        ANCSBigBufFlag = 1;//表示有两包以上的数据\r
-                        memcpy(recvData,totalData,event_size);//从第十七个字节开始接收数据data\r
-                        memset(cmd_data,0,17);\r
-                        memcpy(cmd_data,totalData,17);\r
-                        totalpack=1;\r
-                        break;\r
-                    }else{//直接发送数据解析\r
-                        printf("ancs totalDataLen11;%d packdataLen:%d",totalDataLen,packdataLen);\r
-                        packdataLen = event_size-17;\r
-                        memset(cmd_data,0,17);\r
-                        memcpy(cmd_data,totalData,17);\r
-\r
-                        // 73 2 10 1 0 0 0 16 0 0 0 1 0 0 0 16 0\r
-                        recvData = malloc(packdataLen-1);\r
-                        if(recvData == NULL)return;\r
-                        memcpy(recvData,totalData+17,packdataLen-1);\r
-                        if(totalDataLen == 0){\r
-                            crcvalue = 0x00;\r
-                        }else{\r
-                            crcvalue = totalData[event_size-1];\r
-                        }\r
-                        \r
-                        bleRecvANCSData(recvData,packdataLen-1,cmd_data,totalData,crcvalue);\r
-                        if(recvData != NULL){\r
-                            free(recvData);\r
-                        }\r
-                        packdataLen = 0;\r
-                        break;\r
-                    }\r
-                }\r
-                break;\r
-                \r
-            }else//这是接收两包以上的数据\r
-            {\r
-                totalpack+=1;//包数\r
-                printf("ancs 122222;%d packdataLen:%d",totalDataLen,packdataLen);\r
-                memcpy(recvData+packdataLen,totalData,event_size); //先copy再加\r
-                packdataLen = packdataLen+event_size;\r
-                printf("ancs 133333;%d packdataLen:%d",totalDataLen,packdataLen);\r
-                if(totalDataLen >= (packdataLen-18))//总的数据包 packdataLen-18把前面17个字节的包头和一个字节的校验和去掉得到数据部分和校验和部分\r
-                {\r
-                    bigDataBuf = malloc(totalDataLen);\r
-                    crcvalue = totalData[event_size-1];\r
-                    memcpy(bigDataBuf,recvData+17,totalDataLen);\r
-                    bleRecvANCSData(bigDataBuf,totalDataLen,cmd_data,recvData,crcvalue);\r
-                    totalDataLen = 0;\r
-                    packdataLen = 0;\r
-                    ANCSBigBufFlag = 0;\r
-                    totalpack = 0; \r
-                    if(bigDataBuf != NULL){\r
-                        free(bigDataBuf);\r
-                    }\r
-                    if(recvData != NULL){\r
-                        free(recvData);\r
-                    }\r
-                    break;\r
-                }else{\r
-\r
-                    break;\r
-                }\r
-            }\r
-            \r
-        }\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xhandle %d,%d %d",data2ae3Cmd,data2ae4Cmd,handle);\r
-    }\r
     if(Bleconnect == false)//断开蓝牙不接收数据\r
     {\r
         totalpack = 0;\r
@@ -4857,9 +4787,11 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle)
         sendbigDataBufState = false;\r
         if(bigDataBuf != NULL){\r
             free(bigDataBuf);\r
+            bigDataBuf = NULL;\r
         }\r
         if(recvData != NULL){\r
             free(recvData);\r
+            recvData = NULL;\r
         }\r
     }\r
 }\r
@@ -4874,9 +4806,11 @@ void free_ble_data(void)//以防断开蓝牙没有释放数据类型
     sendbigDataBufState = false;\r
     if(bigDataBuf != NULL){\r
         free(bigDataBuf);\r
+        bigDataBuf = NULL;\r
     }\r
     if(recvData != NULL){\r
         free(recvData);\r
+        recvData = NULL;\r
     }\r
 }\r
 //接收app下发的原始数据 \r
index 8d818dc..7a2cb60 100644 (file)
@@ -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);
index b271550..b5b3924 100644 (file)
@@ -146,7 +146,7 @@ static void svr_ble_adv_data_set(int adv_id)
     uint8_t scan_data_len = 0;\r
     uint8_t ble_data_name[BLE_ADV_BLE_NAME_MAX_LENGTH + 1 ] = {0}; // +TYPE LENGTH\r
     uint8_t ble_data_mac_switch[BD_ADDR_LEN] = {0};\r
-    uint8_t adv_mac_head[BLE_ADV_MAC_LENTH] = {0x9, 0x16, 0xe0, 0x18};\r
+    uint8_t adv_mac_head[BLE_ADV_MAC_LENTH] = {0x9, 0x16, 0x02, 0x38};\r
     gap_ble_config_adv_data_t adv_data_info;\r
     memset_s(&adv_data_info, sizeof(gap_ble_config_adv_data_t), 0, sizeof(gap_ble_config_adv_data_t));\r
     unsigned char addr[BLE_MAC_MAX_LEN] = {0};\r
@@ -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;\r
     if (GAP_BLE_STATE_DISCONNECTED == conn_state) { // restart ble adv when disconnected\r
         Bleconnect = GAP_BLE_STATE_DISCONNECTED;//蓝牙已断开\r
-        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());\r
+        // 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());\r
         // if(AdverFlag == true){\r
-\r
+            free_ble_data();\r
             #ifdef BLE_CHANGE_MODE\r
             svr_ble_adv_start();\r
             #else\r
@@ -304,7 +304,7 @@ static void svr_ble_connstate_change_cb(unsigned short conn_id, bd_addr_t *addr,
             }\r
             \r
             #endif\r
-            free_ble_data();\r
+            \r
         // }    \r
     } else {\r
         devpair_state = 0;//\r
@@ -815,15 +815,25 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t
 \r
     if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data1))\r
     {\r
-        g_ble_server_handle = result->value_handle;\r
-        data2ae5Cmd = result->value_handle;\r
+        if(g_ble_server_handle == 0)\r
+        {\r
+            g_ble_server_handle = result->value_handle;\r
+        }\r
+        if(data2ae5Cmd == 0){\r
+            data2ae5Cmd = result->value_handle;\r
+        }\r
+        \r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " 2ae5 result->value_handle1  %d\r\n",result->value_handle);\r
     }\r
     \r
     if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data2))\r
     {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae3 result->value_handle2  %d\r\n",result->value_handle);\r
-        data2ae3Cmd = result->value_handle;\r
+        if(data2ae3Cmd == 0)\r
+        {\r
+            data2ae3Cmd = result->value_handle;\r
+        }\r
+            \r
     }\r
     \r
     if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data4))\r
@@ -833,7 +843,11 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t
     }\r
     if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data5))\r
     {\r
-        data2ae1Cmd = result->value_handle;\r
+        if(data2ae3Cmd == 0)\r
+        {\r
+            data2ae1Cmd = result->value_handle;\r
+        }\r
+        // data2ae1Cmd = result->value_handle;\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae1 result->value_handle5  %d\r\n",result->value_handle);\r
         // shortCmdChara = result->value_handle;\r
     }\r
@@ -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))\r
     {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae4 result->value_handle3  %d\r\n",result->value_handle);\r
-        data2ae4Cmd = result->value_handle;\r
+        if(data2ae4Cmd == 0)\r
+        {\r
+            data2ae4Cmd = result->value_handle;\r
+        }\r
+        //  = result->value_handle;\r
     }\r
     if (ble_gatts_cmp_uuid(uuid, &hid_report_uuid) == true) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "result->hid_report_uuid  %d\r\n",result->value_handle);\r
index 81f9b4c..437b5a2 100755 (executable)
@@ -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},
index e54ec84..b5fa022 100644 (file)
@@ -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)\r
 {\r
     printf("g_factory_notify_report_att_hdl: 0x%X\r\n",srvc_handle);\r
-    g_factory_notify_report_att_hdl = srvc_handle;\r
+    if(g_factory_notify_report_att_hdl == 0){\r
+        g_factory_notify_report_att_hdl = srvc_handle;\r
+    }\r
 }\r
 void ble_factorytest_store_recv_handle(uint16_t srvc_handle)\r
 {\r
     printf("factory_ate_write_handl : 0x%X\r\n",srvc_handle);\r
-    factory_ate_write_handl = srvc_handle;\r
+    if(factory_ate_write_handl == 0)\r
+    {\r
+        factory_ate_write_handl = srvc_handle;\r
+    }\r
+    \r
 }\r
 \r
 uint32_t get_factory_ate_write_handl(void)\r
@@ -188,12 +194,19 @@ uint32_t get_factory_ate_write_handl(void)
 void ble_factorytest_store_ota_report_handle(uint16_t srvc_handle)\r
 {\r
     printf("g_factory_ota_report_hdl: 0x%X\r\n",srvc_handle);\r
-    g_factory_ota_report_hdl = srvc_handle;\r
+    if(g_factory_ota_report_hdl == 0)\r
+    {\r
+        g_factory_ota_report_hdl = srvc_handle;\r
+    }\r
 }\r
 void ble_factorytest_store_ota_recv_handle(uint16_t srvc_handle)\r
 {\r
     printf("factory_ota_write_handl : 0x%X\r\n",srvc_handle);\r
-    factory_ota_write_handl = srvc_handle;\r
+    if(factory_ota_write_handl == 0)\r
+    {\r
+        factory_ota_write_handl = srvc_handle;\r
+    }\r
+    \r
 }\r
 uint32_t get_factory_ota_write_handl(void)\r
 {\r
index 13093c1..df9c58b 100644 (file)
@@ -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};
+        
     };
 
 }
index 476463e..cb4a651 100644 (file)
@@ -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},
index 9226f70..24ba5cf 100644 (file)
@@ -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;
 
index 105d8b8..7c15265 100644 (file)
@@ -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)\r
 {\r
     printf("g_ppgtest_notify_report_att_hdl: 0x%X\r\n",srvc_handle);\r
-    g_ppgtest_notify_report_att_hdl = srvc_handle;\r
+    if(g_ppgtest_notify_report_att_hdl == 0)\r
+    {\r
+        g_ppgtest_notify_report_att_hdl = srvc_handle;\r
+    }\r
+    \r
 }\r
 \r
 void ble_ppgtest_add_characters_and_descriptors(uint8_t server_id, uint16_t srvc_handle)\r