[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-26 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r398384871
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -1237,6 +1243,46 @@ ble_gap_adv_active_instance(uint8_t instance)
 return ble_gap_slave[instance].op == BLE_GAP_OP_S_ADV;
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_reset_state(int reason)
+{
+uint16_t conn_handle;
+
+while (1) {
+conn_handle = ble_hs_atomic_first_conn_handle();
+if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
+break;
+}
+
+ble_gap_conn_broken(conn_handle, reason);
+}
+
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+if (ble_gap_adv_active_instance(i)) {
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(i, reason, 0, 0);
+}
+}
+#else
+if (ble_gap_adv_active_instance(0)) {
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(0, reason, 0, 0);
+}
+#endif
+#endif
+
+#if NIMBLE_BLE_SCAN
 
 Review comment:
   #if( NIMBLE_BLE_SCAN || NIMBLE_BLE_CONNECT) ?


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-26 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r398386305
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -1034,6 +1034,12 @@ ble_gap_master_failed(int status)
 ble_gap_master_connect_failure(status);
 break;
 
+case BLE_GAP_OP_M_DISC:
+STATS_INC(ble_gap_stats, initiate_fail);
+ble_gap_disc_complete();
+ble_gap_master_reset_state();
 
 Review comment:
   BTW - just noticed that above `ble_gap_master_failed(int status)` there is 
#if NIMBLE_BLE_CONNECT
   
   I believe we need this #if inside that function. Also #if NIMBLE_BLE_SCAN 
should be there.


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-26 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r398385475
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -1034,6 +1034,12 @@ ble_gap_master_failed(int status)
 ble_gap_master_connect_failure(status);
 break;
 
+case BLE_GAP_OP_M_DISC:
+STATS_INC(ble_gap_stats, initiate_fail);
+ble_gap_disc_complete();
+ble_gap_master_reset_state();
 
 Review comment:
   could you double check if ` ble_gap_master_reset_state();` we need only for 
