You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2015/12/22 04:01:41 UTC

[3/4] incubator-mynewt-larva git commit: Reset FSM when the connect procedure completes.

Reset FSM when the connect procedure completes.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/36945a71
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/36945a71
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/36945a71

Branch: refs/heads/master
Commit: 36945a713c6a081775320bea788dfe5d1059b968
Parents: 52d8fdf
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Dec 21 18:43:50 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Dec 21 18:43:50 2015 -0800

----------------------------------------------------------------------
 net/nimble/host/src/ble_gap_conn.c | 45 +++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36945a71/net/nimble/host/src/ble_gap_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap_conn.c b/net/nimble/host/src/ble_gap_conn.c
index 57ad710..8e7bb1a 100644
--- a/net/nimble/host/src/ble_gap_conn.c
+++ b/net/nimble/host/src/ble_gap_conn.c
@@ -438,25 +438,6 @@ ble_gap_conn_rx_conn_complete(struct hci_le_conn_complete *evt)
     }
 
     /* This event refers to a new connection. */
-    switch (evt->role) {
-    case BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER:
-        rc = ble_gap_conn_accept_master_conn(evt->peer_addr_type,
-                                             evt->peer_addr);
-        break;
-
-    case BLE_HCI_LE_CONN_COMPLETE_ROLE_SLAVE:
-        rc = ble_gap_conn_accept_slave_conn(evt->peer_addr_type,
-                                            evt->peer_addr);
-        break;
-
-    default:
-        assert(0);
-        rc = -1;
-        break;
-    }
-    if (rc != 0) {
-        return BLE_HS_ENOENT;
-    }
 
     if (evt->status != BLE_ERR_SUCCESS) {
         switch (evt->role) {
@@ -476,6 +457,32 @@ ble_gap_conn_rx_conn_complete(struct hci_le_conn_complete *evt)
         return 0;
     }
 
+    switch (evt->role) {
+    case BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER:
+        rc = ble_gap_conn_accept_master_conn(evt->peer_addr_type,
+                                             evt->peer_addr);
+        if (rc == 0) {
+            ble_gap_conn_master_reset_state();
+        } else {
+            return BLE_HS_ENOENT;
+        }
+        break;
+
+    case BLE_HCI_LE_CONN_COMPLETE_ROLE_SLAVE:
+        rc = ble_gap_conn_accept_slave_conn(evt->peer_addr_type,
+                                            evt->peer_addr);
+        if (rc == 0) {
+            ble_gap_conn_slave_reset_state();
+        } else {
+            return BLE_HS_ENOENT;
+        }
+        break;
+
+    default:
+        assert(0);
+        break;
+    }
+
     conn = ble_hs_conn_alloc();
     if (conn == NULL) {
         /* XXX: Ensure this never happens. */