You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/11/14 00:07:27 UTC

[GitHub] ccollins476ad closed pull request #236: nimble/host: Allow auto-start to be disabled

ccollins476ad closed pull request #236: nimble/host: Allow auto-start to be disabled
URL: https://github.com/apache/mynewt-nimble/pull/236
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/nimble/host/include/host/ble_hs.h b/nimble/host/include/host/ble_hs.h
index 896d1d00..192fdefd 100644
--- a/nimble/host/include/host/ble_hs.h
+++ b/nimble/host/include/host/ble_hs.h
@@ -311,6 +311,18 @@ int ble_hs_synced(void);
  */
 int ble_hs_start(void);
 
+/**
+ * Enqueues a host start event to the default event queue.  The actual host
+ * startup is performed in the host parent task, but using the default queue
+ * here ensures the event won't run until the end of main() when this is
+ * called during system initialization.  This allows the application to
+ * configure the host package in the meantime.
+ *
+ * If auto-start is disabled, the application should use this function to start
+ * the BLE stack.
+ */
+void ble_hs_sched_start(void);
+
 /**
  * Causes the host to reset the NimBLE stack as soon as possible.  The
  * application is notified when the reset occurs via the host reset callback.
diff --git a/nimble/host/src/ble_hs.c b/nimble/host/src/ble_hs.c
index 917781f5..1718c982 100644
--- a/nimble/host/src/ble_hs.c
+++ b/nimble/host/src/ble_hs.c
@@ -455,6 +455,17 @@ ble_hs_timer_resched(void)
      */
     ble_hs_timer_reset(0);
 }
+ 
+void
+ble_hs_sched_start(void)
+{
+#ifdef MYNEWT
+    ble_npl_eventq_put((struct ble_npl_eventq *)os_eventq_dflt_get(),
+                       &ble_hs_ev_start);
+#else
+    ble_npl_eventq_put(nimble_port_get_dflt_eventq(), &ble_hs_ev_start);
+#endif
+}
 
 static void
 ble_hs_event_rx_hci_ev(struct ble_npl_event *ev)
@@ -698,11 +709,14 @@ ble_hs_init(void)
      * queue ensures the event won't run until the end of main().  This allows
      * the application to configure this package in the meantime.
      */
+#if MYNEWT_VAL(BLE_HS_AUTO_START)
 #ifdef MYNEWT
-    ble_npl_eventq_put((struct ble_npl_eventq *)os_eventq_dflt_get(), &ble_hs_ev_start);
+    ble_npl_eventq_put((struct ble_npl_eventq *)os_eventq_dflt_get(),
+                       &ble_hs_ev_start);
 #else
     ble_npl_eventq_put(nimble_port_get_dflt_eventq(), &ble_hs_ev_start);
 #endif
+#endif
 
 #if BLE_MONITOR
     ble_monitor_new_index(0, (uint8_t[6]){ }, "nimble0");
diff --git a/nimble/host/syscfg.yml b/nimble/host/syscfg.yml
index 7cd8e61e..90a61c19 100644
--- a/nimble/host/syscfg.yml
+++ b/nimble/host/syscfg.yml
@@ -21,6 +21,12 @@ syscfg.defs:
         description: 'Indicates that a BLE host is present.'
         value: 1
 
+    BLE_HS_AUTO_START:
+        description: >
+                Causes the BLE host to automatically start during system
+                initialization.
+        value: 1
+
     # Debug settings.
     BLE_HS_DEBUG:
         description: 'Enables extra runtime assertions.'
diff --git a/porting/examples/linux/include/syscfg/syscfg.h b/porting/examples/linux/include/syscfg/syscfg.h
index da4dd524..244aad82 100644
--- a/porting/examples/linux/include/syscfg/syscfg.h
+++ b/porting/examples/linux/include/syscfg/syscfg.h
@@ -585,6 +585,10 @@
 #define MYNEWT_VAL_BLE_HOST (1)
 #endif
 
+#ifndef MYNEWT_VAL_BLE_HS_AUTO_START
+#define MYNEWT_VAL_BLE_HS_AUTO_START (1)
+#endif
+
 #ifndef MYNEWT_VAL_BLE_HS_DEBUG
 #define MYNEWT_VAL_BLE_HS_DEBUG (0)
 #endif
diff --git a/porting/nimble/include/syscfg/syscfg.h b/porting/nimble/include/syscfg/syscfg.h
index 8d58db96..c9b37557 100644
--- a/porting/nimble/include/syscfg/syscfg.h
+++ b/porting/nimble/include/syscfg/syscfg.h
@@ -570,6 +570,10 @@
 #define MYNEWT_VAL_BLE_HOST (1)
 #endif
 
+#ifndef MYNEWT_VAL_BLE_HS_AUTO_START
+#define MYNEWT_VAL_BLE_HS_AUTO_START (1)
+#endif
+
 #ifndef MYNEWT_VAL_BLE_HS_DEBUG
 #define MYNEWT_VAL_BLE_HS_DEBUG (0)
 #endif
diff --git a/porting/npl/riot/include/syscfg/syscfg.h b/porting/npl/riot/include/syscfg/syscfg.h
index 11985c3f..070f059d 100644
--- a/porting/npl/riot/include/syscfg/syscfg.h
+++ b/porting/npl/riot/include/syscfg/syscfg.h
@@ -777,6 +777,10 @@
 #define MYNEWT_VAL_BLE_HS_DEBUG (0)
 #endif
 
+#ifndef MYNEWT_VAL_BLE_HS_AUTO_START
+#define MYNEWT_VAL_BLE_HS_AUTO_START (1)
+#endif
+
 #ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL
 #define MYNEWT_VAL_BLE_HS_FLOW_CTRL (0)
 #endif


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services