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