cvb
Fork of nrf51-sdk by
source/nordic_sdk/components/ble/peer_manager/id_manager.h@0:bc2961fa1ef0, 2016-04-06 (annotated)
- Committer:
- Jonathan Austin
- Date:
- Wed Apr 06 23:55:04 2016 +0100
- Revision:
- 0:bc2961fa1ef0
Synchronized with git rev 90647e3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jonathan Austin |
0:bc2961fa1ef0 | 1 | /* |
Jonathan Austin |
0:bc2961fa1ef0 | 2 | * Copyright (c) Nordic Semiconductor ASA |
Jonathan Austin |
0:bc2961fa1ef0 | 3 | * All rights reserved. |
Jonathan Austin |
0:bc2961fa1ef0 | 4 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
Jonathan Austin |
0:bc2961fa1ef0 | 6 | * are permitted provided that the following conditions are met: |
Jonathan Austin |
0:bc2961fa1ef0 | 7 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 8 | * 1. Redistributions of source code must retain the above copyright notice, this |
Jonathan Austin |
0:bc2961fa1ef0 | 9 | * list of conditions and the following disclaimer. |
Jonathan Austin |
0:bc2961fa1ef0 | 10 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this |
Jonathan Austin |
0:bc2961fa1ef0 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
Jonathan Austin |
0:bc2961fa1ef0 | 13 | * other materials provided with the distribution. |
Jonathan Austin |
0:bc2961fa1ef0 | 14 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 15 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of other |
Jonathan Austin |
0:bc2961fa1ef0 | 16 | * contributors to this software may be used to endorse or promote products |
Jonathan Austin |
0:bc2961fa1ef0 | 17 | * derived from this software without specific prior written permission. |
Jonathan Austin |
0:bc2961fa1ef0 | 18 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 19 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
Jonathan Austin |
0:bc2961fa1ef0 | 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Jonathan Austin |
0:bc2961fa1ef0 | 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Jonathan Austin |
0:bc2961fa1ef0 | 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
Jonathan Austin |
0:bc2961fa1ef0 | 24 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Jonathan Austin |
0:bc2961fa1ef0 | 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Jonathan Austin |
0:bc2961fa1ef0 | 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
Jonathan Austin |
0:bc2961fa1ef0 | 27 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Jonathan Austin |
0:bc2961fa1ef0 | 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Jonathan Austin |
0:bc2961fa1ef0 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Jonathan Austin |
0:bc2961fa1ef0 | 30 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 31 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 32 | |
Jonathan Austin |
0:bc2961fa1ef0 | 33 | #ifndef PEER_ID_MANAGER_H__ |
Jonathan Austin |
0:bc2961fa1ef0 | 34 | #define PEER_ID_MANAGER_H__ |
Jonathan Austin |
0:bc2961fa1ef0 | 35 | |
Jonathan Austin |
0:bc2961fa1ef0 | 36 | #include "stdint.h" |
Jonathan Austin |
0:bc2961fa1ef0 | 37 | #include "sdk_errors.h" |
Jonathan Austin |
0:bc2961fa1ef0 | 38 | #include "ble.h" |
Jonathan Austin |
0:bc2961fa1ef0 | 39 | #include "ble_gap.h" |
Jonathan Austin |
0:bc2961fa1ef0 | 40 | #include "peer_manager_types.h" |
Jonathan Austin |
0:bc2961fa1ef0 | 41 | |
Jonathan Austin |
0:bc2961fa1ef0 | 42 | |
Jonathan Austin |
0:bc2961fa1ef0 | 43 | /** |
Jonathan Austin |
0:bc2961fa1ef0 | 44 | * @defgroup id_manager ID Manager |
Jonathan Austin |
0:bc2961fa1ef0 | 45 | * @ingroup peer_manager |
Jonathan Austin |
0:bc2961fa1ef0 | 46 | * @{ |
Jonathan Austin |
0:bc2961fa1ef0 | 47 | * @brief An internal module of @ref peer_manager. A module for keeping track of peer identities |
Jonathan Austin |
0:bc2961fa1ef0 | 48 | * (IRK and peer address). |
Jonathan Austin |
0:bc2961fa1ef0 | 49 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 50 | |
Jonathan Austin |
0:bc2961fa1ef0 | 51 | |
Jonathan Austin |
0:bc2961fa1ef0 | 52 | /**@brief Events that can come from the ID Manager module. |
Jonathan Austin |
0:bc2961fa1ef0 | 53 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 54 | typedef enum |
Jonathan Austin |
0:bc2961fa1ef0 | 55 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 56 | IM_EVT_DUPLICATE_ID, /**< The ID Manager module has detected that two stored peers represent the same peer. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 57 | IM_EVT_BONDED_PEER_CONNECTED, /**< A connected peer has been identified as one of the bonded peers. This can happen immediately on connection, or at a later time. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 58 | } im_evt_id_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 59 | |
Jonathan Austin |
0:bc2961fa1ef0 | 60 | |
Jonathan Austin |
0:bc2961fa1ef0 | 61 | typedef struct |
Jonathan Austin |
0:bc2961fa1ef0 | 62 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 63 | im_evt_id_t evt_id; |
Jonathan Austin |
0:bc2961fa1ef0 | 64 | uint16_t conn_handle; |
Jonathan Austin |
0:bc2961fa1ef0 | 65 | union |
Jonathan Austin |
0:bc2961fa1ef0 | 66 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 67 | struct |
Jonathan Austin |
0:bc2961fa1ef0 | 68 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 69 | pm_peer_id_t peer_id_1; |
Jonathan Austin |
0:bc2961fa1ef0 | 70 | pm_peer_id_t peer_id_2; |
Jonathan Austin |
0:bc2961fa1ef0 | 71 | } duplicate_id; |
Jonathan Austin |
0:bc2961fa1ef0 | 72 | } params; |
Jonathan Austin |
0:bc2961fa1ef0 | 73 | } im_evt_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 74 | |
Jonathan Austin |
0:bc2961fa1ef0 | 75 | |
Jonathan Austin |
0:bc2961fa1ef0 | 76 | /**@brief Event handler for events from the ID Manager module. |
Jonathan Austin |
0:bc2961fa1ef0 | 77 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 78 | * @param[in] p_event The event that has happened. |
Jonathan Austin |
0:bc2961fa1ef0 | 79 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 80 | typedef void (*im_evt_handler_t)(im_evt_t const * p_event); |
Jonathan Austin |
0:bc2961fa1ef0 | 81 | |
Jonathan Austin |
0:bc2961fa1ef0 | 82 | /**@brief Function for registering for events from the ID Manager module. |
Jonathan Austin |
0:bc2961fa1ef0 | 83 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 84 | * @note This will also initialize the module if needed. |
Jonathan Austin |
0:bc2961fa1ef0 | 85 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 86 | * @param[in] evt_handler Callback for events from the ID Manager module. |
Jonathan Austin |
0:bc2961fa1ef0 | 87 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 88 | * @retval NRF_SUCCESS Registration was successful. |
Jonathan Austin |
0:bc2961fa1ef0 | 89 | * @retval NRF_ERROR_NO_MEM No more registrations possible. |
Jonathan Austin |
0:bc2961fa1ef0 | 90 | * @retval NRF_ERROR_NULL evt_handler was NULL. |
Jonathan Austin |
0:bc2961fa1ef0 | 91 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 92 | ret_code_t im_register(im_evt_handler_t evt_handler); |
Jonathan Austin |
0:bc2961fa1ef0 | 93 | |
Jonathan Austin |
0:bc2961fa1ef0 | 94 | |
Jonathan Austin |
0:bc2961fa1ef0 | 95 | /**@brief Function for dispatching SoftDevice events to the ID Manager module. |
Jonathan Austin |
0:bc2961fa1ef0 | 96 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 97 | * @param[in] p_ble_evt The SoftDevice event. |
Jonathan Austin |
0:bc2961fa1ef0 | 98 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 99 | void im_ble_evt_handler(ble_evt_t * p_ble_evt); |
Jonathan Austin |
0:bc2961fa1ef0 | 100 | |
Jonathan Austin |
0:bc2961fa1ef0 | 101 | |
Jonathan Austin |
0:bc2961fa1ef0 | 102 | /**@brief Function for getting the corresponding peer ID from a connection handle. |
Jonathan Austin |
0:bc2961fa1ef0 | 103 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 104 | * @param[in] conn_handle The connection handle. |
Jonathan Austin |
0:bc2961fa1ef0 | 105 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 106 | * @return The corresponding peer ID, or @ref PM_PEER_ID_INVALID if none could be resolved. |
Jonathan Austin |
0:bc2961fa1ef0 | 107 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 108 | pm_peer_id_t im_peer_id_get_by_conn_handle(uint16_t conn_handle); |
Jonathan Austin |
0:bc2961fa1ef0 | 109 | |
Jonathan Austin |
0:bc2961fa1ef0 | 110 | |
Jonathan Austin |
0:bc2961fa1ef0 | 111 | /**@brief Function for getting the corresponding peer ID from a master ID (EDIV and rand). |
Jonathan Austin |
0:bc2961fa1ef0 | 112 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 113 | * @param[in] p_master_id The master ID. |
Jonathan Austin |
0:bc2961fa1ef0 | 114 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 115 | * @return The corresponding peer ID, or @ref PM_PEER_ID_INVALID if none could be resolved. |
Jonathan Austin |
0:bc2961fa1ef0 | 116 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 117 | pm_peer_id_t im_peer_id_get_by_master_id(ble_gap_master_id_t * p_master_id); |
Jonathan Austin |
0:bc2961fa1ef0 | 118 | |
Jonathan Austin |
0:bc2961fa1ef0 | 119 | |
Jonathan Austin |
0:bc2961fa1ef0 | 120 | /**@brief Function for getting the corresponding peer ID from an IRK match index, see @ref |
Jonathan Austin |
0:bc2961fa1ef0 | 121 | * ble_gap_evt_connected_t. |
Jonathan Austin |
0:bc2961fa1ef0 | 122 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 123 | * @param[in] irk_match_idx The IRK match index. |
Jonathan Austin |
0:bc2961fa1ef0 | 124 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 125 | * @return The corresponding peer ID, or @ref PM_PEER_ID_INVALID if none could be resolved. |
Jonathan Austin |
0:bc2961fa1ef0 | 126 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 127 | pm_peer_id_t im_peer_id_get_by_irk_match_idx(uint8_t irk_match_idx); |
Jonathan Austin |
0:bc2961fa1ef0 | 128 | |
Jonathan Austin |
0:bc2961fa1ef0 | 129 | |
Jonathan Austin |
0:bc2961fa1ef0 | 130 | /**@brief Function for getting the corresponding connection handle from a peer ID. |
Jonathan Austin |
0:bc2961fa1ef0 | 131 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 132 | * @param[in] peer_id The peer ID. |
Jonathan Austin |
0:bc2961fa1ef0 | 133 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 134 | * @return The corresponding connection handle, or @ref BLE_CONN_HANDLE_INVALID if none could be |
Jonathan Austin |
0:bc2961fa1ef0 | 135 | * resolved. |
Jonathan Austin |
0:bc2961fa1ef0 | 136 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 137 | uint16_t im_conn_handle_get(pm_peer_id_t peer_id); |
Jonathan Austin |
0:bc2961fa1ef0 | 138 | |
Jonathan Austin |
0:bc2961fa1ef0 | 139 | |
Jonathan Austin |
0:bc2961fa1ef0 | 140 | /**@brief Function for getting the BLE address used by the peer when connecting. |
Jonathan Austin |
0:bc2961fa1ef0 | 141 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 142 | * @param[in] conn_handle The connection handle. |
Jonathan Austin |
0:bc2961fa1ef0 | 143 | * @param[out] p_ble_addr The BLE address used by the peer when the connection specified by |
Jonathan Austin |
0:bc2961fa1ef0 | 144 | * conn_handle was established. |
Jonathan Austin |
0:bc2961fa1ef0 | 145 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 146 | * @retval NRF_SUCCESS The address was found and copied. |
Jonathan Austin |
0:bc2961fa1ef0 | 147 | * @retval NRF_ERROR_INVALID_STATE Module not initialized. |
Jonathan Austin |
0:bc2961fa1ef0 | 148 | * @retval BLE_ERROR_CONN_HANDLE_INVALID conn_handle does not refer to an active connection. |
Jonathan Austin |
0:bc2961fa1ef0 | 149 | * @retval NRF_ERROR_NULL p_ble_addr was NULL. |
Jonathan Austin |
0:bc2961fa1ef0 | 150 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 151 | ret_code_t im_ble_addr_get(uint16_t conn_handle, ble_gap_addr_t * p_ble_addr); |
Jonathan Austin |
0:bc2961fa1ef0 | 152 | |
Jonathan Austin |
0:bc2961fa1ef0 | 153 | |
Jonathan Austin |
0:bc2961fa1ef0 | 154 | /**@brief Function for checking whether a master ID is valid or invalid |
Jonathan Austin |
0:bc2961fa1ef0 | 155 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 156 | * @param[in] p_master_id The master ID. |
Jonathan Austin |
0:bc2961fa1ef0 | 157 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 158 | * @retval true The master id is valid. |
Jonathan Austin |
0:bc2961fa1ef0 | 159 | * @retval true The master id is invalid (i.e. all zeros). |
Jonathan Austin |
0:bc2961fa1ef0 | 160 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 161 | bool im_master_id_is_valid(ble_gap_master_id_t const * p_master_id); |
Jonathan Austin |
0:bc2961fa1ef0 | 162 | |
Jonathan Austin |
0:bc2961fa1ef0 | 163 | |
Jonathan Austin |
0:bc2961fa1ef0 | 164 | /**@brief Function for reporting that a new peer ID has been allocated for a specified connection. |
Jonathan Austin |
0:bc2961fa1ef0 | 165 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 166 | * @param[in] conn_handle The connection. |
Jonathan Austin |
0:bc2961fa1ef0 | 167 | * @param[in] peer_id The new peer ID. |
Jonathan Austin |
0:bc2961fa1ef0 | 168 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 169 | void im_new_peer_id(uint16_t conn_handle, pm_peer_id_t peer_id); |
Jonathan Austin |
0:bc2961fa1ef0 | 170 | |
Jonathan Austin |
0:bc2961fa1ef0 | 171 | |
Jonathan Austin |
0:bc2961fa1ef0 | 172 | /** |
Jonathan Austin |
0:bc2961fa1ef0 | 173 | * @brief Function for informing this module of what whitelist will be used. |
Jonathan Austin |
0:bc2961fa1ef0 | 174 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 175 | * @details This function is meant to be used when the app wants to use a custom whitelist. |
Jonathan Austin |
0:bc2961fa1ef0 | 176 | * When using peer manager, this function must be used if a custom whitelist is used. |
Jonathan Austin |
0:bc2961fa1ef0 | 177 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 178 | * @note When using a whitelist, always use the whitelist created/set by the most recent |
Jonathan Austin |
0:bc2961fa1ef0 | 179 | * call to @ref im_wlist_create or to this function, whichever happened most recently. |
Jonathan Austin |
0:bc2961fa1ef0 | 180 | * @note Do not call this function while scanning with another whitelist. |
Jonathan Austin |
0:bc2961fa1ef0 | 181 | * @note Do not add any irks to the whitelist that are not present in the bonding data of a peer in |
Jonathan Austin |
0:bc2961fa1ef0 | 182 | * the peer database. |
Jonathan Austin |
0:bc2961fa1ef0 | 183 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 184 | * @param[in] p_whitelist The whitelist. |
Jonathan Austin |
0:bc2961fa1ef0 | 185 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 186 | * @retval NRF_SUCCESS Whitelist successfully set. |
Jonathan Austin |
0:bc2961fa1ef0 | 187 | * @retval NRF_ERROR_NULL p_whitelist was NULL. |
Jonathan Austin |
0:bc2961fa1ef0 | 188 | * @retval NRF_ERROR_NOT_FOUND One or more of the whitelists irks was not found in the peer_database. |
Jonathan Austin |
0:bc2961fa1ef0 | 189 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 190 | ret_code_t im_wlist_set(ble_gap_whitelist_t * p_whitelist); |
Jonathan Austin |
0:bc2961fa1ef0 | 191 | |
Jonathan Austin |
0:bc2961fa1ef0 | 192 | |
Jonathan Austin |
0:bc2961fa1ef0 | 193 | /** |
Jonathan Austin |
0:bc2961fa1ef0 | 194 | * @brief Function for constructing a whitelist for use when advertising. |
Jonathan Austin |
0:bc2961fa1ef0 | 195 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 196 | * @note When advertising with whitelist, always use the whitelist created/set by the most recent |
Jonathan Austin |
0:bc2961fa1ef0 | 197 | * call to this function or to @ref im_wlist_set, whichever happened most recently. |
Jonathan Austin |
0:bc2961fa1ef0 | 198 | * @note Do not call this function while advertising with another whitelist. |
Jonathan Austin |
0:bc2961fa1ef0 | 199 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 200 | * @param[in] p_peer_ids The ids of the peers to be added to the whitelist. |
Jonathan Austin |
0:bc2961fa1ef0 | 201 | * @param[in] n_peer_ids The number of peer ids in p_peer_ids. |
Jonathan Austin |
0:bc2961fa1ef0 | 202 | * @param[in,out] p_whitelist The constructed whitelist. Note that p_adv_whitelist->pp_addrs |
Jonathan Austin |
0:bc2961fa1ef0 | 203 | * must be NULL or point to an array with size @ref |
Jonathan Austin |
0:bc2961fa1ef0 | 204 | * BLE_GAP_WHITELIST_ADDR_MAX_COUNT and p_adv_whitelist->pp_irks |
Jonathan Austin |
0:bc2961fa1ef0 | 205 | * must be NULL or point to an array with size @ref |
Jonathan Austin |
0:bc2961fa1ef0 | 206 | * BLE_GAP_WHITELIST_IRK_MAX_COUNT. |
Jonathan Austin |
0:bc2961fa1ef0 | 207 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 208 | * @retval NRF_SUCCESS Whitelist successfully created. |
Jonathan Austin |
0:bc2961fa1ef0 | 209 | * @retval NRF_ERROR_NULL p_whitelist was NULL. |
Jonathan Austin |
0:bc2961fa1ef0 | 210 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 211 | ret_code_t im_wlist_create(pm_peer_id_t * p_peer_ids, |
Jonathan Austin |
0:bc2961fa1ef0 | 212 | uint8_t n_peer_ids, |
Jonathan Austin |
0:bc2961fa1ef0 | 213 | ble_gap_whitelist_t * p_whitelist); |
Jonathan Austin |
0:bc2961fa1ef0 | 214 | |
Jonathan Austin |
0:bc2961fa1ef0 | 215 | /** |
Jonathan Austin |
0:bc2961fa1ef0 | 216 | * @brief Function for resolving a resolvable address with an identity resolution key (IRK). |
Jonathan Austin |
0:bc2961fa1ef0 | 217 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 218 | * @details This function will use the ECB peripheral to resolve a resolvable address. |
Jonathan Austin |
0:bc2961fa1ef0 | 219 | * This can be used to resolve the identity of a device distributing a random |
Jonathan Austin |
0:bc2961fa1ef0 | 220 | * resolvable address based on any IRKs you have received earlier. If an address is |
Jonathan Austin |
0:bc2961fa1ef0 | 221 | * resolved by an IRK, the device disributing the address must also know the IRK. |
Jonathan Austin |
0:bc2961fa1ef0 | 222 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 223 | * @param[in] p_addr A random resolvable address. |
Jonathan Austin |
0:bc2961fa1ef0 | 224 | * @param[in] p_irk An identity resolution key (IRK). |
Jonathan Austin |
0:bc2961fa1ef0 | 225 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 226 | * @retval true The irk used matched the one used to create the address. |
Jonathan Austin |
0:bc2961fa1ef0 | 227 | * @retval false The irk used did not match the one used to create the address, or an argument was |
Jonathan Austin |
0:bc2961fa1ef0 | 228 | * NULL. |
Jonathan Austin |
0:bc2961fa1ef0 | 229 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 230 | bool im_address_resolve(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * p_irk); |
Jonathan Austin |
0:bc2961fa1ef0 | 231 | |
Jonathan Austin |
0:bc2961fa1ef0 | 232 | /**@brief Function for calculating the ah() hash function described in Bluetooth core specification |
Jonathan Austin |
0:bc2961fa1ef0 | 233 | * 4.2 section 3.H.2.2.2. |
Jonathan Austin |
0:bc2961fa1ef0 | 234 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 235 | * @detail BLE uses a hash function to calculate the first half of a resolvable address |
Jonathan Austin |
0:bc2961fa1ef0 | 236 | * from the second half of the address and an irk. This function will use the ECB |
Jonathan Austin |
0:bc2961fa1ef0 | 237 | * periferal to hash these data acording to the Bluetooth core specification. |
Jonathan Austin |
0:bc2961fa1ef0 | 238 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 239 | * @note The ECB expect little endian input and output. |
Jonathan Austin |
0:bc2961fa1ef0 | 240 | * This function expect big endian and will reverse the data as necessary. |
Jonathan Austin |
0:bc2961fa1ef0 | 241 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 242 | * @param[in] p_k The key used in the hash function. |
Jonathan Austin |
0:bc2961fa1ef0 | 243 | * For address resolution this is should be the irk. |
Jonathan Austin |
0:bc2961fa1ef0 | 244 | * The array must have a length of 16. |
Jonathan Austin |
0:bc2961fa1ef0 | 245 | * @param[in] p_r The rand used in the hash function. For generating a new address |
Jonathan Austin |
0:bc2961fa1ef0 | 246 | * this would be a random number. For resolving a resolvable address |
Jonathan Austin |
0:bc2961fa1ef0 | 247 | * this would be the last half of the address being resolved. |
Jonathan Austin |
0:bc2961fa1ef0 | 248 | * The array must have a length of 3. |
Jonathan Austin |
0:bc2961fa1ef0 | 249 | * @param[out] p_local_hash The result of the hash operation. For address resolution this |
Jonathan Austin |
0:bc2961fa1ef0 | 250 | * will match the first half of the address being resolved if and only |
Jonathan Austin |
0:bc2961fa1ef0 | 251 | * if the irk used in the hash function is the same one used to generate |
Jonathan Austin |
0:bc2961fa1ef0 | 252 | * the address. |
Jonathan Austin |
0:bc2961fa1ef0 | 253 | * The array must have a length of 16. |
Jonathan Austin |
0:bc2961fa1ef0 | 254 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 255 | * @note ====IMPORTANT==== |
Jonathan Austin |
0:bc2961fa1ef0 | 256 | * This is a special modification to the original nRF51 SDK required by the mbed BLE API |
Jonathan Austin |
0:bc2961fa1ef0 | 257 | * to be able to generate BLE private resolvable addresses. This function is used by |
Jonathan Austin |
0:bc2961fa1ef0 | 258 | * the BLE API implementation for nRF5xSecurityManager::getAddressFromBondTable() in the |
Jonathan Austin |
0:bc2961fa1ef0 | 259 | * ble-nrf51822 yotta module. |
Jonathan Austin |
0:bc2961fa1ef0 | 260 | * ================= |
Jonathan Austin |
0:bc2961fa1ef0 | 261 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 262 | void ah(uint8_t const * p_k, uint8_t const * p_r, uint8_t * p_local_hash); |
Jonathan Austin |
0:bc2961fa1ef0 | 263 | |
Jonathan Austin |
0:bc2961fa1ef0 | 264 | /** @} */ |
Jonathan Austin |
0:bc2961fa1ef0 | 265 | |
Jonathan Austin |
0:bc2961fa1ef0 | 266 | #endif /* PEER_ID_MANAGER_H__ */ |