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