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 2020/03/20 09:51:11 UTC

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

prasad-alatkar opened a new pull request #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777
 
 
   Added `ble_gap_reset_master_slave_states` to clear advertising and discovery states when `ble_hs_reset` is called.

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-601619928
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-604507286
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-603327058
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-603856849
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-601619928
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-603425856
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] prasad-alatkar edited a comment on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
prasad-alatkar edited a comment on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-601681014
 
 
   @sjanc @rymanluk @ccollins476ad  PTAL

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-603856849
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-601703747
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-604458440
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-603425856
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-604458440
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-604382239
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-603327058
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-602703331
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### nimble/host/src/ble_gap.c
   <details>
   
   ```diff
   @@ -244,42 +244,42 @@
    
    STATS_SECT_DECL(ble_gap_stats) ble_gap_stats;
    STATS_NAME_START(ble_gap_stats)
   -    STATS_NAME(ble_gap_stats, wl_set)
   -    STATS_NAME(ble_gap_stats, wl_set_fail)
   -    STATS_NAME(ble_gap_stats, adv_stop)
   -    STATS_NAME(ble_gap_stats, adv_stop_fail)
   -    STATS_NAME(ble_gap_stats, adv_start)
   -    STATS_NAME(ble_gap_stats, adv_start_fail)
   -    STATS_NAME(ble_gap_stats, adv_set_data)
   -    STATS_NAME(ble_gap_stats, adv_set_data_fail)
   -    STATS_NAME(ble_gap_stats, adv_rsp_set_data)
   -    STATS_NAME(ble_gap_stats, adv_rsp_set_data_fail)
   -    STATS_NAME(ble_gap_stats, discover)
   -    STATS_NAME(ble_gap_stats, discover_fail)
   -    STATS_NAME(ble_gap_stats, initiate)
   -    STATS_NAME(ble_gap_stats, initiate_fail)
   -    STATS_NAME(ble_gap_stats, terminate)
   -    STATS_NAME(ble_gap_stats, terminate_fail)
   -    STATS_NAME(ble_gap_stats, cancel)
   -    STATS_NAME(ble_gap_stats, cancel_fail)
   -    STATS_NAME(ble_gap_stats, update)
   -    STATS_NAME(ble_gap_stats, update_fail)
   -    STATS_NAME(ble_gap_stats, connect_mst)
   -    STATS_NAME(ble_gap_stats, connect_slv)
   -    STATS_NAME(ble_gap_stats, disconnect)
   -    STATS_NAME(ble_gap_stats, rx_disconnect)
   -    STATS_NAME(ble_gap_stats, rx_update_complete)
   -    STATS_NAME(ble_gap_stats, rx_adv_report)
   -    STATS_NAME(ble_gap_stats, rx_conn_complete)
   -    STATS_NAME(ble_gap_stats, discover_cancel)
   -    STATS_NAME(ble_gap_stats, discover_cancel_fail)
   -    STATS_NAME(ble_gap_stats, security_initiate)
   -    STATS_NAME(ble_gap_stats, security_initiate_fail)
   +STATS_NAME(ble_gap_stats, wl_set)
   +STATS_NAME(ble_gap_stats, wl_set_fail)
   +STATS_NAME(ble_gap_stats, adv_stop)
   +STATS_NAME(ble_gap_stats, adv_stop_fail)
   +STATS_NAME(ble_gap_stats, adv_start)
   +STATS_NAME(ble_gap_stats, adv_start_fail)
   +STATS_NAME(ble_gap_stats, adv_set_data)
   +STATS_NAME(ble_gap_stats, adv_set_data_fail)
   +STATS_NAME(ble_gap_stats, adv_rsp_set_data)
   +STATS_NAME(ble_gap_stats, adv_rsp_set_data_fail)
   +STATS_NAME(ble_gap_stats, discover)
   +STATS_NAME(ble_gap_stats, discover_fail)
   +STATS_NAME(ble_gap_stats, initiate)
   +STATS_NAME(ble_gap_stats, initiate_fail)
   +STATS_NAME(ble_gap_stats, terminate)
   +STATS_NAME(ble_gap_stats, terminate_fail)
   +STATS_NAME(ble_gap_stats, cancel)
   +STATS_NAME(ble_gap_stats, cancel_fail)
   +STATS_NAME(ble_gap_stats, update)
   +STATS_NAME(ble_gap_stats, update_fail)
   +STATS_NAME(ble_gap_stats, connect_mst)
   +STATS_NAME(ble_gap_stats, connect_slv)
   +STATS_NAME(ble_gap_stats, disconnect)
   +STATS_NAME(ble_gap_stats, rx_disconnect)
   +STATS_NAME(ble_gap_stats, rx_update_complete)
   +STATS_NAME(ble_gap_stats, rx_adv_report)
   +STATS_NAME(ble_gap_stats, rx_conn_complete)
   +STATS_NAME(ble_gap_stats, discover_cancel)
   +STATS_NAME(ble_gap_stats, discover_cancel_fail)
   +STATS_NAME(ble_gap_stats, security_initiate)
   +STATS_NAME(ble_gap_stats, security_initiate_fail)
    STATS_NAME_END(ble_gap_stats)
    
    /*****************************************************************************
   - * $debug                                                                    *
   - *****************************************************************************/
   +* $debug                                                                    *
   +*****************************************************************************/
    
    #if MYNEWT_VAL(BLE_HS_DEBUG)
    int
   ```
   
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-601703747
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

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

