Skip to content

Commit fe862ab

Browse files
lib: bluetooth: ble_db_discovery: fixes for rebase
To be squashed. Signed-off-by: Eivind Jølsgard <eivind.jolsgard@nordicsemi.no>
1 parent 82d2b66 commit fe862ab

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

include/bm/bluetooth/ble_db_discovery.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
#define BLE_DB_DISCOVERY_DEF(_name) \
2929
static struct ble_db_discovery _name = {.discovery_in_progress = 0, \
3030
.conn_handle = BLE_CONN_HANDLE_INVALID}; \
31-
NRF_SDH_BLE_OBSERVER(_name##_obs, ble_db_discovery_on_ble_evt, &_name, \
32-
BLE_DB_DISC_BLE_OBSERVER_PRIO)
31+
NRF_SDH_BLE_OBSERVER(_name##_obs, ble_db_discovery_on_ble_evt, &_name, HIGH);
3332

3433
/**
3534
* @brief BLE database discovery event type.

lib/bluetooth/ble_db_discovery/ble_db_discovery.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ static void discovery_error_handler(uint16_t conn_handle, uint32_t nrf_error, vo
9898
discovery_available_evt_trigger(db_discovery, conn_handle);
9999
}
100100

101+
static void discovery_event_handler(const struct ble_gq_req *req, struct ble_gq_evt *evt)
102+
{
103+
if (evt->evt_type != BLE_GQ_EVT_ERROR) {
104+
return;
105+
}
106+
107+
discovery_error_handler(evt->conn_handle, evt->error.reason, req->ctx);
108+
}
109+
101110
static void discovery_complete_evt_trigger(struct ble_db_discovery *db_discovery, bool is_srv_found,
102111
uint16_t conn_handle)
103112
{
@@ -179,8 +188,8 @@ static void on_srv_disc_completion(struct ble_db_discovery *db_discovery, uint16
179188
db_srv_disc_req.type = BLE_GQ_REQ_SRV_DISCOVERY;
180189
db_srv_disc_req.gattc_srv_disc.start_handle = CONFIG_SRV_DISC_START_HANDLE;
181190
db_srv_disc_req.gattc_srv_disc.srvc_uuid = srv_being_discovered->srv_uuid;
182-
db_srv_disc_req.error_handler.ctx = db_discovery;
183-
db_srv_disc_req.error_handler.cb = discovery_error_handler;
191+
db_srv_disc_req.ctx = db_discovery;
192+
db_srv_disc_req.evt_handler = discovery_event_handler;
184193

185194
err_code = ble_gq_item_add(db_discovery->gatt_queue, &db_srv_disc_req, conn_handle);
186195

@@ -285,8 +294,8 @@ static uint32_t characteristics_discover(struct ble_db_discovery *db_discovery,
285294

286295
db_char_disc_req.type = BLE_GQ_REQ_CHAR_DISCOVERY;
287296
db_char_disc_req.gattc_char_disc = handle_range;
288-
db_char_disc_req.error_handler.ctx = db_discovery;
289-
db_char_disc_req.error_handler.cb = discovery_error_handler;
297+
db_char_disc_req.ctx = db_discovery;
298+
db_char_disc_req.evt_handler = discovery_event_handler;
290299

291300
return ble_gq_item_add(db_discovery->gatt_queue, &db_char_disc_req, conn_handle);
292301
}
@@ -350,8 +359,8 @@ static uint32_t descriptors_discover(struct ble_db_discovery *db_discovery,
350359

351360
db_desc_disc_req.type = BLE_GQ_REQ_DESC_DISCOVERY;
352361
db_desc_disc_req.gattc_desc_disc = handle_range;
353-
db_desc_disc_req.error_handler.ctx = db_discovery;
354-
db_desc_disc_req.error_handler.cb = discovery_error_handler;
362+
db_desc_disc_req.ctx = db_discovery;
363+
db_desc_disc_req.evt_handler = discovery_error_handler;
355364

356365
return ble_gq_item_add(db_discovery->gatt_queue, &db_desc_disc_req, conn_handle);
357366
}
@@ -644,8 +653,8 @@ static uint32_t discovery_start(struct ble_db_discovery *const db_discovery, uin
644653
db_srv_disc_req.type = BLE_GQ_REQ_SRV_DISCOVERY;
645654
db_srv_disc_req.gattc_srv_disc.start_handle = CONFIG_SRV_DISC_START_HANDLE;
646655
db_srv_disc_req.gattc_srv_disc.srvc_uuid = srv_being_discovered->srv_uuid;
647-
db_srv_disc_req.error_handler.ctx = db_discovery;
648-
db_srv_disc_req.error_handler.cb = discovery_error_handler;
656+
db_srv_disc_req.ctx = db_discovery;
657+
db_srv_disc_req.evt_handler = discovery_event_handler;
649658

650659
err_code = ble_gq_item_add(db_discovery->gatt_queue, &db_srv_disc_req, conn_handle);
651660

0 commit comments

Comments
 (0)