David Kester / nRF51822

Dependents:   GonioTrainer

Fork of nRF51822 by Nordic Semiconductor

Committer:
dkester
Date:
Thu Jun 11 20:58:18 2015 +0000
Revision:
187:02500109ccb8
Parent:
124:664d4257a9f8
change to goniometer;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 103:138bdc859cc9 1 /* Copyright (C) 2013 Nordic Semiconductor. All Rights Reserved.
rgrover1 103:138bdc859cc9 2 *
rgrover1 103:138bdc859cc9 3 * The information contained herein is property of Nordic Semiconductor ASA.
rgrover1 103:138bdc859cc9 4 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
rgrover1 103:138bdc859cc9 5 *
rgrover1 103:138bdc859cc9 6 * Licensees are granted free, non-transferable use of the information. NO
rgrover1 103:138bdc859cc9 7 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
rgrover1 103:138bdc859cc9 8 * the file.
rgrover1 103:138bdc859cc9 9 *
rgrover1 103:138bdc859cc9 10 */
rgrover1 103:138bdc859cc9 11
rgrover1 103:138bdc859cc9 12 /**
rgrover1 103:138bdc859cc9 13 * @file device_manager.h
rgrover1 103:138bdc859cc9 14 *
rgrover1 103:138bdc859cc9 15 * @defgroup device_manager Device Manager
rgrover1 103:138bdc859cc9 16 * @ingroup ble_sdk_lib
rgrover1 103:138bdc859cc9 17 * @{
rgrover1 103:138bdc859cc9 18 * @brief Device Manager Application Interface Abstraction.
rgrover1 103:138bdc859cc9 19 *
rgrover1 103:138bdc859cc9 20 * @details The Device Manager module manages Active and Bonded Peers. Management of peer includes
rgrover1 103:138bdc859cc9 21 * book keeping of contextual information like the Security Keys, GATT
rgrover1 103:138bdc859cc9 22 * configuration and any application specific information.
rgrover1 103:138bdc859cc9 23 *
rgrover1 103:138bdc859cc9 24 * Active Peers are devices which are connected, and may or may not be bonded.
rgrover1 103:138bdc859cc9 25 * Bonded Peers are devices which are bonded, and may or may not be Active (Connected).
rgrover1 103:138bdc859cc9 26 * Active Bonded Peer refers to a device which is connected and bonded.
rgrover1 103:138bdc859cc9 27 *
rgrover1 103:138bdc859cc9 28 * Paired Devices refers to peer devices that are connected and have necessary context
rgrover1 103:138bdc859cc9 29 * establishment/exchange for the current connection session. On disconnect,
rgrover1 103:138bdc859cc9 30 * all contextual information is flushed. For example, SMP Information Exchanged during
rgrover1 103:138bdc859cc9 31 * pairing and GATT Configuration is not retained on disconnection.
rgrover1 103:138bdc859cc9 32 *
rgrover1 112:737b08b3b995 33 * Note that this module allows management of contextual information but
rgrover1 103:138bdc859cc9 34 * does not provide an interface for connection management. Therefore, entering connectible
rgrover1 103:138bdc859cc9 35 * mode, connection establishment, or disconnection of a link with peer is not in scope
rgrover1 103:138bdc859cc9 36 * of this module.
rgrover1 103:138bdc859cc9 37 *
rgrover1 103:138bdc859cc9 38 * For bonded peers, the contextual information is required to be retained on disconnection
rgrover1 103:138bdc859cc9 39 * and power cycling. Persistent storage of contextual information is handled by the
rgrover1 103:138bdc859cc9 40 * module. This module categorizes the contextual information into 3 categories:
rgrover1 103:138bdc859cc9 41 * - <b>Bonding Information</b>
rgrover1 103:138bdc859cc9 42 * Bond information is the information exchanged between local and peer device to
rgrover1 103:138bdc859cc9 43 * establish a bond. It also includes peer identification information,
rgrover1 103:138bdc859cc9 44 * like the peer address or the IRK or both. From here on this category of information
rgrover1 103:138bdc859cc9 45 * is referred to as Device Context.
rgrover1 103:138bdc859cc9 46 * - <b>Service/Protocol Information</b>
rgrover1 103:138bdc859cc9 47 * Service/Protocol information is the information retained for the peer to save on one-time
rgrover1 103:138bdc859cc9 48 * procedures like the GATT Service Discovery procedures and Service Configurations.
rgrover1 103:138bdc859cc9 49 * It allows devices to resume data exchange on subsequent reconnection without having
rgrover1 103:138bdc859cc9 50 * to perform initial set-up procedures each time. From here on this category is
rgrover1 103:138bdc859cc9 51 * referred to as Service Context.
rgrover1 103:138bdc859cc9 52 * - <b>Application Information</b>
rgrover1 103:138bdc859cc9 53 * Application information is the context that the application would like to associate with
rgrover1 103:138bdc859cc9 54 * each of the bonded device. For example, if the application chooses to rank its peers
rgrover1 103:138bdc859cc9 55 * in order to manage them better, the rank information could be treated as
rgrover1 103:138bdc859cc9 56 * Application Information. This storage space is provided to save the application from
rgrover1 103:138bdc859cc9 57 * maintaining a mapping table with each Device Instance and Application Information.
rgrover1 103:138bdc859cc9 58 * However, if the application have no use for this, it is possible to not
rgrover1 103:138bdc859cc9 59 * use or employ this at compile time. From here on this category of information is
rgrover1 103:138bdc859cc9 60 * referred to as Application Context.
rgrover1 103:138bdc859cc9 61 */
rgrover1 103:138bdc859cc9 62
rgrover1 103:138bdc859cc9 63
rgrover1 103:138bdc859cc9 64 #ifndef DEVICE_MANAGER_H__
rgrover1 103:138bdc859cc9 65 #define DEVICE_MANAGER_H__
rgrover1 103:138bdc859cc9 66
rgrover1 103:138bdc859cc9 67 #include <stdint.h>
rgrover1 103:138bdc859cc9 68 #include <stdbool.h>
rgrover1 103:138bdc859cc9 69 #include "sdk_common.h"
rgrover1 103:138bdc859cc9 70 #include "ble.h"
rgrover1 103:138bdc859cc9 71 #include "ble_gap.h"
rgrover1 103:138bdc859cc9 72 #include "device_manager_cnfg.h"
rgrover1 103:138bdc859cc9 73
rgrover1 124:664d4257a9f8 74 #ifdef __cplusplus
rgrover1 124:664d4257a9f8 75 extern "C" {
rgrover1 124:664d4257a9f8 76 #endif
rgrover1 124:664d4257a9f8 77
rgrover1 103:138bdc859cc9 78 /**
rgrover1 103:138bdc859cc9 79 * @defgroup dm_service_cntext_types Service/Protocol Types
rgrover1 103:138bdc859cc9 80 *
rgrover1 103:138bdc859cc9 81 * @brief Describes the possible types of Service/Protocol Contexts for a bonded/peer device.
rgrover1 103:138bdc859cc9 82 *
rgrover1 103:138bdc859cc9 83 * @details Possible Service/Protocol context per peer device. The Device Manager provides the
rgrover1 103:138bdc859cc9 84 * functionality of persistently storing the Service/Protocol context and can automatically
rgrover1 103:138bdc859cc9 85 * load them when needed.
rgrover1 112:737b08b3b995 86 * For example system attributes for a GATT Server. Based on the nature of the application,
rgrover1 103:138bdc859cc9 87 * not all service types may be needed. The application can specify
rgrover1 103:138bdc859cc9 88 * only the service/protocol context it wants to use at the time of registration.
rgrover1 103:138bdc859cc9 89 * @{
rgrover1 103:138bdc859cc9 90 */
rgrover1 103:138bdc859cc9 91 #define DM_PROTOCOL_CNTXT_NONE 0x00 /**< No Service Context, this implies the application does not want to associate any service/protocol context with the peer device */
rgrover1 103:138bdc859cc9 92 #define DM_PROTOCOL_CNTXT_GATT_SRVR_ID 0x01 /**< GATT Server Service Context, this implies the application does associate GATT Server with the peer device and this information will be loaded when needed for a bonded device */
rgrover1 103:138bdc859cc9 93 #define DM_PROTOCOL_CNTXT_GATT_CLI_ID 0x02 /**< GATT Client Service Context, this implies the application does associate GATT Client with the peer device and this information will be loaded when needed for a bonded device */
rgrover1 103:138bdc859cc9 94 #define DM_PROTOCOL_CNTXT_ALL \
rgrover1 103:138bdc859cc9 95 (DM_PROTOCOL_CNTXT_GATT_SRVR_ID | DM_PROTOCOL_CNTXT_GATT_CLI_ID) /**< All Service/Protocol Context, this implies that the application wants to associate all Service/Protocol Information with the bonded device. This is configurable based on system requirements. If the application has only one type of service, this define could be altered to reflect the same. */
rgrover1 103:138bdc859cc9 96 /** @} */
rgrover1 103:138bdc859cc9 97
rgrover1 103:138bdc859cc9 98
rgrover1 103:138bdc859cc9 99 /**
rgrover1 103:138bdc859cc9 100 * @defgroup dm_events Device Manager Events
rgrover1 103:138bdc859cc9 101 *
rgrover1 103:138bdc859cc9 102 * @brief This section describes the device manager events that are notified to the application.
rgrover1 103:138bdc859cc9 103 *
rgrover1 103:138bdc859cc9 104 * @details The Device Manager notifies the application of various asynchronous events using the
rgrover1 103:138bdc859cc9 105 * asynchronous event notification callback. All events has been categorized into:
rgrover1 103:138bdc859cc9 106 * a. General.
rgrover1 103:138bdc859cc9 107 * b. Link Status.
rgrover1 103:138bdc859cc9 108 * c. Context Management.
rgrover1 103:138bdc859cc9 109 *
rgrover1 103:138bdc859cc9 110 * In the callback, these events are notified along with handle that uniquely identifies:
rgrover1 103:138bdc859cc9 111 * application instance, active instance (if applicable), device instance
rgrover1 103:138bdc859cc9 112 * bonding instance, (if applicable) and service instance.
rgrover1 103:138bdc859cc9 113 * Not all events are pertaining to an active connection, for example a context deletion event could occur even if the peer
rgrover1 103:138bdc859cc9 114 * is not connected. Also, general category of events may not be pertaining to any specific peer.
rgrover1 103:138bdc859cc9 115 * See also \ref dm_event_cb_t and \ref dm_register.
rgrover1 103:138bdc859cc9 116 * @{
rgrover1 103:138bdc859cc9 117 */
rgrover1 103:138bdc859cc9 118 /**
rgrover1 103:138bdc859cc9 119 * @defgroup general_events General Events
rgrover1 103:138bdc859cc9 120 *
rgrover1 103:138bdc859cc9 121 * @brief General or miscellaneous events.
rgrover1 103:138bdc859cc9 122 *
rgrover1 103:138bdc859cc9 123 * @details This category of events are general events not pertaining to a peer or context.
rgrover1 103:138bdc859cc9 124 *
rgrover1 103:138bdc859cc9 125 * @{
rgrover1 103:138bdc859cc9 126 */
rgrover1 103:138bdc859cc9 127 #define DM_EVT_RFU 0x00 /**< Reserved for future use, is never notified. */
rgrover1 103:138bdc859cc9 128 #define DM_EVT_ERROR 0x01 /**< Device Manager Event Error. */
rgrover1 103:138bdc859cc9 129 /** @} */
rgrover1 103:138bdc859cc9 130
rgrover1 103:138bdc859cc9 131 /**
rgrover1 103:138bdc859cc9 132 * @defgroup link_status_events Link Status Events
rgrover1 103:138bdc859cc9 133 *
rgrover1 103:138bdc859cc9 134 * @brief Link Status Events.
rgrover1 103:138bdc859cc9 135 *
rgrover1 103:138bdc859cc9 136 * @details This category of events notify the application of the link status. Event result associated
rgrover1 103:138bdc859cc9 137 * with the event is provided along with the event in the callback to provide more details of
rgrover1 103:138bdc859cc9 138 * whether a procedure succeeded or failed and assist the application in decision making of
rgrover1 103:138bdc859cc9 139 * how to proceed. For example if a DM_DEVICE_CONNECT_IND is indicated with NRF_SUCCESS
rgrover1 103:138bdc859cc9 140 * result, the application may want to proceed with discovering and association with
rgrover1 103:138bdc859cc9 141 * service of the peer. However, if indicated with a failure result, the application may
rgrover1 103:138bdc859cc9 142 * want to take an alternate action such as reattempting to connect or go into a
rgrover1 103:138bdc859cc9 143 * sleep mode.
rgrover1 103:138bdc859cc9 144 *
rgrover1 103:138bdc859cc9 145 * @{
rgrover1 103:138bdc859cc9 146 */
rgrover1 103:138bdc859cc9 147 #define DM_EVT_CONNECTION 0x11 /**< Indicates that link with the peer is established. */
rgrover1 103:138bdc859cc9 148 #define DM_EVT_DISCONNECTION 0x12 /**< Indicates that link with peer is torn down. */
rgrover1 103:138bdc859cc9 149 #define DM_EVT_SECURITY_SETUP 0x13 /**< Security procedure for link started indication */
rgrover1 103:138bdc859cc9 150 #define DM_EVT_SECURITY_SETUP_COMPLETE 0x14 /**< Security procedure for link completion indication. */
rgrover1 103:138bdc859cc9 151 #define DM_EVT_LINK_SECURED 0x15 /**< Indicates that link with the peer is secured. For bonded devices, subsequent reconnections with bonded peer will result only in this event when the link is secured and setup procedures will not occur unless the bonding information is either lost or deleted on either or both sides. */
rgrover1 103:138bdc859cc9 152 #define DM_EVT_SECURITY_SETUP_REFRESH 0x16 /**< Indicates that the security on the link was re-established. */
rgrover1 103:138bdc859cc9 153 /** @} */
rgrover1 103:138bdc859cc9 154
rgrover1 103:138bdc859cc9 155 /**
rgrover1 103:138bdc859cc9 156 * @defgroup context_mgmt_events Context Management Events
rgrover1 103:138bdc859cc9 157 *
rgrover1 103:138bdc859cc9 158 * @brief Context Management Events.
rgrover1 103:138bdc859cc9 159 *
rgrover1 103:138bdc859cc9 160 * @details These events notify the application of the status of context loading and storing.
rgrover1 103:138bdc859cc9 161 *
rgrover1 103:138bdc859cc9 162 * @{
rgrover1 103:138bdc859cc9 163 */
rgrover1 103:138bdc859cc9 164 #define DM_EVT_DEVICE_CONTEXT_LOADED 0x21 /**< Indicates that device context for a peer is loaded. */
rgrover1 103:138bdc859cc9 165 #define DM_EVT_DEVICE_CONTEXT_STORED 0x22 /**< Indicates that device context is stored persistently. */
rgrover1 103:138bdc859cc9 166 #define DM_EVT_DEVICE_CONTEXT_DELETED 0x23 /**< Indicates that device context is deleted. */
rgrover1 103:138bdc859cc9 167 #define DM_EVT_SERVICE_CONTEXT_LOADED 0x31 /**< Indicates that service context for a peer is loaded. */
rgrover1 103:138bdc859cc9 168 #define DM_EVT_SERVICE_CONTEXT_STORED 0x32 /**< Indicates that service context is stored persistently. */
rgrover1 103:138bdc859cc9 169 #define DM_EVT_SERVICE_CONTEXT_DELETED 0x33 /**< Indicates that service context is deleted. */
rgrover1 103:138bdc859cc9 170 #define DM_EVT_APPL_CONTEXT_LOADED 0x41 /**< Indicates that application context for a peer is loaded. */
rgrover1 103:138bdc859cc9 171 #define DM_EVT_APPL_CONTEXT_STORED 0x42 /**< Indicates that application context is stored persistently. */
rgrover1 103:138bdc859cc9 172 #define DM_EVT_APPL_CONTEXT_DELETED 0x43 /**< Indicates that application context is deleted. */
rgrover1 103:138bdc859cc9 173 /** @} */
rgrover1 103:138bdc859cc9 174 /** @} */
rgrover1 103:138bdc859cc9 175
rgrover1 103:138bdc859cc9 176 #define DM_INVALID_ID 0xFF /**< Invalid instance idenitifer. */
rgrover1 103:138bdc859cc9 177
rgrover1 103:138bdc859cc9 178 /**
rgrover1 103:138bdc859cc9 179 * @defgroup dm_data_structure Device Manager Data Types
rgrover1 103:138bdc859cc9 180 *
rgrover1 103:138bdc859cc9 181 * @brief This section describes all the data types exposed by the module to the application.
rgrover1 103:138bdc859cc9 182 * @{
rgrover1 103:138bdc859cc9 183 */
rgrover1 103:138bdc859cc9 184
rgrover1 103:138bdc859cc9 185 /**
rgrover1 103:138bdc859cc9 186 * @brief Application Instance.
rgrover1 103:138bdc859cc9 187 *
rgrover1 103:138bdc859cc9 188 * @details Application instance uniquely identifies an application. The identifier is allocated by
rgrover1 103:138bdc859cc9 189 * the device manager when application registers with the module. The application is
rgrover1 103:138bdc859cc9 190 * expected to identify itself with this instance identifier when initiating subsequent
rgrover1 103:138bdc859cc9 191 * requests. Application should use the utility API \ref dm_application_instance_set in
rgrover1 103:138bdc859cc9 192 * order to set its application instance in dm_handle_t needed for all subsequent APIs.
rgrover1 103:138bdc859cc9 193 * See also \ref dm_register.
rgrover1 103:138bdc859cc9 194 */
rgrover1 103:138bdc859cc9 195 typedef uint8_t dm_application_instance_t;
rgrover1 103:138bdc859cc9 196
rgrover1 103:138bdc859cc9 197 /**
rgrover1 103:138bdc859cc9 198 * @brief Connection Instance.
rgrover1 103:138bdc859cc9 199 *
rgrover1 112:737b08b3b995 200 * @details Identifies connection instance for an active device. This instance is allocated by the
rgrover1 103:138bdc859cc9 201 * device manager when a connection is established and is notified with DM_EVT_CONNECTION
rgrover1 103:138bdc859cc9 202 * with the event result NRF_SUCCESS.
rgrover1 103:138bdc859cc9 203 */
rgrover1 103:138bdc859cc9 204 typedef uint8_t dm_connection_instance_t;
rgrover1 103:138bdc859cc9 205
rgrover1 103:138bdc859cc9 206 /**
rgrover1 103:138bdc859cc9 207 * @brief Device Instance.
rgrover1 103:138bdc859cc9 208 *
rgrover1 103:138bdc859cc9 209 * @details Uniquely identifies a bonded peer device. The peer device may or may not be connected.
rgrover1 103:138bdc859cc9 210 * In case of the central: The bonded device instance to identify the peer is allocated when bonding procedure is initiated by the central using dm_security_setup_req.
rgrover1 103:138bdc859cc9 211 * In case of the peripheral: When the bonding procedure is successful, the DM_EVT_SECURITY_SETUP_COMPLETE event with success event result, is received.
rgrover1 103:138bdc859cc9 212 * In case the module cannot add more bonded devices, no instance is allocated, this is indicated by an appropriate error code for the API/event as the case may be. Application can choose to disconnect the link.
rgrover1 103:138bdc859cc9 213 */
rgrover1 103:138bdc859cc9 214 typedef uint8_t dm_device_instance_t;
rgrover1 103:138bdc859cc9 215
rgrover1 103:138bdc859cc9 216 /**
rgrover1 103:138bdc859cc9 217 * @brief Service Instance.
rgrover1 103:138bdc859cc9 218 *
rgrover1 103:138bdc859cc9 219 * @details Uniquely identifies a peer device. The peer device may or may not be connected. This
rgrover1 103:138bdc859cc9 220 * instance is allocated by the device manager when a device is bonded and is notified
rgrover1 103:138bdc859cc9 221 * when security procedures have been initiated.
rgrover1 103:138bdc859cc9 222 * Security Procedures initiation is notified with DM_SECURITY_SETUP_IND with
rgrover1 103:138bdc859cc9 223 * success event result. In case the event result indicates that the module cannot add more
rgrover1 103:138bdc859cc9 224 * bonded devices, no instance is allocated. Application can chose to disconnect the link.
rgrover1 103:138bdc859cc9 225 */
rgrover1 103:138bdc859cc9 226 typedef uint8_t dm_service_instance_t;
rgrover1 103:138bdc859cc9 227
rgrover1 103:138bdc859cc9 228 /**
rgrover1 103:138bdc859cc9 229 * @brief Service/Protocol Type Identifier.
rgrover1 103:138bdc859cc9 230 *
rgrover1 103:138bdc859cc9 231 * @details Uniquely identifies a service or a protocol type. Service/Protocol Type identification
rgrover1 103:138bdc859cc9 232 * is needed as each service/protocol can have its own contextual data.
rgrover1 103:138bdc859cc9 233 * This allows the peer to access more than one service at a time. \ref dm_service_cntext_types describes the
rgrover1 103:138bdc859cc9 234 * list of services/protocols supported.
rgrover1 103:138bdc859cc9 235 */
rgrover1 103:138bdc859cc9 236 typedef uint8_t service_type_t;
rgrover1 103:138bdc859cc9 237
rgrover1 103:138bdc859cc9 238 /**@brief Device Manager Master identification and encryption information. */
rgrover1 103:138bdc859cc9 239 typedef struct dm_enc_key
rgrover1 103:138bdc859cc9 240 {
rgrover1 103:138bdc859cc9 241 ble_gap_enc_info_t enc_info; /**< GAP encryption information. */
rgrover1 103:138bdc859cc9 242 ble_gap_master_id_t master_id; /**< Master identification. */
rgrover1 103:138bdc859cc9 243 } dm_enc_key_t;
rgrover1 103:138bdc859cc9 244
rgrover1 103:138bdc859cc9 245 /** @brief Device Manager identity and address information. */
rgrover1 103:138bdc859cc9 246 typedef struct dm_id_key
rgrover1 103:138bdc859cc9 247 {
rgrover1 103:138bdc859cc9 248 ble_gap_irk_t id_info; /**< Identity information. */
rgrover1 103:138bdc859cc9 249 ble_gap_addr_t id_addr_info; /**< Identity address information. */
rgrover1 103:138bdc859cc9 250 } dm_id_key_t;
rgrover1 103:138bdc859cc9 251
rgrover1 103:138bdc859cc9 252 /** @brief Device Manager signing information. */
rgrover1 103:138bdc859cc9 253 typedef struct dm_sign_key
rgrover1 103:138bdc859cc9 254 {
rgrover1 103:138bdc859cc9 255 ble_gap_sign_info_t sign_key; /**< GAP signing information. */
rgrover1 103:138bdc859cc9 256 } dm_sign_key_t;
rgrover1 103:138bdc859cc9 257
rgrover1 103:138bdc859cc9 258 /** @brief Security keys. */
rgrover1 103:138bdc859cc9 259 typedef struct dm_sec_keyset
rgrover1 103:138bdc859cc9 260 {
rgrover1 112:737b08b3b995 261 union
rgrover1 103:138bdc859cc9 262 {
rgrover1 103:138bdc859cc9 263 dm_enc_key_t * p_enc_key; /**< Pointer to Device Manager encryption information structure. */
rgrover1 103:138bdc859cc9 264 } enc_key;
rgrover1 103:138bdc859cc9 265 dm_id_key_t * p_id_key; /**< Identity key, or NULL. */
rgrover1 103:138bdc859cc9 266 dm_sign_key_t * p_sign_key; /**< Signing key, or NULL. */
rgrover1 103:138bdc859cc9 267 } dm_sec_keys_t;
rgrover1 103:138bdc859cc9 268
rgrover1 103:138bdc859cc9 269 /** @brief Device Manager security key set. */
rgrover1 103:138bdc859cc9 270 typedef struct
rgrover1 103:138bdc859cc9 271 {
rgrover1 103:138bdc859cc9 272 dm_sec_keys_t keys_periph; /**< Keys distributed by the device in the Peripheral role. */
rgrover1 103:138bdc859cc9 273 dm_sec_keys_t keys_central; /**< Keys distributed by the device in the Central role. */
rgrover1 103:138bdc859cc9 274 } dm_sec_keyset_t;
rgrover1 103:138bdc859cc9 275
rgrover1 103:138bdc859cc9 276 /**
rgrover1 103:138bdc859cc9 277 * @brief Device Handle used for unique identification of each peer.
rgrover1 103:138bdc859cc9 278 *
rgrover1 103:138bdc859cc9 279 * @details This data type is used to uniquely identify each peer device. A peer device could be
rgrover1 103:138bdc859cc9 280 * active and/or bonded. Therefore an instance for active and bonded is provided.
rgrover1 103:138bdc859cc9 281 * However, the application is expected to treat this is an opaque structure and use this for
rgrover1 103:138bdc859cc9 282 * all API interactions once stored on appropriate events.
rgrover1 103:138bdc859cc9 283 * See \ref dm_events.
rgrover1 103:138bdc859cc9 284 */
rgrover1 103:138bdc859cc9 285 typedef struct device_handle
rgrover1 103:138bdc859cc9 286 {
rgrover1 103:138bdc859cc9 287 dm_application_instance_t appl_id; /**< Identifies the application instances for the device that is being managed. */
rgrover1 103:138bdc859cc9 288 dm_connection_instance_t connection_id; /**< Identifies the active connection instance. */
rgrover1 103:138bdc859cc9 289 dm_device_instance_t device_id; /**< Identifies peer instance in the data base. */
rgrover1 103:138bdc859cc9 290 dm_service_instance_t service_id; /**< Service instance identifier. */
rgrover1 103:138bdc859cc9 291 } dm_handle_t;
rgrover1 103:138bdc859cc9 292
rgrover1 103:138bdc859cc9 293 /**
rgrover1 103:138bdc859cc9 294 * @brief Definition of Data Context.
rgrover1 103:138bdc859cc9 295 *
rgrover1 103:138bdc859cc9 296 * @details Defines contextual data format, it consists of context data length and pointer to data.
rgrover1 103:138bdc859cc9 297 */
rgrover1 103:138bdc859cc9 298 typedef struct
rgrover1 103:138bdc859cc9 299 {
rgrover1 112:737b08b3b995 300 uint32_t flags; /**< Additional flags identifying data. */
rgrover1 112:737b08b3b995 301 uint32_t len; /**< Length of data. */
rgrover1 103:138bdc859cc9 302 uint8_t * p_data; /**< Pointer to contextual data, a copy is made of the data. */
rgrover1 103:138bdc859cc9 303 } dm_context_t;
rgrover1 103:138bdc859cc9 304
rgrover1 103:138bdc859cc9 305
rgrover1 103:138bdc859cc9 306 /**
rgrover1 103:138bdc859cc9 307 * @brief Device Context.
rgrover1 103:138bdc859cc9 308 *
rgrover1 103:138bdc859cc9 309 * @details Defines "device context" type for a device managed by device manager.
rgrover1 103:138bdc859cc9 310 */
rgrover1 103:138bdc859cc9 311 typedef dm_context_t dm_device_context_t;
rgrover1 103:138bdc859cc9 312
rgrover1 103:138bdc859cc9 313 /**
rgrover1 103:138bdc859cc9 314 * @brief Service Context.
rgrover1 103:138bdc859cc9 315 *
rgrover1 103:138bdc859cc9 316 * @details Service context data for a service identified by the 'service_type' field.
rgrover1 103:138bdc859cc9 317 */
rgrover1 103:138bdc859cc9 318 typedef struct
rgrover1 103:138bdc859cc9 319 {
rgrover1 103:138bdc859cc9 320 service_type_t service_type; /**< Identifies the service/protocol to which the context data is related. */
rgrover1 103:138bdc859cc9 321 dm_context_t context_data; /**< Contains length and pointer to context data */
rgrover1 103:138bdc859cc9 322 } dm_service_context_t;
rgrover1 103:138bdc859cc9 323
rgrover1 103:138bdc859cc9 324 /**
rgrover1 103:138bdc859cc9 325 * @brief Application context.
rgrover1 103:138bdc859cc9 326 *
rgrover1 103:138bdc859cc9 327 * @details The application context can be used by the application to map any application level
rgrover1 103:138bdc859cc9 328 * information that is to be mapped with a particular peer.
rgrover1 103:138bdc859cc9 329 * For bonded peers, this information will be stored by the bond manager persistently.
rgrover1 103:138bdc859cc9 330 * Note that the device manager treats this information as an
rgrover1 103:138bdc859cc9 331 * opaque block of bytes.
rgrover1 103:138bdc859cc9 332 * Necessary APIs to get and set this context for a peer have been provided.
rgrover1 103:138bdc859cc9 333 */
rgrover1 103:138bdc859cc9 334 typedef dm_context_t dm_application_context_t;
rgrover1 103:138bdc859cc9 335
rgrover1 103:138bdc859cc9 336 /**
rgrover1 103:138bdc859cc9 337 * @brief Event parameters.
rgrover1 103:138bdc859cc9 338 *
rgrover1 103:138bdc859cc9 339 * @details Defines event parameters for each of the events notified by the module.
rgrover1 103:138bdc859cc9 340 */
rgrover1 103:138bdc859cc9 341 typedef union
rgrover1 103:138bdc859cc9 342 {
rgrover1 103:138bdc859cc9 343 ble_gap_evt_t * p_gap_param; /**< All events that are triggered in device manager as a result of GAP events, like connection, disconnection and security procedures are accompanied with GAP parameters. */
rgrover1 103:138bdc859cc9 344 dm_application_context_t * p_app_context; /**< All events that are associated with application context procedures of store, load, and deletion have this as event parameter. */
rgrover1 103:138bdc859cc9 345 dm_service_context_t * p_service_context; /**< All events that are associated with service context procedures of store, load and deletion have this as event parameter. */
rgrover1 103:138bdc859cc9 346 dm_device_context_t * p_device_context; /**< All events that are associated with device context procedures of store, load and deletion have this as event parameter. */
rgrover1 103:138bdc859cc9 347 } dm_event_param_t;
rgrover1 103:138bdc859cc9 348
rgrover1 103:138bdc859cc9 349 /**
rgrover1 103:138bdc859cc9 350 * @brief Asynchronous events details notified to the application by the module.
rgrover1 103:138bdc859cc9 351 *
rgrover1 103:138bdc859cc9 352 * @details Defines event type along with event parameters notified to the application by the
rgrover1 103:138bdc859cc9 353 * module.
rgrover1 103:138bdc859cc9 354 */
rgrover1 103:138bdc859cc9 355 typedef struct
rgrover1 103:138bdc859cc9 356 {
rgrover1 103:138bdc859cc9 357 uint8_t event_id; /**< Identifies the event. See \ref dm_events for details on event types and their significance. */
rgrover1 103:138bdc859cc9 358 dm_event_param_t event_param; /**< Event parameters. Can be NULL if the event does not have any parameters. */
rgrover1 103:138bdc859cc9 359 uint16_t event_paramlen; /**< Length of the event parameters, is zero if the event does not have any parameters. */
rgrover1 103:138bdc859cc9 360 } dm_event_t;
rgrover1 103:138bdc859cc9 361
rgrover1 103:138bdc859cc9 362 /**
rgrover1 103:138bdc859cc9 363 * @brief Event notification callback registered by application with the module.
rgrover1 103:138bdc859cc9 364 *
rgrover1 103:138bdc859cc9 365 * @details Event notification callback registered by application with the module when registering
rgrover1 103:138bdc859cc9 366 * the module using \ref dm_register API.
rgrover1 103:138bdc859cc9 367 *
rgrover1 103:138bdc859cc9 368 * @param[in] p_handle Identifies the peer for which the event is being notified.
rgrover1 103:138bdc859cc9 369 * @param[in] p_event Identifies the event, any associated parameters and parameter length.
rgrover1 103:138bdc859cc9 370 * See \ref dm_events for details on event types and their significance.
rgrover1 112:737b08b3b995 371 * @param[in,out] event_result Provide additional information on the event.
rgrover1 103:138bdc859cc9 372 * In addition to SDK error codes there is also a return value
rgrover1 103:138bdc859cc9 373 * indicating if maximum number of connections has been reached when connecting or bonding.
rgrover1 103:138bdc859cc9 374 *
rgrover1 103:138bdc859cc9 375 * @retval NRF_SUCCESS on success, or a failure to indicate if it could handle the event
rgrover1 103:138bdc859cc9 376 * successfully. There is no action taken in case application returns a failure.
rgrover1 103:138bdc859cc9 377 */
rgrover1 112:737b08b3b995 378 typedef ret_code_t (*dm_event_cb_t)(dm_handle_t const * p_handle,
rgrover1 112:737b08b3b995 379 dm_event_t const * p_event,
rgrover1 112:737b08b3b995 380 ret_code_t event_result);
rgrover1 103:138bdc859cc9 381
rgrover1 103:138bdc859cc9 382 /**
rgrover1 103:138bdc859cc9 383 * @brief Initialization Parameters.
rgrover1 103:138bdc859cc9 384 *
rgrover1 103:138bdc859cc9 385 * @details Indicates the application parameters. Currently this only encompasses clearing
rgrover1 103:138bdc859cc9 386 * all persistent data.
rgrover1 103:138bdc859cc9 387 */
rgrover1 103:138bdc859cc9 388 typedef struct
rgrover1 103:138bdc859cc9 389 {
rgrover1 103:138bdc859cc9 390 bool clear_persistent_data; /**< Set to true in case the module should clear all persistent data. */
rgrover1 103:138bdc859cc9 391 } dm_init_param_t;
rgrover1 103:138bdc859cc9 392
rgrover1 103:138bdc859cc9 393 /**
rgrover1 103:138bdc859cc9 394 * @brief Application Registration Parameters.
rgrover1 103:138bdc859cc9 395 *
rgrover1 103:138bdc859cc9 396 * @details Parameters needed by the module when registering with it.
rgrover1 103:138bdc859cc9 397 */
rgrover1 103:138bdc859cc9 398 typedef struct
rgrover1 103:138bdc859cc9 399 {
rgrover1 103:138bdc859cc9 400 dm_event_cb_t evt_handler; /**< Event Handler to be registered. It will receive asynchronous notification from the module, see \ref dm_events for asynchronous events. */
rgrover1 103:138bdc859cc9 401 uint8_t service_type; /**< Bit mask identifying services that the application intends to support for all peers. */
rgrover1 103:138bdc859cc9 402 ble_gap_sec_params_t sec_param; /**< Security parameters to be used for the application. */
rgrover1 103:138bdc859cc9 403 } dm_application_param_t;
rgrover1 103:138bdc859cc9 404
rgrover1 103:138bdc859cc9 405 /**
rgrover1 103:138bdc859cc9 406 * @brief Defines possible security status/states.
rgrover1 103:138bdc859cc9 407 *
rgrover1 103:138bdc859cc9 408 * @details Defines possible security status/states of a link when requested by application using
rgrover1 103:138bdc859cc9 409 * the \ref dm_security_status_req.
rgrover1 103:138bdc859cc9 410 */
rgrover1 103:138bdc859cc9 411 typedef enum
rgrover1 103:138bdc859cc9 412 {
rgrover1 112:737b08b3b995 413 NOT_ENCRYPTED, /**< The link is not secured. */
rgrover1 112:737b08b3b995 414 ENCRYPTION_IN_PROGRESS, /**< Link security is being established.*/
rgrover1 112:737b08b3b995 415 ENCRYPTED /**< The link is secure.*/
rgrover1 103:138bdc859cc9 416 } dm_security_status_t;
rgrover1 103:138bdc859cc9 417 /** @} */
rgrover1 103:138bdc859cc9 418
rgrover1 103:138bdc859cc9 419 /**
rgrover1 103:138bdc859cc9 420 * @defgroup dm_api Device Module APIs
rgrover1 103:138bdc859cc9 421 *
rgrover1 103:138bdc859cc9 422 * @brief This section describes APIs exposed by the module.
rgrover1 103:138bdc859cc9 423 *
rgrover1 103:138bdc859cc9 424 * @details This section describes APIs exposed by the module. The APIs have been categorized to provide
rgrover1 103:138bdc859cc9 425 * better and specific look up for developers. Categories are:
rgrover1 103:138bdc859cc9 426 * - Set up APIs.
rgrover1 103:138bdc859cc9 427 * - Context Management APIs.
rgrover1 103:138bdc859cc9 428 * - Utility APIs.
rgrover1 103:138bdc859cc9 429 *
rgrover1 112:737b08b3b995 430 * MSCs describe usage of these APIs.
rgrover1 103:138bdc859cc9 431 * See @ref dm_msc.
rgrover1 103:138bdc859cc9 432 * @{
rgrover1 103:138bdc859cc9 433 */
rgrover1 103:138bdc859cc9 434 /**
rgrover1 103:138bdc859cc9 435 * @defgroup dm_setup_api Device Module Set-up APIs
rgrover1 103:138bdc859cc9 436 *
rgrover1 103:138bdc859cc9 437 * @brief Initialization & registration APIs that are pre-requisite for all other module procedures.
rgrover1 103:138bdc859cc9 438 * @details This section describes the Module Initialization and Registration APIs needed to be set up by
rgrover1 103:138bdc859cc9 439 * the application before device manager can start managing devices and device contexts
rgrover1 103:138bdc859cc9 440 * for the application.
rgrover1 103:138bdc859cc9 441 *
rgrover1 103:138bdc859cc9 442 * @{
rgrover1 103:138bdc859cc9 443 */
rgrover1 103:138bdc859cc9 444
rgrover1 103:138bdc859cc9 445 /**
rgrover1 103:138bdc859cc9 446 * @brief Module Initialization Routine.
rgrover1 103:138bdc859cc9 447 *
rgrover1 103:138bdc859cc9 448 * @details Function for initializing the module. Must called before any other APIs of the module are used.
rgrover1 103:138bdc859cc9 449 *
rgrover1 103:138bdc859cc9 450 * @param[in] p_init_param Initialization parameters.
rgrover1 103:138bdc859cc9 451 *
rgrover1 103:138bdc859cc9 452 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 453 *
rgrover1 103:138bdc859cc9 454 * @note It is mandatory that pstorage is initialized before initializing this module.
rgrover1 103:138bdc859cc9 455 */
rgrover1 112:737b08b3b995 456 ret_code_t dm_init(dm_init_param_t const * p_init_param);
rgrover1 103:138bdc859cc9 457
rgrover1 103:138bdc859cc9 458 /**
rgrover1 103:138bdc859cc9 459 * @brief Function for registering the application.
rgrover1 103:138bdc859cc9 460 *
rgrover1 103:138bdc859cc9 461 * @details This routine is used by the application to register for asynchronous events with the
rgrover1 103:138bdc859cc9 462 * device manager. During registration the application also indicates the services that it
rgrover1 103:138bdc859cc9 463 * intends to support on this instance. It is possible to register multiple times with the
rgrover1 103:138bdc859cc9 464 * device manager. At least one instance shall be registered with the device manager after
rgrover1 103:138bdc859cc9 465 * the module has been initialized.
rgrover1 103:138bdc859cc9 466 * Maximum number of application instances device manager can support is determined
rgrover1 103:138bdc859cc9 467 * by DM_MAX_APPLICATIONS.
rgrover1 103:138bdc859cc9 468 *
rgrover1 112:737b08b3b995 469 * All applications must be registered before initiating or accepting connections from the peer.
rgrover1 103:138bdc859cc9 470 *
rgrover1 103:138bdc859cc9 471 * @param[in] p_appl_param Application parameters.
rgrover1 103:138bdc859cc9 472 * @param[out] p_appl_instance Application Instance Identifier in case registration is successful.
rgrover1 103:138bdc859cc9 473 *
rgrover1 103:138bdc859cc9 474 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 475 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization.
rgrover1 103:138bdc859cc9 476 * @retval NRF_ERROR_NO_MEM If module cannot support more applications.
rgrover1 103:138bdc859cc9 477 *
rgrover1 103:138bdc859cc9 478 * @note Currently only one application instance is supported by the module.
rgrover1 103:138bdc859cc9 479 */
rgrover1 112:737b08b3b995 480 ret_code_t dm_register(dm_application_instance_t * p_appl_instance,
rgrover1 112:737b08b3b995 481 dm_application_param_t const * p_appl_param);
rgrover1 103:138bdc859cc9 482
rgrover1 103:138bdc859cc9 483 /**
rgrover1 103:138bdc859cc9 484 * @brief Function for handling BLE events.
rgrover1 103:138bdc859cc9 485 *
rgrover1 103:138bdc859cc9 486 * @details BLE Event Handler for the module. This routine should be called from BLE stack event
rgrover1 103:138bdc859cc9 487 * dispatcher for the module to work as expected.
rgrover1 103:138bdc859cc9 488 *
rgrover1 103:138bdc859cc9 489 * @param[in] p_ble_evt BLE stack event being dispatched to the function.
rgrover1 103:138bdc859cc9 490 *
rgrover1 103:138bdc859cc9 491 */
rgrover1 103:138bdc859cc9 492 void dm_ble_evt_handler(ble_evt_t * p_ble_evt);
rgrover1 103:138bdc859cc9 493
rgrover1 103:138bdc859cc9 494 /** @} */
rgrover1 103:138bdc859cc9 495
rgrover1 103:138bdc859cc9 496
rgrover1 103:138bdc859cc9 497 /**
rgrover1 103:138bdc859cc9 498 * @defgroup dm_security_api APIs to set up or read status of security on a link.
rgrover1 103:138bdc859cc9 499 *
rgrover1 103:138bdc859cc9 500 * @brief This section describes APIs to set up Security. These APIs require that the peer is
rgrover1 103:138bdc859cc9 501 * connected before the procedures can be requested.
rgrover1 103:138bdc859cc9 502 *
rgrover1 103:138bdc859cc9 503 * @details This group allows application to request security procedures
rgrover1 103:138bdc859cc9 504 * or get the status of the security on a link.
rgrover1 103:138bdc859cc9 505 * @{
rgrover1 103:138bdc859cc9 506 */
rgrover1 103:138bdc859cc9 507 /**
rgrover1 103:138bdc859cc9 508 * @brief Function for requesting setting up security on a link.
rgrover1 103:138bdc859cc9 509 *
rgrover1 103:138bdc859cc9 510 * @details This API initiates security procedures with a peer device.
rgrover1 103:138bdc859cc9 511 * @note For the GAP Central role, in case peer is not bonded, request to bond/pair is
rgrover1 103:138bdc859cc9 512 * initiated. If it is bonded, the link is re-encrypted using the existing bond information.
rgrover1 103:138bdc859cc9 513 * For the GAP peripheral role, a Slave security request is sent.
rgrover1 103:138bdc859cc9 514 * @details If a pairing procedure is initiated successfully, application is notified of
rgrover1 103:138bdc859cc9 515 * @ref DM_EVT_SECURITY_SETUP_COMPLETE. A result indicating success or failure is notified along with the event.
rgrover1 103:138bdc859cc9 516 * In case the link is re-encrypted using existing bond information, @ref DM_EVT_LINK_SECURED is
rgrover1 103:138bdc859cc9 517 * notified to the application.
rgrover1 103:138bdc859cc9 518 *
rgrover1 103:138bdc859cc9 519 * @param[in] p_handle Identifies the link on which security is desired.
rgrover1 103:138bdc859cc9 520 *
rgrover1 103:138bdc859cc9 521 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 522 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 523 * application registration.
rgrover1 103:138bdc859cc9 524 * @retval NRF_ERROR_NULL If p_handle is NULL.
rgrover1 103:138bdc859cc9 525 * @retval NRF_ERROR_INVALID_ADDR If the peer is not identified by the handle provided by the application
rgrover1 103:138bdc859cc9 526 * or if the peer is not connected when this procedure is requested.
rgrover1 103:138bdc859cc9 527 */
rgrover1 112:737b08b3b995 528 ret_code_t dm_security_setup_req(dm_handle_t * p_handle);
rgrover1 103:138bdc859cc9 529
rgrover1 103:138bdc859cc9 530 /**
rgrover1 103:138bdc859cc9 531 * @brief Function for reading the status of the security on a link.
rgrover1 103:138bdc859cc9 532 *
rgrover1 103:138bdc859cc9 533 * @details This API allows application to query status of security on a link.
rgrover1 103:138bdc859cc9 534 *
rgrover1 103:138bdc859cc9 535 * @param[in] p_handle Identifies the link on which security is desired.
rgrover1 103:138bdc859cc9 536 * @param[out] p_status Pointer where security status is provided to the application.
rgrover1 103:138bdc859cc9 537 * See \ref dm_security_status_t for possible statuses that can be expected.
rgrover1 103:138bdc859cc9 538 *
rgrover1 103:138bdc859cc9 539 * @retval NRF_SUCCESS Or appropriate error code indicating reason for failure.
rgrover1 103:138bdc859cc9 540 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 541 * application registration.
rgrover1 103:138bdc859cc9 542 * @retval NRF_ERROR_NULL If p_handle or p_status is NULL.
rgrover1 103:138bdc859cc9 543 * @retval NRF_ERROR_INVALID_ADDR If peer is not identified by the handle provided by the application
rgrover1 103:138bdc859cc9 544 * or if peer is not connected when this procedure is requested.
rgrover1 103:138bdc859cc9 545 */
rgrover1 112:737b08b3b995 546 ret_code_t dm_security_status_req(dm_handle_t const * p_handle, dm_security_status_t * p_status);
rgrover1 103:138bdc859cc9 547
rgrover1 103:138bdc859cc9 548 /**
rgrover1 103:138bdc859cc9 549 * @brief Function for creating the whitelist.
rgrover1 103:138bdc859cc9 550 *
rgrover1 103:138bdc859cc9 551 * @details This API allows application to create whitelist based on bonded peer devices in module
rgrover1 103:138bdc859cc9 552 * data base.
rgrover1 103:138bdc859cc9 553 *
rgrover1 103:138bdc859cc9 554 * @param[in] p_handle Identifies the application requesting whitelist creation.
rgrover1 103:138bdc859cc9 555 * @param[in,out] p_whitelist Pointer where created whitelist is provided to the application.
rgrover1 103:138bdc859cc9 556 *
rgrover1 103:138bdc859cc9 557 * @note 'addr_count' and 'irk_count' fields of the structure should be populated with the maximum
rgrover1 112:737b08b3b995 558 * number of devices that the application wishes to request in the whitelist.
rgrover1 103:138bdc859cc9 559 * If the number of bonded devices is less than requested, the fields are updated with that number of devices.
rgrover1 103:138bdc859cc9 560 * If the number of devices are more than requested, the module will populate the list
rgrover1 103:138bdc859cc9 561 * with devices in the order the bond was established with the peer devices. Also, if this routine is
rgrover1 103:138bdc859cc9 562 * called when a connection exists with one or more peer devices,
rgrover1 103:138bdc859cc9 563 * those connected devices are not added to the whitelist.
rgrover1 103:138bdc859cc9 564 *
rgrover1 103:138bdc859cc9 565 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 566 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 567 * application registration.
rgrover1 103:138bdc859cc9 568 * @retval NRF_ERROR_NULL If p_handle or p_whitelist is NULL.
rgrover1 103:138bdc859cc9 569 */
rgrover1 112:737b08b3b995 570 ret_code_t dm_whitelist_create(dm_application_instance_t const * p_handle,
rgrover1 112:737b08b3b995 571 ble_gap_whitelist_t * p_whitelist);
rgrover1 103:138bdc859cc9 572
rgrover1 103:138bdc859cc9 573 /** @} */
rgrover1 103:138bdc859cc9 574
rgrover1 103:138bdc859cc9 575
rgrover1 103:138bdc859cc9 576 /**
rgrover1 103:138bdc859cc9 577 * @defgroup dm_cntxt_mgmt_api Context Management APIs
rgrover1 103:138bdc859cc9 578 *
rgrover1 103:138bdc859cc9 579 * @brief Utility APIs offered by the device manager to get information about the peer if and
rgrover1 103:138bdc859cc9 580 * when needed.
rgrover1 103:138bdc859cc9 581 *
rgrover1 103:138bdc859cc9 582 * @details This group of API allow the application to access information that is not required to be
rgrover1 103:138bdc859cc9 583 * maintained by the application but may be needed. Hence it is possible to get the
rgrover1 103:138bdc859cc9 584 * information from the module instead of mapping all the information with a device
rgrover1 103:138bdc859cc9 585 * context.
rgrover1 103:138bdc859cc9 586 * @{
rgrover1 103:138bdc859cc9 587 */
rgrover1 103:138bdc859cc9 588
rgrover1 112:737b08b3b995 589 ret_code_t dm_device_add(dm_handle_t * p_handle,
rgrover1 112:737b08b3b995 590 dm_device_context_t const * p_context);
rgrover1 103:138bdc859cc9 591
rgrover1 103:138bdc859cc9 592 /**
rgrover1 103:138bdc859cc9 593 * @brief Function for deleting a peer device context and all related information from the database.
rgrover1 103:138bdc859cc9 594 *
rgrover1 103:138bdc859cc9 595 * @details Delete peer device context and all related information from database. If
rgrover1 103:138bdc859cc9 596 * this API returns NRF_SUCCESS, DM_EVT_DEVICE_CONTEXT_DELETED event is notified to the
rgrover1 103:138bdc859cc9 597 * application. Event result notified along with the event indicates success or failure
rgrover1 103:138bdc859cc9 598 * of this procedure.
rgrover1 103:138bdc859cc9 599 *
rgrover1 103:138bdc859cc9 600 * @param[in] p_handle Identifies the peer device to be deleted.
rgrover1 103:138bdc859cc9 601 *
rgrover1 103:138bdc859cc9 602 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 603 * @retval NRF_ERROR_INVALID_STATE In the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 604 * application registration.
rgrover1 103:138bdc859cc9 605 * @retval NRF_ERROR_NULL If p_handle is NULL.
rgrover1 103:138bdc859cc9 606 * @retval NRF_ERROR_INVALID_ADDR If peer is not identified the handle provided by the application.
rgrover1 103:138bdc859cc9 607 *
rgrover1 103:138bdc859cc9 608 * @note Deleting device context results in deleting service and application context for the
rgrover1 103:138bdc859cc9 609 * bonded device. The respective events DM_EVT_SERVICE_CONTEXT_DELETED and
rgrover1 103:138bdc859cc9 610 * DM_EVT_APPL_CONTEXT_DELETED are not notified to the application.
rgrover1 103:138bdc859cc9 611 */
rgrover1 112:737b08b3b995 612 ret_code_t dm_device_delete(dm_handle_t const * p_handle);
rgrover1 103:138bdc859cc9 613
rgrover1 103:138bdc859cc9 614 /**
rgrover1 103:138bdc859cc9 615 * @brief Function for deleting all peer device context and all related information from the database.
rgrover1 103:138bdc859cc9 616 *
rgrover1 103:138bdc859cc9 617 * @details Delete peer device context and all related information from database. If
rgrover1 103:138bdc859cc9 618 * this API returns NRF_SUCCESS, DM_EVT_DEVICE_CONTEXT_DELETED event is notified to the
rgrover1 103:138bdc859cc9 619 * application for each device that is deleted from the data base. Event result
rgrover1 103:138bdc859cc9 620 * notified along with the event indicates success or failure of this procedure.
rgrover1 103:138bdc859cc9 621 *
rgrover1 103:138bdc859cc9 622 * @param[in] p_handle Identifies application instance that is requesting
rgrover1 103:138bdc859cc9 623 * the deletion of all bonded devices.
rgrover1 103:138bdc859cc9 624 *
rgrover1 103:138bdc859cc9 625 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 626 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 627 * application registration.
rgrover1 103:138bdc859cc9 628 * @retval NRF_ERROR_NULL If p_handle is NULL.
rgrover1 103:138bdc859cc9 629 * @retval NRF_ERROR_INVALID_ADDR If peer is not identified the handle provided by the application.
rgrover1 103:138bdc859cc9 630 *
rgrover1 103:138bdc859cc9 631 * @note Deleting device context results in deleting both service and application context for the
rgrover1 103:138bdc859cc9 632 * bonded device. The respective events DM_EVT_SERVICE_CONTEXT_DELETED and
rgrover1 103:138bdc859cc9 633 * DM_EVT_APPL_CONTEXT_DELETED are not notified to the application.
rgrover1 103:138bdc859cc9 634 */
rgrover1 112:737b08b3b995 635 ret_code_t dm_device_delete_all(dm_application_instance_t const * p_handle);
rgrover1 103:138bdc859cc9 636
rgrover1 103:138bdc859cc9 637 /**
rgrover1 103:138bdc859cc9 638 * @brief Function for setting Service Context for a peer device identified by 'p_handle' parameter.
rgrover1 103:138bdc859cc9 639 *
rgrover1 103:138bdc859cc9 640 * @details This API allows application to Set Service Context for a peer device identified by the
rgrover1 103:138bdc859cc9 641 * 'p_handle' parameter. This API is useful when the Service Context cannot be requested
rgrover1 103:138bdc859cc9 642 * from the SoftDevice, but needs to be assembled by the application or an another module.
rgrover1 103:138bdc859cc9 643 * (or when service context is exchanged in an out of band way.)
rgrover1 103:138bdc859cc9 644 * This API could also be used to trigger a storing of service context into persistent
rgrover1 103:138bdc859cc9 645 * memory. If this is desired, a NULL pointer could be passed to the p_context.
rgrover1 103:138bdc859cc9 646 *
rgrover1 103:138bdc859cc9 647 * @param[in] p_handle Identifies peer device for which the procedure is requested.
rgrover1 103:138bdc859cc9 648 * @param[in] p_context Service context being set. The context information includes length of
rgrover1 103:138bdc859cc9 649 * data and pointer to the contextual data being set. The memory pointed to by
rgrover1 103:138bdc859cc9 650 * the pointer to data is assumed to be resident when API is being called and
rgrover1 103:138bdc859cc9 651 * can be freed or reused once the set procedure is complete. Set procedure
rgrover1 103:138bdc859cc9 652 * completion is indicated by the event \ref DM_EVT_SERVICE_CONTEXT_STORED.
rgrover1 103:138bdc859cc9 653 * The Event result is notified along with the event and indicates success or failure of
rgrover1 103:138bdc859cc9 654 * this procedure.
rgrover1 103:138bdc859cc9 655 *
rgrover1 103:138bdc859cc9 656 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 657 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 658 * application registration.
rgrover1 103:138bdc859cc9 659 * @retval NRF_ERROR_NULL If p_handle is NULL.
rgrover1 103:138bdc859cc9 660 * @retval NRF_ERROR_INVALID_ADDR If the peer is not identified by the handle provided by the application.
rgrover1 103:138bdc859cc9 661 */
rgrover1 112:737b08b3b995 662 ret_code_t dm_service_context_set(dm_handle_t const * p_handle,
rgrover1 112:737b08b3b995 663 dm_service_context_t const * p_context);
rgrover1 103:138bdc859cc9 664
rgrover1 103:138bdc859cc9 665 /**
rgrover1 103:138bdc859cc9 666 * @brief Function for getting Service Context for a peer device identified by 'p_handle' parameter.
rgrover1 103:138bdc859cc9 667 *
rgrover1 103:138bdc859cc9 668 * @details Get Service Context for a peer device identified by the 'p_handle' parameter. If
rgrover1 103:138bdc859cc9 669 * this API returns NRF_SUCCESS, DM_EVT_SERVICE_CONTEXT_LOADED event is notified to the
rgrover1 103:138bdc859cc9 670 * application. The event result is notified along with the event indicates success or failure
rgrover1 103:138bdc859cc9 671 * of this procedure.
rgrover1 103:138bdc859cc9 672 *
rgrover1 103:138bdc859cc9 673 * @param[in] p_handle Identifies peer device for which procedure is requested.
rgrover1 103:138bdc859cc9 674 * @param[in] p_context Application context being requested. The context information includes length
rgrover1 103:138bdc859cc9 675 * of the data and a pointer to the data. Note that requesting a 'get'
rgrover1 103:138bdc859cc9 676 * of application does not need to provide memory, the pointer to data will be
rgrover1 103:138bdc859cc9 677 * pointing to service data and hence no data movement is involved.
rgrover1 103:138bdc859cc9 678 *
rgrover1 103:138bdc859cc9 679 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 680 * @retval NRF_ERROR_INVALID_STATE In case API is called without module initialization and/or
rgrover1 103:138bdc859cc9 681 * application registration.
rgrover1 103:138bdc859cc9 682 * @retval NRF_ERROR_NULL If p_handle is NULL.
rgrover1 103:138bdc859cc9 683 * @retval NRF_ERROR_INVALID_ADDR If the peer is not identified by the handle provided by the application.
rgrover1 103:138bdc859cc9 684 */
rgrover1 112:737b08b3b995 685 ret_code_t dm_service_context_get(dm_handle_t const * p_handle,
rgrover1 112:737b08b3b995 686 dm_service_context_t * p_context);
rgrover1 103:138bdc859cc9 687
rgrover1 103:138bdc859cc9 688 /**
rgrover1 103:138bdc859cc9 689 * @brief Function for deleting a Service Context for a peer device identified by the 'p_handle' parameter.
rgrover1 103:138bdc859cc9 690 *
rgrover1 103:138bdc859cc9 691 * @details This API allows application to delete a Service Context identified for a peer device
rgrover1 103:138bdc859cc9 692 * identified by the 'p_handle' parameter. If this API returns NRF_SUCCESS,
rgrover1 112:737b08b3b995 693 * DM_EVT_SERVICE_CONTEXT_DELETED event is notified to the application.
rgrover1 103:138bdc859cc9 694 * Event result is notified along with the event and indicates success or failure of this
rgrover1 103:138bdc859cc9 695 * procedure.
rgrover1 103:138bdc859cc9 696 *
rgrover1 103:138bdc859cc9 697 * @param[in] p_handle Identifies peer device for which procedure is requested.
rgrover1 103:138bdc859cc9 698 *
rgrover1 103:138bdc859cc9 699 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 700 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 701 * application registration.
rgrover1 103:138bdc859cc9 702 * @retval NRF_ERROR_NULL If p_handle is NULL.
rgrover1 103:138bdc859cc9 703 * @retval NRF_ERROR_INVALID_ADDR If the peer is not identified by the handle provided by the application.
rgrover1 103:138bdc859cc9 704 */
rgrover1 112:737b08b3b995 705 ret_code_t dm_service_context_delete(dm_handle_t const * p_handle);
rgrover1 103:138bdc859cc9 706
rgrover1 103:138bdc859cc9 707 /**
rgrover1 103:138bdc859cc9 708 * @brief Function for setting Application Context for a peer device identified by the 'p_handle' parameter.
rgrover1 103:138bdc859cc9 709 *
rgrover1 103:138bdc859cc9 710 * @details This application allows the setting of the application context for the peer device identified by
rgrover1 103:138bdc859cc9 711 * the 'p_handle'. Application context is stored persistently by the module and can be
rgrover1 103:138bdc859cc9 712 * requested by the application at any time using the \ref dm_application_context_get
rgrover1 103:138bdc859cc9 713 * API. Note that this procedure is permitted only for bonded devices. If the
rgrover1 103:138bdc859cc9 714 * device is not bonded, application context cannot be set. However, it is not mandatory
rgrover1 103:138bdc859cc9 715 * that the bonded device is connected when requesting this procedure.
rgrover1 103:138bdc859cc9 716 *
rgrover1 103:138bdc859cc9 717 * @param[in] p_handle Identifies peer device for which procedure is requested.
rgrover1 103:138bdc859cc9 718 *
rgrover1 103:138bdc859cc9 719 * @param[in] p_context Application context being set. The context information includes length of the
rgrover1 103:138bdc859cc9 720 * data and pointer to the contextual data being set. The memory pointed to by
rgrover1 103:138bdc859cc9 721 * the data pointer is assumed to be resident when API is being called and
rgrover1 103:138bdc859cc9 722 * can be freed or reused once the set procedure is complete. Set procedure
rgrover1 103:138bdc859cc9 723 * completion is notified by the event \ref DM_EVT_APPL_CONTEXT_STORED.
rgrover1 103:138bdc859cc9 724 * The event result is notified along with the event and indicates success or
rgrover1 103:138bdc859cc9 725 * failure of this procedure.
rgrover1 103:138bdc859cc9 726 *
rgrover1 103:138bdc859cc9 727 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 728 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 729 * application registration.
rgrover1 103:138bdc859cc9 730 * @retval NRF_ERROR_NULL If p_handle and/or p_context is NULL.
rgrover1 103:138bdc859cc9 731 * @retval NRF_ERROR_INVALID_ADDR If peer is not identified the handle provided by the application.
rgrover1 103:138bdc859cc9 732 *
rgrover1 103:138bdc859cc9 733 * @note The API returns FEATURE_NOT_ENABLED in case DEVICE_MANAGER_APP_CONTEXT_SIZE is set to zero.
rgrover1 103:138bdc859cc9 734 */
rgrover1 112:737b08b3b995 735 ret_code_t dm_application_context_set(dm_handle_t const * p_handle,
rgrover1 112:737b08b3b995 736 dm_application_context_t const * p_context);
rgrover1 103:138bdc859cc9 737
rgrover1 103:138bdc859cc9 738 /**
rgrover1 103:138bdc859cc9 739 * @brief Function for getting Application Context for a peer device identified by the 'p_handle' parameter.
rgrover1 103:138bdc859cc9 740 *
rgrover1 103:138bdc859cc9 741 * @details Get Application Context for a peer device identified by the 'p_handle' parameter. If
rgrover1 103:138bdc859cc9 742 * this API returns NRF_SUCCESS, DM_EVT_APPL_CONTEXT_LOADED event is notified to the
rgrover1 103:138bdc859cc9 743 * application. Event result notified along with the event indicates success or failure
rgrover1 103:138bdc859cc9 744 * of this procedure.
rgrover1 103:138bdc859cc9 745 *
rgrover1 103:138bdc859cc9 746 * @param[in] p_handle Identifies peer device for which procedure is requested.
rgrover1 103:138bdc859cc9 747 * @param[in] p_context Application context being requested. The context information includes
rgrover1 103:138bdc859cc9 748 * length of data and pointer to the contextual data is provided.
rgrover1 103:138bdc859cc9 749 *
rgrover1 103:138bdc859cc9 750 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 751 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 752 * application registration.
rgrover1 103:138bdc859cc9 753 * @retval NRF_ERROR_NULL If p_handle and/or p_context is NULL.
rgrover1 103:138bdc859cc9 754 * @retval NRF_ERROR_INVALID_ADDR If the peer is not identified by the handle provided by the application.
rgrover1 103:138bdc859cc9 755 * @retval DM_NO_APP_CONTEXT If no application context was set that can be fetched.
rgrover1 103:138bdc859cc9 756 *
rgrover1 103:138bdc859cc9 757 * @note The API returns FEATURE_NOT_ENABLED in case DEVICE_MANAGER_APP_CONTEXT_SIZE is set to
rgrover1 103:138bdc859cc9 758 * zero.
rgrover1 103:138bdc859cc9 759 */
rgrover1 112:737b08b3b995 760 ret_code_t dm_application_context_get(dm_handle_t const * p_handle,
rgrover1 112:737b08b3b995 761 dm_application_context_t * p_context);
rgrover1 103:138bdc859cc9 762
rgrover1 103:138bdc859cc9 763 /**
rgrover1 103:138bdc859cc9 764 * @brief Function for deleting Application Context for a peer device identified by the 'p_handle' parameter.
rgrover1 103:138bdc859cc9 765 *
rgrover1 103:138bdc859cc9 766 * @details Delete Application Context for a peer device identified by the 'p_handle' parameter. If
rgrover1 103:138bdc859cc9 767 * this API returns NRF_SUCCESS, DM_EVT_APPL_CONTEXT_DELETED event is notified to the
rgrover1 103:138bdc859cc9 768 * application. The event result notified along with the event and indicates success or failure
rgrover1 103:138bdc859cc9 769 * of this procedure.
rgrover1 103:138bdc859cc9 770 *
rgrover1 103:138bdc859cc9 771 * @param[in] p_handle Identifies peer device for which procedure is requested.
rgrover1 103:138bdc859cc9 772 *
rgrover1 103:138bdc859cc9 773 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 774 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 775 * application registration.
rgrover1 103:138bdc859cc9 776 * @retval NRF_ERROR_NULL If the p_handle is NULL.
rgrover1 103:138bdc859cc9 777 * @retval NRF_ERROR_INVALID_ADDR If peer is not identified the handle provided by the application.
rgrover1 103:138bdc859cc9 778 * @retval DM_NO_APP_CONTEXT If no application context was set that can be deleted.
rgrover1 103:138bdc859cc9 779 *
rgrover1 103:138bdc859cc9 780 * @note The API returns FEATURE_NOT_ENABLED if the DEVICE_MANAGER_APP_CONTEXT_SIZE is set to zero.
rgrover1 103:138bdc859cc9 781 */
rgrover1 112:737b08b3b995 782 ret_code_t dm_application_context_delete(dm_handle_t const * p_handle);
rgrover1 103:138bdc859cc9 783
rgrover1 103:138bdc859cc9 784 /** @} */
rgrover1 103:138bdc859cc9 785
rgrover1 103:138bdc859cc9 786
rgrover1 103:138bdc859cc9 787 /**
rgrover1 103:138bdc859cc9 788 * @defgroup utility_api Utility APIs
rgrover1 103:138bdc859cc9 789 * @{
rgrover1 103:138bdc859cc9 790 * @brief This section describes the utility APIs offered by the module.
rgrover1 103:138bdc859cc9 791 *
rgrover1 103:138bdc859cc9 792 * @details APIs defined in this section are utility or assisting/helper APIs.
rgrover1 103:138bdc859cc9 793 */
rgrover1 103:138bdc859cc9 794 /**
rgrover1 103:138bdc859cc9 795 * @brief Function for Setting/Copying Application instance to Device Manager handle.
rgrover1 103:138bdc859cc9 796 *
rgrover1 103:138bdc859cc9 797 * @param[in] p_appl_instance Application instance to be set.
rgrover1 103:138bdc859cc9 798 * @param[out] p_handle Device Manager handle for which the instance is to be copied.
rgrover1 103:138bdc859cc9 799 *
rgrover1 103:138bdc859cc9 800 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 801 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 802 * application registration.
rgrover1 103:138bdc859cc9 803 * @retval NRF_ERROR_NULL If p_handle and/or p_addr is NULL.
rgrover1 103:138bdc859cc9 804 */
rgrover1 112:737b08b3b995 805 ret_code_t dm_application_instance_set(dm_application_instance_t const * p_appl_instance,
rgrover1 112:737b08b3b995 806 dm_handle_t * p_handle);
rgrover1 103:138bdc859cc9 807
rgrover1 103:138bdc859cc9 808 /**
rgrover1 103:138bdc859cc9 809 * @brief Function for getting a peer's device address.
rgrover1 103:138bdc859cc9 810 *
rgrover1 103:138bdc859cc9 811 * @param[in] p_handle Identifies the peer device whose address is requested. Can not be NULL.
rgrover1 103:138bdc859cc9 812 * @param[out] p_addr Pointer where address is to be copied. Can not be NULL.
rgrover1 103:138bdc859cc9 813 *
rgrover1 103:138bdc859cc9 814 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 815 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 816 * application registration.
rgrover1 103:138bdc859cc9 817 * @retval NRF_ERROR_NULL If p_handle and/or p_addr is NULL.
rgrover1 103:138bdc859cc9 818 * @retval NRF_ERROR_NOT_FOUND If the peer could not be identified.
rgrover1 103:138bdc859cc9 819 */
rgrover1 112:737b08b3b995 820 ret_code_t dm_peer_addr_get(dm_handle_t const * p_handle,
rgrover1 112:737b08b3b995 821 ble_gap_addr_t * p_addr);
rgrover1 103:138bdc859cc9 822
rgrover1 103:138bdc859cc9 823 /**
rgrover1 103:138bdc859cc9 824 * @brief Function for setting/updating a peer's device address.
rgrover1 103:138bdc859cc9 825 *
rgrover1 103:138bdc859cc9 826 * @param[in] p_handle Identifies the peer device whose address is requested to be set/updated.
rgrover1 103:138bdc859cc9 827 * @param[out] p_addr Address to be set/updated.
rgrover1 103:138bdc859cc9 828 *
rgrover1 103:138bdc859cc9 829 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 830 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 831 * application registration.
rgrover1 103:138bdc859cc9 832 * @retval NRF_ERROR_NULL If p_handle and/or p_addr is NULL.
rgrover1 103:138bdc859cc9 833 * @retval NRF_ERROR_INVALID_ADDR If the peer is not identified by the handle provided by the application.
rgrover1 103:138bdc859cc9 834 * @retval NRF_ERROR_INVALID_PARAM If this procedure is requested while connected to the peer or if the address
rgrover1 103:138bdc859cc9 835 * type was set to BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE.
rgrover1 103:138bdc859cc9 836 *
rgrover1 112:737b08b3b995 837 * @note Setting or updating a peer's device address is permitted
rgrover1 103:138bdc859cc9 838 * only for a peer that is bonded and disconnected.
rgrover1 103:138bdc859cc9 839 * @note Updated address is reflected only after DM_EVT_DEVICE_CONTEXT_STORED is notified to the
rgrover1 103:138bdc859cc9 840 * application for this bonded device instance. In order to avoid abnormal behaviour, it is
rgrover1 103:138bdc859cc9 841 * recommended to not invite/initiate connections on the updated address unless this event
rgrover1 103:138bdc859cc9 842 * has been notified.
rgrover1 103:138bdc859cc9 843 */
rgrover1 112:737b08b3b995 844 ret_code_t dm_peer_addr_set(dm_handle_t const * p_handle,
rgrover1 112:737b08b3b995 845 ble_gap_addr_t const * p_addr);
rgrover1 103:138bdc859cc9 846
rgrover1 103:138bdc859cc9 847 /**
rgrover1 103:138bdc859cc9 848 * @brief Function for initializing Device Manager handle.
rgrover1 103:138bdc859cc9 849 *
rgrover1 103:138bdc859cc9 850 * @param[in] p_handle Device Manager handle to be initialized.
rgrover1 103:138bdc859cc9 851 *
rgrover1 103:138bdc859cc9 852 * @retval NRF_SUCCESS On success.
rgrover1 103:138bdc859cc9 853 * @retval NRF_ERROR_NULL If p_handle is NULL.
rgrover1 103:138bdc859cc9 854 *
rgrover1 103:138bdc859cc9 855 * @note This routine is permitted before initialization of the module.
rgrover1 103:138bdc859cc9 856 */
rgrover1 112:737b08b3b995 857 ret_code_t dm_handle_initialize(dm_handle_t * p_handle);
rgrover1 103:138bdc859cc9 858
rgrover1 103:138bdc859cc9 859 /**
rgrover1 103:138bdc859cc9 860 * @brief Function for getting distributed keys for a device.
rgrover1 103:138bdc859cc9 861 *
rgrover1 112:737b08b3b995 862 * @param[in] p_handle Device Manager handle identifying the peer.
rgrover1 103:138bdc859cc9 863 * @param[out] p_key_dist Pointer to distributed keys.
rgrover1 103:138bdc859cc9 864 *
rgrover1 103:138bdc859cc9 865 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 103:138bdc859cc9 866 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
rgrover1 103:138bdc859cc9 867 * application registration.
rgrover1 103:138bdc859cc9 868 * @retval NRF_ERROR_NULL If the p_handle and/or p_key_dist pointer is NULL.
rgrover1 103:138bdc859cc9 869 * @retval NRF_ERROR_INVALID_ADDR If the peer is not identified by the handle provided by the application.
rgrover1 103:138bdc859cc9 870 */
rgrover1 112:737b08b3b995 871 ret_code_t dm_distributed_keys_get(dm_handle_t const * p_handle,
rgrover1 112:737b08b3b995 872 dm_sec_keyset_t * p_key_dist);
rgrover1 112:737b08b3b995 873
rgrover1 112:737b08b3b995 874 /**
rgrover1 112:737b08b3b995 875 * @brief Function for getting the corresponding dm_handle_t based on the connection handle.
rgrover1 112:737b08b3b995 876 *
rgrover1 112:737b08b3b995 877 * @param[in] conn_handle Connection handle as provided by the SoftDevice.
rgrover1 112:737b08b3b995 878 * @param[in,out] p_handle Pointer to the p_handle containg the application instance for the
rgrover1 112:737b08b3b995 879 * registered application. If the application instance is valid then
rgrover1 112:737b08b3b995 880 * the p_handle will be filled with requested data.
rgrover1 112:737b08b3b995 881 *
rgrover1 112:737b08b3b995 882 * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
rgrover1 112:737b08b3b995 883 * @retval NRF_ERROR_NULL If the p_handle pointer is NULL.
rgrover1 112:737b08b3b995 884 * @retval NRF_ERROR_NOT_FOUND If no p_handle is found for the provided connection handle.
rgrover1 112:737b08b3b995 885 */
rgrover1 112:737b08b3b995 886 ret_code_t dm_handle_get(uint16_t conn_handle, dm_handle_t * p_handle);
rgrover1 103:138bdc859cc9 887
rgrover1 124:664d4257a9f8 888 #ifdef __cplusplus
rgrover1 124:664d4257a9f8 889 }
rgrover1 124:664d4257a9f8 890 #endif
rgrover1 124:664d4257a9f8 891
rgrover1 103:138bdc859cc9 892 /** @} */
rgrover1 103:138bdc859cc9 893 /** @} */
rgrover1 103:138bdc859cc9 894 /** @} */
rgrover1 103:138bdc859cc9 895 #endif // DEVICE_MANAGER_H__
rgrover1 103:138bdc859cc9 896