`BLE_GAP_OP_M_DISC:` and not for `BLE_GAP_OP_M_CONN' ?


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-25 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r397813313
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -1237,6 +1237,53 @@ ble_gap_adv_active_instance(uint8_t instance)
 return ble_gap_slave[instance].op == BLE_GAP_OP_S_ADV;
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_reset_state(int reason)
+{
+uint16_t conn_handle;
+
+while (1) {
+conn_handle = ble_hs_atomic_first_conn_handle();
+if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
+break;
+}
+
+ble_gap_conn_broken(conn_handle, reason);
+}
+
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+if (ble_gap_adv_active_instance(i)) {
+ble_gap_slave_reset_state(i);
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(i, reason, 0, 0);
+}
+}
+#else
+if (ble_gap_adv_active_instance(0)) {
+ble_gap_slave_reset_state(0);
 
 Review comment:
   I don't think we need to call that as this is called later in 
`ble_gap_adv_finished() 
->ble_gap_slave_extract_cb()->ble_gap_slave_reset_state()`


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-25 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r397811581
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -1237,6 +1237,53 @@ ble_gap_adv_active_instance(uint8_t instance)
 return ble_gap_slave[instance].op == BLE_GAP_OP_S_ADV;
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_reset_state(int reason)
+{
+uint16_t conn_handle;
+
+while (1) {
+conn_handle = ble_hs_atomic_first_conn_handle();
+if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
+break;
+}
+
+ble_gap_conn_broken(conn_handle, reason);
+}
+
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+if (ble_gap_adv_active_instance(i)) {
+ble_gap_slave_reset_state(i);
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(i, reason, 0, 0);
+}
+}
+#else
+if (ble_gap_adv_active_instance(0)) {
+ble_gap_slave_reset_state(0);
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(0, reason, 0, 0);
+}
+#endif
+#endif
+
+#if NIMBLE_BLE_SCAN
+ble_gap_master_reset_state();
+if (ble_gap_disc_active()) {
+ble_gap_disc_complete();
+} else if (ble_gap_conn_active()) {
+ble_gap_master_failed(reason);
 
 Review comment:
   hmm when you look inside ` ble_gap_master_failed`  function, there is a 
switch.  Maybe it is worth to add there case for `BLE_GAP_OP_M_DISC` and then 
call that function? I would also add there `ble_gap_master_reset_state()`


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-25 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r397814492
 
 

 ##
 File path: nimble/host/src/ble_hs.c
 ##
 @@ -376,18 +375,12 @@ ble_hs_reset(void)
 
 ble_hs_clear_rx_queue();
 
-while (1) {
-conn_handle = ble_hs_atomic_first_conn_handle();
-if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
-break;
-}
-
-ble_gap_conn_broken(conn_handle, ble_hs_reset_reason);
-}
-
 /* Clear configured addresses. */
 ble_hs_id_reset();
 
+/* Clear adverising and scanning states. */
+ble_gap_reset_state(ble_hs_reset_reason);
 
 Review comment:
   I would call it before the `ble_hs_id_reset()`. It probably will change 
nothing, but since before we were calling `ble_gap_conn_broken()` before that I 
don't see a reason to change that.
   
   


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-25 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r397813459
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -1237,6 +1237,53 @@ ble_gap_adv_active_instance(uint8_t instance)
 return ble_gap_slave[instance].op == BLE_GAP_OP_S_ADV;
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_reset_state(int reason)
+{
+uint16_t conn_handle;
+
+while (1) {
+conn_handle = ble_hs_atomic_first_conn_handle();
+if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
+break;
+}
+
+ble_gap_conn_broken(conn_handle, reason);
+}
+
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+if (ble_gap_adv_active_instance(i)) {
+ble_gap_slave_reset_state(i);
 
 Review comment:
   I don't think we need to call that as this is called later in 
ble_gap_adv_finished() ->ble_gap_slave_extract_cb()->ble_gap_slave_reset_state()


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-25 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r397808408
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -1237,6 +1237,53 @@ ble_gap_adv_active_instance(uint8_t instance)
 return ble_gap_slave[instance].op == BLE_GAP_OP_S_ADV;
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_reset_state(int reason)
+{
+uint16_t conn_handle;
+
+while (1) {
+conn_handle = ble_hs_atomic_first_conn_handle();
+if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
+break;
+}
+
+ble_gap_conn_broken(conn_handle, reason);
+}
+
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+if (ble_gap_adv_active_instance(i)) {
+ble_gap_slave_reset_state(i);
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(i, reason, 0, 0);
+}
+}
+#else
+if (ble_gap_adv_active_instance(0)) {
+ble_gap_slave_reset_state(0);
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(0, reason, 0, 0);
+}
+#endif
+#endif
+
+#if NIMBLE_BLE_SCAN
+ble_gap_master_reset_state();
 
 Review comment:
   this will reset state before we check it below


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-24 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r397004577
 
 

 ##
 File path: nimble/host/src/ble_hs.c
 ##
 @@ -388,6 +388,13 @@ ble_hs_reset(void)
 /* Clear configured addresses. */
 ble_hs_id_reset();
 
+/* Clear adverising and scanning states. */
+if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
 
 Review comment:
   we should just call `ble_gap_reset_state` with a `ble_hs_reset_reason`.  
Imho `conn_handle` at this point is always `BLE_HS_CONN_HANDLE_NONE`.
   
   BTW later I think that we can move following block
   ```
