cvb
Fork of nrf51-sdk by
source/nordic_sdk/components/ble/peer_manager/peer_manager_types.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 | |
Jonathan Austin |
0:bc2961fa1ef0 | 34 | |
Jonathan Austin |
0:bc2961fa1ef0 | 35 | #ifndef PEER_MANAGER_TYPES_H__ |
Jonathan Austin |
0:bc2961fa1ef0 | 36 | #define PEER_MANAGER_TYPES_H__ |
Jonathan Austin |
0:bc2961fa1ef0 | 37 | |
Jonathan Austin |
0:bc2961fa1ef0 | 38 | #include <stdint.h> |
Jonathan Austin |
0:bc2961fa1ef0 | 39 | #include <stdbool.h> |
Jonathan Austin |
0:bc2961fa1ef0 | 40 | |
Jonathan Austin |
0:bc2961fa1ef0 | 41 | |
Jonathan Austin |
0:bc2961fa1ef0 | 42 | /** |
Jonathan Austin |
0:bc2961fa1ef0 | 43 | * @file peer_manager_types.h |
Jonathan Austin |
0:bc2961fa1ef0 | 44 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 45 | * @addtogroup peer_manager |
Jonathan Austin |
0:bc2961fa1ef0 | 46 | * @{ |
Jonathan Austin |
0:bc2961fa1ef0 | 47 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 48 | |
Jonathan Austin |
0:bc2961fa1ef0 | 49 | |
Jonathan Austin |
0:bc2961fa1ef0 | 50 | #include <stdint.h> |
Jonathan Austin |
0:bc2961fa1ef0 | 51 | #include <stddef.h> |
Jonathan Austin |
0:bc2961fa1ef0 | 52 | #include "ble_gap.h" |
Jonathan Austin |
0:bc2961fa1ef0 | 53 | #include "ble_hci.h" |
Jonathan Austin |
0:bc2961fa1ef0 | 54 | #include "ble_gatt_db.h" |
Jonathan Austin |
0:bc2961fa1ef0 | 55 | #include "compiler_abstraction.h" |
Jonathan Austin |
0:bc2961fa1ef0 | 56 | |
Jonathan Austin |
0:bc2961fa1ef0 | 57 | |
Jonathan Austin |
0:bc2961fa1ef0 | 58 | /**@brief Handle to uniquely identify a peer for which we have persistently stored data. |
Jonathan Austin |
0:bc2961fa1ef0 | 59 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 60 | typedef uint16_t pm_peer_id_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 61 | |
Jonathan Austin |
0:bc2961fa1ef0 | 62 | #define PM_PEER_ID_INVALID 0xFFFF /**< Invalid value for @ref pm_peer_id_t. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 63 | #define PM_PEER_ID_N_AVAILABLE_IDS 256 /**< The number of available peer IDs. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 64 | #define PM_LOCAL_DB_LEN_OVERHEAD_BYTES offsetof(pm_peer_data_local_gatt_db_flash_t, p_data) |
Jonathan Austin |
0:bc2961fa1ef0 | 65 | #define PM_REMOTE_DB_LEN_OVERHEAD_BYTES offsetof(pm_peer_data_remote_gatt_db_flash_t, p_data) |
Jonathan Austin |
0:bc2961fa1ef0 | 66 | |
Jonathan Austin |
0:bc2961fa1ef0 | 67 | static __INLINE uint16_t PM_N_WORDS(uint16_t n_bytes) |
Jonathan Austin |
0:bc2961fa1ef0 | 68 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 69 | return ((n_bytes + 3) >> 2); |
Jonathan Austin |
0:bc2961fa1ef0 | 70 | } |
Jonathan Austin |
0:bc2961fa1ef0 | 71 | |
Jonathan Austin |
0:bc2961fa1ef0 | 72 | /**@brief Errors originating from the Peer Manager module. |
Jonathan Austin |
0:bc2961fa1ef0 | 73 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 74 | typedef enum |
Jonathan Austin |
0:bc2961fa1ef0 | 75 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 76 | PM_SEC_ERROR_CODE_PIN_OR_KEY_MISSING = BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING, /**< Encryption failed because the peripheral has lost the LTK for this bond. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 77 | PM_SEC_ERROR_CODE_MIC_FAILURE = BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE, /**< Pairing ended with disconnection because of mismatching keys. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 78 | PM_SEC_ERROR_SMP_TIMEOUT, /**< Pairing/bonding could not start because an SMP timeout has already happened on this link. This means that no more pairing or bonding can happen on this link. To be able to pair or bond, the link must be disconnected and then reconnected. See Bluetooth specification 4.2 section 3.H.3.4 */ |
Jonathan Austin |
0:bc2961fa1ef0 | 79 | } pm_sec_error_code_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 80 | |
Jonathan Austin |
0:bc2961fa1ef0 | 81 | |
Jonathan Austin |
0:bc2961fa1ef0 | 82 | /**@brief Enumeration describing the different procedures that can lead to an encrypted link. |
Jonathan Austin |
0:bc2961fa1ef0 | 83 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 84 | typedef enum |
Jonathan Austin |
0:bc2961fa1ef0 | 85 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 86 | PM_LINK_SECURED_PROCEDURE_ENCRYPTION, /**< Using an LTK shared during a previous bonding procedure to encrypt the link. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 87 | PM_LINK_SECURED_PROCEDURE_BONDING, /**< A pairing procedure, followed by a bonding procedure. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 88 | PM_LINK_SECURED_PROCEDURE_PAIRING, /**< A pairing procedure with no bonding. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 89 | } pm_sec_procedure_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 90 | |
Jonathan Austin |
0:bc2961fa1ef0 | 91 | |
Jonathan Austin |
0:bc2961fa1ef0 | 92 | /**@brief Data associated with a bond to a peer. |
Jonathan Austin |
0:bc2961fa1ef0 | 93 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 94 | typedef struct |
Jonathan Austin |
0:bc2961fa1ef0 | 95 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 96 | uint8_t own_role; /**< The role of the local device during bonding. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 97 | ble_gap_id_key_t peer_id; /**< The peer's peer address and identity resolution key. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 98 | ble_gap_enc_key_t peer_ltk; /**< The peer's long term encryption key. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 99 | ble_gap_enc_key_t own_ltk; /**< Locally generated long term encryption key, distributed to the peer. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 100 | } pm_peer_data_bonding_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 101 | |
Jonathan Austin |
0:bc2961fa1ef0 | 102 | |
Jonathan Austin |
0:bc2961fa1ef0 | 103 | /**@brief Function for calculating the flash size of bonding data. |
Jonathan Austin |
0:bc2961fa1ef0 | 104 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 105 | * @return The number of words the data will take in flash. |
Jonathan Austin |
0:bc2961fa1ef0 | 106 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 107 | static __INLINE uint16_t PM_BONDING_DATA_N_WORDS(void) |
Jonathan Austin |
0:bc2961fa1ef0 | 108 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 109 | return PM_N_WORDS(sizeof(pm_peer_data_bonding_t)); |
Jonathan Austin |
0:bc2961fa1ef0 | 110 | } |
Jonathan Austin |
0:bc2961fa1ef0 | 111 | |
Jonathan Austin |
0:bc2961fa1ef0 | 112 | |
Jonathan Austin |
0:bc2961fa1ef0 | 113 | /**@brief Function for calculating the flash size of service changed pending state. |
Jonathan Austin |
0:bc2961fa1ef0 | 114 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 115 | * @return The number of words the data will take in flash. |
Jonathan Austin |
0:bc2961fa1ef0 | 116 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 117 | static __INLINE uint16_t PM_SC_STATE_N_WORDS(void) |
Jonathan Austin |
0:bc2961fa1ef0 | 118 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 119 | return PM_N_WORDS(sizeof(bool)); |
Jonathan Austin |
0:bc2961fa1ef0 | 120 | } |
Jonathan Austin |
0:bc2961fa1ef0 | 121 | |
Jonathan Austin |
0:bc2961fa1ef0 | 122 | |
Jonathan Austin |
0:bc2961fa1ef0 | 123 | /**@brief Data on a local GATT database. |
Jonathan Austin |
0:bc2961fa1ef0 | 124 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 125 | typedef struct |
Jonathan Austin |
0:bc2961fa1ef0 | 126 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 127 | uint32_t flags; /**< Flags describing the database attributes. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 128 | uint16_t len; /**< Size of attribute array. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 129 | uint8_t * p_data; /**< Array to hold the database attributes. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 130 | } pm_peer_data_local_gatt_db_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 131 | |
Jonathan Austin |
0:bc2961fa1ef0 | 132 | |
Jonathan Austin |
0:bc2961fa1ef0 | 133 | /**@brief Data on a local GATT database, as formatted in flash. |
Jonathan Austin |
0:bc2961fa1ef0 | 134 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 135 | typedef struct |
Jonathan Austin |
0:bc2961fa1ef0 | 136 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 137 | uint32_t flags; |
Jonathan Austin |
0:bc2961fa1ef0 | 138 | uint16_t len; |
Jonathan Austin |
0:bc2961fa1ef0 | 139 | uint16_t _padding; |
Jonathan Austin |
0:bc2961fa1ef0 | 140 | uint8_t p_data[]; |
Jonathan Austin |
0:bc2961fa1ef0 | 141 | } pm_peer_data_local_gatt_db_flash_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 142 | |
Jonathan Austin |
0:bc2961fa1ef0 | 143 | |
Jonathan Austin |
0:bc2961fa1ef0 | 144 | /**@brief Function for calculating the flash size of local GATT database data. |
Jonathan Austin |
0:bc2961fa1ef0 | 145 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 146 | * @param[in] local_db_len The length of the database as reported by the SoftDevice. |
Jonathan Austin |
0:bc2961fa1ef0 | 147 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 148 | * @return The number of words the data will take in flash. |
Jonathan Austin |
0:bc2961fa1ef0 | 149 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 150 | static __INLINE uint16_t PM_LOCAL_DB_N_WORDS(uint16_t local_db_len) |
Jonathan Austin |
0:bc2961fa1ef0 | 151 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 152 | return PM_N_WORDS(local_db_len + PM_LOCAL_DB_LEN_OVERHEAD_BYTES); |
Jonathan Austin |
0:bc2961fa1ef0 | 153 | } |
Jonathan Austin |
0:bc2961fa1ef0 | 154 | |
Jonathan Austin |
0:bc2961fa1ef0 | 155 | |
Jonathan Austin |
0:bc2961fa1ef0 | 156 | /**@brief Function for calculating the length of a local GATT database attribute array. |
Jonathan Austin |
0:bc2961fa1ef0 | 157 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 158 | * @param[in] n_words The number of words the data takes in flash. |
Jonathan Austin |
0:bc2961fa1ef0 | 159 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 160 | * @return The length of the database attribute array. |
Jonathan Austin |
0:bc2961fa1ef0 | 161 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 162 | static __INLINE uint16_t PM_LOCAL_DB_LEN(uint16_t n_words) |
Jonathan Austin |
0:bc2961fa1ef0 | 163 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 164 | return ((n_words * 4) - PM_LOCAL_DB_LEN_OVERHEAD_BYTES); |
Jonathan Austin |
0:bc2961fa1ef0 | 165 | } |
Jonathan Austin |
0:bc2961fa1ef0 | 166 | |
Jonathan Austin |
0:bc2961fa1ef0 | 167 | |
Jonathan Austin |
0:bc2961fa1ef0 | 168 | /**@brief Data on a remote GATT database. |
Jonathan Austin |
0:bc2961fa1ef0 | 169 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 170 | typedef struct |
Jonathan Austin |
0:bc2961fa1ef0 | 171 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 172 | uint32_t service_count; /**< Number of stored services. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 173 | ble_gatt_db_srv_t * p_data; /**< Array to hold the database attributes. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 174 | } pm_peer_data_remote_gatt_db_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 175 | |
Jonathan Austin |
0:bc2961fa1ef0 | 176 | |
Jonathan Austin |
0:bc2961fa1ef0 | 177 | /**@brief Data on a remote GATT database, as formatted in flash. |
Jonathan Austin |
0:bc2961fa1ef0 | 178 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 179 | typedef struct |
Jonathan Austin |
0:bc2961fa1ef0 | 180 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 181 | uint32_t service_count; |
Jonathan Austin |
0:bc2961fa1ef0 | 182 | ble_gatt_db_srv_t p_data[]; |
Jonathan Austin |
0:bc2961fa1ef0 | 183 | } pm_peer_data_remote_gatt_db_flash_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 184 | |
Jonathan Austin |
0:bc2961fa1ef0 | 185 | |
Jonathan Austin |
0:bc2961fa1ef0 | 186 | |
Jonathan Austin |
0:bc2961fa1ef0 | 187 | /**@brief Function for calculating the flash size of remote GATT database data. |
Jonathan Austin |
0:bc2961fa1ef0 | 188 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 189 | * @param[in] service_count The number of services in the service array. |
Jonathan Austin |
0:bc2961fa1ef0 | 190 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 191 | * @return The number of words the data will take in flash. |
Jonathan Austin |
0:bc2961fa1ef0 | 192 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 193 | static __INLINE uint16_t PM_REMOTE_DB_N_WORDS(uint16_t service_count) |
Jonathan Austin |
0:bc2961fa1ef0 | 194 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 195 | return PM_N_WORDS((sizeof(ble_gatt_db_srv_t) * service_count) + PM_REMOTE_DB_LEN_OVERHEAD_BYTES); |
Jonathan Austin |
0:bc2961fa1ef0 | 196 | } |
Jonathan Austin |
0:bc2961fa1ef0 | 197 | |
Jonathan Austin |
0:bc2961fa1ef0 | 198 | |
Jonathan Austin |
0:bc2961fa1ef0 | 199 | /**@brief Union of all data associated with one peer. |
Jonathan Austin |
0:bc2961fa1ef0 | 200 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 201 | typedef union |
Jonathan Austin |
0:bc2961fa1ef0 | 202 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 203 | pm_peer_data_bonding_t * p_bonding_data; /**< The exchanged bond information in addition to metadata of the bonding. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 204 | bool * p_service_changed_pending; /**< Whether a service changed indication should be sent to the peer. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 205 | pm_peer_data_local_gatt_db_t * p_local_gatt_db; /**< Persistent information pertaining to a peer GATT client. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 206 | pm_peer_data_remote_gatt_db_t * p_remote_gatt_db; /**< Persistent information pertaining to a peer GATT server. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 207 | uint8_t * p_application_data; /**< Arbitrary data to associate with the peer. This data can be freely used by the application. */ |
Jonathan Austin |
0:bc2961fa1ef0 | 208 | } pm_peer_data_unit_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 209 | |
Jonathan Austin |
0:bc2961fa1ef0 | 210 | |
Jonathan Austin |
0:bc2961fa1ef0 | 211 | /**@brief Immutable version of @ref pm_peer_data_unit_t. |
Jonathan Austin |
0:bc2961fa1ef0 | 212 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 213 | typedef union |
Jonathan Austin |
0:bc2961fa1ef0 | 214 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 215 | pm_peer_data_bonding_t const * p_bonding_data; |
Jonathan Austin |
0:bc2961fa1ef0 | 216 | bool const * p_service_changed_pending; |
Jonathan Austin |
0:bc2961fa1ef0 | 217 | pm_peer_data_local_gatt_db_t const * p_local_gatt_db; |
Jonathan Austin |
0:bc2961fa1ef0 | 218 | pm_peer_data_remote_gatt_db_t const * p_remote_gatt_db; |
Jonathan Austin |
0:bc2961fa1ef0 | 219 | uint8_t const * p_application_data; |
Jonathan Austin |
0:bc2961fa1ef0 | 220 | } pm_peer_data_unit_const_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 221 | |
Jonathan Austin |
0:bc2961fa1ef0 | 222 | |
Jonathan Austin |
0:bc2961fa1ef0 | 223 | /**@brief Data from @ref pm_peer_data_unit_t, as mapped in flash. |
Jonathan Austin |
0:bc2961fa1ef0 | 224 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 225 | typedef union |
Jonathan Austin |
0:bc2961fa1ef0 | 226 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 227 | pm_peer_data_bonding_t const * p_bonding_data; |
Jonathan Austin |
0:bc2961fa1ef0 | 228 | bool const * p_service_changed_pending; |
Jonathan Austin |
0:bc2961fa1ef0 | 229 | pm_peer_data_local_gatt_db_flash_t const * p_local_gatt_db; |
Jonathan Austin |
0:bc2961fa1ef0 | 230 | pm_peer_data_remote_gatt_db_flash_t const * p_remote_gatt_db; |
Jonathan Austin |
0:bc2961fa1ef0 | 231 | uint8_t const * p_application_data; |
Jonathan Austin |
0:bc2961fa1ef0 | 232 | } pm_peer_data_unit_flash_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 233 | |
Jonathan Austin |
0:bc2961fa1ef0 | 234 | |
Jonathan Austin |
0:bc2961fa1ef0 | 235 | /**@brief The different types of data associated with a peer. |
Jonathan Austin |
0:bc2961fa1ef0 | 236 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 237 | typedef enum |
Jonathan Austin |
0:bc2961fa1ef0 | 238 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 239 | PM_PEER_DATA_ID_BONDING, |
Jonathan Austin |
0:bc2961fa1ef0 | 240 | PM_PEER_DATA_ID_SERVICE_CHANGED_PENDING, |
Jonathan Austin |
0:bc2961fa1ef0 | 241 | PM_PEER_DATA_ID_GATT_LOCAL, |
Jonathan Austin |
0:bc2961fa1ef0 | 242 | PM_PEER_DATA_ID_GATT_REMOTE, |
Jonathan Austin |
0:bc2961fa1ef0 | 243 | PM_PEER_DATA_ID_APPLICATION, |
Jonathan Austin |
0:bc2961fa1ef0 | 244 | PM_PEER_DATA_ID_INVALID, |
Jonathan Austin |
0:bc2961fa1ef0 | 245 | } pm_peer_data_id_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 246 | |
Jonathan Austin |
0:bc2961fa1ef0 | 247 | |
Jonathan Austin |
0:bc2961fa1ef0 | 248 | //STATIC_ASSERT_MSG(sizeof(pm_peer_data_t) == sizeof(pm_peer_data_const_t), "Size of pm_peer_data_t different from immutable version."); |
Jonathan Austin |
0:bc2961fa1ef0 | 249 | |
Jonathan Austin |
0:bc2961fa1ef0 | 250 | |
Jonathan Austin |
0:bc2961fa1ef0 | 251 | /**@brief Macro saying whether a data_id is valid, i.e. one of the valid enum values. |
Jonathan Austin |
0:bc2961fa1ef0 | 252 | * |
Jonathan Austin |
0:bc2961fa1ef0 | 253 | * @param[in] data_id The data_id to check. |
Jonathan Austin |
0:bc2961fa1ef0 | 254 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 255 | static __INLINE bool PM_PEER_DATA_ID_IS_VALID(pm_peer_data_id_t data_id) |
Jonathan Austin |
0:bc2961fa1ef0 | 256 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 257 | return ((data_id - PM_PEER_DATA_ID_BONDING) < (PM_PEER_DATA_ID_INVALID - PM_PEER_DATA_ID_BONDING)); |
Jonathan Austin |
0:bc2961fa1ef0 | 258 | } |
Jonathan Austin |
0:bc2961fa1ef0 | 259 | |
Jonathan Austin |
0:bc2961fa1ef0 | 260 | |
Jonathan Austin |
0:bc2961fa1ef0 | 261 | /**@brief One piece of data associated with a peer, together with the type. |
Jonathan Austin |
0:bc2961fa1ef0 | 262 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 263 | typedef struct |
Jonathan Austin |
0:bc2961fa1ef0 | 264 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 265 | uint16_t length_words; |
Jonathan Austin |
0:bc2961fa1ef0 | 266 | pm_peer_data_id_t data_type; |
Jonathan Austin |
0:bc2961fa1ef0 | 267 | pm_peer_data_unit_t data; |
Jonathan Austin |
0:bc2961fa1ef0 | 268 | } pm_peer_data_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 269 | |
Jonathan Austin |
0:bc2961fa1ef0 | 270 | /**@brief Immutable version of @ref pm_peer_data_t. |
Jonathan Austin |
0:bc2961fa1ef0 | 271 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 272 | typedef struct |
Jonathan Austin |
0:bc2961fa1ef0 | 273 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 274 | uint16_t length_words; |
Jonathan Austin |
0:bc2961fa1ef0 | 275 | pm_peer_data_id_t data_type; |
Jonathan Austin |
0:bc2961fa1ef0 | 276 | pm_peer_data_unit_const_t data; |
Jonathan Austin |
0:bc2961fa1ef0 | 277 | } pm_peer_data_const_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 278 | |
Jonathan Austin |
0:bc2961fa1ef0 | 279 | /**@brief Data from @ref pm_peer_data_t, as mapped in flash. |
Jonathan Austin |
0:bc2961fa1ef0 | 280 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 281 | typedef struct |
Jonathan Austin |
0:bc2961fa1ef0 | 282 | { |
Jonathan Austin |
0:bc2961fa1ef0 | 283 | uint16_t length_words; |
Jonathan Austin |
0:bc2961fa1ef0 | 284 | pm_peer_data_id_t data_type; |
Jonathan Austin |
0:bc2961fa1ef0 | 285 | pm_peer_data_unit_flash_t data; |
Jonathan Austin |
0:bc2961fa1ef0 | 286 | } pm_peer_data_flash_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 287 | |
Jonathan Austin |
0:bc2961fa1ef0 | 288 | |
Jonathan Austin |
0:bc2961fa1ef0 | 289 | /**@brief Typedef for type used for write prepares. Used to reserve space in flash |
Jonathan Austin |
0:bc2961fa1ef0 | 290 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 291 | typedef uint32_t pm_prepare_token_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 292 | |
Jonathan Austin |
0:bc2961fa1ef0 | 293 | |
Jonathan Austin |
0:bc2961fa1ef0 | 294 | /**@brief Typedef for type used to hold reference to stored item in flash. |
Jonathan Austin |
0:bc2961fa1ef0 | 295 | * this token can be used for locking and validity check |
Jonathan Austin |
0:bc2961fa1ef0 | 296 | */ |
Jonathan Austin |
0:bc2961fa1ef0 | 297 | typedef uint32_t pm_store_token_t; |
Jonathan Austin |
0:bc2961fa1ef0 | 298 | |
Jonathan Austin |
0:bc2961fa1ef0 | 299 | /** @} */ |
Jonathan Austin |
0:bc2961fa1ef0 | 300 | |
Jonathan Austin |
0:bc2961fa1ef0 | 301 | #endif /* PEER_MANAGER_TYPES_H__ */ |