nordic

Fork of nRF51822 by Nordic Semiconductor

Revision:
65:98215c4f3a25
Parent:
62:a022be4c545d
Child:
68:936d81c963fe
--- a/btle/btle.cpp	Mon Sep 08 15:45:22 2014 +0000
+++ b/btle/btle.cpp	Mon Sep 08 17:21:46 2014 +0100
@@ -141,9 +141,24 @@
             ASSERT_STATUS_RET_VOID ( ble_bondmngr_bonded_centrals_store());
 #endif
 
-            if (p_ble_evt->evt.gap_evt.params.disconnected.reason == BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION) {
-                nRF51Gap::getInstance().processDisconnectionEvent(handle, Gap::LOCAL_HOST_TERMINATED_CONNECTION);
+            Gap::DisconnectionReason_t reason;
+            switch (p_ble_evt->evt.gap_evt.params.disconnected.reason) {
+                case BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION:
+                    reason = Gap::LOCAL_HOST_TERMINATED_CONNECTION;
+                    break;
+                case BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION:
+                    reason = Gap::REMOTE_USER_TERMINATED_CONNECTION;
+                    break;
+                case BLE_HCI_CONN_INTERVAL_UNACCEPTABLE:
+                    reason = Gap::CONN_INTERVAL_UNACCEPTABLE;
+                    break;
+                default:
+                    /* Please refer to the underlying transport library for an
+                     * interpretion of this reason's value. */
+                    reason = static_cast<Gap::DisconnectionReason_t>(p_ble_evt->evt.gap_evt.params.disconnected.reason);
+                    break;
             }
+            nRF51Gap::getInstance().processDisconnectionEvent(handle, reason);
             break;
         }