Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

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