nRF51 SDK: Functions

| nRF51 SDK

- Home
- Related Pages
- API Reference
- Data Structures

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions
Functions
Database Discovery

## Functions

uint32_t | ble_db_discovery_init (ble_db_discovery_init_t *p_db_discovery_init)
| Function for initializing the DB Discovery module. More...
uint32_t | ble_db_discovery_close (void)
| Function for closing the DB Discovery module. More...
uint32_t | ble_db_discovery_register (const ble_uuid_t *const p_uuid, const ble_db_discovery_evt_handler_t evt_handler)
| Function for registering with the DB Discovery module. More...
uint32_t | ble_db_discovery_start (ble_db_discovery_t *const p_db_discovery, uint16_t conn_handle)
| Function for starting the discovery of the GATT database at the server. More...
void | ble_db_discovery_on_ble_evt (ble_db_discovery_t *const p_db_discovery, const ble_evt_t *const p_ble_evt)
| Function for handling the Application's BLE Stack events. More...

## Detailed Description

## Function Documentation

uint32_t ble_db_discovery_close | ( | void |  | ) |

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.

Return values

  NRF_SUCCESS | on successful close.

uint32_t ble_db_discovery_init | ( | ble_db_discovery_init_t * | p_db_discovery_init | ) |

Function for initializing the DB Discovery module.

Parameters

  [in] | p_db_discovery_init | Pointer to the structure containing initialization information.

Return values

  NRF_SUCCESS | on successful initialization.
  NRF_ERROR_NULL | when a NULL Pointer is passed as input.

void ble_db_discovery_on_ble_evt | ( | ble_db_discovery_t *const | p_db_discovery,
|  | const ble_evt_t *const | p_ble_evt
| ) |  |

Function for handling the Application's BLE Stack events.

Parameters

  [in] | p_db_discovery | Pointer to the DB Discovery structure.
  [in] | p_ble_evt | Pointer to the BLE event received.

uint32_t ble_db_discovery_register | ( | const ble_uuid_t *const | p_uuid,
|  | const ble_db_discovery_evt_handler_t | evt_handler
| ) |  |

Function for registering with the DB Discovery module.

The application can use this function to register with the 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.
  [in] | evt_handler | Event handler to be called by the DB discovery module when any ` event related to discovery of the service registered for occurs.

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 | upon successful registration.
  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_NOT_SUPPORTED | when the total number of applications already registered with this module is equal to BLE_DB_DISCOVERY_MAX_USERS.

uint32_t ble_db_discovery_start | ( | ble_db_discovery_t *const | p_db_discovery,
|  | uint16_t | conn_handle
| ) |  |

Function for starting the discovery of the GATT database at the server.

Parameters

  [in] | 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 | if the database discovery was successfully started.
  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_register.
  NRF_ERROR_BUSY | if a discovery is already in progress for the current connection.

Returns
  This API propagates the error code returned by the SoftDevice API sd_ble_gattc_primary_services_discover.