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