nRF51 SDK
|
Module independent events, type definitions and API calls for the S110 SoftDevice. More...
Modules | |
User Memory Types | |
Data Structures | |
struct | ble_user_mem_block_t |
User Memory Block. More... | |
struct | ble_evt_tx_complete_t |
TX complete event. More... | |
struct | ble_evt_user_mem_request_t |
Event structure for BLE_EVT_USER_MEM_REQUEST. More... | |
struct | ble_evt_user_mem_release_t |
Event structure for BLE_EVT_USER_MEM_RELEASE. More... | |
struct | ble_common_evt_t |
Event structure for events not associated with a specific function module. More... | |
struct | ble_evt_hdr_t |
BLE Event header. More... | |
struct | ble_evt_t |
Common BLE Event type, wrapping the module specific event reports. More... | |
struct | ble_version_t |
Version Information. More... | |
Macros | |
#define | BLE_EVTS_PTR_ALIGNMENT 4 |
Required pointer alignment for BLE Events. | |
#define | BLE_UUID_VS_MAX_COUNT 10 |
Maximum number of Vendor Specific UUIDs. | |
Enumerations | |
enum | BLE_COMMON_SVCS { SD_BLE_EVT_GET = 0x60, SD_BLE_TX_BUFFER_COUNT_GET, SD_BLE_UUID_VS_ADD, SD_BLE_UUID_DECODE, SD_BLE_UUID_ENCODE, SD_BLE_VERSION_GET, SD_BLE_USER_MEM_REPLY, SD_BLE_EVT_GET = 0x60, SD_BLE_TX_BUFFER_COUNT_GET, SD_BLE_UUID_VS_ADD, SD_BLE_UUID_DECODE, SD_BLE_UUID_ENCODE, SD_BLE_VERSION_GET, SD_BLE_USER_MEM_REPLY, SD_BLE_OPT_SET, SD_BLE_OPT_GET, SD_BLE_EVT_GET = 0x60, SD_BLE_TX_BUFFER_COUNT_GET, SD_BLE_UUID_VS_ADD, SD_BLE_UUID_DECODE, SD_BLE_UUID_ENCODE, SD_BLE_VERSION_GET, SD_BLE_USER_MEM_REPLY } |
Common API SVC numbers. More... | |
enum | BLE_COMMON_EVTS { BLE_EVT_TX_COMPLETE = 0x01, BLE_EVT_USER_MEM_REQUEST, BLE_EVT_USER_MEM_RELEASE, BLE_EVT_TX_COMPLETE = 0x01, BLE_EVT_USER_MEM_REQUEST, BLE_EVT_USER_MEM_RELEASE, BLE_EVT_TX_COMPLETE = 0x01, BLE_EVT_USER_MEM_REQUEST, BLE_EVT_USER_MEM_RELEASE } |
BLE Module Independent Event IDs. More... | |
Functions | |
uint32_t | sd_ble_evt_get (uint8_t *p_dest, uint16_t *p_len) |
Get an event from the pending events queue. More... | |
uint32_t | sd_ble_tx_buffer_count_get (uint8_t *p_count) |
Get the total number of available application transmission buffers in the BLE stack. More... | |
uint32_t | sd_ble_uuid_vs_add (ble_uuid128_t const *const p_vs_uuid, uint8_t *const p_uuid_type) |
Add a Vendor Specific UUID. More... | |
uint32_t | sd_ble_uuid_decode (uint8_t uuid_le_len, uint8_t const *const p_uuid_le, ble_uuid_t *const p_uuid) |
Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit ble_uuid_t structure. More... | |
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) |
Encode a ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit). More... | |
uint32_t | sd_ble_version_get (ble_version_t *p_version) |
Get Version Information. More... | |
uint32_t | sd_ble_user_mem_reply (uint16_t conn_handle, ble_user_mem_block_t *p_block) |
Provide a user memory block. More... | |
Module independent events, type definitions and API calls for the S110 SoftDevice.
enum BLE_COMMON_EVTS |
BLE Module Independent Event IDs.
enum BLE_COMMON_SVCS |
Common API SVC numbers.
uint32_t sd_ble_evt_get | ( | uint8_t * | p_dest, |
uint16_t * | p_len | ||
) |
Get an event from the pending events queue.
[in] | p_dest | Pointer to buffer to be filled in with an event, or NULL to retrieve the event length. This buffer must be 4-byte aligned in memory. |
[in,out] | p_len | Pointer the length of the buffer, on return it is filled with the event length. |
This call allows the application to pull a BLE event from the BLE stack. The application is signalled that an event is available from the BLE Stack by the triggering of the SD_EVT_IRQn interrupt (mapped to IRQ 22). The application is free to choose whether to call this function from thread mode (main context) or directly from the Interrupt Service Routine 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 in a loop (until NRF_ERROR_NOT_FOUND is returned) every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the stack. Failure to do so could potentially leave events in the internal queue without the application being aware of this fact. 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 application memory. If the buffer provided is not large enough to fit the entire contents of the event, NRF_ERROR_DATA_SIZE will be returned and the application can then call again with a larger buffer size. 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, 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. The application may "peek" the event length by providing p_dest as a NULL pointer and inspecting the value of *p_len upon return.
uint32_t sd_ble_tx_buffer_count_get | ( | uint8_t * | p_count | ) |
Get the total number of available application transmission buffers in the BLE stack.
This call allows the application to obtain the total number of transmission buffers available for application data. Please note that this does not give the number of free buffers, but rather the total amount of them. The application has two options to handle its own application transmission buffers:
The API functions that may consume an application buffer depending on the parameters supplied to them can be found below:
[out] | p_count | Pointer to a uint8_t which will contain the number of application transmission buffers upon successful return. |
uint32_t sd_ble_user_mem_reply | ( | uint16_t | conn_handle, |
ble_user_mem_block_t * | p_block | ||
) |
Provide a user memory block.
[in] | conn_handle | Connection handle. |
[in] | p_block | Pointer to a user memory block structure. |
uint32_t sd_ble_uuid_decode | ( | uint8_t | uuid_le_len, |
uint8_t const *const | p_uuid_le, | ||
ble_uuid_t *const | p_uuid | ||
) |
Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit ble_uuid_t structure.
The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared to the corresponding ones in each entry of the table of vendor specific UUIDs pouplated with sd_ble_uuid_vs_add to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index relative to BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type.
[in] | uuid_le_len | Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes). |
[in] | p_uuid_le | Pointer pointing to little endian raw UUID bytes. |
[in,out] | p_uuid | Pointer to a ble_uuid_t structure to be filled in. |
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 | ||
) |
Encode a ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit).
[in] | p_uuid | Pointer to a ble_uuid_t structure that will be encoded into bytes. |
[out] | p_uuid_le_len | Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes). |
[out] | p_uuid_le | Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored. |
uint32_t sd_ble_uuid_vs_add | ( | ble_uuid128_t const *const | p_vs_uuid, |
uint8_t *const | p_uuid_type | ||
) |
Add a Vendor Specific UUID.
This call enables the application to add a vendor specific UUID to the BLE stack's table, for later use all other modules and APIs. This then allows the application to use the shorter, 24-bit ble_uuid_t format when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code paths. The way that this is accomplished is by extending the grouping mechanism that the Bluetooth SIG standard base UUID uses for all other 128-bit UUIDs. The type field in the ble_uuid_t structure is an index (relative to BLE_UUID_TYPE_VENDOR_BEGIN) to the table populated by multiple calls to this function, and the uuid field in the same structure contains the 2 bytes at indices 12 and 13. The number of possible 128-bit UUIDs available to the application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536, although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array.
[in] | p_vs_uuid | Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding bytes 12 and 13. |
[out] | p_uuid_type | Pointer where the type field in ble_uuid_t corresponding to this UUID will be stored. |
uint32_t sd_ble_version_get | ( | ble_version_t * | p_version | ) |
Get Version Information.
This call allows the application to get the BLE stack version information.
[in] | p_version | Pointer to ble_version_t structure to be filled in. |