Patched version of nrf51822 FOTA compatible driver, with GPTIO disabled, as it clashed with the mbed definitions...

Fork of nRF51822 by Nordic Semiconductor

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Fri May 08 15:33:56 2015 +0100
Parent:
137:aafab7b0a8bd
Child:
139:b2f5c70b166e
Commit message:
Synchronized with git rev 590b9828
Author: Rohit Grover
add getLinkSecurity()

Changed in this revision

btle/btle_security.cpp Show annotated file Show diff for this revision Revisions of this file
btle/btle_security.h Show annotated file Show diff for this revision Revisions of this file
nRF51Gap.h Show annotated file Show diff for this revision Revisions of this file
--- a/btle/btle_security.cpp	Fri May 08 15:33:56 2015 +0100
+++ b/btle/btle_security.cpp	Fri May 08 15:33:56 2015 +0100
@@ -88,6 +88,33 @@
     }
 }
 
+ble_error_t
+btle_getLinkSecurity(Gap::Handle_t connectionHandle, Gap::LinkSecurityStatus_t *securityStatusP)
+{
+    dm_handle_t dmHandle;
+    ret_code_t rc;
+    if ((rc = dm_handle_get(connectionHandle, &dmHandle)) != NRF_SUCCESS) {
+        if (rc == NRF_ERROR_NOT_FOUND) {
+            return BLE_ERROR_INVALID_PARAM;
+        } else {
+            return BLE_ERROR_UNSPECIFIED;
+        }
+    }
+
+    if ((rc = dm_security_status_req(&dmHandle, reinterpret_cast<dm_security_status_t *>(securityStatusP))) != NRF_SUCCESS) {
+        switch (rc) {
+            case NRF_ERROR_INVALID_STATE:
+                return BLE_ERROR_INVALID_STATE;
+            case NRF_ERROR_NO_MEM:
+                return BLE_ERROR_NO_MEM;
+            default:
+                return BLE_ERROR_UNSPECIFIED;
+        }
+    }
+
+    return BLE_ERROR_NONE;
+}
+
 ret_code_t
 dm_handler(dm_handle_t const *p_handle, dm_event_t const *p_event, ret_code_t event_result)
 {
--- a/btle/btle_security.h	Fri May 08 15:33:56 2015 +0100
+++ b/btle/btle_security.h	Fri May 08 15:33:56 2015 +0100
@@ -28,6 +28,19 @@
 ble_error_t btle_initializeSecurity();
 
 /**
+ * Get the security status of a link.
+ *
+ * @param[in]  connectionHandle
+ *               Handle to identify the connection.
+ * @param[out] securityStatusP
+ *               security status.
+ *
+ * @return BLE_SUCCESS Or appropriate error code indicating reason for failure.
+ */
+
+ble_error_t btle_getLinkSecurity(Gap::Handle_t connectionHandle, Gap::LinkSecurityStatus_t *securityStatusP);
+
+/**
  * Function for deleting all peer device context and all related bonding
  * information from the database.
  *
--- a/nRF51Gap.h	Fri May 08 15:33:56 2015 +0100
+++ b/nRF51Gap.h	Fri May 08 15:33:56 2015 +0100
@@ -56,6 +56,9 @@
     virtual ble_error_t disconnect(DisconnectionReason_t reason);
 
     virtual ble_error_t deleteAllBondedDevices(void) {return btle_deleteAllStoredDevices();}
+    virtual ble_error_t getLinkSecurity(Handle_t connectionHandle, LinkSecurityStatus_t *securityStatusP) {
+        return btle_getLinkSecurity(connectionHandle, securityStatusP);
+    }
 
     virtual ble_error_t setDeviceName(const uint8_t *deviceName);
     virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP);