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