nrf5/drivers/bluetooth: Updating primary service discovery api to take in start handle from where to start the service discovery. Also adjusting return parameter to signal whether anything was found or not.
This commit is contained in:
parent
3420843774
commit
b4f96a1dc3
|
@ -67,6 +67,7 @@ if (ble_drv_stack_enabled() == 0) { \
|
|||
|
||||
static volatile bool m_adv_in_progress;
|
||||
static volatile bool m_tx_in_progress;
|
||||
static volatile bool m_primary_service_found;
|
||||
|
||||
static ble_drv_gap_evt_callback_t gap_event_handler;
|
||||
static ble_drv_gatts_evt_callback_t gatts_event_handler;
|
||||
|
@ -755,16 +756,18 @@ void ble_drv_connect(uint8_t * p_addr, uint8_t addr_type) {
|
|||
}
|
||||
}
|
||||
|
||||
bool ble_drv_discover_services(mp_obj_t obj, uint16_t conn_handle, ble_drv_disc_add_service_callback_t cb) {
|
||||
bool ble_drv_discover_services(mp_obj_t obj, uint16_t conn_handle, uint16_t start_handle, ble_drv_disc_add_service_callback_t cb) {
|
||||
BLE_DRIVER_LOG("Discover primary services. Conn handle: 0x" HEX2_FMT "\n",
|
||||
conn_handle);
|
||||
|
||||
mp_gattc_disc_service_observer = obj;
|
||||
disc_add_service_handler = cb;
|
||||
|
||||
m_primary_service_found = false;
|
||||
|
||||
uint32_t err_code;
|
||||
err_code = sd_ble_gattc_primary_services_discover(conn_handle,
|
||||
0x0001,
|
||||
start_handle,
|
||||
NULL);
|
||||
if (err_code != 0) {
|
||||
return false;
|
||||
|
@ -775,7 +778,11 @@ bool ble_drv_discover_services(mp_obj_t obj, uint16_t conn_handle, ble_drv_disc_
|
|||
;
|
||||
}
|
||||
|
||||
return true;
|
||||
if (m_primary_service_found) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ble_drv_discover_characteristic(mp_obj_t obj,
|
||||
|
@ -907,7 +914,7 @@ static void ble_evt_handler(ble_evt_t * p_ble_evt) {
|
|||
|
||||
case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP:
|
||||
BLE_DRIVER_LOG("BLE EVT PRIMARY SERVICE DISCOVERY RESPONSE\n");
|
||||
|
||||
BLE_DRIVER_LOG(">>> service count: %d\n", p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp.count);
|
||||
for (uint16_t i = 0; i < p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp.count; i++) {
|
||||
ble_gattc_service_t * p_service = &p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp.services[i];
|
||||
|
||||
|
@ -920,6 +927,10 @@ static void ble_evt_handler(ble_evt_t * p_ble_evt) {
|
|||
disc_add_service_handler(mp_gattc_disc_service_observer, &service);
|
||||
}
|
||||
|
||||
if (p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp.count > 0) {
|
||||
m_primary_service_found = true;
|
||||
}
|
||||
|
||||
// mark end of service discovery
|
||||
disc_add_service_handler = NULL;
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ void ble_drv_adv_report_handler_set(mp_obj_t obj, ble_drv_adv_evt_callback_t evt
|
|||
|
||||
void ble_drv_connect(uint8_t * p_addr, uint8_t addr_type);
|
||||
|
||||
bool ble_drv_discover_services(mp_obj_t obj, uint16_t conn_handle, ble_drv_disc_add_service_callback_t cb);
|
||||
bool ble_drv_discover_services(mp_obj_t obj, uint16_t conn_handle, uint16_t start_handle, ble_drv_disc_add_service_callback_t cb);
|
||||
|
||||
bool ble_drv_discover_characteristic(mp_obj_t obj,
|
||||
uint16_t conn_handle,
|
||||
|
|
Loading…
Reference in New Issue