Nordic stack and drivers for the mbed BLE API

Dependents:   BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate writable_gatt ... more

Committer:
Vincent Coubard
Date:
Wed Sep 14 14:39:43 2016 +0100
Revision:
638:c90ae1400bf2
Sync with bdab10dc0f90748b6989c8b577771bb403ca6bd8 from ARMmbed/mbed-os.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Vincent Coubard 638:c90ae1400bf2 1 /*
Vincent Coubard 638:c90ae1400bf2 2 * Copyright (c) Nordic Semiconductor ASA
Vincent Coubard 638:c90ae1400bf2 3 * All rights reserved.
Vincent Coubard 638:c90ae1400bf2 4 *
Vincent Coubard 638:c90ae1400bf2 5 * Redistribution and use in source and binary forms, with or without modification,
Vincent Coubard 638:c90ae1400bf2 6 * are permitted provided that the following conditions are met:
Vincent Coubard 638:c90ae1400bf2 7 *
Vincent Coubard 638:c90ae1400bf2 8 * 1. Redistributions of source code must retain the above copyright notice, this
Vincent Coubard 638:c90ae1400bf2 9 * list of conditions and the following disclaimer.
Vincent Coubard 638:c90ae1400bf2 10 *
Vincent Coubard 638:c90ae1400bf2 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
Vincent Coubard 638:c90ae1400bf2 12 * list of conditions and the following disclaimer in the documentation and/or
Vincent Coubard 638:c90ae1400bf2 13 * other materials provided with the distribution.
Vincent Coubard 638:c90ae1400bf2 14 *
Vincent Coubard 638:c90ae1400bf2 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
Vincent Coubard 638:c90ae1400bf2 16 * contributors to this software may be used to endorse or promote products
Vincent Coubard 638:c90ae1400bf2 17 * derived from this software without specific prior written permission.
Vincent Coubard 638:c90ae1400bf2 18 *
Vincent Coubard 638:c90ae1400bf2 19 *
Vincent Coubard 638:c90ae1400bf2 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Vincent Coubard 638:c90ae1400bf2 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Vincent Coubard 638:c90ae1400bf2 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Vincent Coubard 638:c90ae1400bf2 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
Vincent Coubard 638:c90ae1400bf2 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Vincent Coubard 638:c90ae1400bf2 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Vincent Coubard 638:c90ae1400bf2 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Vincent Coubard 638:c90ae1400bf2 27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Vincent Coubard 638:c90ae1400bf2 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Vincent Coubard 638:c90ae1400bf2 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Vincent Coubard 638:c90ae1400bf2 30 *
Vincent Coubard 638:c90ae1400bf2 31 */
Vincent Coubard 638:c90ae1400bf2 32
Vincent Coubard 638:c90ae1400bf2 33
Vincent Coubard 638:c90ae1400bf2 34
Vincent Coubard 638:c90ae1400bf2 35 #ifndef PEER_MANAGER_TYPES_H__
Vincent Coubard 638:c90ae1400bf2 36 #define PEER_MANAGER_TYPES_H__
Vincent Coubard 638:c90ae1400bf2 37
Vincent Coubard 638:c90ae1400bf2 38 #include <stdint.h>
Vincent Coubard 638:c90ae1400bf2 39 #include <stdbool.h>
Vincent Coubard 638:c90ae1400bf2 40
Vincent Coubard 638:c90ae1400bf2 41
Vincent Coubard 638:c90ae1400bf2 42 /**
Vincent Coubard 638:c90ae1400bf2 43 * @file peer_manager_types.h
Vincent Coubard 638:c90ae1400bf2 44 *
Vincent Coubard 638:c90ae1400bf2 45 * @addtogroup peer_manager
Vincent Coubard 638:c90ae1400bf2 46 * @{
Vincent Coubard 638:c90ae1400bf2 47 */
Vincent Coubard 638:c90ae1400bf2 48
Vincent Coubard 638:c90ae1400bf2 49
Vincent Coubard 638:c90ae1400bf2 50 #include <stdint.h>
Vincent Coubard 638:c90ae1400bf2 51 #include <stddef.h>
Vincent Coubard 638:c90ae1400bf2 52 #include "ble_gap.h"
Vincent Coubard 638:c90ae1400bf2 53 #include "ble_hci.h"
Vincent Coubard 638:c90ae1400bf2 54 #include "ble_gatt_db.h"
Vincent Coubard 638:c90ae1400bf2 55 #include "compiler_abstraction.h"
Vincent Coubard 638:c90ae1400bf2 56
Vincent Coubard 638:c90ae1400bf2 57
Vincent Coubard 638:c90ae1400bf2 58 /**@brief Handle to uniquely identify a peer for which we have persistently stored data.
Vincent Coubard 638:c90ae1400bf2 59 */
Vincent Coubard 638:c90ae1400bf2 60 typedef uint16_t pm_peer_id_t;
Vincent Coubard 638:c90ae1400bf2 61
Vincent Coubard 638:c90ae1400bf2 62 #define PM_PEER_ID_INVALID 0xFFFF /**< Invalid value for @ref pm_peer_id_t. */
Vincent Coubard 638:c90ae1400bf2 63 #define PM_PEER_ID_N_AVAILABLE_IDS 256 /**< The number of available peer IDs. */
Vincent Coubard 638:c90ae1400bf2 64 #define PM_LOCAL_DB_LEN_OVERHEAD_BYTES offsetof(pm_peer_data_local_gatt_db_flash_t, p_data)
Vincent Coubard 638:c90ae1400bf2 65 #define PM_REMOTE_DB_LEN_OVERHEAD_BYTES offsetof(pm_peer_data_remote_gatt_db_flash_t, p_data)
Vincent Coubard 638:c90ae1400bf2 66
Vincent Coubard 638:c90ae1400bf2 67 static __INLINE uint16_t PM_N_WORDS(uint16_t n_bytes)
Vincent Coubard 638:c90ae1400bf2 68 {
Vincent Coubard 638:c90ae1400bf2 69 return ((n_bytes + 3) >> 2);
Vincent Coubard 638:c90ae1400bf2 70 }
Vincent Coubard 638:c90ae1400bf2 71
Vincent Coubard 638:c90ae1400bf2 72 /**@brief Errors originating from the Peer Manager module.
Vincent Coubard 638:c90ae1400bf2 73 */
Vincent Coubard 638:c90ae1400bf2 74 typedef enum
Vincent Coubard 638:c90ae1400bf2 75 {
Vincent Coubard 638:c90ae1400bf2 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. */
Vincent Coubard 638:c90ae1400bf2 77 PM_SEC_ERROR_CODE_MIC_FAILURE = BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE, /**< Pairing ended with disconnection because of mismatching keys. */
Vincent Coubard 638:c90ae1400bf2 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 */
Vincent Coubard 638:c90ae1400bf2 79 } pm_sec_error_code_t;
Vincent Coubard 638:c90ae1400bf2 80
Vincent Coubard 638:c90ae1400bf2 81
Vincent Coubard 638:c90ae1400bf2 82 /**@brief Enumeration describing the different procedures that can lead to an encrypted link.
Vincent Coubard 638:c90ae1400bf2 83 */
Vincent Coubard 638:c90ae1400bf2 84 typedef enum
Vincent Coubard 638:c90ae1400bf2 85 {
Vincent Coubard 638:c90ae1400bf2 86 PM_LINK_SECURED_PROCEDURE_ENCRYPTION, /**< Using an LTK shared during a previous bonding procedure to encrypt the link. */
Vincent Coubard 638:c90ae1400bf2 87 PM_LINK_SECURED_PROCEDURE_BONDING, /**< A pairing procedure, followed by a bonding procedure. */
Vincent Coubard 638:c90ae1400bf2 88 PM_LINK_SECURED_PROCEDURE_PAIRING, /**< A pairing procedure with no bonding. */
Vincent Coubard 638:c90ae1400bf2 89 } pm_sec_procedure_t;
Vincent Coubard 638:c90ae1400bf2 90
Vincent Coubard 638:c90ae1400bf2 91
Vincent Coubard 638:c90ae1400bf2 92 /**@brief Data associated with a bond to a peer.
Vincent Coubard 638:c90ae1400bf2 93 */
Vincent Coubard 638:c90ae1400bf2 94 typedef struct
Vincent Coubard 638:c90ae1400bf2 95 {
Vincent Coubard 638:c90ae1400bf2 96 uint8_t own_role; /**< The role of the local device during bonding. */
Vincent Coubard 638:c90ae1400bf2 97 ble_gap_id_key_t peer_id; /**< The peer's peer address and identity resolution key. */
Vincent Coubard 638:c90ae1400bf2 98 ble_gap_enc_key_t peer_ltk; /**< The peer's long term encryption key. */
Vincent Coubard 638:c90ae1400bf2 99 ble_gap_enc_key_t own_ltk; /**< Locally generated long term encryption key, distributed to the peer. */
Vincent Coubard 638:c90ae1400bf2 100 } pm_peer_data_bonding_t;
Vincent Coubard 638:c90ae1400bf2 101
Vincent Coubard 638:c90ae1400bf2 102
Vincent Coubard 638:c90ae1400bf2 103 /**@brief Function for calculating the flash size of bonding data.
Vincent Coubard 638:c90ae1400bf2 104 *
Vincent Coubard 638:c90ae1400bf2 105 * @return The number of words the data will take in flash.
Vincent Coubard 638:c90ae1400bf2 106 */
Vincent Coubard 638:c90ae1400bf2 107 static __INLINE uint16_t PM_BONDING_DATA_N_WORDS(void)
Vincent Coubard 638:c90ae1400bf2 108 {
Vincent Coubard 638:c90ae1400bf2 109 return PM_N_WORDS(sizeof(pm_peer_data_bonding_t));
Vincent Coubard 638:c90ae1400bf2 110 }
Vincent Coubard 638:c90ae1400bf2 111
Vincent Coubard 638:c90ae1400bf2 112
Vincent Coubard 638:c90ae1400bf2 113 /**@brief Function for calculating the flash size of service changed pending state.
Vincent Coubard 638:c90ae1400bf2 114 *
Vincent Coubard 638:c90ae1400bf2 115 * @return The number of words the data will take in flash.
Vincent Coubard 638:c90ae1400bf2 116 */
Vincent Coubard 638:c90ae1400bf2 117 static __INLINE uint16_t PM_SC_STATE_N_WORDS(void)
Vincent Coubard 638:c90ae1400bf2 118 {
Vincent Coubard 638:c90ae1400bf2 119 return PM_N_WORDS(sizeof(bool));
Vincent Coubard 638:c90ae1400bf2 120 }
Vincent Coubard 638:c90ae1400bf2 121
Vincent Coubard 638:c90ae1400bf2 122
Vincent Coubard 638:c90ae1400bf2 123 /**@brief Data on a local GATT database.
Vincent Coubard 638:c90ae1400bf2 124 */
Vincent Coubard 638:c90ae1400bf2 125 typedef struct
Vincent Coubard 638:c90ae1400bf2 126 {
Vincent Coubard 638:c90ae1400bf2 127 uint32_t flags; /**< Flags describing the database attributes. */
Vincent Coubard 638:c90ae1400bf2 128 uint16_t len; /**< Size of attribute array. */
Vincent Coubard 638:c90ae1400bf2 129 uint8_t * p_data; /**< Array to hold the database attributes. */
Vincent Coubard 638:c90ae1400bf2 130 } pm_peer_data_local_gatt_db_t;
Vincent Coubard 638:c90ae1400bf2 131
Vincent Coubard 638:c90ae1400bf2 132
Vincent Coubard 638:c90ae1400bf2 133 /**@brief Data on a local GATT database, as formatted in flash.
Vincent Coubard 638:c90ae1400bf2 134 */
Vincent Coubard 638:c90ae1400bf2 135 typedef struct
Vincent Coubard 638:c90ae1400bf2 136 {
Vincent Coubard 638:c90ae1400bf2 137 uint32_t flags;
Vincent Coubard 638:c90ae1400bf2 138 uint16_t len;
Vincent Coubard 638:c90ae1400bf2 139 uint16_t _padding;
Vincent Coubard 638:c90ae1400bf2 140 uint8_t p_data[];
Vincent Coubard 638:c90ae1400bf2 141 } pm_peer_data_local_gatt_db_flash_t;
Vincent Coubard 638:c90ae1400bf2 142
Vincent Coubard 638:c90ae1400bf2 143
Vincent Coubard 638:c90ae1400bf2 144 /**@brief Function for calculating the flash size of local GATT database data.
Vincent Coubard 638:c90ae1400bf2 145 *
Vincent Coubard 638:c90ae1400bf2 146 * @param[in] local_db_len The length of the database as reported by the SoftDevice.
Vincent Coubard 638:c90ae1400bf2 147 *
Vincent Coubard 638:c90ae1400bf2 148 * @return The number of words the data will take in flash.
Vincent Coubard 638:c90ae1400bf2 149 */
Vincent Coubard 638:c90ae1400bf2 150 static __INLINE uint16_t PM_LOCAL_DB_N_WORDS(uint16_t local_db_len)
Vincent Coubard 638:c90ae1400bf2 151 {
Vincent Coubard 638:c90ae1400bf2 152 return PM_N_WORDS(local_db_len + PM_LOCAL_DB_LEN_OVERHEAD_BYTES);
Vincent Coubard 638:c90ae1400bf2 153 }
Vincent Coubard 638:c90ae1400bf2 154
Vincent Coubard 638:c90ae1400bf2 155
Vincent Coubard 638:c90ae1400bf2 156 /**@brief Function for calculating the length of a local GATT database attribute array.
Vincent Coubard 638:c90ae1400bf2 157 *
Vincent Coubard 638:c90ae1400bf2 158 * @param[in] n_words The number of words the data takes in flash.
Vincent Coubard 638:c90ae1400bf2 159 *
Vincent Coubard 638:c90ae1400bf2 160 * @return The length of the database attribute array.
Vincent Coubard 638:c90ae1400bf2 161 */
Vincent Coubard 638:c90ae1400bf2 162 static __INLINE uint16_t PM_LOCAL_DB_LEN(uint16_t n_words)
Vincent Coubard 638:c90ae1400bf2 163 {
Vincent Coubard 638:c90ae1400bf2 164 return ((n_words * 4) - PM_LOCAL_DB_LEN_OVERHEAD_BYTES);
Vincent Coubard 638:c90ae1400bf2 165 }
Vincent Coubard 638:c90ae1400bf2 166
Vincent Coubard 638:c90ae1400bf2 167
Vincent Coubard 638:c90ae1400bf2 168 /**@brief Data on a remote GATT database.
Vincent Coubard 638:c90ae1400bf2 169 */
Vincent Coubard 638:c90ae1400bf2 170 typedef struct
Vincent Coubard 638:c90ae1400bf2 171 {
Vincent Coubard 638:c90ae1400bf2 172 uint32_t service_count; /**< Number of stored services. */
Vincent Coubard 638:c90ae1400bf2 173 ble_gatt_db_srv_t * p_data; /**< Array to hold the database attributes. */
Vincent Coubard 638:c90ae1400bf2 174 } pm_peer_data_remote_gatt_db_t;
Vincent Coubard 638:c90ae1400bf2 175
Vincent Coubard 638:c90ae1400bf2 176
Vincent Coubard 638:c90ae1400bf2 177 /**@brief Data on a remote GATT database, as formatted in flash.
Vincent Coubard 638:c90ae1400bf2 178 */
Vincent Coubard 638:c90ae1400bf2 179 typedef struct
Vincent Coubard 638:c90ae1400bf2 180 {
Vincent Coubard 638:c90ae1400bf2 181 uint32_t service_count;
Vincent Coubard 638:c90ae1400bf2 182 ble_gatt_db_srv_t p_data[];
Vincent Coubard 638:c90ae1400bf2 183 } pm_peer_data_remote_gatt_db_flash_t;
Vincent Coubard 638:c90ae1400bf2 184
Vincent Coubard 638:c90ae1400bf2 185
Vincent Coubard 638:c90ae1400bf2 186
Vincent Coubard 638:c90ae1400bf2 187 /**@brief Function for calculating the flash size of remote GATT database data.
Vincent Coubard 638:c90ae1400bf2 188 *
Vincent Coubard 638:c90ae1400bf2 189 * @param[in] service_count The number of services in the service array.
Vincent Coubard 638:c90ae1400bf2 190 *
Vincent Coubard 638:c90ae1400bf2 191 * @return The number of words the data will take in flash.
Vincent Coubard 638:c90ae1400bf2 192 */
Vincent Coubard 638:c90ae1400bf2 193 static __INLINE uint16_t PM_REMOTE_DB_N_WORDS(uint16_t service_count)
Vincent Coubard 638:c90ae1400bf2 194 {
Vincent Coubard 638:c90ae1400bf2 195 return PM_N_WORDS((sizeof(ble_gatt_db_srv_t) * service_count) + PM_REMOTE_DB_LEN_OVERHEAD_BYTES);
Vincent Coubard 638:c90ae1400bf2 196 }
Vincent Coubard 638:c90ae1400bf2 197
Vincent Coubard 638:c90ae1400bf2 198
Vincent Coubard 638:c90ae1400bf2 199 /**@brief Union of all data associated with one peer.
Vincent Coubard 638:c90ae1400bf2 200 */
Vincent Coubard 638:c90ae1400bf2 201 typedef union
Vincent Coubard 638:c90ae1400bf2 202 {
Vincent Coubard 638:c90ae1400bf2 203 pm_peer_data_bonding_t * p_bonding_data; /**< The exchanged bond information in addition to metadata of the bonding. */
Vincent Coubard 638:c90ae1400bf2 204 bool * p_service_changed_pending; /**< Whether a service changed indication should be sent to the peer. */
Vincent Coubard 638:c90ae1400bf2 205 pm_peer_data_local_gatt_db_t * p_local_gatt_db; /**< Persistent information pertaining to a peer GATT client. */
Vincent Coubard 638:c90ae1400bf2 206 pm_peer_data_remote_gatt_db_t * p_remote_gatt_db; /**< Persistent information pertaining to a peer GATT server. */
Vincent Coubard 638:c90ae1400bf2 207 uint8_t * p_application_data; /**< Arbitrary data to associate with the peer. This data can be freely used by the application. */
Vincent Coubard 638:c90ae1400bf2 208 } pm_peer_data_unit_t;
Vincent Coubard 638:c90ae1400bf2 209
Vincent Coubard 638:c90ae1400bf2 210
Vincent Coubard 638:c90ae1400bf2 211 /**@brief Immutable version of @ref pm_peer_data_unit_t.
Vincent Coubard 638:c90ae1400bf2 212 */
Vincent Coubard 638:c90ae1400bf2 213 typedef union
Vincent Coubard 638:c90ae1400bf2 214 {
Vincent Coubard 638:c90ae1400bf2 215 pm_peer_data_bonding_t const * p_bonding_data;
Vincent Coubard 638:c90ae1400bf2 216 bool const * p_service_changed_pending;
Vincent Coubard 638:c90ae1400bf2 217 pm_peer_data_local_gatt_db_t const * p_local_gatt_db;
Vincent Coubard 638:c90ae1400bf2 218 pm_peer_data_remote_gatt_db_t const * p_remote_gatt_db;
Vincent Coubard 638:c90ae1400bf2 219 uint8_t const * p_application_data;
Vincent Coubard 638:c90ae1400bf2 220 } pm_peer_data_unit_const_t;
Vincent Coubard 638:c90ae1400bf2 221
Vincent Coubard 638:c90ae1400bf2 222
Vincent Coubard 638:c90ae1400bf2 223 /**@brief Data from @ref pm_peer_data_unit_t, as mapped in flash.
Vincent Coubard 638:c90ae1400bf2 224 */
Vincent Coubard 638:c90ae1400bf2 225 typedef union
Vincent Coubard 638:c90ae1400bf2 226 {
Vincent Coubard 638:c90ae1400bf2 227 pm_peer_data_bonding_t const * p_bonding_data;
Vincent Coubard 638:c90ae1400bf2 228 bool const * p_service_changed_pending;
Vincent Coubard 638:c90ae1400bf2 229 pm_peer_data_local_gatt_db_flash_t const * p_local_gatt_db;
Vincent Coubard 638:c90ae1400bf2 230 pm_peer_data_remote_gatt_db_flash_t const * p_remote_gatt_db;
Vincent Coubard 638:c90ae1400bf2 231 uint8_t const * p_application_data;
Vincent Coubard 638:c90ae1400bf2 232 } pm_peer_data_unit_flash_t;
Vincent Coubard 638:c90ae1400bf2 233
Vincent Coubard 638:c90ae1400bf2 234
Vincent Coubard 638:c90ae1400bf2 235 /**@brief The different types of data associated with a peer.
Vincent Coubard 638:c90ae1400bf2 236 */
Vincent Coubard 638:c90ae1400bf2 237 typedef enum
Vincent Coubard 638:c90ae1400bf2 238 {
Vincent Coubard 638:c90ae1400bf2 239 PM_PEER_DATA_ID_BONDING,
Vincent Coubard 638:c90ae1400bf2 240 PM_PEER_DATA_ID_SERVICE_CHANGED_PENDING,
Vincent Coubard 638:c90ae1400bf2 241 PM_PEER_DATA_ID_GATT_LOCAL,
Vincent Coubard 638:c90ae1400bf2 242 PM_PEER_DATA_ID_GATT_REMOTE,
Vincent Coubard 638:c90ae1400bf2 243 PM_PEER_DATA_ID_APPLICATION,
Vincent Coubard 638:c90ae1400bf2 244 PM_PEER_DATA_ID_INVALID,
Vincent Coubard 638:c90ae1400bf2 245 } pm_peer_data_id_t;
Vincent Coubard 638:c90ae1400bf2 246
Vincent Coubard 638:c90ae1400bf2 247
Vincent Coubard 638:c90ae1400bf2 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.");
Vincent Coubard 638:c90ae1400bf2 249
Vincent Coubard 638:c90ae1400bf2 250
Vincent Coubard 638:c90ae1400bf2 251 /**@brief Macro saying whether a data_id is valid, i.e. one of the valid enum values.
Vincent Coubard 638:c90ae1400bf2 252 *
Vincent Coubard 638:c90ae1400bf2 253 * @param[in] data_id The data_id to check.
Vincent Coubard 638:c90ae1400bf2 254 */
Vincent Coubard 638:c90ae1400bf2 255 static __INLINE bool PM_PEER_DATA_ID_IS_VALID(pm_peer_data_id_t data_id)
Vincent Coubard 638:c90ae1400bf2 256 {
Vincent Coubard 638:c90ae1400bf2 257 return ((data_id - PM_PEER_DATA_ID_BONDING) < (PM_PEER_DATA_ID_INVALID - PM_PEER_DATA_ID_BONDING));
Vincent Coubard 638:c90ae1400bf2 258 }
Vincent Coubard 638:c90ae1400bf2 259
Vincent Coubard 638:c90ae1400bf2 260
Vincent Coubard 638:c90ae1400bf2 261 /**@brief One piece of data associated with a peer, together with the type.
Vincent Coubard 638:c90ae1400bf2 262 */
Vincent Coubard 638:c90ae1400bf2 263 typedef struct
Vincent Coubard 638:c90ae1400bf2 264 {
Vincent Coubard 638:c90ae1400bf2 265 uint16_t length_words;
Vincent Coubard 638:c90ae1400bf2 266 pm_peer_data_id_t data_type;
Vincent Coubard 638:c90ae1400bf2 267 pm_peer_data_unit_t data;
Vincent Coubard 638:c90ae1400bf2 268 } pm_peer_data_t;
Vincent Coubard 638:c90ae1400bf2 269
Vincent Coubard 638:c90ae1400bf2 270 /**@brief Immutable version of @ref pm_peer_data_t.
Vincent Coubard 638:c90ae1400bf2 271 */
Vincent Coubard 638:c90ae1400bf2 272 typedef struct
Vincent Coubard 638:c90ae1400bf2 273 {
Vincent Coubard 638:c90ae1400bf2 274 uint16_t length_words;
Vincent Coubard 638:c90ae1400bf2 275 pm_peer_data_id_t data_type;
Vincent Coubard 638:c90ae1400bf2 276 pm_peer_data_unit_const_t data;
Vincent Coubard 638:c90ae1400bf2 277 } pm_peer_data_const_t;
Vincent Coubard 638:c90ae1400bf2 278
Vincent Coubard 638:c90ae1400bf2 279 /**@brief Data from @ref pm_peer_data_t, as mapped in flash.
Vincent Coubard 638:c90ae1400bf2 280 */
Vincent Coubard 638:c90ae1400bf2 281 typedef struct
Vincent Coubard 638:c90ae1400bf2 282 {
Vincent Coubard 638:c90ae1400bf2 283 uint16_t length_words;
Vincent Coubard 638:c90ae1400bf2 284 pm_peer_data_id_t data_type;
Vincent Coubard 638:c90ae1400bf2 285 pm_peer_data_unit_flash_t data;
Vincent Coubard 638:c90ae1400bf2 286 } pm_peer_data_flash_t;
Vincent Coubard 638:c90ae1400bf2 287
Vincent Coubard 638:c90ae1400bf2 288
Vincent Coubard 638:c90ae1400bf2 289 /**@brief Typedef for type used for write prepares. Used to reserve space in flash
Vincent Coubard 638:c90ae1400bf2 290 */
Vincent Coubard 638:c90ae1400bf2 291 typedef uint32_t pm_prepare_token_t;
Vincent Coubard 638:c90ae1400bf2 292
Vincent Coubard 638:c90ae1400bf2 293
Vincent Coubard 638:c90ae1400bf2 294 /**@brief Typedef for type used to hold reference to stored item in flash.
Vincent Coubard 638:c90ae1400bf2 295 * this token can be used for locking and validity check
Vincent Coubard 638:c90ae1400bf2 296 */
Vincent Coubard 638:c90ae1400bf2 297 typedef uint32_t pm_store_token_t;
Vincent Coubard 638:c90ae1400bf2 298
Vincent Coubard 638:c90ae1400bf2 299 /** @} */
Vincent Coubard 638:c90ae1400bf2 300
Vincent Coubard 638:c90ae1400bf2 301 #endif /* PEER_MANAGER_TYPES_H__ */