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 2016/05/10 20:29:24 UTC
incubator-mynewt-core git commit: BLE host - More specific reasons
for disconnect.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop fc5d42d50 -> c7755e0a6
BLE host - More specific reasons for disconnect.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c7755e0a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c7755e0a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c7755e0a
Branch: refs/heads/develop
Commit: c7755e0a62c9b2d09a62cc4332119c8a47aacf8f
Parents: fc5d42d
Author: Christopher Collins <cc...@apache.org>
Authored: Tue May 10 13:25:18 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue May 10 13:26:49 2016 -0700
----------------------------------------------------------------------
net/nimble/host/src/ble_gap.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7755e0a/net/nimble/host/src/ble_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
index 97be06b..a0ca36c 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -519,7 +519,7 @@ ble_gap_update_failed(uint16_t conn_handle, int status)
}
static void
-ble_gap_conn_broken(struct ble_gap_snapshot *snap)
+ble_gap_conn_broken(struct ble_gap_snapshot *snap, int status)
{
struct ble_gap_conn_ctxt ctxt;
@@ -528,7 +528,7 @@ ble_gap_conn_broken(struct ble_gap_snapshot *snap)
memset(&ctxt, 0, sizeof ctxt);
ctxt.desc = &snap->desc;
- ble_gap_call_conn_cb(BLE_GAP_EVENT_CONN, BLE_HS_ENOTCONN, &ctxt,
+ ble_gap_call_conn_cb(BLE_GAP_EVENT_CONN, status, &ctxt,
snap->cb, snap->cb_arg);
ble_hs_atomic_conn_delete(snap->desc.conn_handle);
@@ -544,6 +544,7 @@ ble_gap_rx_disconn_complete(struct hci_disconn_complete *evt)
struct ble_gap_conn_ctxt ctxt;
struct ble_gap_snapshot snap;
+ int status;
int rc;
STATS_INC(ble_gap_stats, rx_disconnect);
@@ -555,7 +556,15 @@ ble_gap_rx_disconn_complete(struct hci_disconn_complete *evt)
}
if (evt->status == 0) {
- ble_gap_conn_broken(&snap);
+ if (evt->reason == BLE_ERR_CONN_TERM_LOCAL) {
+ /* Don't confuse the application with an HCI error code in the
+ * success case.
+ */
+ status = BLE_HS_ENOTCONN;
+ } else {
+ status = BLE_HS_HCI_ERR(evt->reason);
+ }
+ ble_gap_conn_broken(&snap, status);
} else {
memset(&ctxt, 0, sizeof ctxt);
ctxt.desc = &snap.desc;
@@ -781,7 +790,7 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt)
/* XXX: Does this ever happen? */
if (evt->status != 0) {
- ble_gap_conn_broken(&snap);
+ ble_gap_conn_broken(&snap, BLE_HS_HCI_ERR(evt->status));
}
return 0;
}