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/19 18:43:44 UTC

[GitHub] ccollins476ad commented on a change in pull request #216: Allow the host to be stopped and started again

ccollins476ad commented on a change in pull request #216: Allow the host to be stopped and started again
URL: https://github.com/apache/mynewt-nimble/pull/216#discussion_r234735925
 
 

 ##########
 File path: nimble/host/src/ble_gap.c
 ##########
 @@ -4643,13 +4648,47 @@ ble_gap_preempt(void)
         ble_gap_master.preempted_op = BLE_GAP_OP_M_DISC;
     }
 #endif
+}
+
+/**
+ * Aborts all active GAP procedures and prevents new ones from being started.
+ * This function is used to ensure an idle GAP so that the controller's
+ * resolving list can be modified.  When done accessing the resolving list, the
+ * caller must call `ble_gap_preempt_done()` to permit new GAP procedures.
+ *
+ * On preemption, all aborted GAP procedures are reported with a status or
+ * reason code of BLE_HS_EPREEMPTED.  An attempt to initiate a new GAP
+ * procedure during preemption fails with a return code of BLE_HS_EPREEMPTED.
+ */
+void
+ble_gap_preempt(void)
+{
+    ble_hs_lock();
+
+    BLE_HS_DBG_ASSERT(!ble_gap_is_preempted());
+    ble_gap_preempt_no_lock();
+
+    ble_hs_unlock();
+}
+
+/**
+ * Preempts the GAP if it is not already preempted.
+ */
+void
+ble_gap_ensure_preempted(void)
+{
+    ble_hs_lock();
+
+    if (!ble_gap_is_preempted()) {
 
 Review comment:
   I was actually wondering the same thing.  I don't see any need for both functions.  I have combined the two and named it `ble_gap_preempt()`.

----------------------------------------------------------------
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