while (1) {
   
   conn_handle = ble_hs_atomic_first_conn_handle();
   if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
   break;
   }
   
   ble_gap_conn_broken(conn_handle, ble_hs_reset_reason);
   }
   ```
   to the new `ble_gap_reset_state()`
   


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-24 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r396993791
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -737,6 +748,39 @@ ble_gap_slave_reset_state(uint8_t instance)
 #endif
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_reset_state(uint16_t conn_handle, int reason)
+{
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+ble_gap_slave_reset_state(i);
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(i, reason, conn_handle, 0);
+}
+#else
+ble_gap_slave_reset_state(0);
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(0, reason, conn_handle, 0);
 
 Review comment:
   same here, we need to do in only when active.


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-24 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r396993578
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -737,6 +737,30 @@ ble_gap_slave_reset_state(uint8_t instance)
 #endif
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_master_slave_reset_state(void)
+{
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+ble_gap_slave_reset_state(i);
 
 Review comment:
   but, don't  we need to call it only for the active instances?


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-24 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r397000378
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -737,6 +748,39 @@ ble_gap_slave_reset_state(uint8_t instance)
 #endif
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_reset_state(uint16_t conn_handle, int reason)
 
 Review comment:
   I would remove `conn_handle` at all because it is not needed. I explained 
below why.


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-24 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r397000116
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -737,6 +748,39 @@ ble_gap_slave_reset_state(uint8_t instance)
 #endif
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_reset_state(uint16_t conn_handle, int reason)
+{
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+ble_gap_slave_reset_state(i);
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(i, reason, conn_handle, 0);
 
 Review comment:
   I don't think we need `conn_handle` here. It is used when advertising is 
completed because connection has been established and it is not a case here for 
sure


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-24 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r397010560
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -737,6 +737,30 @@ ble_gap_slave_reset_state(uint8_t instance)
 #endif
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_master_slave_reset_state(void)
+{
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+ble_gap_slave_reset_state(i);
+}
+#else
+ble_gap_slave_reset_state(0);
+#endif
+#endif
+
+#if NIMBLE_BLE_SCAN
+ble_gap_master_reset_state();
 
 Review comment:
   ad 2. Because application started connection procedure and is waiting for a 
result of it. 
   As the example, if device is not around and application sent Connect, host 
has internal timeout for Connection procedure. When it timeouts, then host do 
connect cancel and when connection complete arrives host is calling 
`ble_gap_master_connect_cancelled`. In our case we don't want to send connect 
cancel but we want to notify application that connection is failed. 
   


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-23 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r396301225
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -737,6 +737,30 @@ ble_gap_slave_reset_state(uint8_t instance)
 #endif
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_master_slave_reset_state(void)
+{
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+ble_gap_slave_reset_state(i);
+}
+#else
+ble_gap_slave_reset_state(0);
+#endif
+#endif
+
+#if NIMBLE_BLE_SCAN
+ble_gap_master_reset_state();
 
 Review comment:
   For the master role, imho we need bit more:
   1) when BLE_GAP_OP_M_DISC is ongoing, we need to call  
ble_gap_disc_complete()
   2) when BLE_GAP_OP_M_CONN is ongoing we probably should call 
ble_gap_master_connect_failure()


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-23 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r396291147
 
 

 ##
 File path: nimble/host/src/ble_gap_priv.h
 ##
 @@ -136,6 +136,7 @@ void ble_gap_preempt(void);
 void ble_gap_preempt_done(void);
 
 int ble_gap_terminate_with_conn(struct ble_hs_conn *conn, uint8_t hci_reason);
+void ble_gap_master_slave_reset_state(void);
 
 Review comment:
   just a nit pick - I would call it ble_gap_reset_state(void).


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


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] rymanluk commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-23 Thread GitBox
rymanluk commented on a change in pull request #777: nimble/host: Clear master 
and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#discussion_r396296255
 
 

 ##
 File path: nimble/host/src/ble_gap.c
 ##
 @@ -737,6 +737,30 @@ ble_gap_slave_reset_state(uint8_t instance)
 #endif
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_master_slave_reset_state(void)
+{
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+ble_gap_slave_reset_state(i);
 
 Review comment:
   Imho we should call ble_gap_adv_finished() as well so the app will get 
information about stopped advertising.


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


With regards,
Apache Git Services