Nordic stack and drivers for the mbed BLE API

Dependents:   BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate writable_gatt ... more

Files at this revision

API Documentation at this revision

Comitter:
vcoubard
Date:
Mon Jan 11 10:19:36 2016 +0000
Parent:
598:814c1ce92947
Child:
600:0978b5626451
Commit message:
Synchronized with git rev 2ebbcb08
Author: Andres Amaya Garcia
Add documentation and fix style of SecurityManager

Changed in this revision

source/btle/btle_security.cpp Show annotated file Show diff for this revision Revisions of this file
source/btle/btle_security.h Show annotated file Show diff for this revision Revisions of this file
source/nRF5xSecurityManager.h Show annotated file Show diff for this revision Revisions of this file
--- a/source/btle/btle_security.cpp	Mon Jan 11 10:19:35 2016 +0000
+++ b/source/btle/btle_security.cpp	Mon Jan 11 10:19:36 2016 +0000
@@ -45,19 +45,8 @@
     },                             /**< Key distribution bitmap: keys that the peripheral device will distribute. */
 };
 
-ble_error_t btle_createWhitelistFromBondTable(ble_gap_whitelist_t *p_whitelist)
-{
-    ret_code_t err = dm_whitelist_create(&applicationInstance, p_whitelist);
-    if (err == NRF_SUCCESS) {
-        return BLE_ERROR_NONE;
-    } else if (err == NRF_ERROR_NULL) {
-        return BLE_ERROR_PARAM_OUT_OF_RANGE;
-    } else {
-        return BLE_ERROR_INVALID_STATE;
-    }
-}
-
-bool btle_hasInitializedSecurity(void)
+bool
+btle_hasInitializedSecurity(void)
 {
     return initialized;
 }
@@ -281,7 +270,26 @@
     return NRF_SUCCESS;
 }
 
-bool btle_matchAddressAndIrk(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * p_irk)
+ble_error_t
+btle_createWhitelistFromBondTable(ble_gap_whitelist_t *p_whitelist)
 {
+    ret_code_t err = dm_whitelist_create(&applicationInstance, p_whitelist);
+    if (err == NRF_SUCCESS) {
+        return BLE_ERROR_NONE;
+    } else if (err == NRF_ERROR_NULL) {
+        return BLE_ERROR_PARAM_OUT_OF_RANGE;
+    } else {
+        return BLE_ERROR_INVALID_STATE;
+    }
+}
+
+
+bool
+btle_matchAddressAndIrk(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * p_irk)
+{
+    /*
+     * Use a helper function from the Nordic SDK to test whether the BLE
+     * address can be generated using the IRK.
+     */
     return im_address_resolve(p_addr, p_irk);
 }
\ No newline at end of file
--- a/source/btle/btle_security.h	Mon Jan 11 10:19:35 2016 +0000
+++ b/source/btle/btle_security.h	Mon Jan 11 10:19:36 2016 +0000
@@ -77,8 +77,25 @@
  */
 ble_error_t btle_purgeAllBondingState(void);
 
+/**
+ * Function to test whether the SecurityManager has been initialized.
+ * Possible by a call to @ref btle_initializeSecurity().
+ *
+ * @return True if the SecurityManager was previously initialized, false
+ *         otherwise.
+ */
 bool btle_hasInitializedSecurity(void);
 
+/**
+ * Function to test whether a BLE address is generated using an IRK.
+ *
+ * @param[in]   p_addr
+ *                  Pointer to a BLE address.
+ * @param[in]   p_irk
+ *                  Pointer to an IRK.
+ *
+ * @return True if p_addr can be generated using p_irk, false otherwise.
+ */
 bool btle_matchAddressAndIrk(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * p_irk);
 
 #endif /* _BTLE_SECURITY_H_ */
\ No newline at end of file
--- a/source/nRF5xSecurityManager.h	Mon Jan 11 10:19:35 2016 +0000
+++ b/source/nRF5xSecurityManager.h	Mon Jan 11 10:19:36 2016 +0000
@@ -79,13 +79,28 @@
     nRF5xSecurityManager(const nRF5xSecurityManager &);
     const nRF5xSecurityManager& operator=(const nRF5xSecurityManager &);
 
+    /*
+     * Expose an interface that allows us to query the SoftDevice bond table
+     * and extract a whitelist.
+     */
     ble_error_t createWhitelistFromBondTable(ble_gap_whitelist_t &whitelistFromBondTable) const {
         return btle_createWhitelistFromBondTable(&whitelistFromBondTable);
     }
 
+    /*
+     * Given a BLE address and a IRK this function check whether the address
+     * can be generated from the IRK. To do so, this function uses the hash
+     * function and algorithm described in the Bluetooth low Energy
+     * Specification. Internally, Nordic SDK functions are used.
+     */
     bool matchAddressAndIrk(ble_gap_addr_t *address, ble_gap_irk_t *irk) const {
         return btle_matchAddressAndIrk(address, irk);
     }
+
+    /*
+     * Give nRF5xGap access to createWhitelistFromBondTable() and
+     * matchAddressAndIrk()
+     */
     friend class nRF5xGap;
 };