BLE Temperature Service Mobile and Ubiquitous Computing Module Birkbeck College
mbed/TARGET_NRF51822/ble.h@0:dd0fea342ad2, 2015-03-08 (annotated)
- Committer:
- gkroussos
- Date:
- Sun Mar 08 19:42:20 2015 +0000
- Revision:
- 0:dd0fea342ad2
BLE Temperature Service ; Mobile and Ubiquitous Computing Module; Birkbeck College
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gkroussos | 0:dd0fea342ad2 | 1 | /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. |
gkroussos | 0:dd0fea342ad2 | 2 | * |
gkroussos | 0:dd0fea342ad2 | 3 | * The information contained herein is confidential property of Nordic Semiconductor. The use, |
gkroussos | 0:dd0fea342ad2 | 4 | * copying, transfer or disclosure of such information is prohibited except by express written |
gkroussos | 0:dd0fea342ad2 | 5 | * agreement with Nordic Semiconductor. |
gkroussos | 0:dd0fea342ad2 | 6 | * |
gkroussos | 0:dd0fea342ad2 | 7 | */ |
gkroussos | 0:dd0fea342ad2 | 8 | /** |
gkroussos | 0:dd0fea342ad2 | 9 | @addtogroup BLE_COMMON BLE SoftDevice Common |
gkroussos | 0:dd0fea342ad2 | 10 | @{ |
gkroussos | 0:dd0fea342ad2 | 11 | @defgroup ble_api Events, type definitions and API calls |
gkroussos | 0:dd0fea342ad2 | 12 | @{ |
gkroussos | 0:dd0fea342ad2 | 13 | |
gkroussos | 0:dd0fea342ad2 | 14 | @brief Module independent events, type definitions and API calls for the S110 SoftDevice. |
gkroussos | 0:dd0fea342ad2 | 15 | |
gkroussos | 0:dd0fea342ad2 | 16 | */ |
gkroussos | 0:dd0fea342ad2 | 17 | |
gkroussos | 0:dd0fea342ad2 | 18 | #ifndef BLE_H__ |
gkroussos | 0:dd0fea342ad2 | 19 | #define BLE_H__ |
gkroussos | 0:dd0fea342ad2 | 20 | |
gkroussos | 0:dd0fea342ad2 | 21 | #include "ble_ranges.h" |
gkroussos | 0:dd0fea342ad2 | 22 | #include "ble_types.h" |
gkroussos | 0:dd0fea342ad2 | 23 | #include "ble_gap.h" |
gkroussos | 0:dd0fea342ad2 | 24 | #include "ble_l2cap.h" |
gkroussos | 0:dd0fea342ad2 | 25 | #include "ble_gatt.h" |
gkroussos | 0:dd0fea342ad2 | 26 | #include "ble_gattc.h" |
gkroussos | 0:dd0fea342ad2 | 27 | #include "ble_gatts.h" |
gkroussos | 0:dd0fea342ad2 | 28 | |
gkroussos | 0:dd0fea342ad2 | 29 | /** |
gkroussos | 0:dd0fea342ad2 | 30 | * @brief Common API SVC numbers. |
gkroussos | 0:dd0fea342ad2 | 31 | */ |
gkroussos | 0:dd0fea342ad2 | 32 | enum BLE_COMMON_SVCS |
gkroussos | 0:dd0fea342ad2 | 33 | { |
gkroussos | 0:dd0fea342ad2 | 34 | SD_BLE_EVT_GET = BLE_SVC_BASE, /**< Get an event from the pending events queue. */ |
gkroussos | 0:dd0fea342ad2 | 35 | SD_BLE_TX_BUFFER_COUNT_GET, /**< Get the total number of available application transmission buffers from the stack. */ |
gkroussos | 0:dd0fea342ad2 | 36 | SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific UUID. */ |
gkroussos | 0:dd0fea342ad2 | 37 | SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */ |
gkroussos | 0:dd0fea342ad2 | 38 | SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */ |
gkroussos | 0:dd0fea342ad2 | 39 | SD_BLE_VERSION_GET, /**< Get the local version information (company id, LMP Version, LMP Subversion). */ |
gkroussos | 0:dd0fea342ad2 | 40 | SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */ |
gkroussos | 0:dd0fea342ad2 | 41 | }; |
gkroussos | 0:dd0fea342ad2 | 42 | |
gkroussos | 0:dd0fea342ad2 | 43 | /** @brief Required pointer alignment for BLE Events. |
gkroussos | 0:dd0fea342ad2 | 44 | */ |
gkroussos | 0:dd0fea342ad2 | 45 | #define BLE_EVTS_PTR_ALIGNMENT 4 |
gkroussos | 0:dd0fea342ad2 | 46 | |
gkroussos | 0:dd0fea342ad2 | 47 | /** @defgroup BLE_USER_MEM_TYPES User Memory Types |
gkroussos | 0:dd0fea342ad2 | 48 | * @{ */ |
gkroussos | 0:dd0fea342ad2 | 49 | #define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */ |
gkroussos | 0:dd0fea342ad2 | 50 | #define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */ |
gkroussos | 0:dd0fea342ad2 | 51 | /** @} */ |
gkroussos | 0:dd0fea342ad2 | 52 | |
gkroussos | 0:dd0fea342ad2 | 53 | /** @brief Maximum number of Vendor Specific UUIDs. |
gkroussos | 0:dd0fea342ad2 | 54 | */ |
gkroussos | 0:dd0fea342ad2 | 55 | #define BLE_UUID_VS_MAX_COUNT 10 |
gkroussos | 0:dd0fea342ad2 | 56 | |
gkroussos | 0:dd0fea342ad2 | 57 | /** |
gkroussos | 0:dd0fea342ad2 | 58 | * @brief BLE Module Independent Event IDs. |
gkroussos | 0:dd0fea342ad2 | 59 | */ |
gkroussos | 0:dd0fea342ad2 | 60 | enum BLE_COMMON_EVTS |
gkroussos | 0:dd0fea342ad2 | 61 | { |
gkroussos | 0:dd0fea342ad2 | 62 | BLE_EVT_TX_COMPLETE = BLE_EVT_BASE, /**< Transmission Complete. */ |
gkroussos | 0:dd0fea342ad2 | 63 | BLE_EVT_USER_MEM_REQUEST, /**< User Memory request. */ |
gkroussos | 0:dd0fea342ad2 | 64 | BLE_EVT_USER_MEM_RELEASE /**< User Memory release. */ |
gkroussos | 0:dd0fea342ad2 | 65 | }; |
gkroussos | 0:dd0fea342ad2 | 66 | |
gkroussos | 0:dd0fea342ad2 | 67 | /**@brief User Memory Block. */ |
gkroussos | 0:dd0fea342ad2 | 68 | typedef struct |
gkroussos | 0:dd0fea342ad2 | 69 | { |
gkroussos | 0:dd0fea342ad2 | 70 | uint8_t* p_mem; /**< Pointer to the start of the user memory block. */ |
gkroussos | 0:dd0fea342ad2 | 71 | uint16_t len; /**< Length in bytes of the user memory block. */ |
gkroussos | 0:dd0fea342ad2 | 72 | } ble_user_mem_block_t; |
gkroussos | 0:dd0fea342ad2 | 73 | |
gkroussos | 0:dd0fea342ad2 | 74 | /** |
gkroussos | 0:dd0fea342ad2 | 75 | * @brief TX complete event. |
gkroussos | 0:dd0fea342ad2 | 76 | */ |
gkroussos | 0:dd0fea342ad2 | 77 | typedef struct |
gkroussos | 0:dd0fea342ad2 | 78 | { |
gkroussos | 0:dd0fea342ad2 | 79 | uint8_t count; /**< Number of packets transmitted. */ |
gkroussos | 0:dd0fea342ad2 | 80 | } ble_evt_tx_complete_t; |
gkroussos | 0:dd0fea342ad2 | 81 | |
gkroussos | 0:dd0fea342ad2 | 82 | /**@brief Event structure for BLE_EVT_USER_MEM_REQUEST. */ |
gkroussos | 0:dd0fea342ad2 | 83 | typedef struct |
gkroussos | 0:dd0fea342ad2 | 84 | { |
gkroussos | 0:dd0fea342ad2 | 85 | uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */ |
gkroussos | 0:dd0fea342ad2 | 86 | } ble_evt_user_mem_request_t; |
gkroussos | 0:dd0fea342ad2 | 87 | |
gkroussos | 0:dd0fea342ad2 | 88 | /**@brief Event structure for BLE_EVT_USER_MEM_RELEASE. */ |
gkroussos | 0:dd0fea342ad2 | 89 | typedef struct |
gkroussos | 0:dd0fea342ad2 | 90 | { |
gkroussos | 0:dd0fea342ad2 | 91 | uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */ |
gkroussos | 0:dd0fea342ad2 | 92 | ble_user_mem_block_t mem_block; /**< User memory block */ |
gkroussos | 0:dd0fea342ad2 | 93 | } ble_evt_user_mem_release_t; |
gkroussos | 0:dd0fea342ad2 | 94 | |
gkroussos | 0:dd0fea342ad2 | 95 | |
gkroussos | 0:dd0fea342ad2 | 96 | /**@brief Event structure for events not associated with a specific function module. */ |
gkroussos | 0:dd0fea342ad2 | 97 | typedef struct |
gkroussos | 0:dd0fea342ad2 | 98 | { |
gkroussos | 0:dd0fea342ad2 | 99 | uint16_t conn_handle; /**< Connection Handle on which this event occured. */ |
gkroussos | 0:dd0fea342ad2 | 100 | union |
gkroussos | 0:dd0fea342ad2 | 101 | { |
gkroussos | 0:dd0fea342ad2 | 102 | ble_evt_tx_complete_t tx_complete; /**< Transmission Complete. */ |
gkroussos | 0:dd0fea342ad2 | 103 | ble_evt_user_mem_request_t user_mem_request; /**< User Memory Request Event Parameters. */ |
gkroussos | 0:dd0fea342ad2 | 104 | ble_evt_user_mem_release_t user_mem_release; /**< User Memory Release Event Parameters. */ |
gkroussos | 0:dd0fea342ad2 | 105 | } params; |
gkroussos | 0:dd0fea342ad2 | 106 | } ble_common_evt_t; |
gkroussos | 0:dd0fea342ad2 | 107 | |
gkroussos | 0:dd0fea342ad2 | 108 | /**@brief BLE Event header. */ |
gkroussos | 0:dd0fea342ad2 | 109 | typedef struct |
gkroussos | 0:dd0fea342ad2 | 110 | { |
gkroussos | 0:dd0fea342ad2 | 111 | uint16_t evt_id; /**< Value from a BLE_<module>_EVT series. */ |
gkroussos | 0:dd0fea342ad2 | 112 | uint16_t evt_len; /**< Length in octets excluding this header. */ |
gkroussos | 0:dd0fea342ad2 | 113 | } ble_evt_hdr_t; |
gkroussos | 0:dd0fea342ad2 | 114 | |
gkroussos | 0:dd0fea342ad2 | 115 | /**@brief Common BLE Event type, wrapping the module specific event reports. */ |
gkroussos | 0:dd0fea342ad2 | 116 | typedef struct |
gkroussos | 0:dd0fea342ad2 | 117 | { |
gkroussos | 0:dd0fea342ad2 | 118 | ble_evt_hdr_t header; /**< Event header. */ |
gkroussos | 0:dd0fea342ad2 | 119 | union |
gkroussos | 0:dd0fea342ad2 | 120 | { |
gkroussos | 0:dd0fea342ad2 | 121 | ble_common_evt_t common_evt; /**< Common Event, evt_id in BLE_EVT_* series. */ |
gkroussos | 0:dd0fea342ad2 | 122 | ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */ |
gkroussos | 0:dd0fea342ad2 | 123 | ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */ |
gkroussos | 0:dd0fea342ad2 | 124 | ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */ |
gkroussos | 0:dd0fea342ad2 | 125 | ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */ |
gkroussos | 0:dd0fea342ad2 | 126 | } evt; |
gkroussos | 0:dd0fea342ad2 | 127 | } ble_evt_t; |
gkroussos | 0:dd0fea342ad2 | 128 | |
gkroussos | 0:dd0fea342ad2 | 129 | |
gkroussos | 0:dd0fea342ad2 | 130 | /** |
gkroussos | 0:dd0fea342ad2 | 131 | * @brief Version Information. |
gkroussos | 0:dd0fea342ad2 | 132 | */ |
gkroussos | 0:dd0fea342ad2 | 133 | typedef struct |
gkroussos | 0:dd0fea342ad2 | 134 | { |
gkroussos | 0:dd0fea342ad2 | 135 | uint8_t version_number; /**< LMP Version number for BT 4.0 spec is 6 (https://www.bluetooth.org/technical/assignednumbers/link_layer.htm). */ |
gkroussos | 0:dd0fea342ad2 | 136 | 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). */ |
gkroussos | 0:dd0fea342ad2 | 137 | uint16_t subversion_number; /**< LMP Sub Version number corresponds to the SoftDevice Config ID. */ |
gkroussos | 0:dd0fea342ad2 | 138 | } ble_version_t; |
gkroussos | 0:dd0fea342ad2 | 139 | |
gkroussos | 0:dd0fea342ad2 | 140 | |
gkroussos | 0:dd0fea342ad2 | 141 | /**@brief Get an event from the pending events queue. |
gkroussos | 0:dd0fea342ad2 | 142 | * |
gkroussos | 0:dd0fea342ad2 | 143 | * @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>. |
gkroussos | 0:dd0fea342ad2 | 144 | * @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length. |
gkroussos | 0:dd0fea342ad2 | 145 | * |
gkroussos | 0:dd0fea342ad2 | 146 | * @details This call allows the application to pull a BLE event from the BLE stack. The application is signalled that an event is |
gkroussos | 0:dd0fea342ad2 | 147 | * available from the BLE Stack by the triggering of the SD_EVT_IRQn interrupt (mapped to IRQ 22). |
gkroussos | 0:dd0fea342ad2 | 148 | * The application is free to choose whether to call this function from thread mode (main context) or directly from the Interrupt Service Routine |
gkroussos | 0:dd0fea342ad2 | 149 | * 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 |
gkroussos | 0:dd0fea342ad2 | 150 | * 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. |
gkroussos | 0:dd0fea342ad2 | 151 | * Failure to do so could potentially leave events in the internal queue without the application being aware of this fact. |
gkroussos | 0:dd0fea342ad2 | 152 | * 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 |
gkroussos | 0:dd0fea342ad2 | 153 | * 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 |
gkroussos | 0:dd0fea342ad2 | 154 | * and the application can then call again with a larger buffer size. |
gkroussos | 0:dd0fea342ad2 | 155 | * 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, |
gkroussos | 0:dd0fea342ad2 | 156 | * 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. |
gkroussos | 0:dd0fea342ad2 | 157 | * The application may "peek" the event length by providing p_dest as a NULL pointer and inspecting the value of *p_len upon return. |
gkroussos | 0:dd0fea342ad2 | 158 | * |
gkroussos | 0:dd0fea342ad2 | 159 | * @note The pointer supplied must be aligned to the extend defined by @ref BLE_EVTS_PTR_ALIGNMENT |
gkroussos | 0:dd0fea342ad2 | 160 | * |
gkroussos | 0:dd0fea342ad2 | 161 | * @return @ref NRF_SUCCESS Event pulled and stored into the supplied buffer. |
gkroussos | 0:dd0fea342ad2 | 162 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied. |
gkroussos | 0:dd0fea342ad2 | 163 | * @return @ref NRF_ERROR_NOT_FOUND No events ready to be pulled. |
gkroussos | 0:dd0fea342ad2 | 164 | * @return @ref NRF_ERROR_DATA_SIZE Event ready but could not fit into the supplied buffer. |
gkroussos | 0:dd0fea342ad2 | 165 | */ |
gkroussos | 0:dd0fea342ad2 | 166 | SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t* p_dest, uint16_t *p_len)); |
gkroussos | 0:dd0fea342ad2 | 167 | |
gkroussos | 0:dd0fea342ad2 | 168 | |
gkroussos | 0:dd0fea342ad2 | 169 | /**@brief Get the total number of available application transmission buffers in the BLE stack. |
gkroussos | 0:dd0fea342ad2 | 170 | * |
gkroussos | 0:dd0fea342ad2 | 171 | * @details This call allows the application to obtain the total number of |
gkroussos | 0:dd0fea342ad2 | 172 | * transmission buffers available for application data. Please note that |
gkroussos | 0:dd0fea342ad2 | 173 | * this does not give the number of free buffers, but rather the total amount of them. |
gkroussos | 0:dd0fea342ad2 | 174 | * The application has two options to handle its own application transmission buffers: |
gkroussos | 0:dd0fea342ad2 | 175 | * - Use a simple arithmetic calculation: at boot time the application should use this function |
gkroussos | 0:dd0fea342ad2 | 176 | * to find out the total amount of buffers available to it and store it in a variable. |
gkroussos | 0:dd0fea342ad2 | 177 | * Every time a packet that consumes an application buffer is sent using any of the |
gkroussos | 0:dd0fea342ad2 | 178 | * exposed functions in this BLE API, the application should decrement that variable. |
gkroussos | 0:dd0fea342ad2 | 179 | * Conversely, whenever a @ref BLE_EVT_TX_COMPLETE event is received by the application |
gkroussos | 0:dd0fea342ad2 | 180 | * it should retrieve the count field in such event and add that number to the same |
gkroussos | 0:dd0fea342ad2 | 181 | * variable storing the number of available packets. |
gkroussos | 0:dd0fea342ad2 | 182 | * This mechanism allows the application to be aware at any time of the number of |
gkroussos | 0:dd0fea342ad2 | 183 | * application packets available in the BLE stack's internal buffers, and therefore |
gkroussos | 0:dd0fea342ad2 | 184 | * it can know with certainty whether it is possible to send more data or it has to |
gkroussos | 0:dd0fea342ad2 | 185 | * wait for a @ref BLE_EVT_TX_COMPLETE event before it proceeds. |
gkroussos | 0:dd0fea342ad2 | 186 | * - Choose to simply not keep track of available buffers at all, and instead handle the |
gkroussos | 0:dd0fea342ad2 | 187 | * @ref BLE_ERROR_NO_TX_BUFFERS error by queueing the packet to be transmitted and |
gkroussos | 0:dd0fea342ad2 | 188 | * try again as soon as a @ref BLE_EVT_TX_COMPLETE event arrives. |
gkroussos | 0:dd0fea342ad2 | 189 | * |
gkroussos | 0:dd0fea342ad2 | 190 | * The API functions that <b>may</b> consume an application buffer depending on |
gkroussos | 0:dd0fea342ad2 | 191 | * the parameters supplied to them can be found below: |
gkroussos | 0:dd0fea342ad2 | 192 | * |
gkroussos | 0:dd0fea342ad2 | 193 | * - @ref sd_ble_gattc_write (write witout response only) |
gkroussos | 0:dd0fea342ad2 | 194 | * - @ref sd_ble_gatts_hvx (notifications only) |
gkroussos | 0:dd0fea342ad2 | 195 | * - @ref sd_ble_l2cap_tx (all packets) |
gkroussos | 0:dd0fea342ad2 | 196 | * |
gkroussos | 0:dd0fea342ad2 | 197 | * @param[out] p_count Pointer to a uint8_t which will contain the number of application transmission buffers upon |
gkroussos | 0:dd0fea342ad2 | 198 | * successful return. |
gkroussos | 0:dd0fea342ad2 | 199 | * |
gkroussos | 0:dd0fea342ad2 | 200 | * @return @ref NRF_SUCCESS Number of application transmission buffers retrieved successfully. |
gkroussos | 0:dd0fea342ad2 | 201 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
gkroussos | 0:dd0fea342ad2 | 202 | */ |
gkroussos | 0:dd0fea342ad2 | 203 | SVCALL(SD_BLE_TX_BUFFER_COUNT_GET, uint32_t, sd_ble_tx_buffer_count_get(uint8_t* p_count)); |
gkroussos | 0:dd0fea342ad2 | 204 | |
gkroussos | 0:dd0fea342ad2 | 205 | |
gkroussos | 0:dd0fea342ad2 | 206 | /**@brief Add a Vendor Specific UUID. |
gkroussos | 0:dd0fea342ad2 | 207 | * |
gkroussos | 0:dd0fea342ad2 | 208 | * @details This call enables the application to add a vendor specific UUID to the BLE stack's table, |
gkroussos | 0:dd0fea342ad2 | 209 | * for later use all other modules and APIs. This then allows the application to use the shorter, |
gkroussos | 0:dd0fea342ad2 | 210 | * 24-bit @ref ble_uuid_t format when dealing with both 16-bit and 128-bit UUIDs without having to |
gkroussos | 0:dd0fea342ad2 | 211 | * check for lengths and having split code paths. The way that this is accomplished is by extending the |
gkroussos | 0:dd0fea342ad2 | 212 | * grouping mechanism that the Bluetooth SIG standard base UUID uses for all other 128-bit UUIDs. The |
gkroussos | 0:dd0fea342ad2 | 213 | * type field in the @ref ble_uuid_t structure is an index (relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN) |
gkroussos | 0:dd0fea342ad2 | 214 | * to the table populated by multiple calls to this function, and the uuid field in the same structure |
gkroussos | 0:dd0fea342ad2 | 215 | * contains the 2 bytes at indices 12 and 13. The number of possible 128-bit UUIDs available to the |
gkroussos | 0:dd0fea342ad2 | 216 | * application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536, |
gkroussos | 0:dd0fea342ad2 | 217 | * although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array. |
gkroussos | 0:dd0fea342ad2 | 218 | * |
gkroussos | 0:dd0fea342ad2 | 219 | * @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by |
gkroussos | 0:dd0fea342ad2 | 220 | * the 16-bit uuid field in @ref ble_uuid_t. |
gkroussos | 0:dd0fea342ad2 | 221 | * |
gkroussos | 0:dd0fea342ad2 | 222 | * |
gkroussos | 0:dd0fea342ad2 | 223 | * @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding |
gkroussos | 0:dd0fea342ad2 | 224 | * bytes 12 and 13. |
gkroussos | 0:dd0fea342ad2 | 225 | * @param[out] p_uuid_type Pointer where the type field in @ref ble_uuid_t corresponding to this UUID will be stored. |
gkroussos | 0:dd0fea342ad2 | 226 | * |
gkroussos | 0:dd0fea342ad2 | 227 | * @return @ref NRF_SUCCESS Successfully added the Vendor Specific UUID. |
gkroussos | 0:dd0fea342ad2 | 228 | * @return @ref NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid. |
gkroussos | 0:dd0fea342ad2 | 229 | * @return @ref NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs. |
gkroussos | 0:dd0fea342ad2 | 230 | * @return @ref NRF_ERROR_FORBIDDEN If p_vs_uuid has already been added to the VS UUID table. |
gkroussos | 0:dd0fea342ad2 | 231 | */ |
gkroussos | 0:dd0fea342ad2 | 232 | 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)); |
gkroussos | 0:dd0fea342ad2 | 233 | |
gkroussos | 0:dd0fea342ad2 | 234 | |
gkroussos | 0:dd0fea342ad2 | 235 | /** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure. |
gkroussos | 0:dd0fea342ad2 | 236 | * |
gkroussos | 0:dd0fea342ad2 | 237 | * @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared |
gkroussos | 0:dd0fea342ad2 | 238 | * to the corresponding ones in each entry of the table of vendor specific UUIDs pouplated with @ref sd_ble_uuid_vs_add |
gkroussos | 0:dd0fea342ad2 | 239 | * to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index |
gkroussos | 0:dd0fea342ad2 | 240 | * relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type. |
gkroussos | 0:dd0fea342ad2 | 241 | * |
gkroussos | 0:dd0fea342ad2 | 242 | * @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE. |
gkroussos | 0:dd0fea342ad2 | 243 | * |
gkroussos | 0:dd0fea342ad2 | 244 | * @param[in] uuid_le_len Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes). |
gkroussos | 0:dd0fea342ad2 | 245 | * @param[in] p_uuid_le Pointer pointing to little endian raw UUID bytes. |
gkroussos | 0:dd0fea342ad2 | 246 | * @param[in,out] p_uuid Pointer to a @ref ble_uuid_t structure to be filled in. |
gkroussos | 0:dd0fea342ad2 | 247 | * |
gkroussos | 0:dd0fea342ad2 | 248 | * @return @ref NRF_SUCCESS Successfully decoded into the @ref ble_uuid_t structure. |
gkroussos | 0:dd0fea342ad2 | 249 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
gkroussos | 0:dd0fea342ad2 | 250 | * @return @ref NRF_ERROR_INVALID_LENGTH Invalid UUID length. |
gkroussos | 0:dd0fea342ad2 | 251 | * @return @ref NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs. |
gkroussos | 0:dd0fea342ad2 | 252 | */ |
gkroussos | 0:dd0fea342ad2 | 253 | 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)); |
gkroussos | 0:dd0fea342ad2 | 254 | |
gkroussos | 0:dd0fea342ad2 | 255 | |
gkroussos | 0:dd0fea342ad2 | 256 | /** @brief Encode a @ref ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit). |
gkroussos | 0:dd0fea342ad2 | 257 | * |
gkroussos | 0:dd0fea342ad2 | 258 | * @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. |
gkroussos | 0:dd0fea342ad2 | 259 | * |
gkroussos | 0:dd0fea342ad2 | 260 | * @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes. |
gkroussos | 0:dd0fea342ad2 | 261 | * @param[out] p_uuid_le_len Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes). |
gkroussos | 0:dd0fea342ad2 | 262 | * @param[out] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored. |
gkroussos | 0:dd0fea342ad2 | 263 | * |
gkroussos | 0:dd0fea342ad2 | 264 | * @return @ref NRF_SUCCESS Successfully encoded into the buffer. |
gkroussos | 0:dd0fea342ad2 | 265 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
gkroussos | 0:dd0fea342ad2 | 266 | * @return @ref NRF_ERROR_INVALID_PARAM Invalid UUID type. |
gkroussos | 0:dd0fea342ad2 | 267 | */ |
gkroussos | 0:dd0fea342ad2 | 268 | 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)); |
gkroussos | 0:dd0fea342ad2 | 269 | |
gkroussos | 0:dd0fea342ad2 | 270 | |
gkroussos | 0:dd0fea342ad2 | 271 | /**@brief Get Version Information. |
gkroussos | 0:dd0fea342ad2 | 272 | * |
gkroussos | 0:dd0fea342ad2 | 273 | * @details This call allows the application to get the BLE stack version information. |
gkroussos | 0:dd0fea342ad2 | 274 | * |
gkroussos | 0:dd0fea342ad2 | 275 | * @param[in] p_version Pointer to ble_version_t structure to be filled in. |
gkroussos | 0:dd0fea342ad2 | 276 | * |
gkroussos | 0:dd0fea342ad2 | 277 | * @return @ref NRF_SUCCESS Version information stored successfully. |
gkroussos | 0:dd0fea342ad2 | 278 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
gkroussos | 0:dd0fea342ad2 | 279 | * @return @ref NRF_ERROR_BUSY The stack is busy (typically doing a locally-initiated disconnection procedure). |
gkroussos | 0:dd0fea342ad2 | 280 | */ |
gkroussos | 0:dd0fea342ad2 | 281 | SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t * p_version)); |
gkroussos | 0:dd0fea342ad2 | 282 | |
gkroussos | 0:dd0fea342ad2 | 283 | |
gkroussos | 0:dd0fea342ad2 | 284 | /**@brief Provide a user memory block. |
gkroussos | 0:dd0fea342ad2 | 285 | * |
gkroussos | 0:dd0fea342ad2 | 286 | * @note This call can only be used as a response to a @ref BLE_EVT_USER_MEM_REQUEST event issued to the application. |
gkroussos | 0:dd0fea342ad2 | 287 | * |
gkroussos | 0:dd0fea342ad2 | 288 | * @param[in] conn_handle Connection handle. |
gkroussos | 0:dd0fea342ad2 | 289 | * @param[in] p_block Pointer to a user memory block structure. |
gkroussos | 0:dd0fea342ad2 | 290 | * |
gkroussos | 0:dd0fea342ad2 | 291 | * @return @ref NRF_SUCCESS Successfully queued a response to the peer. |
gkroussos | 0:dd0fea342ad2 | 292 | * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
gkroussos | 0:dd0fea342ad2 | 293 | * @return @ref NRF_ERROR_INVALID_STATE No execute write request pending. |
gkroussos | 0:dd0fea342ad2 | 294 | */ |
gkroussos | 0:dd0fea342ad2 | 295 | SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t *p_block)); |
gkroussos | 0:dd0fea342ad2 | 296 | |
gkroussos | 0:dd0fea342ad2 | 297 | #endif /* BLE_H__ */ |
gkroussos | 0:dd0fea342ad2 | 298 | |
gkroussos | 0:dd0fea342ad2 | 299 | /** |
gkroussos | 0:dd0fea342ad2 | 300 | @} |
gkroussos | 0:dd0fea342ad2 | 301 | @} |
gkroussos | 0:dd0fea342ad2 | 302 | */ |