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

2020-03-26 Thread GitBox
prasad-alatkar 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_r398626365
 
 

 ##
 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:
   Hi @rymanluk Do we really need `NIMBLE_BLE_CONNECT` here ? I mean given that 
we want to reset state of only master, I was thinking `NIMBLE_BLE_SCAN` should 
suffice.


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-26 Thread GitBox
prasad-alatkar 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_r398557210
 
 

 ##
 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:
   I think it is better if we keep `#if NIMBLE_BLE_CONNECT` or `#if 
NIMBLE_BLE_SCAN` outside of `ble_gap_master_failed` function. 


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-26 Thread GitBox
prasad-alatkar 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_r398555603
 
 

 ##
 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:
   Hi @rymanluk I am getting CI failure
   
   ```
   echo 'Building target=nordic_pca10056_bttester'
   
   Building target=nordic_pca10056_bttester
   
   +newt build -q -l info nordic_pca10056_bttester
   
   2020/03/26 11:46:51.604 [INFO] Ignoring 
/home/travis/gopath/src/github.com/apache/mynewt-nimble/repos/apache-mynewt-core/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_power.c
 because package dictates it.
   
   +rc=0
   
   +[[ 0 -ne 0 ]]
   
   +[[ 0 -eq 127 ]]
   
   +for target in '${TARGETS}'
   
   +echo 'Building target=nordic_pca10056_ext_advertiser'
   
   Building target=nordic_pca10056_ext_advertiser
   
   +newt build -q -l info nordic_pca10056_ext_advertiser
   
   2020/03/26 11:47:43.511 [INFO] Ignoring 
/home/travis/gopath/src/github.com/apache/mynewt-nimble/repos/apache-mynewt-core/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_power.c
 because package dictates it.
   
   Error: nimble/host/src/ble_gap.c:1028:1: error: 'ble_gap_master_failed' 
defined but not used [-Werror=unused-function]
   
ble_gap_master_failed(int status)
   
^
   
   cc1: all warnings being treated as errors
   
   ```


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-26 Thread GitBox
prasad-alatkar 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_r398463915
 
 

 ##
 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:
   `#if NIMBLE_BLE_CONNECT` is applied for both functions: 
`ble_gap_master_failed` & `ble_gap_update_failed`, I will make changes 
accordinly. 
   
   > I believe we need this #if inside that function. Also #if NIMBLE_BLE_SCAN 
should be there.
   
   Yes, I will make the required changes.


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-26 Thread GitBox
prasad-alatkar 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_r398392913
 
 

 ##
 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' ?
   
   For `BLE_GAP_OP_M_CONN`, `ble_gap_master_connect_failure` --> 
`ble_gap_master_extract_state` --> calls `ble_gap_master_reset_state`. So we 
need it only for `BLE_GAP_OP_M_DISC`


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-25 Thread GitBox
prasad-alatkar 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_r397868096
 
 

 ##
 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:
   sorry for that, done !!


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-25 Thread GitBox
prasad-alatkar 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_r397856732
 
 

 ##
 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:
   Ok !!


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-25 Thread GitBox
prasad-alatkar 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_r397856466
 
 

 ##
 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:
   Yes !! 


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-25 Thread GitBox
prasad-alatkar 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_r397856548
 
 

 ##
 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:
   > It probably will change nothing
   
   Had the same though in mind :smile: will make the changes.


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-25 Thread GitBox
prasad-alatkar 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_r397856412
 
 

 ##
 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:
   Yes !! 


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-24 Thread GitBox
prasad-alatkar 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_r397265344
 
 

 ##
 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:
   True.


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-24 Thread GitBox
prasad-alatkar 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_r397265064
 
 

 ##
 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:
   Makes sense :+1: 


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-24 Thread GitBox
prasad-alatkar 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_r397265292
 
 

 ##
 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:
   Done !!


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-24 Thread GitBox
prasad-alatkar 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_r397263894
 
 

 ##
 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:
   Thank you for the explanation :+1: 


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-24 Thread GitBox
prasad-alatkar 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_r397263377
 
 

 ##
 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:
   Yes, but I thought as we are anyway resetting the host stack, so resetting 
slave_state should be all right. However I understand, as far as 
`ble_gap_adv_finished` is concerned, we should only call it when actually 
active adv instance was 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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-23 Thread GitBox
prasad-alatkar 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_r396568391
 
 

 ##
 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:
   1. Yes, we should call ` ble_gap_disc_complete`, have made changes.
   2. Yes, however in `ble_hs_reset`, we also call `ble_gap_conn_broken` which 
ultimately calls GAP event `BLE_GAP_EVENT_DISCONNECT` to notify app. But I do 
understand, you want to cover the cases where  there may be `connection 
establishment procedure` and may not be any `active connection (established)`. 


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-23 Thread GitBox
prasad-alatkar 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_r396553102
 
 

 ##
 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:
   Yes, we should, have made the changes.


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] prasad-alatkar commented on a change in pull request #777: nimble/host: Clear master and slave states on host reset

2020-03-23 Thread GitBox
prasad-alatkar 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_r396552550
 
 

 ##
 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:
   Sure, but `ble_gap_reset_state` appears quite generic, doesn't it ?


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