From ae079c1fc5d990ba55714d4b3a51b19f96edaec4 Mon Sep 17 00:00:00 2001
From: WXK <287788329@qq.com>
Date: 星期四, 24 四月 2025 16:01:43 +0800
Subject: [PATCH] 改为中断来低电平触发发送当前扫描数据,3s内扫描不到的会退出,串口来55 AA 75 70 64 61 74 65,进入升级模式

---
 01_SDK/nimble/host/nimble/nimble/host/src/ble_gatts.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/01_SDK/nimble/host/nimble/nimble/host/src/ble_gatts.c b/01_SDK/nimble/host/nimble/nimble/host/src/ble_gatts.c
index 413130b..41d3f0b 100644
--- a/01_SDK/nimble/host/nimble/nimble/host/src/ble_gatts.c
+++ b/01_SDK/nimble/host/nimble/nimble/host/src/ble_gatts.c
@@ -1155,7 +1155,7 @@
 static void
 ble_gatts_free_svc_defs(void)
 {
-    free(ble_gatts_svc_defs);
+    nimble_mem_free(ble_gatts_svc_defs);
     ble_gatts_svc_defs = NULL;
     ble_gatts_num_svc_defs = 0;
 }
@@ -1163,10 +1163,10 @@
 static void
 ble_gatts_free_mem(void)
 {
-    free(ble_gatts_clt_cfg_mem);
+    nimble_mem_free(ble_gatts_clt_cfg_mem);
     ble_gatts_clt_cfg_mem = NULL;
 
-    free(ble_gatts_svc_entries);
+    nimble_mem_free(ble_gatts_svc_entries);
     ble_gatts_svc_entries = NULL;
 }
 
@@ -1196,7 +1196,7 @@
     }
 
     if (ble_hs_max_client_configs > 0) {
-        ble_gatts_clt_cfg_mem = pvPortMalloc(
+        ble_gatts_clt_cfg_mem = nimble_mem_alloc(
             OS_MEMPOOL_BYTES(ble_hs_max_client_configs,
                              sizeof (struct ble_gatts_clt_cfg)));
         if (ble_gatts_clt_cfg_mem == NULL) {
@@ -1207,7 +1207,7 @@
 
     if (ble_hs_max_services > 0) {
         ble_gatts_svc_entries =
-            pvPortMalloc(ble_hs_max_services * sizeof *ble_gatts_svc_entries);
+            nimble_mem_alloc(ble_hs_max_services * sizeof *ble_gatts_svc_entries);
         if (ble_gatts_svc_entries == NULL) {
             rc = BLE_HS_ENOMEM;
             goto done;
@@ -1962,12 +1962,24 @@
         goto done;
     }
 
+#if 1
+	p = nimble_mem_alloc((ble_gatts_num_svc_defs + 1) * sizeof *ble_gatts_svc_defs);
+    if (p == NULL) {
+        rc = BLE_HS_ENOMEM;
+        goto done;
+    }
+
+    memcpy(p, ble_gatts_svc_defs, ble_gatts_num_svc_defs * (sizeof *ble_gatts_svc_defs));
+    nimble_mem_free(ble_gatts_svc_defs);
+	
+#else
     p = realloc(ble_gatts_svc_defs,
                 (ble_gatts_num_svc_defs + 1) * sizeof *ble_gatts_svc_defs);
     if (p == NULL) {
         rc = BLE_HS_ENOMEM;
         goto done;
     }
+#endif
 
     ble_gatts_svc_defs = p;
     ble_gatts_svc_defs[ble_gatts_num_svc_defs] = svcs;

--
Gitblit v1.9.3