Posted by GitBox <gi...@apache.org>.
rymanluk merged pull request #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777
 
 
   

----------------------------------------------------------------
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:
users@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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] prasad-alatkar commented on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
prasad-alatkar commented on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-601681014
 
 
   @sjanc @rymanluk @christ PTAL

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-602703331
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### nimble/host/src/ble_gap.c
   <details>
   
   ```diff
   @@ -244,42 +244,42 @@
    
    STATS_SECT_DECL(ble_gap_stats) ble_gap_stats;
    STATS_NAME_START(ble_gap_stats)
   -    STATS_NAME(ble_gap_stats, wl_set)
   -    STATS_NAME(ble_gap_stats, wl_set_fail)
   -    STATS_NAME(ble_gap_stats, adv_stop)
   -    STATS_NAME(ble_gap_stats, adv_stop_fail)
   -    STATS_NAME(ble_gap_stats, adv_start)
   -    STATS_NAME(ble_gap_stats, adv_start_fail)
   -    STATS_NAME(ble_gap_stats, adv_set_data)
   -    STATS_NAME(ble_gap_stats, adv_set_data_fail)
   -    STATS_NAME(ble_gap_stats, adv_rsp_set_data)
   -    STATS_NAME(ble_gap_stats, adv_rsp_set_data_fail)
   -    STATS_NAME(ble_gap_stats, discover)
   -    STATS_NAME(ble_gap_stats, discover_fail)
   -    STATS_NAME(ble_gap_stats, initiate)
   -    STATS_NAME(ble_gap_stats, initiate_fail)
   -    STATS_NAME(ble_gap_stats, terminate)
   -    STATS_NAME(ble_gap_stats, terminate_fail)
   -    STATS_NAME(ble_gap_stats, cancel)
   -    STATS_NAME(ble_gap_stats, cancel_fail)
   -    STATS_NAME(ble_gap_stats, update)
   -    STATS_NAME(ble_gap_stats, update_fail)
   -    STATS_NAME(ble_gap_stats, connect_mst)
   -    STATS_NAME(ble_gap_stats, connect_slv)
   -    STATS_NAME(ble_gap_stats, disconnect)
   -    STATS_NAME(ble_gap_stats, rx_disconnect)
   -    STATS_NAME(ble_gap_stats, rx_update_complete)
   -    STATS_NAME(ble_gap_stats, rx_adv_report)
   -    STATS_NAME(ble_gap_stats, rx_conn_complete)
   -    STATS_NAME(ble_gap_stats, discover_cancel)
   -    STATS_NAME(ble_gap_stats, discover_cancel_fail)
   -    STATS_NAME(ble_gap_stats, security_initiate)
   -    STATS_NAME(ble_gap_stats, security_initiate_fail)
   +STATS_NAME(ble_gap_stats, wl_set)
   +STATS_NAME(ble_gap_stats, wl_set_fail)
   +STATS_NAME(ble_gap_stats, adv_stop)
   +STATS_NAME(ble_gap_stats, adv_stop_fail)
   +STATS_NAME(ble_gap_stats, adv_start)
   +STATS_NAME(ble_gap_stats, adv_start_fail)
   +STATS_NAME(ble_gap_stats, adv_set_data)
   +STATS_NAME(ble_gap_stats, adv_set_data_fail)
   +STATS_NAME(ble_gap_stats, adv_rsp_set_data)
   +STATS_NAME(ble_gap_stats, adv_rsp_set_data_fail)
   +STATS_NAME(ble_gap_stats, discover)
   +STATS_NAME(ble_gap_stats, discover_fail)
   +STATS_NAME(ble_gap_stats, initiate)
   +STATS_NAME(ble_gap_stats, initiate_fail)
   +STATS_NAME(ble_gap_stats, terminate)
   +STATS_NAME(ble_gap_stats, terminate_fail)
   +STATS_NAME(ble_gap_stats, cancel)
   +STATS_NAME(ble_gap_stats, cancel_fail)
   +STATS_NAME(ble_gap_stats, update)
   +STATS_NAME(ble_gap_stats, update_fail)
   +STATS_NAME(ble_gap_stats, connect_mst)
   +STATS_NAME(ble_gap_stats, connect_slv)
   +STATS_NAME(ble_gap_stats, disconnect)
   +STATS_NAME(ble_gap_stats, rx_disconnect)
   +STATS_NAME(ble_gap_stats, rx_update_complete)
   +STATS_NAME(ble_gap_stats, rx_adv_report)
   +STATS_NAME(ble_gap_stats, rx_conn_complete)
   +STATS_NAME(ble_gap_stats, discover_cancel)
   +STATS_NAME(ble_gap_stats, discover_cancel_fail)
   +STATS_NAME(ble_gap_stats, security_initiate)
   +STATS_NAME(ble_gap_stats, security_initiate_fail)
    STATS_NAME_END(ble_gap_stats)
    
    /*****************************************************************************
   - * $debug                                                                    *
   - *****************************************************************************/
   +* $debug                                                                    *
   +*****************************************************************************/
    
    #if MYNEWT_VAL(BLE_HS_DEBUG)
    int
   ```
   
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #777: nimble/host: Clear master and slave states on host reset
URL: https://github.com/apache/mynewt-nimble/pull/777#issuecomment-604382239
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services