Old version
Fork of nRF51822 by
nordic/nrf-sdk/ble/ble_bondmngr.h@94:22533f51b97f, 2016-01-21 (annotated)
- Committer:
- longdh
- Date:
- Thu Jan 21 02:04:47 2016 +0000
- Revision:
- 94:22533f51b97f
- Parent:
- 0:eff01767de02
First commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 0:eff01767de02 | 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. |
bogdanm | 0:eff01767de02 | 2 | * |
bogdanm | 0:eff01767de02 | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
bogdanm | 0:eff01767de02 | 4 | * Terms and conditions of usage are described in detail in NORDIC |
bogdanm | 0:eff01767de02 | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
bogdanm | 0:eff01767de02 | 6 | * |
bogdanm | 0:eff01767de02 | 7 | * Licensees are granted free, non-transferable use of the information. NO |
bogdanm | 0:eff01767de02 | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
bogdanm | 0:eff01767de02 | 9 | * the file. |
bogdanm | 0:eff01767de02 | 10 | * |
bogdanm | 0:eff01767de02 | 11 | */ |
bogdanm | 0:eff01767de02 | 12 | |
bogdanm | 0:eff01767de02 | 13 | /** @file |
bogdanm | 0:eff01767de02 | 14 | * |
bogdanm | 0:eff01767de02 | 15 | * @defgroup ble_sdk_lib_bond_manager Bonds and Persistent Data Manager |
bogdanm | 0:eff01767de02 | 16 | * @{ |
bogdanm | 0:eff01767de02 | 17 | * @ingroup ble_sdk_lib |
bogdanm | 0:eff01767de02 | 18 | * @brief This module handles multiple bonds and persistent attributes. |
bogdanm | 0:eff01767de02 | 19 | * |
bogdanm | 0:eff01767de02 | 20 | * @details When using <i>Bluetooth</i> low energy, a central device and a peripheral device can |
bogdanm | 0:eff01767de02 | 21 | * exchange identification information which they are capable of storing in memory (for |
bogdanm | 0:eff01767de02 | 22 | * example, in non-volatile memory). This information can be used for identity verification |
bogdanm | 0:eff01767de02 | 23 | * between the devices when they reconnect in the future. This relationship is known as a |
bogdanm | 0:eff01767de02 | 24 | * 'bond'. |
bogdanm | 0:eff01767de02 | 25 | * |
bogdanm | 0:eff01767de02 | 26 | * <b>Bonding Information:</b> |
bogdanm | 0:eff01767de02 | 27 | * |
bogdanm | 0:eff01767de02 | 28 | * The S110 SoftDevice handles the BLE on-air transactions necessary to establish a new |
bogdanm | 0:eff01767de02 | 29 | * bond or to use a previous bond when it reconnects to a bonded central. It is however up |
bogdanm | 0:eff01767de02 | 30 | * to the application layer to memorize the <i>identification information</i> between |
bogdanm | 0:eff01767de02 | 31 | * connections and to provide them back to the S110 stack when it detects a re-connection |
bogdanm | 0:eff01767de02 | 32 | * from a previously bonded central. This identification information is referred to as |
bogdanm | 0:eff01767de02 | 33 | * Bonding Information in code and the SDK. |
bogdanm | 0:eff01767de02 | 34 | * |
bogdanm | 0:eff01767de02 | 35 | * <b>System Attributes:</b> |
bogdanm | 0:eff01767de02 | 36 | * |
bogdanm | 0:eff01767de02 | 37 | * If the application is a GATT server, it stores a set of persistent attributes related |
bogdanm | 0:eff01767de02 | 38 | * to a connection when bonding with a central. On reconnection with the known bonded |
bogdanm | 0:eff01767de02 | 39 | * central, the application restores the related persistent attributes in the last known |
bogdanm | 0:eff01767de02 | 40 | * state back to the S110 SoftDevice. These persistent attributes mainly include the Client |
bogdanm | 0:eff01767de02 | 41 | * Characteristic Configuration Descriptor (or CCCD, see the <i><b>Bluetooth</b> |
bogdanm | 0:eff01767de02 | 42 | * Core Specification</i> for more information) states and could include other attributes |
bogdanm | 0:eff01767de02 | 43 | * in the future. Persistent attributes are referred to as System Attributes in code and |
bogdanm | 0:eff01767de02 | 44 | * in the SDK documentation. |
bogdanm | 0:eff01767de02 | 45 | * |
bogdanm | 0:eff01767de02 | 46 | * An application can use the Bonds and Persistent Data Manager module (referred to as the |
bogdanm | 0:eff01767de02 | 47 | * bond manager) included in the nRF51 SDK to handle most of the operations related to |
bogdanm | 0:eff01767de02 | 48 | * the Bonding Information and System Attributes. The bond manager notifies the |
bogdanm | 0:eff01767de02 | 49 | * application when it's connected to a new bonded central or to a previously bonded central. |
bogdanm | 0:eff01767de02 | 50 | * The application can use the Bond Manager API to store or load (or restore) the |
bogdanm | 0:eff01767de02 | 51 | * Bonding Information and System Attributes. The bond manager identifies all the centrals |
bogdanm | 0:eff01767de02 | 52 | * the application is bonded to and restores their respective Bonding Information and |
bogdanm | 0:eff01767de02 | 53 | * System Attributes to the S110 stack. |
bogdanm | 0:eff01767de02 | 54 | * |
bogdanm | 0:eff01767de02 | 55 | * In addition, you can use the bond manager to set up your application to advertise: |
bogdanm | 0:eff01767de02 | 56 | * |
bogdanm | 0:eff01767de02 | 57 | * - To a given bonded central using directed advertisement. |
bogdanm | 0:eff01767de02 | 58 | * - To a list of bonded centrals - i.e. using whitelist. |
bogdanm | 0:eff01767de02 | 59 | * |
bogdanm | 0:eff01767de02 | 60 | * The bond manager automatically writes the Bonding Information to the flash memory when |
bogdanm | 0:eff01767de02 | 61 | * the bonding procedure to a new central is finished. Upon disconnection, the application |
bogdanm | 0:eff01767de02 | 62 | * should use the Bond Manager API @ref ble_bondmngr_bonded_centrals_store to write the |
bogdanm | 0:eff01767de02 | 63 | * latest Bonding Information and System Attributes to flash. |
bogdanm | 0:eff01767de02 | 64 | * |
bogdanm | 0:eff01767de02 | 65 | * The bond manager provides the API @ref ble_bondmngr_sys_attr_store to allow the |
bogdanm | 0:eff01767de02 | 66 | * application to write the System Attributes to flash while in a connection. Your |
bogdanm | 0:eff01767de02 | 67 | * application should call this API when it considers that all CCCDs and other persistent |
bogdanm | 0:eff01767de02 | 68 | * attributes are in a stable state. This API call will safely fail if System Attributes |
bogdanm | 0:eff01767de02 | 69 | * data for the current connected central is already present in the flash. The API does so |
bogdanm | 0:eff01767de02 | 70 | * because a flash write in such a situation would require an erase of flash, which takes a |
bogdanm | 0:eff01767de02 | 71 | * long time (21 milliseconds) to complete. This may disrupt the radio. |
bogdanm | 0:eff01767de02 | 72 | * |
bogdanm | 0:eff01767de02 | 73 | * Applications using the Bond Manager must have a configuration file named |
bogdanm | 0:eff01767de02 | 74 | * ble_bondmngr_cfg.h (see below for details). |
bogdanm | 0:eff01767de02 | 75 | * |
bogdanm | 0:eff01767de02 | 76 | * Refer to @ref ble_bond_mgr_msc to see the flow of events when connecting to a central |
bogdanm | 0:eff01767de02 | 77 | * using the Bond Manager |
bogdanm | 0:eff01767de02 | 78 | * |
bogdanm | 0:eff01767de02 | 79 | * |
bogdanm | 0:eff01767de02 | 80 | * @section ble_sdk_lib_bond_manager_cfg Configuration File |
bogdanm | 0:eff01767de02 | 81 | * Applications using the Bond Manager must have a configuration file named ble_bondmngr_cfg.h. |
bogdanm | 0:eff01767de02 | 82 | * Here is an example of this file: |
bogdanm | 0:eff01767de02 | 83 | * |
bogdanm | 0:eff01767de02 | 84 | * @code |
bogdanm | 0:eff01767de02 | 85 | * #ifndef BLE_BONDMNGR_CFG_H__ |
bogdanm | 0:eff01767de02 | 86 | * #define BLE_BONDMNGR_CFG_H__ |
bogdanm | 0:eff01767de02 | 87 | * |
bogdanm | 0:eff01767de02 | 88 | * #define BLE_BONDMNGR_CCCD_COUNT 1 |
bogdanm | 0:eff01767de02 | 89 | * #define BLE_BONDMNGR_MAX_BONDED_CENTRALS 4 |
bogdanm | 0:eff01767de02 | 90 | * |
bogdanm | 0:eff01767de02 | 91 | * #endif // BLE_BONDMNGR_CFG_H__ |
bogdanm | 0:eff01767de02 | 92 | * @endcode |
bogdanm | 0:eff01767de02 | 93 | * |
bogdanm | 0:eff01767de02 | 94 | * BLE_BONDMNGR_CCCD_COUNT is the number of CCCDs used in the application, and |
bogdanm | 0:eff01767de02 | 95 | * BLE_BONDMNGR_MAX_BONDED_CENTRALS is the maximum number of bonded centrals to be supported by the |
bogdanm | 0:eff01767de02 | 96 | * application. |
bogdanm | 0:eff01767de02 | 97 | */ |
bogdanm | 0:eff01767de02 | 98 | |
bogdanm | 0:eff01767de02 | 99 | #ifndef BLE_BONDMNGR_H__ |
bogdanm | 0:eff01767de02 | 100 | #define BLE_BONDMNGR_H__ |
bogdanm | 0:eff01767de02 | 101 | |
bogdanm | 0:eff01767de02 | 102 | #include <stdint.h> |
bogdanm | 0:eff01767de02 | 103 | #include "nordic_global.h" |
bogdanm | 0:eff01767de02 | 104 | #include "ble.h" |
bogdanm | 0:eff01767de02 | 105 | #include "ble_srv_common.h" |
bogdanm | 0:eff01767de02 | 106 | |
bogdanm | 0:eff01767de02 | 107 | |
bogdanm | 0:eff01767de02 | 108 | /** @defgroup ble_bond_mgr_msc Message Sequence Charts |
bogdanm | 0:eff01767de02 | 109 | * @{ |
bogdanm | 0:eff01767de02 | 110 | * @brief Bond Manager interaction with S110 Stack |
bogdanm | 0:eff01767de02 | 111 | * @{ |
bogdanm | 0:eff01767de02 | 112 | * @defgroup UNBONDED_CENTRAL Connecting to an unbonded central |
bogdanm | 0:eff01767de02 | 113 | * @image html bond_manager_unbonded_master.jpg Connecting to an unbonded central |
bogdanm | 0:eff01767de02 | 114 | * @defgroup BONDED_CENTRAL Connecting to a bonded central |
bogdanm | 0:eff01767de02 | 115 | * @image html bond_manager_bonded_master.jpg Connecting to a bonded central |
bogdanm | 0:eff01767de02 | 116 | * @} |
bogdanm | 0:eff01767de02 | 117 | * @} |
bogdanm | 0:eff01767de02 | 118 | */ |
bogdanm | 0:eff01767de02 | 119 | |
bogdanm | 0:eff01767de02 | 120 | /** @defgroup DEFINES Defines |
bogdanm | 0:eff01767de02 | 121 | * @brief Macros defined by this module. |
bogdanm | 0:eff01767de02 | 122 | * @{ */ |
bogdanm | 0:eff01767de02 | 123 | |
bogdanm | 0:eff01767de02 | 124 | #define INVALID_CENTRAL_HANDLE (-1) /**< Invalid handle, used to indicate that the central is not a known bonded central. */ |
bogdanm | 0:eff01767de02 | 125 | |
bogdanm | 0:eff01767de02 | 126 | /** @} */ |
bogdanm | 0:eff01767de02 | 127 | |
bogdanm | 0:eff01767de02 | 128 | /** @defgroup ENUMS Enumerations |
bogdanm | 0:eff01767de02 | 129 | * @brief Enumerations defined by this module. |
bogdanm | 0:eff01767de02 | 130 | * @{ */ |
bogdanm | 0:eff01767de02 | 131 | |
bogdanm | 0:eff01767de02 | 132 | /**@brief Bond Manager Module event type. */ |
bogdanm | 0:eff01767de02 | 133 | typedef enum |
bogdanm | 0:eff01767de02 | 134 | { |
bogdanm | 0:eff01767de02 | 135 | BLE_BONDMNGR_EVT_NEW_BOND, /**< New bond has been created. */ |
bogdanm | 0:eff01767de02 | 136 | BLE_BONDMNGR_EVT_CONN_TO_BONDED_CENTRAL, /**< Connected to a previously bonded central. */ |
bogdanm | 0:eff01767de02 | 137 | BLE_BONDMNGR_EVT_ENCRYPTED, /**< Current link is encrypted. */ |
bogdanm | 0:eff01767de02 | 138 | BLE_BONDMNGR_EVT_AUTH_STATUS_UPDATED, /**< Authentication status updated for current central. */ |
bogdanm | 0:eff01767de02 | 139 | BLE_BONDMNGR_EVT_BOND_FLASH_FULL /**< Flash block for storing Bonding Information is full. */ |
bogdanm | 0:eff01767de02 | 140 | } ble_bondmngr_evt_type_t; |
bogdanm | 0:eff01767de02 | 141 | |
bogdanm | 0:eff01767de02 | 142 | /** @} */ |
bogdanm | 0:eff01767de02 | 143 | |
bogdanm | 0:eff01767de02 | 144 | |
bogdanm | 0:eff01767de02 | 145 | /** @defgroup DATA_STRUCTURES Data Structures |
bogdanm | 0:eff01767de02 | 146 | * @brief Data Structures defined by this module. |
bogdanm | 0:eff01767de02 | 147 | * @{ */ |
bogdanm | 0:eff01767de02 | 148 | |
bogdanm | 0:eff01767de02 | 149 | /**@brief Bond Manager Module event. */ |
bogdanm | 0:eff01767de02 | 150 | typedef struct |
bogdanm | 0:eff01767de02 | 151 | { |
bogdanm | 0:eff01767de02 | 152 | ble_bondmngr_evt_type_t evt_type; /**< Type of event. */ |
bogdanm | 0:eff01767de02 | 153 | int8_t central_handle; /**< Handle to the current central. This is an index to the central list maintained internally by the bond manager. */ |
bogdanm | 0:eff01767de02 | 154 | uint16_t central_id; /**< Identifier to the central. This will be the same as Encryption diversifier of the central (see @ref ble_gap_evt_sec_info_request_t). This value is constant for the duration of the bond. */ |
bogdanm | 0:eff01767de02 | 155 | } ble_bondmngr_evt_t; |
bogdanm | 0:eff01767de02 | 156 | |
bogdanm | 0:eff01767de02 | 157 | /** @} */ |
bogdanm | 0:eff01767de02 | 158 | |
bogdanm | 0:eff01767de02 | 159 | /** @defgroup TYPEDEFS Typedefs |
bogdanm | 0:eff01767de02 | 160 | * @brief Typedefs defined by this module. |
bogdanm | 0:eff01767de02 | 161 | * @{ */ |
bogdanm | 0:eff01767de02 | 162 | |
bogdanm | 0:eff01767de02 | 163 | /**@brief Bond Manager Module event handler type. */ |
bogdanm | 0:eff01767de02 | 164 | typedef void (*ble_bondmngr_evt_handler_t) (ble_bondmngr_evt_t * p_evt); |
bogdanm | 0:eff01767de02 | 165 | |
bogdanm | 0:eff01767de02 | 166 | /** @} */ |
bogdanm | 0:eff01767de02 | 167 | |
bogdanm | 0:eff01767de02 | 168 | /** @addtogroup DATA_STRUCTURES |
bogdanm | 0:eff01767de02 | 169 | * @{ */ |
bogdanm | 0:eff01767de02 | 170 | |
bogdanm | 0:eff01767de02 | 171 | /**@brief Bond Manager Module init structure. This contains all options and data needed for |
bogdanm | 0:eff01767de02 | 172 | * initialization of the Bond Manager module. */ |
bogdanm | 0:eff01767de02 | 173 | typedef struct |
bogdanm | 0:eff01767de02 | 174 | { |
bogdanm | 0:eff01767de02 | 175 | uint8_t flash_page_num_bond; /**< Flash page number to use for storing Bonding Information. */ |
bogdanm | 0:eff01767de02 | 176 | uint8_t flash_page_num_sys_attr; /**< Flash page number to use for storing System Attributes. */ |
bogdanm | 0:eff01767de02 | 177 | bool bonds_delete; /**< TRUE if bonding and System Attributes for all centrals is to be deleted from flash during initialization, FALSE otherwise. */ |
bogdanm | 0:eff01767de02 | 178 | ble_bondmngr_evt_handler_t evt_handler; /**< Event handler to be called for handling events in bond manager. */ |
bogdanm | 0:eff01767de02 | 179 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
bogdanm | 0:eff01767de02 | 180 | } ble_bondmngr_init_t; |
bogdanm | 0:eff01767de02 | 181 | |
bogdanm | 0:eff01767de02 | 182 | /** @} */ |
bogdanm | 0:eff01767de02 | 183 | |
bogdanm | 0:eff01767de02 | 184 | |
bogdanm | 0:eff01767de02 | 185 | /** @defgroup FUNCTIONS Functions |
bogdanm | 0:eff01767de02 | 186 | * @brief Functions/APIs implemented and exposed by this module. |
bogdanm | 0:eff01767de02 | 187 | * @{ */ |
bogdanm | 0:eff01767de02 | 188 | |
bogdanm | 0:eff01767de02 | 189 | /**@brief Function for initializing the Bond Manager. |
bogdanm | 0:eff01767de02 | 190 | * |
bogdanm | 0:eff01767de02 | 191 | * @param[in] p_init This contains information needed to initialize this module. |
bogdanm | 0:eff01767de02 | 192 | * |
bogdanm | 0:eff01767de02 | 193 | * @return NRF_SUCCESS on successful initialization, otherwise an error code. |
bogdanm | 0:eff01767de02 | 194 | */ |
bogdanm | 0:eff01767de02 | 195 | uint32_t ble_bondmngr_init(ble_bondmngr_init_t * p_init); |
bogdanm | 0:eff01767de02 | 196 | |
bogdanm | 0:eff01767de02 | 197 | /**@brief Function for handling all events from the BLE stack that relate to this module. |
bogdanm | 0:eff01767de02 | 198 | * |
bogdanm | 0:eff01767de02 | 199 | * @param[in] p_ble_evt The event received from the BLE stack. |
bogdanm | 0:eff01767de02 | 200 | * |
bogdanm | 0:eff01767de02 | 201 | * @return NRF_SUCCESS if all operations went successfully, |
bogdanm | 0:eff01767de02 | 202 | * NRF_ERROR_NO_MEM if the maximum number of bonded centrals has been reached. |
bogdanm | 0:eff01767de02 | 203 | * Other error codes in other situations. |
bogdanm | 0:eff01767de02 | 204 | */ |
bogdanm | 0:eff01767de02 | 205 | void ble_bondmngr_on_ble_evt(ble_evt_t * p_ble_evt); |
bogdanm | 0:eff01767de02 | 206 | |
bogdanm | 0:eff01767de02 | 207 | /**@brief Function for storing the bonded centrals data including bonding info and System Attributes into |
bogdanm | 0:eff01767de02 | 208 | * flash memory. |
bogdanm | 0:eff01767de02 | 209 | * |
bogdanm | 0:eff01767de02 | 210 | * @details If the data to be written is different from the existing data, this function erases the |
bogdanm | 0:eff01767de02 | 211 | * flash pages before writing to flash. |
bogdanm | 0:eff01767de02 | 212 | * |
bogdanm | 0:eff01767de02 | 213 | * @warning This function could prevent the radio from running. Therefore it MUST be called ONLY |
bogdanm | 0:eff01767de02 | 214 | * when the application knows that the <i>Bluetooth</i> radio is not active. An example of |
bogdanm | 0:eff01767de02 | 215 | * such a state is when the application has received the Disconnected event and has not yet |
bogdanm | 0:eff01767de02 | 216 | * started advertising. <b>If it is called in any other state, or if it is not called at |
bogdanm | 0:eff01767de02 | 217 | * all, the behavior is undefined.</b> |
bogdanm | 0:eff01767de02 | 218 | * |
bogdanm | 0:eff01767de02 | 219 | * @return NRF_SUCCESS on success, an error_code otherwise. |
bogdanm | 0:eff01767de02 | 220 | */ |
bogdanm | 0:eff01767de02 | 221 | uint32_t ble_bondmngr_bonded_centrals_store(void); |
bogdanm | 0:eff01767de02 | 222 | |
bogdanm | 0:eff01767de02 | 223 | /**@brief Function for deleting the bonded central database from flash. |
bogdanm | 0:eff01767de02 | 224 | * |
bogdanm | 0:eff01767de02 | 225 | * @details After calling this function you should call ble_bondmngr_init() to re-initialize the |
bogdanm | 0:eff01767de02 | 226 | * RAM database. |
bogdanm | 0:eff01767de02 | 227 | * |
bogdanm | 0:eff01767de02 | 228 | * @return NRF_SUCCESS on success, an error_code otherwise. |
bogdanm | 0:eff01767de02 | 229 | */ |
bogdanm | 0:eff01767de02 | 230 | uint32_t ble_bondmngr_bonded_centrals_delete(void); |
bogdanm | 0:eff01767de02 | 231 | |
bogdanm | 0:eff01767de02 | 232 | /**@brief Function for getting the whitelist containing all currently bonded centrals. |
bogdanm | 0:eff01767de02 | 233 | * |
bogdanm | 0:eff01767de02 | 234 | * @details This function populates the whitelist with either the IRKs or the public adresses |
bogdanm | 0:eff01767de02 | 235 | * of all bonded centrals. |
bogdanm | 0:eff01767de02 | 236 | * |
bogdanm | 0:eff01767de02 | 237 | * @param[out] p_whitelist Whitelist structure with all bonded centrals. |
bogdanm | 0:eff01767de02 | 238 | * |
bogdanm | 0:eff01767de02 | 239 | * @return NRF_SUCCESS on success, an error_code otherwise. |
bogdanm | 0:eff01767de02 | 240 | */ |
bogdanm | 0:eff01767de02 | 241 | uint32_t ble_bondmngr_whitelist_get(ble_gap_whitelist_t * p_whitelist); |
bogdanm | 0:eff01767de02 | 242 | |
bogdanm | 0:eff01767de02 | 243 | /**@brief Function for getting the central's address corresponding to a given central_handle. |
bogdanm | 0:eff01767de02 | 244 | * |
bogdanm | 0:eff01767de02 | 245 | * @note This function returns NRF_ERROR_INVALID_PARAM if the given central has a private |
bogdanm | 0:eff01767de02 | 246 | * address. |
bogdanm | 0:eff01767de02 | 247 | * |
bogdanm | 0:eff01767de02 | 248 | * @param[in] central_handle Central's handle. |
bogdanm | 0:eff01767de02 | 249 | * @param[out] p_central_addr Pointer to the central's address which can be used for |
bogdanm | 0:eff01767de02 | 250 | * directed advertising. |
bogdanm | 0:eff01767de02 | 251 | */ |
bogdanm | 0:eff01767de02 | 252 | uint32_t ble_bondmngr_central_addr_get(int8_t central_handle, ble_gap_addr_t * p_central_addr); |
bogdanm | 0:eff01767de02 | 253 | |
bogdanm | 0:eff01767de02 | 254 | /**@brief Function for storing the System Attributes of a newly connected central. |
bogdanm | 0:eff01767de02 | 255 | * |
bogdanm | 0:eff01767de02 | 256 | * @details This function fetches the System Attributes of the current central from the stack, adds |
bogdanm | 0:eff01767de02 | 257 | * it to the database in memory, and also stores it in the flash (without erasing any |
bogdanm | 0:eff01767de02 | 258 | * flash page). |
bogdanm | 0:eff01767de02 | 259 | * This function is intended to facilitate the storage of System Attributes when connected |
bogdanm | 0:eff01767de02 | 260 | * to new central (whose System Attributes are NOT yet stored in flash) even in connected |
bogdanm | 0:eff01767de02 | 261 | * state without affecting radio link. This function can, for example, be called after the |
bogdanm | 0:eff01767de02 | 262 | * CCCD is written by a central. The function will succeed if the central is a new central. |
bogdanm | 0:eff01767de02 | 263 | * See @ref ble_sdk_app_hids_keyboard or @ref ble_sdk_app_hids_mouse for sample usage. |
bogdanm | 0:eff01767de02 | 264 | * |
bogdanm | 0:eff01767de02 | 265 | * @return NRF_SUCCESS on success, otherwise an error code. |
bogdanm | 0:eff01767de02 | 266 | * NRF_ERROR_INVALID_STATE is returned if the System Attributes of the current central is |
bogdanm | 0:eff01767de02 | 267 | * already present in the flash because it is a previously known central. |
bogdanm | 0:eff01767de02 | 268 | */ |
bogdanm | 0:eff01767de02 | 269 | uint32_t ble_bondmngr_sys_attr_store(void); |
bogdanm | 0:eff01767de02 | 270 | |
bogdanm | 0:eff01767de02 | 271 | /**@brief Function for fetching the identifiers of known centrals. |
bogdanm | 0:eff01767de02 | 272 | * |
bogdanm | 0:eff01767de02 | 273 | * @details This function fetches the identifiers of the centrals that are currently in the |
bogdanm | 0:eff01767de02 | 274 | * database, or in other words, known to the bond manager. |
bogdanm | 0:eff01767de02 | 275 | * |
bogdanm | 0:eff01767de02 | 276 | * @param[out] p_central_ids Pointer to the array of central identifiers. It is recommended |
bogdanm | 0:eff01767de02 | 277 | * that the length of this array be equal to |
bogdanm | 0:eff01767de02 | 278 | * MAX_NUMBER_OF_BONDED_CENTRALS * 2 bytes. If value of this pointer |
bogdanm | 0:eff01767de02 | 279 | * is NULL, only the number of centrals in the database will be |
bogdanm | 0:eff01767de02 | 280 | * filled in p_length. This can be used to find out the |
bogdanm | 0:eff01767de02 | 281 | * required size of the array pointed to by p_central_ids in |
bogdanm | 0:eff01767de02 | 282 | * a subsequent call. |
bogdanm | 0:eff01767de02 | 283 | * @param[in, out] p_length Pointer to the length of p_central_ids array provided as |
bogdanm | 0:eff01767de02 | 284 | * input. On return, this function will write the number of central |
bogdanm | 0:eff01767de02 | 285 | * identifiers found to p_length |
bogdanm | 0:eff01767de02 | 286 | * |
bogdanm | 0:eff01767de02 | 287 | * @return NRF_SUCCESS on success. |
bogdanm | 0:eff01767de02 | 288 | * NRF_ERROR_NULL if the input parameter p_length is NULL. |
bogdanm | 0:eff01767de02 | 289 | * NRF_ERROR_INVALID_STATE is returned if the bond manager was not initialized. |
bogdanm | 0:eff01767de02 | 290 | * NRF_ERROR_DATA_SIZE is returned if the length of the input parameter |
bogdanm | 0:eff01767de02 | 291 | * p_central_ids provided is not enough to fit in all the central identifiers in the |
bogdanm | 0:eff01767de02 | 292 | * database. |
bogdanm | 0:eff01767de02 | 293 | */ |
bogdanm | 0:eff01767de02 | 294 | uint32_t ble_bondmngr_central_ids_get(uint16_t * p_central_ids, uint16_t * p_length); |
bogdanm | 0:eff01767de02 | 295 | |
bogdanm | 0:eff01767de02 | 296 | /**@brief Function for deleting a single central from the database. |
bogdanm | 0:eff01767de02 | 297 | * @details This function deletes the Bonding Information and System Attributes of a single |
bogdanm | 0:eff01767de02 | 298 | * central from the flash. |
bogdanm | 0:eff01767de02 | 299 | * The application can use the @ref ble_bondmngr_central_ids_get function to fetch the |
bogdanm | 0:eff01767de02 | 300 | * identifiers of centrals present in the database and then call this function. |
bogdanm | 0:eff01767de02 | 301 | * |
bogdanm | 0:eff01767de02 | 302 | * @warning This function could prevent the radio from running. Therefore it MUST be called ONLY |
bogdanm | 0:eff01767de02 | 303 | * when the application knows that the <i>Bluetooth</i> radio is not active. An example |
bogdanm | 0:eff01767de02 | 304 | * of such a state could be when the application is not in a connected state AND is |
bogdanm | 0:eff01767de02 | 305 | * also not advertising. <b>If it is called in any other state, the behavior is |
bogdanm | 0:eff01767de02 | 306 | * undefined.</b> |
bogdanm | 0:eff01767de02 | 307 | * |
bogdanm | 0:eff01767de02 | 308 | * @param[in] central_id Identifier of the central to be deleted. |
bogdanm | 0:eff01767de02 | 309 | * |
bogdanm | 0:eff01767de02 | 310 | * @return NRF_SUCCESS on success. |
bogdanm | 0:eff01767de02 | 311 | * NRF_ERROR_INVALID_STATE is returned if the bond manager was not initialized. |
bogdanm | 0:eff01767de02 | 312 | * NRF_ERROR_NOT_FOUND if the central with the given identifier is not found in the |
bogdanm | 0:eff01767de02 | 313 | * database. |
bogdanm | 0:eff01767de02 | 314 | */ |
bogdanm | 0:eff01767de02 | 315 | uint32_t ble_bondmngr_bonded_central_delete(uint16_t central_id); |
bogdanm | 0:eff01767de02 | 316 | |
bogdanm | 0:eff01767de02 | 317 | /**@brief Function to verify encryption status link with bonded central is encrypted or not. |
bogdanm | 0:eff01767de02 | 318 | * @details This function provides status of encrption of the link with a bonded central. |
bogdanm | 0:eff01767de02 | 319 | * Its is recommended that the application can use the |
bogdanm | 0:eff01767de02 | 320 | * @ref ble_bondmngr_central_ids_get function to verify if the central is in the |
bogdanm | 0:eff01767de02 | 321 | * database and then call this function. |
bogdanm | 0:eff01767de02 | 322 | * |
bogdanm | 0:eff01767de02 | 323 | * @warning Currently the central id paramater is unused and is added only for future extension. |
bogdanm | 0:eff01767de02 | 324 | * As, today only one link is permitted for the peripheral device, status of current |
bogdanm | 0:eff01767de02 | 325 | * link is provided. In future, with more possibilities in the topology, central_id |
bogdanm | 0:eff01767de02 | 326 | * will be needed to identify the central. |
bogdanm | 0:eff01767de02 | 327 | * |
bogdanm | 0:eff01767de02 | 328 | * @param[out] status Status of encryption, true implies link encrypted. |
bogdanm | 0:eff01767de02 | 329 | * |
bogdanm | 0:eff01767de02 | 330 | * @return NRF_SUCCESS on success. |
bogdanm | 0:eff01767de02 | 331 | * NRF_ERROR_INVALID_STATE is returned if the bond manager was not initialized. |
bogdanm | 0:eff01767de02 | 332 | */ |
bogdanm | 0:eff01767de02 | 333 | uint32_t ble_bondmngr_is_link_encrypted(bool * status); |
bogdanm | 0:eff01767de02 | 334 | |
bogdanm | 0:eff01767de02 | 335 | /** @} */ |
bogdanm | 0:eff01767de02 | 336 | |
bogdanm | 0:eff01767de02 | 337 | #endif // BLE_BONDMNGR_H__ |
bogdanm | 0:eff01767de02 | 338 | |
bogdanm | 0:eff01767de02 | 339 | /** @} */ |