浏览代码

Nimble:Re-run ext adv after completion

Kevin Evans 3 年之前
父节点
当前提交
22e7f02ba3
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      examples/bluetooth/nimble/bleprph/main/main.c

+ 8 - 2
examples/bluetooth/nimble/bleprph/main/main.c

@@ -89,9 +89,13 @@ ext_bleprph_advertise(void)
 {
     struct ble_gap_ext_adv_params params;
     struct os_mbuf *data;
-    uint8_t instance = 1;
+    uint8_t instance = 0;
     int rc;
 
+    /* First check if any instance is already active */
+    if(ble_gap_adv_active())
+        return;
+
     /* use defaults for non-set params */
     memset (&params, 0, sizeof(params));
 
@@ -324,7 +328,9 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
     case BLE_GAP_EVENT_ADV_COMPLETE:
         MODLOG_DFLT(INFO, "advertise complete; reason=%d",
                     event->adv_complete.reason);
-#if !CONFIG_EXAMPLE_EXTENDED_ADV
+#if CONFIG_EXAMPLE_EXTENDED_ADV
+        ext_bleprph_advertise();
+#else
         bleprph_advertise();
 #endif
         return 0;