*
******************************************************************************/
void bta_dm_search_start(tBTA_DM_MSG* p_data) {
- tBTM_INQUIRY_CMPL result;
+ tBTM_INQUIRY_CMPL result = {};
size_t len = sizeof(Uuid) * p_data->search.num_uuid;
bta_dm_gattc_register();
if (p_bta_dm_cfg->avoid_scatter &&
(p_data->search.rs_res == BTA_DM_RS_NONE) &&
bta_dm_check_av(BTA_DM_API_SEARCH_EVT)) {
+ LOG(INFO) << __func__ << ": delay search to avoid scatter";
memcpy(&bta_dm_cb.search_msg, &p_data->search, sizeof(tBTA_DM_API_SEARCH));
return;
}
- BTM_ClearInqDb(NULL);
+ BTM_ClearInqDb(nullptr);
/* save search params */
bta_dm_search_cb.p_search_cback = p_data->search.p_cback;
bta_dm_search_cb.services = p_data->search.services;
osi_free_and_reset((void**)&bta_dm_search_cb.p_srvc_uuid);
if ((bta_dm_search_cb.num_uuid = p_data->search.num_uuid) != 0 &&
- p_data->search.p_uuid != NULL) {
+ p_data->search.p_uuid != nullptr) {
bta_dm_search_cb.p_srvc_uuid = (Uuid*)osi_malloc(len);
*bta_dm_search_cb.p_srvc_uuid = *p_data->search.p_uuid;
}
APPL_TRACE_EVENT("%s status=%d", __func__, result.status);
if (result.status != BTM_CMD_STARTED) {
+ LOG(ERROR) << __func__ << ": BTM_StartInquiry returned "
+ << std::to_string(result.status);
result.num_resp = 0;
bta_dm_inq_cmpl_cb((void*)&result);
}
tBTM_STATUS BTM_StartInquiry(tBTM_INQ_PARMS* p_inqparms,
tBTM_INQ_RESULTS_CB* p_results_cb,
tBTM_CMPL_CB* p_cmpl_cb) {
- tBTM_STATUS status = BTM_CMD_STARTED;
tBTM_INQUIRY_VAR_ST* p_inq = &btm_cb.btm_inq_vars;
BTM_TRACE_API("BTM_StartInquiry: mode: %d, dur: %d, rsps: %d, flt: %d",
if (p_inq->inq_active || p_inq->inqfilt_active) {
/*check if LE observe is already running*/
if (p_inq->scan_type == INQ_LE_OBSERVE &&
- p_inq->p_inq_ble_results_cb != NULL) {
+ p_inq->p_inq_ble_results_cb != nullptr) {
BTM_TRACE_API("BTM_StartInquiry: LE observe in progress");
p_inq->scan_type = INQ_GENERAL;
p_inq->inq_active = BTM_INQUIRY_INACTIVE;
btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
btm_send_hci_scan_enable(BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE);
} else {
- BTM_TRACE_API("BTM_StartInquiry: return BUSY");
+ LOG(ERROR) << __func__ << ": BTM_BUSY";
return (BTM_BUSY);
}
- } else
+ } else {
p_inq->scan_type = INQ_GENERAL;
+ }
/*** Make sure the device is ready ***/
- if (!BTM_IsDeviceUp()) return (BTM_WRONG_MODE);
+ if (!BTM_IsDeviceUp()) {
+ LOG(ERROR) << __func__ << ": adapter is not up";
+ return BTM_WRONG_MODE;
+ }
if ((p_inqparms->mode & BTM_BR_INQUIRY_MASK) != BTM_GENERAL_INQUIRY &&
(p_inqparms->mode & BTM_BR_INQUIRY_MASK) != BTM_LIMITED_INQUIRY &&
(p_inqparms->mode & BTM_BLE_INQUIRY_MASK) != BTM_BLE_GENERAL_INQUIRY &&
- (p_inqparms->mode & BTM_BLE_INQUIRY_MASK) != BTM_BLE_LIMITED_INQUIRY)
+ (p_inqparms->mode & BTM_BLE_INQUIRY_MASK) != BTM_BLE_LIMITED_INQUIRY) {
+ LOG(ERROR) << __func__ << ": illegal inquiry mode "
+ << std::to_string(p_inqparms->mode);
return (BTM_ILLEGAL_VALUE);
+ }
/* Save the inquiry parameters to be used upon the completion of
* setting/clearing the inquiry filter */
BTM_TRACE_DEBUG("BTM_StartInquiry: p_inq->inq_active = 0x%02x",
p_inq->inq_active);
+ tBTM_STATUS status = BTM_CMD_STARTED;
/* start LE inquiry here if requested */
if ((p_inqparms->mode & BTM_BLE_INQUIRY_MASK)) {
if (!controller_get_interface()->supports_ble()) {
+ LOG(ERROR) << __func__ << ": trying to do LE scan on a non-LE adapter";
p_inq->inqparms.mode &= ~BTM_BLE_INQUIRY_MASK;
status = BTM_ILLEGAL_VALUE;
- }
- /* BLE for now does not support filter condition for inquiry */
- else {
+ } else {
+ /* BLE for now does not support filter condition for inquiry */
status = btm_ble_start_inquiry(
(uint8_t)(p_inqparms->mode & BTM_BLE_INQUIRY_MASK),
p_inqparms->duration);
if (status != BTM_CMD_STARTED) {
- BTM_TRACE_ERROR("Err Starting LE Inquiry.");
+ LOG(ERROR) << __func__ << ": Error Starting LE Inquiry";
p_inq->inqparms.mode &= ~BTM_BLE_INQUIRY_MASK;
}
}
}
/* we're done with this routine if BR/EDR inquiry is not desired. */
- if ((p_inqparms->mode & BTM_BR_INQUIRY_MASK) == BTM_INQUIRY_NONE)
+ if ((p_inqparms->mode & BTM_BR_INQUIRY_MASK) == BTM_INQUIRY_NONE) {
return status;
+ }
-/* BR/EDR inquiry portion */
- /* If a filter is specified, then save it for later and clear the current
- filter.
- The setting of the filter is done upon completion of clearing of the
- previous
- filter.
- */
- switch (p_inqparms->filter_cond_type) {
- case BTM_CLR_INQUIRY_FILTER:
- p_inq->state = BTM_INQ_SET_FILT_STATE;
- break;
-
- case BTM_FILTER_COND_DEVICE_CLASS:
- case BTM_FILTER_COND_BD_ADDR:
- /* The filter is not being used so simply clear it;
- the inquiry can start after this operation */
- p_inq->state = BTM_INQ_CLR_FILT_STATE;
- p_inqparms->filter_cond_type = BTM_CLR_INQUIRY_FILTER;
- /* =============>>>> adding LE filtering here ????? */
- break;
-
- default:
- return (BTM_ILLEGAL_VALUE);
+ /* BR/EDR inquiry portion */
+ /* If a filter is specified, then save it for later and clear the current
+ filter.
+ The setting of the filter is done upon completion of clearing of the
+ previous
+ filter.
+ */
+ switch (p_inqparms->filter_cond_type) {
+ case BTM_CLR_INQUIRY_FILTER:
+ p_inq->state = BTM_INQ_SET_FILT_STATE;
+ break;
+
+ case BTM_FILTER_COND_DEVICE_CLASS:
+ case BTM_FILTER_COND_BD_ADDR:
+ /* The filter is not being used so simply clear it;
+ the inquiry can start after this operation */
+ p_inq->state = BTM_INQ_CLR_FILT_STATE;
+ p_inqparms->filter_cond_type = BTM_CLR_INQUIRY_FILTER;
+ /* =============>>>> adding LE filtering here ????? */
+ break;
+
+ default:
+ LOG(ERROR) << __func__ << ": invalid filter condition type "
+ << std::to_string(p_inqparms->filter_cond_type);
+ return (BTM_ILLEGAL_VALUE);
}
/* Before beginning the inquiry the current filter must be cleared, so
* initiate the command */
status = btm_set_inq_event_filter(p_inqparms->filter_cond_type,
&p_inqparms->filter_cond);
- if (status != BTM_CMD_STARTED) p_inq->state = BTM_INQ_INACTIVE_STATE;
+ if (status != BTM_CMD_STARTED) {
+ LOG(ERROR) << __func__ << ": failed to set inquiry event filter";
+ p_inq->state = BTM_INQ_INACTIVE_STATE;
+ }
- return (status);
+ return (status);
}
/*******************************************************************************