Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /*
sahilmgandhi 18:6a4db94011d3 2 * Copyright (c) 2000 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 @addtogroup BLE_COMMON BLE SoftDevice Common
sahilmgandhi 18:6a4db94011d3 42 @{
sahilmgandhi 18:6a4db94011d3 43 @defgroup ble_api Events, type definitions and API calls
sahilmgandhi 18:6a4db94011d3 44 @{
sahilmgandhi 18:6a4db94011d3 45
sahilmgandhi 18:6a4db94011d3 46 @brief Module independent events, type definitions and API calls for the BLE SoftDevice.
sahilmgandhi 18:6a4db94011d3 47
sahilmgandhi 18:6a4db94011d3 48 */
sahilmgandhi 18:6a4db94011d3 49
sahilmgandhi 18:6a4db94011d3 50 #ifndef NRF_BLE_H__
sahilmgandhi 18:6a4db94011d3 51 #define NRF_BLE_H__
sahilmgandhi 18:6a4db94011d3 52
sahilmgandhi 18:6a4db94011d3 53 #include "nrf_ble_ranges.h"
sahilmgandhi 18:6a4db94011d3 54 #include "nrf_ble_types.h"
sahilmgandhi 18:6a4db94011d3 55 #include "nrf_ble_gap.h"
sahilmgandhi 18:6a4db94011d3 56 #include "nrf_ble_l2cap.h"
sahilmgandhi 18:6a4db94011d3 57 #include "nrf_ble_gatt.h"
sahilmgandhi 18:6a4db94011d3 58 #include "nrf_ble_gattc.h"
sahilmgandhi 18:6a4db94011d3 59 #include "nrf_ble_gatts.h"
sahilmgandhi 18:6a4db94011d3 60
sahilmgandhi 18:6a4db94011d3 61 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 62 extern "C" {
sahilmgandhi 18:6a4db94011d3 63 #endif
sahilmgandhi 18:6a4db94011d3 64
sahilmgandhi 18:6a4db94011d3 65 /** @addtogroup BLE_COMMON_ENUMERATIONS Enumerations
sahilmgandhi 18:6a4db94011d3 66 * @{ */
sahilmgandhi 18:6a4db94011d3 67
sahilmgandhi 18:6a4db94011d3 68 /**
sahilmgandhi 18:6a4db94011d3 69 * @brief Common API SVC numbers.
sahilmgandhi 18:6a4db94011d3 70 */
sahilmgandhi 18:6a4db94011d3 71 enum BLE_COMMON_SVCS
sahilmgandhi 18:6a4db94011d3 72 {
sahilmgandhi 18:6a4db94011d3 73 SD_BLE_ENABLE = BLE_SVC_BASE, /**< Enable and initialize the BLE stack */
sahilmgandhi 18:6a4db94011d3 74 SD_BLE_EVT_GET, /**< Get an event from the pending events queue. */
sahilmgandhi 18:6a4db94011d3 75 SD_BLE_TX_PACKET_COUNT_GET, /**< Get the total number of available application transmission packets for a particular connection. */
sahilmgandhi 18:6a4db94011d3 76 SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific UUID. */
sahilmgandhi 18:6a4db94011d3 77 SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */
sahilmgandhi 18:6a4db94011d3 78 SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */
sahilmgandhi 18:6a4db94011d3 79 SD_BLE_VERSION_GET, /**< Get the local version information (company id, Link Layer Version, Link Layer Subversion). */
sahilmgandhi 18:6a4db94011d3 80 SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */
sahilmgandhi 18:6a4db94011d3 81 SD_BLE_OPT_SET, /**< Set a BLE option. */
sahilmgandhi 18:6a4db94011d3 82 SD_BLE_OPT_GET, /**< Get a BLE option. */
sahilmgandhi 18:6a4db94011d3 83 };
sahilmgandhi 18:6a4db94011d3 84
sahilmgandhi 18:6a4db94011d3 85 /**
sahilmgandhi 18:6a4db94011d3 86 * @brief BLE Module Independent Event IDs.
sahilmgandhi 18:6a4db94011d3 87 */
sahilmgandhi 18:6a4db94011d3 88 enum BLE_COMMON_EVTS
sahilmgandhi 18:6a4db94011d3 89 {
sahilmgandhi 18:6a4db94011d3 90 BLE_EVT_TX_COMPLETE = BLE_EVT_BASE, /**< Transmission Complete. @ref ble_evt_tx_complete_t */
sahilmgandhi 18:6a4db94011d3 91 BLE_EVT_USER_MEM_REQUEST, /**< User Memory request. @ref ble_evt_user_mem_request_t */
sahilmgandhi 18:6a4db94011d3 92 BLE_EVT_USER_MEM_RELEASE /**< User Memory release. @ref ble_evt_user_mem_release_t */
sahilmgandhi 18:6a4db94011d3 93 };
sahilmgandhi 18:6a4db94011d3 94
sahilmgandhi 18:6a4db94011d3 95 /**@brief BLE connection bandwidth types.
sahilmgandhi 18:6a4db94011d3 96 * Bandwidth types supported by the SoftDevice in packets per connection interval.
sahilmgandhi 18:6a4db94011d3 97 */
sahilmgandhi 18:6a4db94011d3 98 enum BLE_CONN_BWS
sahilmgandhi 18:6a4db94011d3 99 {
sahilmgandhi 18:6a4db94011d3 100 BLE_CONN_BW_NONE = 0,
sahilmgandhi 18:6a4db94011d3 101 BLE_CONN_BW_LOW,
sahilmgandhi 18:6a4db94011d3 102 BLE_CONN_BW_MID,
sahilmgandhi 18:6a4db94011d3 103 BLE_CONN_BW_HIGH
sahilmgandhi 18:6a4db94011d3 104 };
sahilmgandhi 18:6a4db94011d3 105
sahilmgandhi 18:6a4db94011d3 106 /**@brief Common Option IDs.
sahilmgandhi 18:6a4db94011d3 107 * IDs that uniquely identify a common option.
sahilmgandhi 18:6a4db94011d3 108 */
sahilmgandhi 18:6a4db94011d3 109 enum BLE_COMMON_OPTS
sahilmgandhi 18:6a4db94011d3 110 {
sahilmgandhi 18:6a4db94011d3 111 BLE_COMMON_OPT_CONN_BW = BLE_OPT_BASE, /**< Bandwidth configuration @ref ble_common_opt_conn_bw_t */
sahilmgandhi 18:6a4db94011d3 112 BLE_COMMON_OPT_PA_LNA /**< PA and LNA options */
sahilmgandhi 18:6a4db94011d3 113 };
sahilmgandhi 18:6a4db94011d3 114
sahilmgandhi 18:6a4db94011d3 115 /** @} */
sahilmgandhi 18:6a4db94011d3 116
sahilmgandhi 18:6a4db94011d3 117 /** @addtogroup BLE_COMMON_DEFINES Defines
sahilmgandhi 18:6a4db94011d3 118 * @{ */
sahilmgandhi 18:6a4db94011d3 119
sahilmgandhi 18:6a4db94011d3 120 /** @brief Required pointer alignment for BLE Events.
sahilmgandhi 18:6a4db94011d3 121 */
sahilmgandhi 18:6a4db94011d3 122 #define BLE_EVTS_PTR_ALIGNMENT 4
sahilmgandhi 18:6a4db94011d3 123
sahilmgandhi 18:6a4db94011d3 124 /** @defgroup BLE_USER_MEM_TYPES User Memory Types
sahilmgandhi 18:6a4db94011d3 125 * @{ */
sahilmgandhi 18:6a4db94011d3 126 #define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */
sahilmgandhi 18:6a4db94011d3 127 #define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */
sahilmgandhi 18:6a4db94011d3 128 /** @} */
sahilmgandhi 18:6a4db94011d3 129
sahilmgandhi 18:6a4db94011d3 130 /** @defgroup BLE_UUID_VS_COUNTS Vendor Specific UUID counts
sahilmgandhi 18:6a4db94011d3 131 * @{
sahilmgandhi 18:6a4db94011d3 132 */
sahilmgandhi 18:6a4db94011d3 133 #define BLE_UUID_VS_COUNT_MIN 1 /**< Minimum VS UUID count. */
sahilmgandhi 18:6a4db94011d3 134 #define BLE_UUID_VS_COUNT_DEFAULT 0 /**< Use the default VS UUID count (10 for this version of the SoftDevice). */
sahilmgandhi 18:6a4db94011d3 135 /** @} */
sahilmgandhi 18:6a4db94011d3 136
sahilmgandhi 18:6a4db94011d3 137 /** @} */
sahilmgandhi 18:6a4db94011d3 138
sahilmgandhi 18:6a4db94011d3 139 /** @addtogroup BLE_COMMON_STRUCTURES Structures
sahilmgandhi 18:6a4db94011d3 140 * @{ */
sahilmgandhi 18:6a4db94011d3 141
sahilmgandhi 18:6a4db94011d3 142 /**@brief User Memory Block. */
sahilmgandhi 18:6a4db94011d3 143 typedef struct
sahilmgandhi 18:6a4db94011d3 144 {
sahilmgandhi 18:6a4db94011d3 145 uint8_t *p_mem; /**< Pointer to the start of the user memory block. */
sahilmgandhi 18:6a4db94011d3 146 uint16_t len; /**< Length in bytes of the user memory block. */
sahilmgandhi 18:6a4db94011d3 147 } ble_user_mem_block_t;
sahilmgandhi 18:6a4db94011d3 148
sahilmgandhi 18:6a4db94011d3 149 /**
sahilmgandhi 18:6a4db94011d3 150 * @brief Event structure for @ref BLE_EVT_TX_COMPLETE.
sahilmgandhi 18:6a4db94011d3 151 */
sahilmgandhi 18:6a4db94011d3 152 typedef struct
sahilmgandhi 18:6a4db94011d3 153 {
sahilmgandhi 18:6a4db94011d3 154 uint8_t count; /**< Number of packets transmitted. */
sahilmgandhi 18:6a4db94011d3 155 } ble_evt_tx_complete_t;
sahilmgandhi 18:6a4db94011d3 156
sahilmgandhi 18:6a4db94011d3 157 /**@brief Event structure for @ref BLE_EVT_USER_MEM_REQUEST. */
sahilmgandhi 18:6a4db94011d3 158 typedef struct
sahilmgandhi 18:6a4db94011d3 159 {
sahilmgandhi 18:6a4db94011d3 160 uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
sahilmgandhi 18:6a4db94011d3 161 } ble_evt_user_mem_request_t;
sahilmgandhi 18:6a4db94011d3 162
sahilmgandhi 18:6a4db94011d3 163 /**@brief Event structure for @ref BLE_EVT_USER_MEM_RELEASE. */
sahilmgandhi 18:6a4db94011d3 164 typedef struct
sahilmgandhi 18:6a4db94011d3 165 {
sahilmgandhi 18:6a4db94011d3 166 uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
sahilmgandhi 18:6a4db94011d3 167 ble_user_mem_block_t mem_block; /**< User memory block */
sahilmgandhi 18:6a4db94011d3 168 } ble_evt_user_mem_release_t;
sahilmgandhi 18:6a4db94011d3 169
sahilmgandhi 18:6a4db94011d3 170
sahilmgandhi 18:6a4db94011d3 171 /**@brief Event structure for events not associated with a specific function module. */
sahilmgandhi 18:6a4db94011d3 172 typedef struct
sahilmgandhi 18:6a4db94011d3 173 {
sahilmgandhi 18:6a4db94011d3 174 uint16_t conn_handle; /**< Connection Handle on which this event occurred. */
sahilmgandhi 18:6a4db94011d3 175 union
sahilmgandhi 18:6a4db94011d3 176 {
sahilmgandhi 18:6a4db94011d3 177 ble_evt_tx_complete_t tx_complete; /**< Transmission Complete. */
sahilmgandhi 18:6a4db94011d3 178 ble_evt_user_mem_request_t user_mem_request; /**< User Memory Request Event Parameters. */
sahilmgandhi 18:6a4db94011d3 179 ble_evt_user_mem_release_t user_mem_release; /**< User Memory Release Event Parameters. */
sahilmgandhi 18:6a4db94011d3 180 } params;
sahilmgandhi 18:6a4db94011d3 181 } ble_common_evt_t;
sahilmgandhi 18:6a4db94011d3 182
sahilmgandhi 18:6a4db94011d3 183 /**@brief BLE Event header. */
sahilmgandhi 18:6a4db94011d3 184 typedef struct
sahilmgandhi 18:6a4db94011d3 185 {
sahilmgandhi 18:6a4db94011d3 186 uint16_t evt_id; /**< Value from a BLE_<module>_EVT series. */
sahilmgandhi 18:6a4db94011d3 187 uint16_t evt_len; /**< Length in octets including this header. */
sahilmgandhi 18:6a4db94011d3 188 } ble_evt_hdr_t;
sahilmgandhi 18:6a4db94011d3 189
sahilmgandhi 18:6a4db94011d3 190 /**@brief Common BLE Event type, wrapping the module specific event reports. */
sahilmgandhi 18:6a4db94011d3 191 typedef struct
sahilmgandhi 18:6a4db94011d3 192 {
sahilmgandhi 18:6a4db94011d3 193 ble_evt_hdr_t header; /**< Event header. */
sahilmgandhi 18:6a4db94011d3 194 union
sahilmgandhi 18:6a4db94011d3 195 {
sahilmgandhi 18:6a4db94011d3 196 ble_common_evt_t common_evt; /**< Common Event, evt_id in BLE_EVT_* series. */
sahilmgandhi 18:6a4db94011d3 197 ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */
sahilmgandhi 18:6a4db94011d3 198 ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */
sahilmgandhi 18:6a4db94011d3 199 ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */
sahilmgandhi 18:6a4db94011d3 200 ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */
sahilmgandhi 18:6a4db94011d3 201 } evt;
sahilmgandhi 18:6a4db94011d3 202 } ble_evt_t;
sahilmgandhi 18:6a4db94011d3 203
sahilmgandhi 18:6a4db94011d3 204
sahilmgandhi 18:6a4db94011d3 205 /**
sahilmgandhi 18:6a4db94011d3 206 * @brief Version Information.
sahilmgandhi 18:6a4db94011d3 207 */
sahilmgandhi 18:6a4db94011d3 208 typedef struct
sahilmgandhi 18:6a4db94011d3 209 {
sahilmgandhi 18:6a4db94011d3 210 uint8_t version_number; /**< Link Layer Version number for BT 4.1 spec is 7 (https://www.bluetooth.org/en-us/specification/assigned-numbers/link-layer). */
sahilmgandhi 18:6a4db94011d3 211 uint16_t company_id; /**< Company ID, Nordic Semiconductor's company ID is 89 (0x0059) (https://www.bluetooth.org/apps/content/Default.aspx?doc_id=49708). */
sahilmgandhi 18:6a4db94011d3 212 uint16_t subversion_number; /**< Link Layer Sub Version number, corresponds to the SoftDevice Config ID or Firmware ID (FWID). */
sahilmgandhi 18:6a4db94011d3 213 } ble_version_t;
sahilmgandhi 18:6a4db94011d3 214
sahilmgandhi 18:6a4db94011d3 215 /* @brief: Configuration parameters for the PA and LNA. */
sahilmgandhi 18:6a4db94011d3 216 typedef struct
sahilmgandhi 18:6a4db94011d3 217 {
sahilmgandhi 18:6a4db94011d3 218 uint8_t enable :1; /**< Enable toggling for this amplifier */
sahilmgandhi 18:6a4db94011d3 219 uint8_t active_high :1; /**< Set the pin to be active high */
sahilmgandhi 18:6a4db94011d3 220 uint8_t gpio_pin :6; /**< The GPIO pin to toggle for this amplifier */
sahilmgandhi 18:6a4db94011d3 221 } ble_pa_lna_cfg_t;
sahilmgandhi 18:6a4db94011d3 222
sahilmgandhi 18:6a4db94011d3 223 /*
sahilmgandhi 18:6a4db94011d3 224 * @brief PA & LNA GPIO toggle configuration
sahilmgandhi 18:6a4db94011d3 225 *
sahilmgandhi 18:6a4db94011d3 226 * This option configures the SoftDevice to toggle pins when the radio is active for use with a power amplifier and/or
sahilmgandhi 18:6a4db94011d3 227 * a low noise amplifier.
sahilmgandhi 18:6a4db94011d3 228 *
sahilmgandhi 18:6a4db94011d3 229 * Toggling the pins is achieved by using two PPI channels and a GPIOTE channel. The hardware channel IDs are provided
sahilmgandhi 18:6a4db94011d3 230 * by the application and should be regarded as reserved as long as any PA/LNA toggling is enabled.
sahilmgandhi 18:6a4db94011d3 231 *
sahilmgandhi 18:6a4db94011d3 232 * @note @ref sd_ble_opt_get is not supported for this option.
sahilmgandhi 18:6a4db94011d3 233 * @note This feature is only supported for nRF52, on nRF51 @ref NRF_ERROR_NOT_SUPPORTED will always be returned.
sahilmgandhi 18:6a4db94011d3 234 * @note Setting this option while the radio is in use (i.e. any of the roles are active) may have undefined consequences
sahilmgandhi 18:6a4db94011d3 235 * and must be avoided by the application.
sahilmgandhi 18:6a4db94011d3 236 *
sahilmgandhi 18:6a4db94011d3 237 */
sahilmgandhi 18:6a4db94011d3 238 typedef struct
sahilmgandhi 18:6a4db94011d3 239 {
sahilmgandhi 18:6a4db94011d3 240 ble_pa_lna_cfg_t pa_cfg; /**< Power Amplifier configuration */
sahilmgandhi 18:6a4db94011d3 241 ble_pa_lna_cfg_t lna_cfg; /**< Low Noise Amplifier configuration */
sahilmgandhi 18:6a4db94011d3 242
sahilmgandhi 18:6a4db94011d3 243 uint8_t ppi_ch_id_set; /**< PPI channel used for radio pin setting */
sahilmgandhi 18:6a4db94011d3 244 uint8_t ppi_ch_id_clr; /**< PPI channel used for radio pin clearing */
sahilmgandhi 18:6a4db94011d3 245 uint8_t gpiote_ch_id; /**< GPIOTE channel used for radio pin toggling */
sahilmgandhi 18:6a4db94011d3 246 } ble_common_opt_pa_lna_t;
sahilmgandhi 18:6a4db94011d3 247
sahilmgandhi 18:6a4db94011d3 248 /**
sahilmgandhi 18:6a4db94011d3 249 * @brief BLE connection bandwidth configuration parameters
sahilmgandhi 18:6a4db94011d3 250 */
sahilmgandhi 18:6a4db94011d3 251 typedef struct
sahilmgandhi 18:6a4db94011d3 252 {
sahilmgandhi 18:6a4db94011d3 253 uint8_t conn_bw_tx; /**< Connection bandwidth configuration for transmission, see @ref BLE_CONN_BWS.*/
sahilmgandhi 18:6a4db94011d3 254 uint8_t conn_bw_rx; /**< Connection bandwidth configuration for reception, see @ref BLE_CONN_BWS.*/
sahilmgandhi 18:6a4db94011d3 255 } ble_conn_bw_t;
sahilmgandhi 18:6a4db94011d3 256
sahilmgandhi 18:6a4db94011d3 257 /**@brief BLE connection specific bandwidth configuration parameters.
sahilmgandhi 18:6a4db94011d3 258 *
sahilmgandhi 18:6a4db94011d3 259 * This can be used with @ref sd_ble_opt_set to set the bandwidth configuration to be used when creating connections.
sahilmgandhi 18:6a4db94011d3 260 *
sahilmgandhi 18:6a4db94011d3 261 * Call @ref sd_ble_opt_set with this option prior to calling @ref sd_ble_gap_adv_start or @ref sd_ble_gap_connect.
sahilmgandhi 18:6a4db94011d3 262 *
sahilmgandhi 18:6a4db94011d3 263 * The bandwidth configurations set via @ref sd_ble_opt_set are maintained separately for central and peripheral
sahilmgandhi 18:6a4db94011d3 264 * connections. The given configurations are used for all future connections of the role indicated in this structure
sahilmgandhi 18:6a4db94011d3 265 * unless they are changed by subsequent @ref sd_ble_opt_set calls.
sahilmgandhi 18:6a4db94011d3 266 *
sahilmgandhi 18:6a4db94011d3 267 * @note When this option is not used, the SoftDevice will use the default options:
sahilmgandhi 18:6a4db94011d3 268 * - @ref BLE_CONN_BW_HIGH for @ref BLE_GAP_ROLE_PERIPH connections (both transmission and reception).
sahilmgandhi 18:6a4db94011d3 269 * - @ref BLE_CONN_BW_MID for @ref BLE_GAP_ROLE_CENTRAL connections (both transmisison and reception).
sahilmgandhi 18:6a4db94011d3 270 * This option allows the application to selectively override these defaults for each role.
sahilmgandhi 18:6a4db94011d3 271 *
sahilmgandhi 18:6a4db94011d3 272 * @note The global memory pool configuration can be set with the @ref ble_conn_bw_counts_t configuration parameter, which
sahilmgandhi 18:6a4db94011d3 273 * is provided to @ref sd_ble_enable.
sahilmgandhi 18:6a4db94011d3 274 *
sahilmgandhi 18:6a4db94011d3 275 * @note Please refer to SoftDevice Specification for more information on bandwidth configuration.
sahilmgandhi 18:6a4db94011d3 276 *
sahilmgandhi 18:6a4db94011d3 277 * @mscs
sahilmgandhi 18:6a4db94011d3 278 * @mmsc{@ref BLE_COMMON_CONF_BW}
sahilmgandhi 18:6a4db94011d3 279 * @endmscs
sahilmgandhi 18:6a4db94011d3 280 *
sahilmgandhi 18:6a4db94011d3 281 * @retval ::NRF_SUCCESS Set successfully.
sahilmgandhi 18:6a4db94011d3 282 * @retval ::BLE_ERROR_INVALID_ROLE The role is invalid.
sahilmgandhi 18:6a4db94011d3 283 * @retval ::NRF_ERROR_INVALID_PARAM Invalid bandwidth configuration parameters.
sahilmgandhi 18:6a4db94011d3 284 * @retval ::NRF_ERROR_NOT_SUPPORTED If the combination of role and bandwidth configuration is not supported.
sahilmgandhi 18:6a4db94011d3 285 */
sahilmgandhi 18:6a4db94011d3 286 typedef struct
sahilmgandhi 18:6a4db94011d3 287 {
sahilmgandhi 18:6a4db94011d3 288 uint8_t role; /**< BLE role of the connection, see @ref BLE_GAP_ROLES. */
sahilmgandhi 18:6a4db94011d3 289 ble_conn_bw_t conn_bw; /**< Bandwidth configuration parameters. */
sahilmgandhi 18:6a4db94011d3 290 } ble_common_opt_conn_bw_t;
sahilmgandhi 18:6a4db94011d3 291
sahilmgandhi 18:6a4db94011d3 292 /**@brief Option structure for common options. */
sahilmgandhi 18:6a4db94011d3 293 typedef union
sahilmgandhi 18:6a4db94011d3 294 {
sahilmgandhi 18:6a4db94011d3 295 ble_common_opt_conn_bw_t conn_bw; /**< Parameters for the connection bandwidth option. */
sahilmgandhi 18:6a4db94011d3 296 ble_common_opt_pa_lna_t pa_lna; /**< Parameters for controlling PA and LNA pin toggling. */
sahilmgandhi 18:6a4db94011d3 297 } ble_common_opt_t;
sahilmgandhi 18:6a4db94011d3 298
sahilmgandhi 18:6a4db94011d3 299 /**@brief Common BLE Option type, wrapping the module specific options. */
sahilmgandhi 18:6a4db94011d3 300 typedef union
sahilmgandhi 18:6a4db94011d3 301 {
sahilmgandhi 18:6a4db94011d3 302 ble_common_opt_t common_opt; /**< COMMON options, opt_id in @ref BLE_COMMON_OPTS series. */
sahilmgandhi 18:6a4db94011d3 303 ble_gap_opt_t gap_opt; /**< GAP option, opt_id in @ref BLE_GAP_OPTS series. */
sahilmgandhi 18:6a4db94011d3 304 } ble_opt_t;
sahilmgandhi 18:6a4db94011d3 305
sahilmgandhi 18:6a4db94011d3 306 /**
sahilmgandhi 18:6a4db94011d3 307 * @brief BLE bandwidth count parameters
sahilmgandhi 18:6a4db94011d3 308 *
sahilmgandhi 18:6a4db94011d3 309 * These parameters are used to configure the memory pools allocated within the SoftDevice for application packets
sahilmgandhi 18:6a4db94011d3 310 * (both transmission and reception) for all connections.
sahilmgandhi 18:6a4db94011d3 311 *
sahilmgandhi 18:6a4db94011d3 312 * @note The sum of all three counts must add up to the sum of @ref ble_gap_enable_params_t::central_conn_count and
sahilmgandhi 18:6a4db94011d3 313 * @ref ble_gap_enable_params_t::periph_conn_count in @ref ble_gap_enable_params_t.
sahilmgandhi 18:6a4db94011d3 314 */
sahilmgandhi 18:6a4db94011d3 315 typedef struct {
sahilmgandhi 18:6a4db94011d3 316 uint8_t high_count; /**< Total number of high bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
sahilmgandhi 18:6a4db94011d3 317 uint8_t mid_count; /**< Total number of medium bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
sahilmgandhi 18:6a4db94011d3 318 uint8_t low_count; /**< Total number of low bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
sahilmgandhi 18:6a4db94011d3 319 } ble_conn_bw_count_t;
sahilmgandhi 18:6a4db94011d3 320
sahilmgandhi 18:6a4db94011d3 321 /**
sahilmgandhi 18:6a4db94011d3 322 * @brief BLE bandwidth global memory pool configuration parameters
sahilmgandhi 18:6a4db94011d3 323 *
sahilmgandhi 18:6a4db94011d3 324 * These configuration parameters are used to set the amount of memory dedicated to application packets for
sahilmgandhi 18:6a4db94011d3 325 * all connections. The application should specify the most demanding configuration for the intended use.
sahilmgandhi 18:6a4db94011d3 326 *
sahilmgandhi 18:6a4db94011d3 327 * Please refer to the SoftDevice Specification for more information on bandwidth configuration.
sahilmgandhi 18:6a4db94011d3 328 *
sahilmgandhi 18:6a4db94011d3 329 * @note Each connection created at runtime requires both a TX and an RX memory pool. By the use of these configuration
sahilmgandhi 18:6a4db94011d3 330 * parameters, the application can decide the size and total number of the global memory pools that will be later
sahilmgandhi 18:6a4db94011d3 331 * available for connection creation.
sahilmgandhi 18:6a4db94011d3 332 *
sahilmgandhi 18:6a4db94011d3 333 * @mscs
sahilmgandhi 18:6a4db94011d3 334 * @mmsc{@ref BLE_COMMON_CONF_BW}
sahilmgandhi 18:6a4db94011d3 335 * @endmscs
sahilmgandhi 18:6a4db94011d3 336 *
sahilmgandhi 18:6a4db94011d3 337 */
sahilmgandhi 18:6a4db94011d3 338 typedef struct {
sahilmgandhi 18:6a4db94011d3 339 ble_conn_bw_count_t tx_counts; /**< Global memory pool configuration for transmission.*/
sahilmgandhi 18:6a4db94011d3 340 ble_conn_bw_count_t rx_counts; /**< Global memory pool configuration for reception.*/
sahilmgandhi 18:6a4db94011d3 341 } ble_conn_bw_counts_t;
sahilmgandhi 18:6a4db94011d3 342
sahilmgandhi 18:6a4db94011d3 343 /**
sahilmgandhi 18:6a4db94011d3 344 * @brief BLE Common Initialization parameters.
sahilmgandhi 18:6a4db94011d3 345 *
sahilmgandhi 18:6a4db94011d3 346 * @note If @ref p_conn_bw_counts is NULL the SoftDevice will assume default bandwidth configuration for all connections.
sahilmgandhi 18:6a4db94011d3 347 * To fit a custom bandwidth configuration requirement, the application developer may have to specify a custom memory
sahilmgandhi 18:6a4db94011d3 348 * pool configuration here. See @ref ble_common_opt_conn_bw_t for bandwidth configuration of individual connections.
sahilmgandhi 18:6a4db94011d3 349 * Please refer to the SoftDevice Specification for more information on bandwidth configuration.
sahilmgandhi 18:6a4db94011d3 350 */
sahilmgandhi 18:6a4db94011d3 351 typedef struct
sahilmgandhi 18:6a4db94011d3 352 {
sahilmgandhi 18:6a4db94011d3 353 uint16_t vs_uuid_count; /**< Maximum number of 128-bit, Vendor Specific UUID bases to allocate. */
sahilmgandhi 18:6a4db94011d3 354 ble_conn_bw_counts_t *p_conn_bw_counts; /**< Bandwidth configuration parameters or NULL for defaults. */
sahilmgandhi 18:6a4db94011d3 355 } ble_common_enable_params_t;
sahilmgandhi 18:6a4db94011d3 356
sahilmgandhi 18:6a4db94011d3 357 /**
sahilmgandhi 18:6a4db94011d3 358 * @brief BLE Initialization parameters.
sahilmgandhi 18:6a4db94011d3 359 */
sahilmgandhi 18:6a4db94011d3 360 typedef struct
sahilmgandhi 18:6a4db94011d3 361 {
sahilmgandhi 18:6a4db94011d3 362 ble_common_enable_params_t common_enable_params; /**< Common init parameters @ref ble_common_enable_params_t. */
sahilmgandhi 18:6a4db94011d3 363 ble_gap_enable_params_t gap_enable_params; /**< GAP init parameters @ref ble_gap_enable_params_t. */
sahilmgandhi 18:6a4db94011d3 364 ble_gatts_enable_params_t gatts_enable_params; /**< GATTS init parameters @ref ble_gatts_enable_params_t. */
sahilmgandhi 18:6a4db94011d3 365 } ble_enable_params_t;
sahilmgandhi 18:6a4db94011d3 366
sahilmgandhi 18:6a4db94011d3 367 /** @} */
sahilmgandhi 18:6a4db94011d3 368
sahilmgandhi 18:6a4db94011d3 369 /** @addtogroup BLE_COMMON_FUNCTIONS Functions
sahilmgandhi 18:6a4db94011d3 370 * @{ */
sahilmgandhi 18:6a4db94011d3 371
sahilmgandhi 18:6a4db94011d3 372 /**@brief Enable the BLE stack
sahilmgandhi 18:6a4db94011d3 373 *
sahilmgandhi 18:6a4db94011d3 374 * @param[in, out] p_ble_enable_params Pointer to ble_enable_params_t
sahilmgandhi 18:6a4db94011d3 375 * @param[in, out] p_app_ram_base Pointer to a variable containing the start address of the application RAM region
sahilmgandhi 18:6a4db94011d3 376 * (APP_RAM_BASE). On return, this will contain the minimum start address of the application RAM region required by the
sahilmgandhi 18:6a4db94011d3 377 * SoftDevice for this configuration. Calling @ref sd_ble_enable() with *p_app_ram_base set to 0 can be used during
sahilmgandhi 18:6a4db94011d3 378 * development to find out how much memory a specific configuration will need.
sahilmgandhi 18:6a4db94011d3 379 *
sahilmgandhi 18:6a4db94011d3 380 * @note The memory requirement for a specific configuration will not increase between SoftDevices with the same major
sahilmgandhi 18:6a4db94011d3 381 * version number.
sahilmgandhi 18:6a4db94011d3 382 *
sahilmgandhi 18:6a4db94011d3 383 * @note At runtime the IC's RAM is split into 2 regions: The SoftDevice RAM region is located between 0x20000000 and
sahilmgandhi 18:6a4db94011d3 384 * APP_RAM_BASE-1 and the application's RAM region is located between APP_RAM_BASE and the start of the call stack.
sahilmgandhi 18:6a4db94011d3 385 *
sahilmgandhi 18:6a4db94011d3 386 * @details This call initializes the BLE stack, no other BLE related function can be called before this one.
sahilmgandhi 18:6a4db94011d3 387 *
sahilmgandhi 18:6a4db94011d3 388 * @mscs
sahilmgandhi 18:6a4db94011d3 389 * @mmsc{@ref BLE_COMMON_ENABLE}
sahilmgandhi 18:6a4db94011d3 390 * @endmscs
sahilmgandhi 18:6a4db94011d3 391 *
sahilmgandhi 18:6a4db94011d3 392 * @retval ::NRF_SUCCESS The BLE stack has been initialized successfully.
sahilmgandhi 18:6a4db94011d3 393 * @retval ::NRF_ERROR_INVALID_STATE The BLE stack had already been initialized and cannot be reinitialized.
sahilmgandhi 18:6a4db94011d3 394 * @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
sahilmgandhi 18:6a4db94011d3 395 * @retval ::NRF_ERROR_INVALID_LENGTH The specified Attribute Table size is either too small or not a multiple of 4.
sahilmgandhi 18:6a4db94011d3 396 * The minimum acceptable size is defined by @ref BLE_GATTS_ATTR_TAB_SIZE_MIN.
sahilmgandhi 18:6a4db94011d3 397 * @retval ::NRF_ERROR_INVALID_PARAM Incorrectly configured VS UUID count or connection count parameters.
sahilmgandhi 18:6a4db94011d3 398 * @retval ::NRF_ERROR_NO_MEM The amount of memory assigned to the SoftDevice by *p_app_ram_base is not
sahilmgandhi 18:6a4db94011d3 399 * large enough to fit this configuration's memory requirement. Check *p_app_ram_base
sahilmgandhi 18:6a4db94011d3 400 * and set the start address of the application RAM region accordingly.
sahilmgandhi 18:6a4db94011d3 401 * @retval ::NRF_ERROR_CONN_COUNT The requested number of connections exceeds the maximum supported by the SoftDevice.
sahilmgandhi 18:6a4db94011d3 402 * Please refer to the SoftDevice Specification for more information on role configuration.
sahilmgandhi 18:6a4db94011d3 403 */
sahilmgandhi 18:6a4db94011d3 404 SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(ble_enable_params_t * p_ble_enable_params, uint32_t * p_app_ram_base));
sahilmgandhi 18:6a4db94011d3 405
sahilmgandhi 18:6a4db94011d3 406 /**@brief Get an event from the pending events queue.
sahilmgandhi 18:6a4db94011d3 407 *
sahilmgandhi 18:6a4db94011d3 408 * @param[out] p_dest Pointer to buffer to be filled in with an event, or NULL to retrieve the event length.
sahilmgandhi 18:6a4db94011d3 409 * This buffer <b>must be 4-byte aligned in memory</b>.
sahilmgandhi 18:6a4db94011d3 410 * @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length.
sahilmgandhi 18:6a4db94011d3 411 *
sahilmgandhi 18:6a4db94011d3 412 * @details This call allows the application to pull a BLE event from the BLE stack. The application is signaled that
sahilmgandhi 18:6a4db94011d3 413 * an event is available from the BLE stack by the triggering of the SD_EVT_IRQn interrupt.
sahilmgandhi 18:6a4db94011d3 414 * The application is free to choose whether to call this function from thread mode (main context) or directly from the
sahilmgandhi 18:6a4db94011d3 415 * Interrupt Service Routine that maps to SD_EVT_IRQn. In any case however, and because the BLE stack runs at a higher
sahilmgandhi 18:6a4db94011d3 416 * priority than the application, this function should be called in a loop (until @ref NRF_ERROR_NOT_FOUND is returned)
sahilmgandhi 18:6a4db94011d3 417 * every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the BLE stack. Failure to do so
sahilmgandhi 18:6a4db94011d3 418 * could potentially leave events in the internal queue without the application being aware of this fact. Sizing the
sahilmgandhi 18:6a4db94011d3 419 * p_dest buffer is equally important, since the application needs to provide all the memory necessary for the event to
sahilmgandhi 18:6a4db94011d3 420 * be copied into application memory. If the buffer provided is not large enough to fit the entire contents of the event,
sahilmgandhi 18:6a4db94011d3 421 * @ref NRF_ERROR_DATA_SIZE will be returned and the application can then call again with a larger buffer size.
sahilmgandhi 18:6a4db94011d3 422 * Please note that because of the variable length nature of some events, sizeof(ble_evt_t) will not always be large
sahilmgandhi 18:6a4db94011d3 423 * enough to fit certain events, and so it is the application's responsibility to provide an amount of memory large
sahilmgandhi 18:6a4db94011d3 424 * enough so that the relevant event is copied in full. The application may "peek" the event length by providing p_dest
sahilmgandhi 18:6a4db94011d3 425 * as a NULL pointer and inspecting the value of *p_len upon return:
sahilmgandhi 18:6a4db94011d3 426 *
sahilmgandhi 18:6a4db94011d3 427 * \code
sahilmgandhi 18:6a4db94011d3 428 * uint16_t len;
sahilmgandhi 18:6a4db94011d3 429 * errcode = sd_ble_evt_get(NULL, &len);
sahilmgandhi 18:6a4db94011d3 430 * \endcode
sahilmgandhi 18:6a4db94011d3 431 *
sahilmgandhi 18:6a4db94011d3 432 * @note The pointer supplied must be aligned to the extend defined by @ref BLE_EVTS_PTR_ALIGNMENT
sahilmgandhi 18:6a4db94011d3 433 *
sahilmgandhi 18:6a4db94011d3 434 * @mscs
sahilmgandhi 18:6a4db94011d3 435 * @mmsc{@ref BLE_COMMON_IRQ_EVT_MSC}
sahilmgandhi 18:6a4db94011d3 436 * @mmsc{@ref BLE_COMMON_THREAD_EVT_MSC}
sahilmgandhi 18:6a4db94011d3 437 * @endmscs
sahilmgandhi 18:6a4db94011d3 438 *
sahilmgandhi 18:6a4db94011d3 439 * @retval ::NRF_SUCCESS Event pulled and stored into the supplied buffer.
sahilmgandhi 18:6a4db94011d3 440 * @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
sahilmgandhi 18:6a4db94011d3 441 * @retval ::NRF_ERROR_NOT_FOUND No events ready to be pulled.
sahilmgandhi 18:6a4db94011d3 442 * @retval ::NRF_ERROR_DATA_SIZE Event ready but could not fit into the supplied buffer.
sahilmgandhi 18:6a4db94011d3 443 */
sahilmgandhi 18:6a4db94011d3 444 SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len));
sahilmgandhi 18:6a4db94011d3 445
sahilmgandhi 18:6a4db94011d3 446
sahilmgandhi 18:6a4db94011d3 447 /**@brief Get the total number of available guaranteed application transmission packets for a particular connection.
sahilmgandhi 18:6a4db94011d3 448 *
sahilmgandhi 18:6a4db94011d3 449 * @details This call allows the application to obtain the total number of guaranteed application transmission packets
sahilmgandhi 18:6a4db94011d3 450 * available for a connection. Please note that this does not return the number of free packets, but rather the total
sahilmgandhi 18:6a4db94011d3 451 * amount of them for that particular connection. The application has two options to handle transmitting application packets:
sahilmgandhi 18:6a4db94011d3 452 * - Use a simple arithmetic calculation: after connection creation time the application should use this function to
sahilmgandhi 18:6a4db94011d3 453 * find out the total amount of guaranteed packets available to it and store it in a variable.
sahilmgandhi 18:6a4db94011d3 454 * Every time a packet is successfully queued for a transmission on this connection using any of the exposed functions in
sahilmgandhi 18:6a4db94011d3 455 * this BLE API, the application should decrement that variable. Conversely, whenever a @ref BLE_EVT_TX_COMPLETE event
sahilmgandhi 18:6a4db94011d3 456 * with the conn_handle matching the particular connection is received by the application, it should retrieve the count
sahilmgandhi 18:6a4db94011d3 457 * field in such event and add that number to the same variable storing the number of available guaranteed packets. This
sahilmgandhi 18:6a4db94011d3 458 * mechanism allows the application to be aware at any time of the number of guaranteed application packets available for
sahilmgandhi 18:6a4db94011d3 459 * each of the active connections, and therefore it can know with certainty whether it is possible to send more data or
sahilmgandhi 18:6a4db94011d3 460 * it has to wait for a @ref BLE_EVT_TX_COMPLETE event before it proceeds.
sahilmgandhi 18:6a4db94011d3 461 * The application can still pursue transmissions when the number of guaranteed application packets available is smaller
sahilmgandhi 18:6a4db94011d3 462 * than or equal to zero, but successful queuing of the tranmsission is not guaranteed.
sahilmgandhi 18:6a4db94011d3 463 * - Choose to simply not keep track of available packets at all, and instead handle the @ref BLE_ERROR_NO_TX_PACKETS error
sahilmgandhi 18:6a4db94011d3 464 * by queueing the packet to be transmitted and try again as soon as a @ref BLE_EVT_TX_COMPLETE event arrives.
sahilmgandhi 18:6a4db94011d3 465 *
sahilmgandhi 18:6a4db94011d3 466 * The API functions that <b>may</b> consume an application packet depending on the parameters supplied to them can be found below:
sahilmgandhi 18:6a4db94011d3 467 * - @ref sd_ble_gattc_write (write without response only)
sahilmgandhi 18:6a4db94011d3 468 * - @ref sd_ble_gatts_hvx (notifications only)
sahilmgandhi 18:6a4db94011d3 469 * - @ref sd_ble_l2cap_tx (all packets)
sahilmgandhi 18:6a4db94011d3 470 *
sahilmgandhi 18:6a4db94011d3 471 * @param[in] conn_handle Connection handle.
sahilmgandhi 18:6a4db94011d3 472 * @param[out] p_count Pointer to a uint8_t which will contain the number of application transmission packets upon
sahilmgandhi 18:6a4db94011d3 473 * successful return.
sahilmgandhi 18:6a4db94011d3 474 * @mscs
sahilmgandhi 18:6a4db94011d3 475 * @mmsc{@ref BLE_COMMON_APP_BUFF_MSC}
sahilmgandhi 18:6a4db94011d3 476 * @endmscs
sahilmgandhi 18:6a4db94011d3 477 *
sahilmgandhi 18:6a4db94011d3 478 * @retval ::NRF_SUCCESS Number of application transmission packets retrieved successfully.
sahilmgandhi 18:6a4db94011d3 479 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
sahilmgandhi 18:6a4db94011d3 480 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
sahilmgandhi 18:6a4db94011d3 481 */
sahilmgandhi 18:6a4db94011d3 482 SVCALL(SD_BLE_TX_PACKET_COUNT_GET, uint32_t, sd_ble_tx_packet_count_get(uint16_t conn_handle, uint8_t *p_count));
sahilmgandhi 18:6a4db94011d3 483
sahilmgandhi 18:6a4db94011d3 484
sahilmgandhi 18:6a4db94011d3 485 /**@brief Add a Vendor Specific UUID.
sahilmgandhi 18:6a4db94011d3 486 *
sahilmgandhi 18:6a4db94011d3 487 * @details This call enables the application to add a vendor specific UUID to the BLE stack's table, for later use
sahilmgandhi 18:6a4db94011d3 488 * all other modules and APIs. This then allows the application to use the shorter, 24-bit @ref ble_uuid_t format
sahilmgandhi 18:6a4db94011d3 489 * when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code paths.
sahilmgandhi 18:6a4db94011d3 490 * The way that this is accomplished is by extending the grouping mechanism that the Bluetooth SIG standard base
sahilmgandhi 18:6a4db94011d3 491 * UUID uses for all other 128-bit UUIDs. The type field in the @ref ble_uuid_t structure is an index (relative to
sahilmgandhi 18:6a4db94011d3 492 * @ref BLE_UUID_TYPE_VENDOR_BEGIN) to the table populated by multiple calls to this function, and the uuid field
sahilmgandhi 18:6a4db94011d3 493 * in the same structure contains the 2 bytes at indices 12 and 13. The number of possible 128-bit UUIDs available to
sahilmgandhi 18:6a4db94011d3 494 * the application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536,
sahilmgandhi 18:6a4db94011d3 495 * although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array.
sahilmgandhi 18:6a4db94011d3 496 *
sahilmgandhi 18:6a4db94011d3 497 * @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by
sahilmgandhi 18:6a4db94011d3 498 * the 16-bit uuid field in @ref ble_uuid_t.
sahilmgandhi 18:6a4db94011d3 499 *
sahilmgandhi 18:6a4db94011d3 500 * @note If a UUID is already present in the BLE stack's internal table, the corresponding index will be returned in
sahilmgandhi 18:6a4db94011d3 501 * p_uuid_type along with an NRF_SUCCESS error code.
sahilmgandhi 18:6a4db94011d3 502 *
sahilmgandhi 18:6a4db94011d3 503 * @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding
sahilmgandhi 18:6a4db94011d3 504 * bytes 12 and 13.
sahilmgandhi 18:6a4db94011d3 505 * @param[out] p_uuid_type Pointer to a uint8_t where the type field in @ref ble_uuid_t corresponding to this UUID will be stored.
sahilmgandhi 18:6a4db94011d3 506 *
sahilmgandhi 18:6a4db94011d3 507 * @retval ::NRF_SUCCESS Successfully added the Vendor Specific UUID.
sahilmgandhi 18:6a4db94011d3 508 * @retval ::NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid.
sahilmgandhi 18:6a4db94011d3 509 * @retval ::NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs.
sahilmgandhi 18:6a4db94011d3 510 */
sahilmgandhi 18:6a4db94011d3 511 SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type));
sahilmgandhi 18:6a4db94011d3 512
sahilmgandhi 18:6a4db94011d3 513
sahilmgandhi 18:6a4db94011d3 514 /** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure.
sahilmgandhi 18:6a4db94011d3 515 *
sahilmgandhi 18:6a4db94011d3 516 * @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared
sahilmgandhi 18:6a4db94011d3 517 * to the corresponding ones in each entry of the table of vendor specific UUIDs populated with @ref sd_ble_uuid_vs_add
sahilmgandhi 18:6a4db94011d3 518 * to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index
sahilmgandhi 18:6a4db94011d3 519 * relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type.
sahilmgandhi 18:6a4db94011d3 520 *
sahilmgandhi 18:6a4db94011d3 521 * @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE.
sahilmgandhi 18:6a4db94011d3 522 *
sahilmgandhi 18:6a4db94011d3 523 * @param[in] uuid_le_len Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes).
sahilmgandhi 18:6a4db94011d3 524 * @param[in] p_uuid_le Pointer pointing to little endian raw UUID bytes.
sahilmgandhi 18:6a4db94011d3 525 * @param[out] p_uuid Pointer to a @ref ble_uuid_t structure to be filled in.
sahilmgandhi 18:6a4db94011d3 526 *
sahilmgandhi 18:6a4db94011d3 527 * @retval ::NRF_SUCCESS Successfully decoded into the @ref ble_uuid_t structure.
sahilmgandhi 18:6a4db94011d3 528 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
sahilmgandhi 18:6a4db94011d3 529 * @retval ::NRF_ERROR_INVALID_LENGTH Invalid UUID length.
sahilmgandhi 18:6a4db94011d3 530 * @retval ::NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs.
sahilmgandhi 18:6a4db94011d3 531 */
sahilmgandhi 18:6a4db94011d3 532 SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const *p_uuid_le, ble_uuid_t *p_uuid));
sahilmgandhi 18:6a4db94011d3 533
sahilmgandhi 18:6a4db94011d3 534
sahilmgandhi 18:6a4db94011d3 535 /** @brief Encode a @ref ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit).
sahilmgandhi 18:6a4db94011d3 536 *
sahilmgandhi 18:6a4db94011d3 537 * @note The pointer to the destination buffer p_uuid_le may be NULL, in which case only the validity and size of p_uuid is computed.
sahilmgandhi 18:6a4db94011d3 538 *
sahilmgandhi 18:6a4db94011d3 539 * @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes.
sahilmgandhi 18:6a4db94011d3 540 * @param[out] p_uuid_le_len Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes).
sahilmgandhi 18:6a4db94011d3 541 * @param[out] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored.
sahilmgandhi 18:6a4db94011d3 542 *
sahilmgandhi 18:6a4db94011d3 543 * @retval ::NRF_SUCCESS Successfully encoded into the buffer.
sahilmgandhi 18:6a4db94011d3 544 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
sahilmgandhi 18:6a4db94011d3 545 * @retval ::NRF_ERROR_INVALID_PARAM Invalid UUID type.
sahilmgandhi 18:6a4db94011d3 546 */
sahilmgandhi 18:6a4db94011d3 547 SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const *p_uuid, uint8_t *p_uuid_le_len, uint8_t *p_uuid_le));
sahilmgandhi 18:6a4db94011d3 548
sahilmgandhi 18:6a4db94011d3 549
sahilmgandhi 18:6a4db94011d3 550 /**@brief Get Version Information.
sahilmgandhi 18:6a4db94011d3 551 *
sahilmgandhi 18:6a4db94011d3 552 * @details This call allows the application to get the BLE stack version information.
sahilmgandhi 18:6a4db94011d3 553 *
sahilmgandhi 18:6a4db94011d3 554 * @param[out] p_version Pointer to a ble_version_t structure to be filled in.
sahilmgandhi 18:6a4db94011d3 555 *
sahilmgandhi 18:6a4db94011d3 556 * @retval ::NRF_SUCCESS Version information stored successfully.
sahilmgandhi 18:6a4db94011d3 557 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
sahilmgandhi 18:6a4db94011d3 558 * @retval ::NRF_ERROR_BUSY The BLE stack is busy (typically doing a locally-initiated disconnection procedure).
sahilmgandhi 18:6a4db94011d3 559 */
sahilmgandhi 18:6a4db94011d3 560 SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t *p_version));
sahilmgandhi 18:6a4db94011d3 561
sahilmgandhi 18:6a4db94011d3 562
sahilmgandhi 18:6a4db94011d3 563 /**@brief Provide a user memory block.
sahilmgandhi 18:6a4db94011d3 564 *
sahilmgandhi 18:6a4db94011d3 565 * @note This call can only be used as a response to a @ref BLE_EVT_USER_MEM_REQUEST event issued to the application.
sahilmgandhi 18:6a4db94011d3 566 *
sahilmgandhi 18:6a4db94011d3 567 * @param[in] conn_handle Connection handle.
sahilmgandhi 18:6a4db94011d3 568 * @param[in,out] p_block Pointer to a user memory block structure.
sahilmgandhi 18:6a4db94011d3 569 *
sahilmgandhi 18:6a4db94011d3 570 * @mscs
sahilmgandhi 18:6a4db94011d3 571 * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_PEER_CANCEL_MSC}
sahilmgandhi 18:6a4db94011d3 572 * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC}
sahilmgandhi 18:6a4db94011d3 573 * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC}
sahilmgandhi 18:6a4db94011d3 574 * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC}
sahilmgandhi 18:6a4db94011d3 575 * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_NOAUTH_MSC}
sahilmgandhi 18:6a4db94011d3 576 * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC}
sahilmgandhi 18:6a4db94011d3 577 * @endmscs
sahilmgandhi 18:6a4db94011d3 578 *
sahilmgandhi 18:6a4db94011d3 579 * @retval ::NRF_SUCCESS Successfully queued a response to the peer.
sahilmgandhi 18:6a4db94011d3 580 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
sahilmgandhi 18:6a4db94011d3 581 * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection state or no execute write request pending.
sahilmgandhi 18:6a4db94011d3 582 * @retval ::NRF_ERROR_BUSY The BLE stack is busy. Retry at later time.
sahilmgandhi 18:6a4db94011d3 583 */
sahilmgandhi 18:6a4db94011d3 584 SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block));
sahilmgandhi 18:6a4db94011d3 585
sahilmgandhi 18:6a4db94011d3 586 /**@brief Set a BLE option.
sahilmgandhi 18:6a4db94011d3 587 *
sahilmgandhi 18:6a4db94011d3 588 * @details This call allows the application to set the value of an option.
sahilmgandhi 18:6a4db94011d3 589 *
sahilmgandhi 18:6a4db94011d3 590 * @mscs
sahilmgandhi 18:6a4db94011d3 591 * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
sahilmgandhi 18:6a4db94011d3 592 * @mmsc{@ref BLE_COMMON_CONF_BW}
sahilmgandhi 18:6a4db94011d3 593 * @endmscs
sahilmgandhi 18:6a4db94011d3 594 *
sahilmgandhi 18:6a4db94011d3 595 * @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS.
sahilmgandhi 18:6a4db94011d3 596 * @param[in] p_opt Pointer to a ble_opt_t structure containing the option value.
sahilmgandhi 18:6a4db94011d3 597 *
sahilmgandhi 18:6a4db94011d3 598 * @retval ::NRF_SUCCESS Option set successfully.
sahilmgandhi 18:6a4db94011d3 599 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
sahilmgandhi 18:6a4db94011d3 600 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
sahilmgandhi 18:6a4db94011d3 601 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
sahilmgandhi 18:6a4db94011d3 602 * @retval ::NRF_ERROR_INVALID_STATE Unable to set the parameter at this time.
sahilmgandhi 18:6a4db94011d3 603 * @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed.
sahilmgandhi 18:6a4db94011d3 604 */
sahilmgandhi 18:6a4db94011d3 605 SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt));
sahilmgandhi 18:6a4db94011d3 606
sahilmgandhi 18:6a4db94011d3 607
sahilmgandhi 18:6a4db94011d3 608 /**@brief Get a BLE option.
sahilmgandhi 18:6a4db94011d3 609 *
sahilmgandhi 18:6a4db94011d3 610 * @details This call allows the application to retrieve the value of an option.
sahilmgandhi 18:6a4db94011d3 611 *
sahilmgandhi 18:6a4db94011d3 612 * @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS.
sahilmgandhi 18:6a4db94011d3 613 * @param[out] p_opt Pointer to a ble_opt_t structure to be filled in.
sahilmgandhi 18:6a4db94011d3 614 *
sahilmgandhi 18:6a4db94011d3 615 * @retval ::NRF_SUCCESS Option retrieved successfully.
sahilmgandhi 18:6a4db94011d3 616 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
sahilmgandhi 18:6a4db94011d3 617 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
sahilmgandhi 18:6a4db94011d3 618 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
sahilmgandhi 18:6a4db94011d3 619 * @retval ::NRF_ERROR_INVALID_STATE Unable to retrieve the parameter at this time.
sahilmgandhi 18:6a4db94011d3 620 * @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed.
sahilmgandhi 18:6a4db94011d3 621 * @retval ::NRF_ERROR_NOT_SUPPORTED This option is not supported.
sahilmgandhi 18:6a4db94011d3 622 *
sahilmgandhi 18:6a4db94011d3 623 */
sahilmgandhi 18:6a4db94011d3 624 SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt));
sahilmgandhi 18:6a4db94011d3 625
sahilmgandhi 18:6a4db94011d3 626 /** @} */
sahilmgandhi 18:6a4db94011d3 627 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 628 }
sahilmgandhi 18:6a4db94011d3 629 #endif
sahilmgandhi 18:6a4db94011d3 630 #endif /* NRF_BLE_H__ */
sahilmgandhi 18:6a4db94011d3 631
sahilmgandhi 18:6a4db94011d3 632 /**
sahilmgandhi 18:6a4db94011d3 633 @}
sahilmgandhi 18:6a4db94011d3 634 @}
sahilmgandhi 18:6a4db94011d3 635 */