cvb

Fork of nrf51-sdk by Lancaster University

Committer:
tb942
Date:
Tue Aug 14 18:27:20 2018 +0000
Revision:
9:d3dd910b0f4b
Parent:
0:bc2961fa1ef0

        

Who changed what in which revision?

UserRevisionLine numberNew 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 * @file
Jonathan Austin 0:bc2961fa1ef0 35 *
Jonathan Austin 0:bc2961fa1ef0 36 * @defgroup ble_conn_state Connection state
Jonathan Austin 0:bc2961fa1ef0 37 * @ingroup ble_sdk_lib
Jonathan Austin 0:bc2961fa1ef0 38 * @{
Jonathan Austin 0:bc2961fa1ef0 39 * @brief Module for storing data on BLE connections.
Jonathan Austin 0:bc2961fa1ef0 40 *
Jonathan Austin 0:bc2961fa1ef0 41 * @details This module stores certain states for each connection, which can be queried by
Jonathan Austin 0:bc2961fa1ef0 42 * connection handle. The module uses BLE events to keep the states updated.
Jonathan Austin 0:bc2961fa1ef0 43 *
Jonathan Austin 0:bc2961fa1ef0 44 * In addition to the preprogrammed states, this module can also keep track of a number of
Jonathan Austin 0:bc2961fa1ef0 45 * binary user states, or <i>user flags</i>. These are reset to 0 for new connections, but
Jonathan Austin 0:bc2961fa1ef0 46 * otherwise not touched by this module.
Jonathan Austin 0:bc2961fa1ef0 47 *
Jonathan Austin 0:bc2961fa1ef0 48 * This module uses the @ref sdk_mapped_flags module, with connection handles as keys and
Jonathan Austin 0:bc2961fa1ef0 49 * the connection states as flags.
Jonathan Austin 0:bc2961fa1ef0 50 *
Jonathan Austin 0:bc2961fa1ef0 51 * @note A connection handle is not immediately invalidated when it is disconnected. Certain states,
Jonathan Austin 0:bc2961fa1ef0 52 * such as the role, can still be queried until the next time a new connection is established
Jonathan Austin 0:bc2961fa1ef0 53 * to any device.
Jonathan Austin 0:bc2961fa1ef0 54 *
Jonathan Austin 0:bc2961fa1ef0 55 * To function properly, this module must be provided with BLE events from the SoftDevice
Jonathan Austin 0:bc2961fa1ef0 56 * through the @ref ble_conn_state_on_ble_evt() function. This module should be the first
Jonathan Austin 0:bc2961fa1ef0 57 * to receive BLE events if they are dispatched to multiple modules.
Jonathan Austin 0:bc2961fa1ef0 58 */
Jonathan Austin 0:bc2961fa1ef0 59
Jonathan Austin 0:bc2961fa1ef0 60 #ifndef BLE_CONN_STATE_H__
Jonathan Austin 0:bc2961fa1ef0 61 #define BLE_CONN_STATE_H__
Jonathan Austin 0:bc2961fa1ef0 62
Jonathan Austin 0:bc2961fa1ef0 63 #include <stdbool.h>
Jonathan Austin 0:bc2961fa1ef0 64 #include <stdint.h>
Jonathan Austin 0:bc2961fa1ef0 65 #include "ble.h"
Jonathan Austin 0:bc2961fa1ef0 66 #include "sdk_mapped_flags.h"
Jonathan Austin 0:bc2961fa1ef0 67
Jonathan Austin 0:bc2961fa1ef0 68 /**@brief Connection handle statuses.
Jonathan Austin 0:bc2961fa1ef0 69 */
Jonathan Austin 0:bc2961fa1ef0 70 typedef enum
Jonathan Austin 0:bc2961fa1ef0 71 {
Jonathan Austin 0:bc2961fa1ef0 72 BLE_CONN_STATUS_INVALID, /**< The connection handle is invalid. */
Jonathan Austin 0:bc2961fa1ef0 73 BLE_CONN_STATUS_DISCONNECTED, /**< The connection handle refers to a connection that has been disconnected, but not yet invalidated. */
Jonathan Austin 0:bc2961fa1ef0 74 BLE_CONN_STATUS_CONNECTED, /**< The connection handle refers to an active connection. */
Jonathan Austin 0:bc2961fa1ef0 75 } ble_conn_state_status_t;
Jonathan Austin 0:bc2961fa1ef0 76
Jonathan Austin 0:bc2961fa1ef0 77 #define BLE_CONN_STATE_N_USER_FLAGS 16 /**< The number of available user flags. */
Jonathan Austin 0:bc2961fa1ef0 78
Jonathan Austin 0:bc2961fa1ef0 79
Jonathan Austin 0:bc2961fa1ef0 80 /**@brief One ID for each user flag collection.
Jonathan Austin 0:bc2961fa1ef0 81 *
Jonathan Austin 0:bc2961fa1ef0 82 * @details These IDs are used to identify user flag collections in the API calls.
Jonathan Austin 0:bc2961fa1ef0 83 */
Jonathan Austin 0:bc2961fa1ef0 84 typedef enum
Jonathan Austin 0:bc2961fa1ef0 85 {
Jonathan Austin 0:bc2961fa1ef0 86 BLE_CONN_STATE_USER_FLAG0 = 0,
Jonathan Austin 0:bc2961fa1ef0 87 BLE_CONN_STATE_USER_FLAG1,
Jonathan Austin 0:bc2961fa1ef0 88 BLE_CONN_STATE_USER_FLAG2,
Jonathan Austin 0:bc2961fa1ef0 89 BLE_CONN_STATE_USER_FLAG3,
Jonathan Austin 0:bc2961fa1ef0 90 BLE_CONN_STATE_USER_FLAG4,
Jonathan Austin 0:bc2961fa1ef0 91 BLE_CONN_STATE_USER_FLAG5,
Jonathan Austin 0:bc2961fa1ef0 92 BLE_CONN_STATE_USER_FLAG6,
Jonathan Austin 0:bc2961fa1ef0 93 BLE_CONN_STATE_USER_FLAG7,
Jonathan Austin 0:bc2961fa1ef0 94 BLE_CONN_STATE_USER_FLAG8,
Jonathan Austin 0:bc2961fa1ef0 95 BLE_CONN_STATE_USER_FLAG9,
Jonathan Austin 0:bc2961fa1ef0 96 BLE_CONN_STATE_USER_FLAG10,
Jonathan Austin 0:bc2961fa1ef0 97 BLE_CONN_STATE_USER_FLAG11,
Jonathan Austin 0:bc2961fa1ef0 98 BLE_CONN_STATE_USER_FLAG12,
Jonathan Austin 0:bc2961fa1ef0 99 BLE_CONN_STATE_USER_FLAG13,
Jonathan Austin 0:bc2961fa1ef0 100 BLE_CONN_STATE_USER_FLAG14,
Jonathan Austin 0:bc2961fa1ef0 101 BLE_CONN_STATE_USER_FLAG15,
Jonathan Austin 0:bc2961fa1ef0 102 BLE_CONN_STATE_USER_FLAG_INVALID,
Jonathan Austin 0:bc2961fa1ef0 103 } ble_conn_state_user_flag_id_t;
Jonathan Austin 0:bc2961fa1ef0 104
Jonathan Austin 0:bc2961fa1ef0 105
Jonathan Austin 0:bc2961fa1ef0 106 /**
Jonathan Austin 0:bc2961fa1ef0 107 * @defgroup ble_conn_state_functions BLE connection state functions
Jonathan Austin 0:bc2961fa1ef0 108 * @{
Jonathan Austin 0:bc2961fa1ef0 109 */
Jonathan Austin 0:bc2961fa1ef0 110
Jonathan Austin 0:bc2961fa1ef0 111
Jonathan Austin 0:bc2961fa1ef0 112 /**@brief Function for initializing or resetting the module.
Jonathan Austin 0:bc2961fa1ef0 113 *
Jonathan Austin 0:bc2961fa1ef0 114 * @details This function sets all states to their default, removing all records of connection handles.
Jonathan Austin 0:bc2961fa1ef0 115 */
Jonathan Austin 0:bc2961fa1ef0 116 void ble_conn_state_init(void);
Jonathan Austin 0:bc2961fa1ef0 117
Jonathan Austin 0:bc2961fa1ef0 118
Jonathan Austin 0:bc2961fa1ef0 119 /**@brief Function for providing BLE SoftDevice events to the connection state module.
Jonathan Austin 0:bc2961fa1ef0 120 *
Jonathan Austin 0:bc2961fa1ef0 121 * @param[in] p_ble_evt The SoftDevice event.
Jonathan Austin 0:bc2961fa1ef0 122 */
Jonathan Austin 0:bc2961fa1ef0 123 void ble_conn_state_on_ble_evt(ble_evt_t * p_ble_evt);
Jonathan Austin 0:bc2961fa1ef0 124
Jonathan Austin 0:bc2961fa1ef0 125
Jonathan Austin 0:bc2961fa1ef0 126 /**@brief Function for querying whether a connection handle represents a valid connection.
Jonathan Austin 0:bc2961fa1ef0 127 *
Jonathan Austin 0:bc2961fa1ef0 128 * @details A connection might be valid and have a BLE_CONN_STATUS_DISCONNECTED status.
Jonathan Austin 0:bc2961fa1ef0 129 * Those connections are invalidated after a new connection occurs.
Jonathan Austin 0:bc2961fa1ef0 130 *
Jonathan Austin 0:bc2961fa1ef0 131 * @param[in] conn_handle Handle of the connection.
Jonathan Austin 0:bc2961fa1ef0 132 *
Jonathan Austin 0:bc2961fa1ef0 133 * @retval true If conn_handle represents a valid connection, thus a connection for which
Jonathan Austin 0:bc2961fa1ef0 134 we have a record.
Jonathan Austin 0:bc2961fa1ef0 135 * @retval false If conn_handle is @ref BLE_GAP_ROLE_INVALID, or if it has never been recorded.
Jonathan Austin 0:bc2961fa1ef0 136 */
Jonathan Austin 0:bc2961fa1ef0 137 bool ble_conn_state_valid(uint16_t conn_handle);
Jonathan Austin 0:bc2961fa1ef0 138
Jonathan Austin 0:bc2961fa1ef0 139
Jonathan Austin 0:bc2961fa1ef0 140 /**@brief Function for querying the role of the local device in a connection.
Jonathan Austin 0:bc2961fa1ef0 141 *
Jonathan Austin 0:bc2961fa1ef0 142 * @param[in] conn_handle Handle of the connection to get the role for.
Jonathan Austin 0:bc2961fa1ef0 143 *
Jonathan Austin 0:bc2961fa1ef0 144 * @return The role of the local device in the connection (see @ref BLE_GAP_ROLES).
Jonathan Austin 0:bc2961fa1ef0 145 * If conn_handle is not valid, the function returns BLE_GAP_ROLE_INVALID.
Jonathan Austin 0:bc2961fa1ef0 146 */
Jonathan Austin 0:bc2961fa1ef0 147 uint8_t ble_conn_state_role(uint16_t conn_handle);
Jonathan Austin 0:bc2961fa1ef0 148
Jonathan Austin 0:bc2961fa1ef0 149
Jonathan Austin 0:bc2961fa1ef0 150 /**@brief Function for querying the status of a connection.
Jonathan Austin 0:bc2961fa1ef0 151 *
Jonathan Austin 0:bc2961fa1ef0 152 * @param[in] conn_handle Handle of the connection.
Jonathan Austin 0:bc2961fa1ef0 153 *
Jonathan Austin 0:bc2961fa1ef0 154 * @return The status of the connection.
Jonathan Austin 0:bc2961fa1ef0 155 * If conn_handle is not valid, the function returns BLE_CONN_STATE_INVALID.
Jonathan Austin 0:bc2961fa1ef0 156 */
Jonathan Austin 0:bc2961fa1ef0 157 ble_conn_state_status_t ble_conn_state_status(uint16_t conn_handle);
Jonathan Austin 0:bc2961fa1ef0 158
Jonathan Austin 0:bc2961fa1ef0 159
Jonathan Austin 0:bc2961fa1ef0 160 /**@brief Function for querying whether a connection is encrypted.
Jonathan Austin 0:bc2961fa1ef0 161 *
Jonathan Austin 0:bc2961fa1ef0 162 * @param[in] conn_handle Handle of connection to get the encryption state for.
Jonathan Austin 0:bc2961fa1ef0 163 *
Jonathan Austin 0:bc2961fa1ef0 164 * @retval true If the connection is encrypted.
Jonathan Austin 0:bc2961fa1ef0 165 * @retval false If the connection is not encrypted or conn_handle is invalid.
Jonathan Austin 0:bc2961fa1ef0 166 */
Jonathan Austin 0:bc2961fa1ef0 167 bool ble_conn_state_encrypted(uint16_t conn_handle);
Jonathan Austin 0:bc2961fa1ef0 168
Jonathan Austin 0:bc2961fa1ef0 169
Jonathan Austin 0:bc2961fa1ef0 170 /**@brief Function for querying whether a connection encryption is protected from Man in the Middle
Jonathan Austin 0:bc2961fa1ef0 171 * attacks.
Jonathan Austin 0:bc2961fa1ef0 172 *
Jonathan Austin 0:bc2961fa1ef0 173 * @param[in] conn_handle Handle of connection to get the MITM state for.
Jonathan Austin 0:bc2961fa1ef0 174 *
Jonathan Austin 0:bc2961fa1ef0 175 * @retval true If the connection is encrypted with MITM protection.
Jonathan Austin 0:bc2961fa1ef0 176 * @retval false If the connection is not encrypted, or encryption is not MITM protected, or
Jonathan Austin 0:bc2961fa1ef0 177 * conn_handle is invalid.
Jonathan Austin 0:bc2961fa1ef0 178 */
Jonathan Austin 0:bc2961fa1ef0 179 bool ble_conn_state_mitm_protected(uint16_t conn_handle);
Jonathan Austin 0:bc2961fa1ef0 180
Jonathan Austin 0:bc2961fa1ef0 181
Jonathan Austin 0:bc2961fa1ef0 182 /**@brief Function for querying the total number of connections.
Jonathan Austin 0:bc2961fa1ef0 183 *
Jonathan Austin 0:bc2961fa1ef0 184 * @return The total number of valid connections for which the module has a record.
Jonathan Austin 0:bc2961fa1ef0 185 */
Jonathan Austin 0:bc2961fa1ef0 186 uint32_t ble_conn_state_n_connections(void);
Jonathan Austin 0:bc2961fa1ef0 187
Jonathan Austin 0:bc2961fa1ef0 188
Jonathan Austin 0:bc2961fa1ef0 189 /**@brief Function for querying the total number of connections in which the role of the local
Jonathan Austin 0:bc2961fa1ef0 190 * device is @ref BLE_GAP_ROLE_CENTRAL.
Jonathan Austin 0:bc2961fa1ef0 191 *
Jonathan Austin 0:bc2961fa1ef0 192 * @return The number of connections in which the role of the local device is
Jonathan Austin 0:bc2961fa1ef0 193 * @ref BLE_GAP_ROLE_CENTRAL.
Jonathan Austin 0:bc2961fa1ef0 194 */
Jonathan Austin 0:bc2961fa1ef0 195 uint32_t ble_conn_state_n_centrals(void);
Jonathan Austin 0:bc2961fa1ef0 196
Jonathan Austin 0:bc2961fa1ef0 197
Jonathan Austin 0:bc2961fa1ef0 198 /**@brief Function for querying the total number of connections in which the role of the local
Jonathan Austin 0:bc2961fa1ef0 199 * device is @ref BLE_GAP_ROLE_PERIPH.
Jonathan Austin 0:bc2961fa1ef0 200 *
Jonathan Austin 0:bc2961fa1ef0 201 * @return The number of connections in which the role of the local device is
Jonathan Austin 0:bc2961fa1ef0 202 * @ref BLE_GAP_ROLE_PERIPH.
Jonathan Austin 0:bc2961fa1ef0 203 */
Jonathan Austin 0:bc2961fa1ef0 204 uint32_t ble_conn_state_n_peripherals(void);
Jonathan Austin 0:bc2961fa1ef0 205
Jonathan Austin 0:bc2961fa1ef0 206
Jonathan Austin 0:bc2961fa1ef0 207 /**@brief Function for obtaining a list of all connection handles for which the module has a record.
Jonathan Austin 0:bc2961fa1ef0 208 *
Jonathan Austin 0:bc2961fa1ef0 209 * @details This function takes into account connections whose state is BLE_CONN_STATUS_DISCONNECTED.
Jonathan Austin 0:bc2961fa1ef0 210 *
Jonathan Austin 0:bc2961fa1ef0 211 * @return A list of all valid connection handles for which the module has a record.
Jonathan Austin 0:bc2961fa1ef0 212 */
Jonathan Austin 0:bc2961fa1ef0 213 sdk_mapped_flags_key_list_t ble_conn_state_conn_handles(void);
Jonathan Austin 0:bc2961fa1ef0 214
Jonathan Austin 0:bc2961fa1ef0 215
Jonathan Austin 0:bc2961fa1ef0 216 /**@brief Function for obtaining a list of connection handles in which the role of the local
Jonathan Austin 0:bc2961fa1ef0 217 * device is @ref BLE_GAP_ROLE_CENTRAL.
Jonathan Austin 0:bc2961fa1ef0 218 *
Jonathan Austin 0:bc2961fa1ef0 219 * @details This function takes into account connections whose state is BLE_CONN_STATUS_DISCONNECTED.
Jonathan Austin 0:bc2961fa1ef0 220 *
Jonathan Austin 0:bc2961fa1ef0 221 * @return A list of all valid connection handles for which the module has a record and in which
Jonathan Austin 0:bc2961fa1ef0 222 * the role of local device is @ref BLE_GAP_ROLE_CENTRAL.
Jonathan Austin 0:bc2961fa1ef0 223 */
Jonathan Austin 0:bc2961fa1ef0 224 sdk_mapped_flags_key_list_t ble_conn_state_central_handles(void);
Jonathan Austin 0:bc2961fa1ef0 225
Jonathan Austin 0:bc2961fa1ef0 226
Jonathan Austin 0:bc2961fa1ef0 227 /**@brief Function for obtaining the handle for the connection in which the role of the local device
Jonathan Austin 0:bc2961fa1ef0 228 * is @ref BLE_GAP_ROLE_PERIPH.
Jonathan Austin 0:bc2961fa1ef0 229 *
Jonathan Austin 0:bc2961fa1ef0 230 * @details This function takes into account connections whose state is BLE_CONN_STATUS_DISCONNECTED.
Jonathan Austin 0:bc2961fa1ef0 231 *
Jonathan Austin 0:bc2961fa1ef0 232 * @return A list of all valid connection handles for which the module has a record and in which
Jonathan Austin 0:bc2961fa1ef0 233 * the role of local device is @ref BLE_GAP_ROLE_PERIPH.
Jonathan Austin 0:bc2961fa1ef0 234 */
Jonathan Austin 0:bc2961fa1ef0 235 sdk_mapped_flags_key_list_t ble_conn_state_periph_handles(void);
Jonathan Austin 0:bc2961fa1ef0 236
Jonathan Austin 0:bc2961fa1ef0 237
Jonathan Austin 0:bc2961fa1ef0 238 /**@brief Function for obtaining exclusive access to one of the user flag collections.
Jonathan Austin 0:bc2961fa1ef0 239 *
Jonathan Austin 0:bc2961fa1ef0 240 * @details The acquired collection contains one flag for each connection. These flags can be set
Jonathan Austin 0:bc2961fa1ef0 241 * and read individually for each connection.
Jonathan Austin 0:bc2961fa1ef0 242 *
Jonathan Austin 0:bc2961fa1ef0 243 * The state of user flags will not be modified by the connection state module, except to
Jonathan Austin 0:bc2961fa1ef0 244 * set it to 0 for a connection when that connection is invalidated.
Jonathan Austin 0:bc2961fa1ef0 245 *
Jonathan Austin 0:bc2961fa1ef0 246 * @return The ID of the acquired flag, or BLE_CONN_STATE_USER_FLAG_INVALID if none are available.
Jonathan Austin 0:bc2961fa1ef0 247 */
Jonathan Austin 0:bc2961fa1ef0 248 ble_conn_state_user_flag_id_t ble_conn_state_user_flag_acquire(void);
Jonathan Austin 0:bc2961fa1ef0 249
Jonathan Austin 0:bc2961fa1ef0 250
Jonathan Austin 0:bc2961fa1ef0 251 /**@brief Function for reading the value of a user flag.
Jonathan Austin 0:bc2961fa1ef0 252 *
Jonathan Austin 0:bc2961fa1ef0 253 * @param[in] conn_handle Handle of connection to get the flag state for.
Jonathan Austin 0:bc2961fa1ef0 254 * @param[in] flag_id Which flag to get the state for.
Jonathan Austin 0:bc2961fa1ef0 255 *
Jonathan Austin 0:bc2961fa1ef0 256 * @return The state of the flag. If conn_handle is invalid, the function returns false.
Jonathan Austin 0:bc2961fa1ef0 257 */
Jonathan Austin 0:bc2961fa1ef0 258 bool ble_conn_state_user_flag_get(uint16_t conn_handle, ble_conn_state_user_flag_id_t flag_id);
Jonathan Austin 0:bc2961fa1ef0 259
Jonathan Austin 0:bc2961fa1ef0 260
Jonathan Austin 0:bc2961fa1ef0 261 /**@brief Function for setting the value of a user flag.
Jonathan Austin 0:bc2961fa1ef0 262 *
Jonathan Austin 0:bc2961fa1ef0 263 * @param[in] conn_handle Handle of connection to set the flag state for.
Jonathan Austin 0:bc2961fa1ef0 264 * @param[in] flag_id Which flag to set the state for.
Jonathan Austin 0:bc2961fa1ef0 265 * @param[in] value Value to set the flag state to.
Jonathan Austin 0:bc2961fa1ef0 266 */
Jonathan Austin 0:bc2961fa1ef0 267 void ble_conn_state_user_flag_set(uint16_t conn_handle,
Jonathan Austin 0:bc2961fa1ef0 268 ble_conn_state_user_flag_id_t flag_id,
Jonathan Austin 0:bc2961fa1ef0 269 bool value);
Jonathan Austin 0:bc2961fa1ef0 270
Jonathan Austin 0:bc2961fa1ef0 271
Jonathan Austin 0:bc2961fa1ef0 272 /**@brief Function for getting the state of a user flag for all connection handles.
Jonathan Austin 0:bc2961fa1ef0 273 *
Jonathan Austin 0:bc2961fa1ef0 274 * @details The returned collection can be used with the @ref sdk_mapped_flags API. The returned
Jonathan Austin 0:bc2961fa1ef0 275 * collection is a copy, so modifying it has no effect on the conn_state module.
Jonathan Austin 0:bc2961fa1ef0 276 *
Jonathan Austin 0:bc2961fa1ef0 277 * @param[in] flag_id Which flag to get states for.
Jonathan Austin 0:bc2961fa1ef0 278 *
Jonathan Austin 0:bc2961fa1ef0 279 * @return The collection of flag states. The collection is always all zeros when the flag_id is
Jonathan Austin 0:bc2961fa1ef0 280 * unregistered.
Jonathan Austin 0:bc2961fa1ef0 281 */
Jonathan Austin 0:bc2961fa1ef0 282 sdk_mapped_flags_t ble_conn_state_user_flag_collection(ble_conn_state_user_flag_id_t flag_id);
Jonathan Austin 0:bc2961fa1ef0 283
Jonathan Austin 0:bc2961fa1ef0 284 /** @} */
Jonathan Austin 0:bc2961fa1ef0 285 /** @} */
Jonathan Austin 0:bc2961fa1ef0 286
Jonathan Austin 0:bc2961fa1ef0 287 #endif /* BLE_CONN_STATE_H__ */