Database discovery module.
More...
Database discovery module.
This module contains the APIs and types exposed by the DB Discovery module. These APIs and types can be used by the application to perform discovery of a service and its characteristics at the peer server. This module can also be used to discover the desired services in multiple remote devices.
- Warning
- The maximum number of characteristics per service that can be discovered by this module is determined by the number of characteristics in the service structure defined in db_disc_config.h. If the peer has more than the supported number of characteristics, then the first found will be discovered and any further characteristics will be ignored. Only the following descriptors will be searched for at the peer: Client Characteristic Configuration, Characteristic Extended Properties, Characteristic User Description, and Report Reference.
- Note
- Presently only one instance of a Primary Service can be discovered by this module. If there are multiple instances of the service at the peer, only the first instance of it at the peer is fetched and returned to the application.
-
The application must propagate BLE stack events to this module by calling ble_db_discovery_on_ble_evt().
#define BLE_DB_DISCOVERY_ARRAY_DEF |
( |
|
_name, |
|
|
|
_cnt |
|
) |
| |
Value:
Macro for defining multiple ble_db_discovery instances.
- Parameters
-
_name | Name of the array of instances. |
_cnt | Number of instances to define. |
#define BLE_DB_DISCOVERY_DEF |
( |
|
_name | ) |
|
Macro for defining a ble_db_discovery instance.
- Parameters
-
_name | Name of the instance. |
#define BLE_DB_DISCOVERY_MAX_SRV 6 |
(defined(LINT))
Maximum number of services supported by this module. This also indicates the maximum number of users allowed to be registered to this module (one user per service).
DB Discovery event type.
Enumerator |
---|
BLE_DB_DISCOVERY_COMPLETE |
Event indicating that the discovery of one service is complete.
|
BLE_DB_DISCOVERY_ERROR |
Event indicating that an internal error has occurred in the DB Discovery module. This could typically be because of the SoftDevice API returning an error code during the DB discover.
|
BLE_DB_DISCOVERY_SRV_NOT_FOUND |
Event indicating that the service was not found at the peer.
|
BLE_DB_DISCOVERY_AVAILABLE |
Event indicating that the DB discovery instance is available.
|
Function for closing the DB Discovery module.
This function will clear up any internal variables and states maintained by the module. To re-use the module after calling this function, the function ble_db_discovery_init must be called again. When using more than one DB Discovery instance, this function should be called for each instance.
- Parameters
-
[out] | p_db_discovery | Pointer to the DB discovery structure. |
- Return values
-
NRF_SUCCESS | Operation success. |
uint32_t ble_db_discovery_evt_register |
( |
const ble_uuid_t *const |
p_uuid | ) |
|
Function for registering with the DB Discovery module.
The application can use this function to inform which service it is interested in discovering at the server.
- Parameters
-
[in] | p_uuid | Pointer to the UUID of the service to be discovered at the server. |
- Note
- The total number of services that can be discovered by this module is BLE_DB_DISCOVERY_MAX_SRV. This effectively means that the maximum number of registrations possible is equal to the BLE_DB_DISCOVERY_MAX_SRV.
- Return values
-
NRF_SUCCESS | Operation success. |
NRF_ERROR_NULL | When a NULL pointer is passed as input. |
NRF_ERROR_INVALID_STATE | If this function is called without calling the ble_db_discovery_init. |
NRF_ERROR_NO_MEM | The maximum number of registrations allowed by this module has been reached. |
Function for initializing the DB Discovery module.
- Parameters
-
[in] | p_db_init | Pointer to DB discovery initialization structure. |
- Return values
-
NRF_SUCCESS | On successful initialization. |
NRF_ERROR_NULL | If the initialization structure was NULL or the structure content is empty. |
void ble_db_discovery_on_ble_evt |
( |
ble_evt_t const * |
p_ble_evt, |
|
|
void * |
p_context |
|
) |
| |
Function for handling the Application's BLE Stack events.
- Parameters
-
[in] | p_ble_evt | Pointer to the BLE event received. |
[in,out] | p_context | Pointer to the DB Discovery structure. |
uint32_t ble_db_discovery_start |
( |
ble_db_discovery_t * |
p_db_discovery, |
|
|
uint16_t |
conn_handle |
|
) |
| |
Function for starting the discovery of the GATT database at the server.
- Parameters
-
[out] | p_db_discovery | Pointer to the DB Discovery structure. |
[in] | conn_handle | The handle of the connection for which the discovery should be started. |
- Return values
-
NRF_SUCCESS | Operation success. |
NRF_ERROR_NULL | When a NULL pointer is passed as input. |
NRF_ERROR_INVALID_STATE | If this function is called without calling the ble_db_discovery_init, or without calling ble_db_discovery_evt_register. |
NRF_ERROR_BUSY | If a discovery is already in progress using p_db_discovery . Use a different ble_db_discovery_t structure, or wait for a DB Discovery event before retrying. |
- Returns
- This API propagates the error code returned by functions: nrf_ble_gq_conn_handle_register and nrf_ble_gq_item_add.