Cefn Hoile / nRF51822

Dependencies:   nrf51-sdk

Dependents:   microbit-dal

Fork of nRF51822 by Lancaster University

Committer:
rgrover1
Date:
Wed Apr 15 08:59:11 2015 +0100
Revision:
103:138bdc859cc9
Child:
112:737b08b3b995
Synchronized with git rev fa183c40
Author: Rohit Grover
updating to v7.1 of the Nordic SDK.
Re-organized file layout to match that from the SDK.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 103:138bdc859cc9 1 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
rgrover1 103:138bdc859cc9 2 *
rgrover1 103:138bdc859cc9 3 * The information contained herein is confidential property of Nordic Semiconductor. The use,
rgrover1 103:138bdc859cc9 4 * copying, transfer or disclosure of such information is prohibited except by express written
rgrover1 103:138bdc859cc9 5 * agreement with Nordic Semiconductor.
rgrover1 103:138bdc859cc9 6 *
rgrover1 103:138bdc859cc9 7 */
rgrover1 103:138bdc859cc9 8 /**
rgrover1 103:138bdc859cc9 9 @addtogroup BLE_COMMON BLE SoftDevice Common
rgrover1 103:138bdc859cc9 10 @{
rgrover1 103:138bdc859cc9 11 @defgroup ble_api Events, type definitions and API calls
rgrover1 103:138bdc859cc9 12 @{
rgrover1 103:138bdc859cc9 13
rgrover1 103:138bdc859cc9 14 @brief Module independent events, type definitions and API calls for the S110 SoftDevice.
rgrover1 103:138bdc859cc9 15
rgrover1 103:138bdc859cc9 16 */
rgrover1 103:138bdc859cc9 17
rgrover1 103:138bdc859cc9 18 #ifndef BLE_H__
rgrover1 103:138bdc859cc9 19 #define BLE_H__
rgrover1 103:138bdc859cc9 20
rgrover1 103:138bdc859cc9 21 #include "ble_ranges.h"
rgrover1 103:138bdc859cc9 22 #include "ble_types.h"
rgrover1 103:138bdc859cc9 23 #include "ble_gap.h"
rgrover1 103:138bdc859cc9 24 #include "ble_l2cap.h"
rgrover1 103:138bdc859cc9 25 #include "ble_gatt.h"
rgrover1 103:138bdc859cc9 26 #include "ble_gattc.h"
rgrover1 103:138bdc859cc9 27 #include "ble_gatts.h"
rgrover1 103:138bdc859cc9 28
rgrover1 103:138bdc859cc9 29 /** @addtogroup BLE_COMMON_ENUMERATIONS Enumerations
rgrover1 103:138bdc859cc9 30 * @{ */
rgrover1 103:138bdc859cc9 31
rgrover1 103:138bdc859cc9 32 /**
rgrover1 103:138bdc859cc9 33 * @brief Common API SVC numbers.
rgrover1 103:138bdc859cc9 34 */
rgrover1 103:138bdc859cc9 35 enum BLE_COMMON_SVCS
rgrover1 103:138bdc859cc9 36 {
rgrover1 103:138bdc859cc9 37 SD_BLE_ENABLE = BLE_SVC_BASE, /**< Enable and initialize the BLE stack */
rgrover1 103:138bdc859cc9 38 SD_BLE_EVT_GET, /**< Get an event from the pending events queue. */
rgrover1 103:138bdc859cc9 39 SD_BLE_TX_BUFFER_COUNT_GET, /**< Get the total number of available application transmission buffers from the stack. */
rgrover1 103:138bdc859cc9 40 SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific UUID. */
rgrover1 103:138bdc859cc9 41 SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */
rgrover1 103:138bdc859cc9 42 SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */
rgrover1 103:138bdc859cc9 43 SD_BLE_VERSION_GET, /**< Get the local version information (company id, Link Layer Version, Link Layer Subversion). */
rgrover1 103:138bdc859cc9 44 SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */
rgrover1 103:138bdc859cc9 45 SD_BLE_OPT_SET, /**< Set a BLE option. */
rgrover1 103:138bdc859cc9 46 SD_BLE_OPT_GET, /**< Get a BLE option. */
rgrover1 103:138bdc859cc9 47 };
rgrover1 103:138bdc859cc9 48
rgrover1 103:138bdc859cc9 49 /**@brief Common Option IDs.
rgrover1 103:138bdc859cc9 50 * IDs that uniquely identify a common option.
rgrover1 103:138bdc859cc9 51 */
rgrover1 103:138bdc859cc9 52 enum BLE_COMMON_OPTS
rgrover1 103:138bdc859cc9 53 {
rgrover1 103:138bdc859cc9 54 BLE_COMMON_OPT_RADIO_CPU_MUTEX = BLE_OPT_BASE /**< Radio CPU mutex option. @ref ble_common_opt_radio_cpu_mutex_t */
rgrover1 103:138bdc859cc9 55 };
rgrover1 103:138bdc859cc9 56 /** @} */
rgrover1 103:138bdc859cc9 57
rgrover1 103:138bdc859cc9 58 /** @addtogroup BLE_COMMON_DEFINES Defines
rgrover1 103:138bdc859cc9 59 * @{ */
rgrover1 103:138bdc859cc9 60
rgrover1 103:138bdc859cc9 61 /** @brief Required pointer alignment for BLE Events.
rgrover1 103:138bdc859cc9 62 */
rgrover1 103:138bdc859cc9 63 #define BLE_EVTS_PTR_ALIGNMENT 4
rgrover1 103:138bdc859cc9 64
rgrover1 103:138bdc859cc9 65 /** @defgroup BLE_USER_MEM_TYPES User Memory Types
rgrover1 103:138bdc859cc9 66 * @{ */
rgrover1 103:138bdc859cc9 67 #define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */
rgrover1 103:138bdc859cc9 68 #define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */
rgrover1 103:138bdc859cc9 69 /** @} */
rgrover1 103:138bdc859cc9 70
rgrover1 103:138bdc859cc9 71 /** @brief Maximum number of Vendor Specific UUIDs.
rgrover1 103:138bdc859cc9 72 */
rgrover1 103:138bdc859cc9 73 #define BLE_UUID_VS_MAX_COUNT 10
rgrover1 103:138bdc859cc9 74
rgrover1 103:138bdc859cc9 75 /** @} */
rgrover1 103:138bdc859cc9 76
rgrover1 103:138bdc859cc9 77 /** @addtogroup BLE_COMMON_STRUCTURES Structures
rgrover1 103:138bdc859cc9 78 * @{ */
rgrover1 103:138bdc859cc9 79
rgrover1 103:138bdc859cc9 80 /**
rgrover1 103:138bdc859cc9 81 * @brief BLE Module Independent Event IDs.
rgrover1 103:138bdc859cc9 82 */
rgrover1 103:138bdc859cc9 83 enum BLE_COMMON_EVTS
rgrover1 103:138bdc859cc9 84 {
rgrover1 103:138bdc859cc9 85 BLE_EVT_TX_COMPLETE = BLE_EVT_BASE, /**< Transmission Complete. */
rgrover1 103:138bdc859cc9 86 BLE_EVT_USER_MEM_REQUEST, /**< User Memory request. */
rgrover1 103:138bdc859cc9 87 BLE_EVT_USER_MEM_RELEASE /**< User Memory release. */
rgrover1 103:138bdc859cc9 88 };
rgrover1 103:138bdc859cc9 89
rgrover1 103:138bdc859cc9 90 /**@brief User Memory Block. */
rgrover1 103:138bdc859cc9 91 typedef struct
rgrover1 103:138bdc859cc9 92 {
rgrover1 103:138bdc859cc9 93 uint8_t* p_mem; /**< Pointer to the start of the user memory block. */
rgrover1 103:138bdc859cc9 94 uint16_t len; /**< Length in bytes of the user memory block. */
rgrover1 103:138bdc859cc9 95 } ble_user_mem_block_t;
rgrover1 103:138bdc859cc9 96
rgrover1 103:138bdc859cc9 97 /**
rgrover1 103:138bdc859cc9 98 * @brief TX complete event.
rgrover1 103:138bdc859cc9 99 */
rgrover1 103:138bdc859cc9 100 typedef struct
rgrover1 103:138bdc859cc9 101 {
rgrover1 103:138bdc859cc9 102 uint8_t count; /**< Number of packets transmitted. */
rgrover1 103:138bdc859cc9 103 } ble_evt_tx_complete_t;
rgrover1 103:138bdc859cc9 104
rgrover1 103:138bdc859cc9 105 /**@brief Event structure for BLE_EVT_USER_MEM_REQUEST. */
rgrover1 103:138bdc859cc9 106 typedef struct
rgrover1 103:138bdc859cc9 107 {
rgrover1 103:138bdc859cc9 108 uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
rgrover1 103:138bdc859cc9 109 } ble_evt_user_mem_request_t;
rgrover1 103:138bdc859cc9 110
rgrover1 103:138bdc859cc9 111 /**@brief Event structure for BLE_EVT_USER_MEM_RELEASE. */
rgrover1 103:138bdc859cc9 112 typedef struct
rgrover1 103:138bdc859cc9 113 {
rgrover1 103:138bdc859cc9 114 uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
rgrover1 103:138bdc859cc9 115 ble_user_mem_block_t mem_block; /**< User memory block */
rgrover1 103:138bdc859cc9 116 } ble_evt_user_mem_release_t;
rgrover1 103:138bdc859cc9 117
rgrover1 103:138bdc859cc9 118
rgrover1 103:138bdc859cc9 119 /**@brief Event structure for events not associated with a specific function module. */
rgrover1 103:138bdc859cc9 120 typedef struct
rgrover1 103:138bdc859cc9 121 {
rgrover1 103:138bdc859cc9 122 uint16_t conn_handle; /**< Connection Handle on which this event occured. */
rgrover1 103:138bdc859cc9 123 union
rgrover1 103:138bdc859cc9 124 {
rgrover1 103:138bdc859cc9 125 ble_evt_tx_complete_t tx_complete; /**< Transmission Complete. */
rgrover1 103:138bdc859cc9 126 ble_evt_user_mem_request_t user_mem_request; /**< User Memory Request Event Parameters. */
rgrover1 103:138bdc859cc9 127 ble_evt_user_mem_release_t user_mem_release; /**< User Memory Release Event Parameters. */
rgrover1 103:138bdc859cc9 128 } params;
rgrover1 103:138bdc859cc9 129 } ble_common_evt_t;
rgrover1 103:138bdc859cc9 130
rgrover1 103:138bdc859cc9 131 /**@brief BLE Event header. */
rgrover1 103:138bdc859cc9 132 typedef struct
rgrover1 103:138bdc859cc9 133 {
rgrover1 103:138bdc859cc9 134 uint16_t evt_id; /**< Value from a BLE_<module>_EVT series. */
rgrover1 103:138bdc859cc9 135 uint16_t evt_len; /**< Length in octets excluding this header. */
rgrover1 103:138bdc859cc9 136 } ble_evt_hdr_t;
rgrover1 103:138bdc859cc9 137
rgrover1 103:138bdc859cc9 138 /**@brief Common BLE Event type, wrapping the module specific event reports. */
rgrover1 103:138bdc859cc9 139 typedef struct
rgrover1 103:138bdc859cc9 140 {
rgrover1 103:138bdc859cc9 141 ble_evt_hdr_t header; /**< Event header. */
rgrover1 103:138bdc859cc9 142 union
rgrover1 103:138bdc859cc9 143 {
rgrover1 103:138bdc859cc9 144 ble_common_evt_t common_evt; /**< Common Event, evt_id in BLE_EVT_* series. */
rgrover1 103:138bdc859cc9 145 ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */
rgrover1 103:138bdc859cc9 146 ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */
rgrover1 103:138bdc859cc9 147 ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */
rgrover1 103:138bdc859cc9 148 ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */
rgrover1 103:138bdc859cc9 149 } evt;
rgrover1 103:138bdc859cc9 150 } ble_evt_t;
rgrover1 103:138bdc859cc9 151
rgrover1 103:138bdc859cc9 152
rgrover1 103:138bdc859cc9 153 /**
rgrover1 103:138bdc859cc9 154 * @brief Version Information.
rgrover1 103:138bdc859cc9 155 */
rgrover1 103:138bdc859cc9 156 typedef struct
rgrover1 103:138bdc859cc9 157 {
rgrover1 103:138bdc859cc9 158 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). */
rgrover1 103:138bdc859cc9 159 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). */
rgrover1 103:138bdc859cc9 160 uint16_t subversion_number; /**< Link Layer Sub Version number, corresponds to the SoftDevice Config ID or Firmware ID (FWID). */
rgrover1 103:138bdc859cc9 161 } ble_version_t;
rgrover1 103:138bdc859cc9 162
rgrover1 103:138bdc859cc9 163 /**@brief Mutual exclusion of radio activity and CPU execution.
rgrover1 103:138bdc859cc9 164 *
rgrover1 103:138bdc859cc9 165 * This option configures the application's access to the CPU when the radio is active. The
rgrover1 103:138bdc859cc9 166 * application can configure itself to have access to the CPU while the radio is active.
rgrover1 103:138bdc859cc9 167 * By default, the application will be not able to share CPU time with the SoftDevice
rgrover1 103:138bdc859cc9 168 * during radio activity. This parameter structure is used together with @ref sd_ble_opt_set
rgrover1 103:138bdc859cc9 169 * to configure the @ref BLE_COMMON_OPT_RADIO_CPU_MUTEX option.
rgrover1 103:138bdc859cc9 170 *
rgrover1 103:138bdc859cc9 171 * @note Note that the mutual exclusion of radio activity and CPU execution should remain enabled
rgrover1 103:138bdc859cc9 172 * when running the SoftDevice on hardware affected by PAN #44 "CCM may exceed real time
rgrover1 103:138bdc859cc9 173 * requirements"and PAN #45 "AAR may exceed real time requirements".
rgrover1 103:138bdc859cc9 174 *
rgrover1 103:138bdc859cc9 175 * @note @ref sd_ble_opt_get is not supported for this option.
rgrover1 103:138bdc859cc9 176 *
rgrover1 103:138bdc859cc9 177 */
rgrover1 103:138bdc859cc9 178 typedef struct
rgrover1 103:138bdc859cc9 179 {
rgrover1 103:138bdc859cc9 180 uint8_t enable : 1; /**< Enable mutual exclusion of radio activity and the CPU execution. */
rgrover1 103:138bdc859cc9 181 } ble_common_opt_radio_cpu_mutex_t;
rgrover1 103:138bdc859cc9 182
rgrover1 103:138bdc859cc9 183 /**@brief Option structure for common options. */
rgrover1 103:138bdc859cc9 184 typedef union
rgrover1 103:138bdc859cc9 185 {
rgrover1 103:138bdc859cc9 186 ble_common_opt_radio_cpu_mutex_t radio_cpu_mutex; /**< Parameters for the option for the mutual exclusion of radio activity and CPU execution. */
rgrover1 103:138bdc859cc9 187 } ble_common_opt_t;
rgrover1 103:138bdc859cc9 188
rgrover1 103:138bdc859cc9 189 /**@brief Common BLE Option type, wrapping the module specific options. */
rgrover1 103:138bdc859cc9 190 typedef union
rgrover1 103:138bdc859cc9 191 {
rgrover1 103:138bdc859cc9 192 ble_common_opt_t common_opt; /**< Common option, opt_id in BLE_COMMON_OPT_* series. */
rgrover1 103:138bdc859cc9 193 ble_gap_opt_t gap_opt; /**< GAP option, opt_id in BLE_GAP_OPT_* series. */
rgrover1 103:138bdc859cc9 194 } ble_opt_t;
rgrover1 103:138bdc859cc9 195
rgrover1 103:138bdc859cc9 196 /**
rgrover1 103:138bdc859cc9 197 * @brief BLE GATTS init options
rgrover1 103:138bdc859cc9 198 */
rgrover1 103:138bdc859cc9 199 typedef struct
rgrover1 103:138bdc859cc9 200 {
rgrover1 103:138bdc859cc9 201 ble_gatts_enable_params_t gatts_enable_params; /**< GATTS init options @ref ble_gatts_enable_params_t. */
rgrover1 103:138bdc859cc9 202 } ble_enable_params_t;
rgrover1 103:138bdc859cc9 203
rgrover1 103:138bdc859cc9 204 /** @} */
rgrover1 103:138bdc859cc9 205
rgrover1 103:138bdc859cc9 206 /** @addtogroup BLE_COMMON_FUNCTIONS Functions
rgrover1 103:138bdc859cc9 207 * @{ */
rgrover1 103:138bdc859cc9 208
rgrover1 103:138bdc859cc9 209 /**@brief Enable the bluetooth stack
rgrover1 103:138bdc859cc9 210 *
rgrover1 103:138bdc859cc9 211 * @param[in] p_ble_enable_params Pointer to ble_enable_params_t
rgrover1 103:138bdc859cc9 212 *
rgrover1 103:138bdc859cc9 213 * @details This call initializes the bluetooth stack, no other BLE related call can be called before this one has been executed.
rgrover1 103:138bdc859cc9 214 *
rgrover1 103:138bdc859cc9 215 * @return @ref NRF_SUCCESS BLE stack has been initialized successfully
rgrover1 103:138bdc859cc9 216 * @return @ref NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
rgrover1 103:138bdc859cc9 217 */
rgrover1 103:138bdc859cc9 218 SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(ble_enable_params_t * p_ble_enable_params));
rgrover1 103:138bdc859cc9 219
rgrover1 103:138bdc859cc9 220 /**@brief Get an event from the pending events queue.
rgrover1 103:138bdc859cc9 221 *
rgrover1 103:138bdc859cc9 222 * @param[in] p_dest Pointer to buffer to be filled in with an event, or NULL to retrieve the event length. This buffer <b>must be 4-byte aligned in memory</b>.
rgrover1 103:138bdc859cc9 223 * @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length.
rgrover1 103:138bdc859cc9 224 *
rgrover1 103:138bdc859cc9 225 * @details This call allows the application to pull a BLE event from the BLE stack. The application is signalled that an event is
rgrover1 103:138bdc859cc9 226 * available from the BLE Stack by the triggering of the SD_EVT_IRQn interrupt (mapped to IRQ 22).
rgrover1 103:138bdc859cc9 227 * The application is free to choose whether to call this function from thread mode (main context) or directly from the Interrupt Service Routine
rgrover1 103:138bdc859cc9 228 * that maps to SD_EVT_IRQn. In any case however, and because the BLE stack runs at a higher priority than the application, this function should be called
rgrover1 103:138bdc859cc9 229 * in a loop (until @ref NRF_ERROR_NOT_FOUND is returned) every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the stack.
rgrover1 103:138bdc859cc9 230 * Failure to do so could potentially leave events in the internal queue without the application being aware of this fact.
rgrover1 103:138bdc859cc9 231 * Sizing the p_dest buffer is equally important, since the application needs to provide all the memory necessary for the event to be copied into
rgrover1 103:138bdc859cc9 232 * application memory. If the buffer provided is not large enough to fit the entire contents of the event, @ref NRF_ERROR_DATA_SIZE will be returned
rgrover1 103:138bdc859cc9 233 * and the application can then call again with a larger buffer size.
rgrover1 103:138bdc859cc9 234 * Please note that because of the variable length nature of some events, sizeof(ble_evt_t) will not always be large enough to fit certain events,
rgrover1 103:138bdc859cc9 235 * and so it is the application's responsability to provide an amount of memory large enough so that the relevant event is copied in full.
rgrover1 103:138bdc859cc9 236 * The application may "peek" the event length by providing p_dest as a NULL pointer and inspecting the value of *p_len upon return.
rgrover1 103:138bdc859cc9 237 *
rgrover1 103:138bdc859cc9 238 * @note The pointer supplied must be aligned to the extend defined by @ref BLE_EVTS_PTR_ALIGNMENT
rgrover1 103:138bdc859cc9 239 *
rgrover1 103:138bdc859cc9 240 * @return @ref NRF_SUCCESS Event pulled and stored into the supplied buffer.
rgrover1 103:138bdc859cc9 241 * @return @ref NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
rgrover1 103:138bdc859cc9 242 * @return @ref NRF_ERROR_NOT_FOUND No events ready to be pulled.
rgrover1 103:138bdc859cc9 243 * @return @ref NRF_ERROR_DATA_SIZE Event ready but could not fit into the supplied buffer.
rgrover1 103:138bdc859cc9 244 */
rgrover1 103:138bdc859cc9 245 SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t* p_dest, uint16_t *p_len));
rgrover1 103:138bdc859cc9 246
rgrover1 103:138bdc859cc9 247
rgrover1 103:138bdc859cc9 248 /**@brief Get the total number of available application transmission buffers in the BLE stack.
rgrover1 103:138bdc859cc9 249 *
rgrover1 103:138bdc859cc9 250 * @details This call allows the application to obtain the total number of
rgrover1 103:138bdc859cc9 251 * transmission buffers available for application data. Please note that
rgrover1 103:138bdc859cc9 252 * this does not give the number of free buffers, but rather the total amount of them.
rgrover1 103:138bdc859cc9 253 * The application has two options to handle its own application transmission buffers:
rgrover1 103:138bdc859cc9 254 * - Use a simple arithmetic calculation: at boot time the application should use this function
rgrover1 103:138bdc859cc9 255 * to find out the total amount of buffers available to it and store it in a variable.
rgrover1 103:138bdc859cc9 256 * Every time a packet that consumes an application buffer is sent using any of the
rgrover1 103:138bdc859cc9 257 * exposed functions in this BLE API, the application should decrement that variable.
rgrover1 103:138bdc859cc9 258 * Conversely, whenever a @ref BLE_EVT_TX_COMPLETE event is received by the application
rgrover1 103:138bdc859cc9 259 * it should retrieve the count field in such event and add that number to the same
rgrover1 103:138bdc859cc9 260 * variable storing the number of available packets.
rgrover1 103:138bdc859cc9 261 * This mechanism allows the application to be aware at any time of the number of
rgrover1 103:138bdc859cc9 262 * application packets available in the BLE stack's internal buffers, and therefore
rgrover1 103:138bdc859cc9 263 * it can know with certainty whether it is possible to send more data or it has to
rgrover1 103:138bdc859cc9 264 * wait for a @ref BLE_EVT_TX_COMPLETE event before it proceeds.
rgrover1 103:138bdc859cc9 265 * - Choose to simply not keep track of available buffers at all, and instead handle the
rgrover1 103:138bdc859cc9 266 * @ref BLE_ERROR_NO_TX_BUFFERS error by queueing the packet to be transmitted and
rgrover1 103:138bdc859cc9 267 * try again as soon as a @ref BLE_EVT_TX_COMPLETE event arrives.
rgrover1 103:138bdc859cc9 268 *
rgrover1 103:138bdc859cc9 269 * The API functions that <b>may</b> consume an application buffer depending on
rgrover1 103:138bdc859cc9 270 * the parameters supplied to them can be found below:
rgrover1 103:138bdc859cc9 271 *
rgrover1 103:138bdc859cc9 272 * - @ref sd_ble_gattc_write (write witout response only)
rgrover1 103:138bdc859cc9 273 * - @ref sd_ble_gatts_hvx (notifications only)
rgrover1 103:138bdc859cc9 274 * - @ref sd_ble_l2cap_tx (all packets)
rgrover1 103:138bdc859cc9 275 *
rgrover1 103:138bdc859cc9 276 * @param[out] p_count Pointer to a uint8_t which will contain the number of application transmission buffers upon
rgrover1 103:138bdc859cc9 277 * successful return.
rgrover1 103:138bdc859cc9 278 *
rgrover1 103:138bdc859cc9 279 * @return @ref NRF_SUCCESS Number of application transmission buffers retrieved successfully.
rgrover1 103:138bdc859cc9 280 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
rgrover1 103:138bdc859cc9 281 */
rgrover1 103:138bdc859cc9 282 SVCALL(SD_BLE_TX_BUFFER_COUNT_GET, uint32_t, sd_ble_tx_buffer_count_get(uint8_t* p_count));
rgrover1 103:138bdc859cc9 283
rgrover1 103:138bdc859cc9 284
rgrover1 103:138bdc859cc9 285 /**@brief Add a Vendor Specific UUID.
rgrover1 103:138bdc859cc9 286 *
rgrover1 103:138bdc859cc9 287 * @details This call enables the application to add a vendor specific UUID to the BLE stack's table,
rgrover1 103:138bdc859cc9 288 * for later use all other modules and APIs. This then allows the application to use the shorter,
rgrover1 103:138bdc859cc9 289 * 24-bit @ref ble_uuid_t format when dealing with both 16-bit and 128-bit UUIDs without having to
rgrover1 103:138bdc859cc9 290 * check for lengths and having split code paths. The way that this is accomplished is by extending the
rgrover1 103:138bdc859cc9 291 * grouping mechanism that the Bluetooth SIG standard base UUID uses for all other 128-bit UUIDs. The
rgrover1 103:138bdc859cc9 292 * type field in the @ref ble_uuid_t structure is an index (relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN)
rgrover1 103:138bdc859cc9 293 * to the table populated by multiple calls to this function, and the uuid field in the same structure
rgrover1 103:138bdc859cc9 294 * contains the 2 bytes at indices 12 and 13. The number of possible 128-bit UUIDs available to the
rgrover1 103:138bdc859cc9 295 * application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536,
rgrover1 103:138bdc859cc9 296 * although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array.
rgrover1 103:138bdc859cc9 297 *
rgrover1 103:138bdc859cc9 298 * @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by
rgrover1 103:138bdc859cc9 299 * the 16-bit uuid field in @ref ble_uuid_t.
rgrover1 103:138bdc859cc9 300 *
rgrover1 103:138bdc859cc9 301 *
rgrover1 103:138bdc859cc9 302 * @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding
rgrover1 103:138bdc859cc9 303 * bytes 12 and 13.
rgrover1 103:138bdc859cc9 304 * @param[out] p_uuid_type Pointer where the type field in @ref ble_uuid_t corresponding to this UUID will be stored.
rgrover1 103:138bdc859cc9 305 *
rgrover1 103:138bdc859cc9 306 * @return @ref NRF_SUCCESS Successfully added the Vendor Specific UUID.
rgrover1 103:138bdc859cc9 307 * @return @ref NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid.
rgrover1 103:138bdc859cc9 308 * @return @ref NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs.
rgrover1 103:138bdc859cc9 309 * @return @ref NRF_ERROR_FORBIDDEN If p_vs_uuid has already been added to the VS UUID table.
rgrover1 103:138bdc859cc9 310 */
rgrover1 103:138bdc859cc9 311 SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const * const p_vs_uuid, uint8_t * const p_uuid_type));
rgrover1 103:138bdc859cc9 312
rgrover1 103:138bdc859cc9 313
rgrover1 103:138bdc859cc9 314 /** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure.
rgrover1 103:138bdc859cc9 315 *
rgrover1 103:138bdc859cc9 316 * @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared
rgrover1 103:138bdc859cc9 317 * to the corresponding ones in each entry of the table of vendor specific UUIDs pouplated with @ref sd_ble_uuid_vs_add
rgrover1 103:138bdc859cc9 318 * to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index
rgrover1 103:138bdc859cc9 319 * relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type.
rgrover1 103:138bdc859cc9 320 *
rgrover1 103:138bdc859cc9 321 * @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE.
rgrover1 103:138bdc859cc9 322 *
rgrover1 103:138bdc859cc9 323 * @param[in] uuid_le_len Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes).
rgrover1 103:138bdc859cc9 324 * @param[in] p_uuid_le Pointer pointing to little endian raw UUID bytes.
rgrover1 103:138bdc859cc9 325 * @param[in,out] p_uuid Pointer to a @ref ble_uuid_t structure to be filled in.
rgrover1 103:138bdc859cc9 326 *
rgrover1 103:138bdc859cc9 327 * @return @ref NRF_SUCCESS Successfully decoded into the @ref ble_uuid_t structure.
rgrover1 103:138bdc859cc9 328 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
rgrover1 103:138bdc859cc9 329 * @return @ref NRF_ERROR_INVALID_LENGTH Invalid UUID length.
rgrover1 103:138bdc859cc9 330 * @return @ref NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs.
rgrover1 103:138bdc859cc9 331 */
rgrover1 103:138bdc859cc9 332 SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const * const p_uuid_le, ble_uuid_t * const p_uuid));
rgrover1 103:138bdc859cc9 333
rgrover1 103:138bdc859cc9 334
rgrover1 103:138bdc859cc9 335 /** @brief Encode a @ref ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit).
rgrover1 103:138bdc859cc9 336 *
rgrover1 103:138bdc859cc9 337 * @note The pointer to the destination buffer p_uuid_le may be NULL, in which case only the validitiy and size of p_uuid is computed.
rgrover1 103:138bdc859cc9 338 *
rgrover1 103:138bdc859cc9 339 * @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes.
rgrover1 103:138bdc859cc9 340 * @param[out] p_uuid_le_len Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes).
rgrover1 103:138bdc859cc9 341 * @param[out] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored.
rgrover1 103:138bdc859cc9 342 *
rgrover1 103:138bdc859cc9 343 * @return @ref NRF_SUCCESS Successfully encoded into the buffer.
rgrover1 103:138bdc859cc9 344 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
rgrover1 103:138bdc859cc9 345 * @return @ref NRF_ERROR_INVALID_PARAM Invalid UUID type.
rgrover1 103:138bdc859cc9 346 */
rgrover1 103:138bdc859cc9 347 SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const * const p_uuid, uint8_t * const p_uuid_le_len, uint8_t * const p_uuid_le));
rgrover1 103:138bdc859cc9 348
rgrover1 103:138bdc859cc9 349
rgrover1 103:138bdc859cc9 350 /**@brief Get Version Information.
rgrover1 103:138bdc859cc9 351 *
rgrover1 103:138bdc859cc9 352 * @details This call allows the application to get the BLE stack version information.
rgrover1 103:138bdc859cc9 353 *
rgrover1 103:138bdc859cc9 354 * @param[in] p_version Pointer to ble_version_t structure to be filled in.
rgrover1 103:138bdc859cc9 355 *
rgrover1 103:138bdc859cc9 356 * @return @ref NRF_SUCCESS Version information stored successfully.
rgrover1 103:138bdc859cc9 357 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
rgrover1 103:138bdc859cc9 358 * @return @ref NRF_ERROR_BUSY The stack is busy (typically doing a locally-initiated disconnection procedure).
rgrover1 103:138bdc859cc9 359 */
rgrover1 103:138bdc859cc9 360 SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t * p_version));
rgrover1 103:138bdc859cc9 361
rgrover1 103:138bdc859cc9 362
rgrover1 103:138bdc859cc9 363 /**@brief Provide a user memory block.
rgrover1 103:138bdc859cc9 364 *
rgrover1 103:138bdc859cc9 365 * @note This call can only be used as a response to a @ref BLE_EVT_USER_MEM_REQUEST event issued to the application.
rgrover1 103:138bdc859cc9 366 *
rgrover1 103:138bdc859cc9 367 * @param[in] conn_handle Connection handle.
rgrover1 103:138bdc859cc9 368 * @param[in] p_block Pointer to a user memory block structure.
rgrover1 103:138bdc859cc9 369 *
rgrover1 103:138bdc859cc9 370 * @return @ref NRF_SUCCESS Successfully queued a response to the peer.
rgrover1 103:138bdc859cc9 371 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
rgrover1 103:138bdc859cc9 372 * @return @ref NRF_ERROR_INVALID_STATE No execute write request pending.
rgrover1 103:138bdc859cc9 373 */
rgrover1 103:138bdc859cc9 374 SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t *p_block));
rgrover1 103:138bdc859cc9 375
rgrover1 103:138bdc859cc9 376
rgrover1 103:138bdc859cc9 377 /**@brief Set a BLE option.
rgrover1 103:138bdc859cc9 378 *
rgrover1 103:138bdc859cc9 379 * @details This call allows the application to set the value of an option.
rgrover1 103:138bdc859cc9 380 *
rgrover1 103:138bdc859cc9 381 * @param[in] opt_id Option ID.
rgrover1 103:138bdc859cc9 382 * @param[in] p_opt Pointer to a ble_opt_t structure containing the option value.
rgrover1 103:138bdc859cc9 383 *
rgrover1 103:138bdc859cc9 384 * @retval ::NRF_SUCCESS Option set successfully.
rgrover1 103:138bdc859cc9 385 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
rgrover1 103:138bdc859cc9 386 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
rgrover1 103:138bdc859cc9 387 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
rgrover1 103:138bdc859cc9 388 * @retval ::NRF_ERROR_INVALID_STATE Unable to set the parameter at this time.
rgrover1 103:138bdc859cc9 389 * @retval ::NRF_ERROR_BUSY The stack is busy or the previous procedure has not completed.
rgrover1 103:138bdc859cc9 390 */
rgrover1 103:138bdc859cc9 391 SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt));
rgrover1 103:138bdc859cc9 392
rgrover1 103:138bdc859cc9 393
rgrover1 103:138bdc859cc9 394 /**@brief Get a BLE option.
rgrover1 103:138bdc859cc9 395 *
rgrover1 103:138bdc859cc9 396 * @details This call allows the application to retrieve the value of an option.
rgrover1 103:138bdc859cc9 397 *
rgrover1 103:138bdc859cc9 398 * @param[in] opt_id Option ID.
rgrover1 103:138bdc859cc9 399 * @param[out] p_opt Pointer to a ble_opt_t structure to be filled in.
rgrover1 103:138bdc859cc9 400 *
rgrover1 103:138bdc859cc9 401 * @retval ::NRF_SUCCESS Option retrieved successfully.
rgrover1 103:138bdc859cc9 402 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
rgrover1 103:138bdc859cc9 403 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
rgrover1 103:138bdc859cc9 404 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
rgrover1 103:138bdc859cc9 405 * @retval ::NRF_ERROR_INVALID_STATE Unable to retrieve the parameter at this time.
rgrover1 103:138bdc859cc9 406 * @retval ::NRF_ERROR_BUSY The stack is busy or the previous procedure has not completed.
rgrover1 103:138bdc859cc9 407 * @retval ::NRF_ERROR_NOT_SUPPORTED This option is not supported.
rgrover1 103:138bdc859cc9 408 *
rgrover1 103:138bdc859cc9 409 */
rgrover1 103:138bdc859cc9 410 SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt));
rgrover1 103:138bdc859cc9 411
rgrover1 103:138bdc859cc9 412 /** @} */
rgrover1 103:138bdc859cc9 413
rgrover1 103:138bdc859cc9 414 #endif /* BLE_H__ */
rgrover1 103:138bdc859cc9 415
rgrover1 103:138bdc859cc9 416 /**
rgrover1 103:138bdc859cc9 417 @}
rgrover1 103:138bdc859cc9 418 @}
rgrover1 103:138bdc859cc9 419 */