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