test

Fork of nRF51822 by Nordic Semiconductor

Committer:
GlimwormBeacons
Date:
Sat Oct 10 09:19:50 2015 +0000
Revision:
448:b71e96a821de
Parent:
387:b13ab9a7ddb9
test

Who changed what in which revision?

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