nRF Connect SDK Bare Metal API 2.0.99
Loading...
Searching...
No Matches
ble_db_discovery.h
1/*
2 * Copyright (c) 2013 - 2026 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
14#include <stdint.h>
15#include <zephyr/kernel.h>
16#include <ble_gattc.h>
17#include <bm/bluetooth/ble_gq.h>
18#include <bm/bluetooth/ble_gatt_db.h>
19
20#ifndef BLE_DB_DISCOVERY_H__
21#define BLE_DB_DISCOVERY_H__
22
28#define BLE_DB_DISCOVERY_DEF(_name) \
29 static struct ble_db_discovery _name = {.discovery_in_progress = 0, \
30 .conn_handle = BLE_CONN_HANDLE_INVALID}; \
31 NRF_SDH_BLE_OBSERVER(_name##_obs, ble_db_discovery_on_ble_evt, &_name, HIGH)
32
57
69 uint16_t conn_handle;
70 union {
83 ble_uuid_t srv_uuid;
87 struct {
91 uint32_t reason;
93 };
94};
95
96/* Forward declaration. */
97struct ble_db_discovery;
98
102typedef void (*ble_db_discovery_evt_handler)(struct ble_db_discovery *db_discovery,
103 struct ble_db_discovery_evt *evt);
104
118
128 struct ble_gatt_db_srv services[CONFIG_BLE_DB_DISCOVERY_MAX_SRV];
132 ble_uuid_t registered_uuids[CONFIG_BLE_DB_DISCOVERY_MAX_SRV];
140 const struct ble_gq *gatt_queue;
148 uint8_t srv_count;
172 uint16_t conn_handle;
183 struct ble_db_discovery_evt pending_usr_evts[CONFIG_BLE_DB_DISCOVERY_MAX_SRV];
184};
185
196uint32_t ble_db_discovery_init(struct ble_db_discovery *db_discovery,
197 const struct ble_db_discovery_config *db_config);
198
218uint32_t ble_db_discovery_start(struct ble_db_discovery *db_discovery, uint16_t conn_handle);
219
241 const ble_uuid_t *uuid);
242
256void ble_db_discovery_on_ble_evt(const ble_evt_t *ble_evt, void *ble_db_discovery);
257
258#endif /* BLE_DB_DISCOVERY_H__ */
259
uint32_t ble_db_discovery_init(struct ble_db_discovery *db_discovery, const struct ble_db_discovery_config *db_config)
Initialize the DB Discovery library.
uint32_t ble_db_discovery_start(struct ble_db_discovery *db_discovery, uint16_t conn_handle)
Start the discovery of the GATT database at the server.
uint32_t ble_db_discovery_service_register(struct ble_db_discovery *db_discovery, const ble_uuid_t *uuid)
Register service UUID with the DB Discovery instance.
ble_db_discovery_evt_type
Bluetooth LE database discovery event type.
Definition ble_db_discovery.h:36
@ BLE_DB_DISCOVERY_SRV_NOT_FOUND
Event indicating that the service was not found at the peer.
Definition ble_db_discovery.h:44
@ BLE_DB_DISCOVERY_AVAILABLE
Event indicating that the DB discovery instance is available.
Definition ble_db_discovery.h:48
@ BLE_DB_DISCOVERY_ERROR
Event indicating that an internal error has occurred in the DB Discovery library.
Definition ble_db_discovery.h:55
@ BLE_DB_DISCOVERY_COMPLETE
Event indicating that the discovery of one service is complete.
Definition ble_db_discovery.h:40
void(* ble_db_discovery_evt_handler)(struct ble_db_discovery *db_discovery, struct ble_db_discovery_evt *evt)
DB discovery event handler type.
Definition ble_db_discovery.h:102
void ble_db_discovery_on_ble_evt(const ble_evt_t *ble_evt, void *ble_db_discovery)
Bluetooth LE event handler for the Database Discovery library.
ble_db_discovery_evt_handler evt_handler
Event handler to be called by the DB Discovery library.
Definition ble_db_discovery.h:112
const struct ble_gq * gatt_queue
Pointer to Bluetooth LE GATT Queue instance.
Definition ble_db_discovery.h:116
Bluetooth LE database discovery configuration.
Definition ble_db_discovery.h:108
uint16_t conn_handle
Handle of the connection for which this event has occurred.
Definition ble_db_discovery.h:69
struct ble_db_discovery_evt::@8::@10 error
Parameters for BLE_DB_DISCOVERY_ERROR.
enum ble_db_discovery_evt_type evt_type
Type of event.
Definition ble_db_discovery.h:65
ble_uuid_t srv_uuid
Parameters for BLE_DB_DISCOVERY_SRV_NOT_FOUND.
Definition ble_db_discovery.h:83
uint32_t reason
Error reason.
Definition ble_db_discovery.h:91
const struct ble_gatt_db_srv * discovered_db
Parameters for BLE_DB_DISCOVERY_COMPLETE.
Definition ble_db_discovery.h:79
Bluetooth LE database discovery event.
Definition ble_db_discovery.h:61
uint8_t srv_count
Number of services at the peer's GATT database.
Definition ble_db_discovery.h:148
struct ble_db_discovery_evt pending_usr_evts[CONFIG_BLE_DB_DISCOVERY_MAX_SRV]
Whenever a discovery related event is to be raised, it is stored in this array first....
Definition ble_db_discovery.h:183
uint32_t pending_usr_evt_idx
The index to the pending user event array, pointing to the last added pending user event.
Definition ble_db_discovery.h:177
ble_uuid_t registered_uuids[CONFIG_BLE_DB_DISCOVERY_MAX_SRV]
UUID of registered handlers.
Definition ble_db_discovery.h:132
uint16_t conn_handle
Connection handle on which the discovery is started.
Definition ble_db_discovery.h:172
uint8_t curr_srv_idx
Index of the current service being discovered.
Definition ble_db_discovery.h:160
bool discovery_in_progress
Variable to indicate whether there is a service discovery in progress.
Definition ble_db_discovery.h:168
ble_db_discovery_evt_handler evt_handler
Instance event handler.
Definition ble_db_discovery.h:136
uint8_t curr_char_idx
Index of the current characteristic being discovered.
Definition ble_db_discovery.h:154
const struct ble_gq * gatt_queue
Bluetooth LE GATT Queue instance.
Definition ble_db_discovery.h:140
struct ble_gatt_db_srv services[CONFIG_BLE_DB_DISCOVERY_MAX_SRV]
Information related to the current service being discovered.
Definition ble_db_discovery.h:128
uint32_t num_registered_uuids
The number of UUIDs registered with the DB Discovery library.
Definition ble_db_discovery.h:144
uint8_t discoveries_count
Number of service discoveries made, both successful and unsuccessful.
Definition ble_db_discovery.h:164
Bluetooth LE database discovery.
Definition ble_db_discovery.h:122
Structure for holding information about the service and the characteristics present on a server.
Definition ble_gatt_db.h:61
Bluetooth LE GATT Queue.
Definition ble_gq.h:238