修复ios配对问题
authorhcj <1224667075@qq.com>
Fri, 27 Sep 2024 01:50:46 +0000 (09:50 +0800)
committerhcj <1224667075@qq.com>
Fri, 27 Sep 2024 01:50:46 +0000 (09:50 +0800)
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c

index 4e55dca..e7ddd7b 100644 (file)
@@ -712,10 +712,11 @@ void getPhoneNameLen(uint8_t *data,uint8_t *datalen,uint8_t *type)//获取手机
             printf("设备名称: %s len:%d\n", pn->valuestring,len);\r
         }\r
         cJSON* tp = cJSON_GetObjectItem(root, "tp");\r
-        if(tp && cJSON_IsNumber(pn))\r
+        if(tp && cJSON_IsNumber(tp))\r
         {\r
             *type=tp->valueint;\r
         }\r
+        printf("%d\r\n",type);\r
        \r
         cJSON* bond=cJSON_GetObjectItem(root, "bond");\r
         if(bond)\r
@@ -2800,18 +2801,15 @@ bool bin_Check_schedule(uint8_t *data,uint16_t len)
 {\r
     uint16 offset=0;\r
     uint16 buf_len=0;\r
-    // for(int i=0;i<len;i++)\r
-    // {\r
-    //     printf(" %02X",data[i]);\r
-    // }\r
-    // printf("\r\n");\r
     while (offset<len)\r
     {\r
-        uint8_t id;\r
-        id=data[offset]+data[offset+1];\r
+        uint16_t id;\r
+        memcpy_s(&id,2,&data[offset],2);\r
         offset+=2;\r
         if(offset>=len)\r
-        break;\r
+        {\r
+            break;\r
+        }\r
 \r
         memcpy_s(&buf_len,2,&data[offset],2);\r
         offset+=2;\r
@@ -2821,9 +2819,10 @@ bool bin_Check_schedule(uint8_t *data,uint16_t len)
         char *title=(char*)malloc(buf_len+1);\r
         memset_s(title,512,0,buf_len+1);\r
         memcpy_s(title,512,&data[offset],buf_len);\r
-        //printf("len:%d str %s\r\n",buf_len,title);\r
+        printf("len:%d str %s\r\n",buf_len,title);\r
 \r
         offset+=buf_len;\r
+\r
         if(offset>=len)\r
         {\r
             if(title)\r
@@ -2862,6 +2861,10 @@ bool bin_Check_schedule(uint8_t *data,uint16_t len)
         }\r
         if(offset>=len)\r
         {\r
+            if(title)\r
+            {\r
+                free(title);\r
+            }\r
             break;\r
         }\r
        \r