Loading system/main/shim/hci_layer.cc +0 −1 Original line number Original line Diff line number Diff line Loading @@ -63,7 +63,6 @@ namespace { bool register_event_code(bluetooth::hci::EventCode event_code) { bool register_event_code(bluetooth::hci::EventCode event_code) { switch (event_code) { switch (event_code) { // Inquiry // Inquiry case bluetooth::hci::EventCode::INQUIRY_COMPLETE: case bluetooth::hci::EventCode::INQUIRY_RESULT: case bluetooth::hci::EventCode::INQUIRY_RESULT: case bluetooth::hci::EventCode::INQUIRY_RESULT_WITH_RSSI: case bluetooth::hci::EventCode::INQUIRY_RESULT_WITH_RSSI: case bluetooth::hci::EventCode::EXTENDED_INQUIRY_RESULT: case bluetooth::hci::EventCode::EXTENDED_INQUIRY_RESULT: Loading system/stack/btm/btm_inq.cc +44 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,8 @@ * * ******************************************************************************/ ******************************************************************************/ #include "hci_error_code.h" #include "neighbor_inquiry.h" #define LOG_TAG "bluetooth" #define LOG_TAG "bluetooth" #include <base/logging.h> #include <base/logging.h> Loading Loading @@ -253,6 +255,7 @@ void SendRemoteNameRequest(const RawAddress& raw_address) { HCI_MANDATARY_PAGE_SCAN_MODE, 0); HCI_MANDATARY_PAGE_SCAN_MODE, 0); } } static void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode); static void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode); static void on_incoming_hci_event(bluetooth::hci::EventView event); /******************************************************************************* /******************************************************************************* * * * Function BTM_SetDiscoverability * Function BTM_SetDiscoverability Loading Loading @@ -635,6 +638,16 @@ tBTM_STATUS BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb, return BTM_BUSY; return BTM_BUSY; } } if (btm_cb.btm_inq_vars.registered_for_hci_events == false) { bluetooth::shim::GetHciLayer()->RegisterEventHandler( bluetooth::hci::EventCode::INQUIRY_COMPLETE, get_main_thread()->Bind([](bluetooth::hci::EventView event) { on_incoming_hci_event(event); })); btm_cb.btm_inq_vars.registered_for_hci_events = true; } /*** Make sure the device is ready ***/ /*** Make sure the device is ready ***/ if (!BTM_IsDeviceUp()) { if (!BTM_IsDeviceUp()) { log::error("adapter is not up"); log::error("adapter is not up"); Loading Loading @@ -2183,6 +2196,37 @@ void btm_set_eir_uuid(const uint8_t* p_eir, tBTM_INQ_RESULTS* p_results) { } } } } static void on_inquiry_complete(bluetooth::hci::EventView event) { auto complete = bluetooth::hci::InquiryCompleteView::Create(event); ASSERT(complete.IsValid()); auto status = to_hci_status_code(static_cast<uint8_t>(complete.GetStatus())); btm_process_inq_complete(status, BTM_BR_INQUIRY_MASK); } /******************************************************************************* * * Function on_incoming_hci_event * * Description This function is called to process events from the HCI layer * * Parameters event - an EventView with the specific event * * Returns None * ******************************************************************************/ static void on_incoming_hci_event(bluetooth::hci::EventView event) { ASSERT(event.IsValid()); auto event_code = event.GetEventCode(); switch (event_code) { case bluetooth::hci::EventCode::INQUIRY_COMPLETE: on_inquiry_complete(event); break; default: LOG_WARN("Dropping unhandled event: %s", bluetooth::hci::EventCodeText(event_code).c_str()); } } namespace bluetooth { namespace bluetooth { namespace legacy { namespace legacy { namespace testing { namespace testing { Loading system/stack/btm/neighbor_inquiry.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -266,6 +266,8 @@ struct tBTM_INQUIRY_VAR_ST { uint8_t inq_active; /* Bit Mask indicating type of inquiry is active */ uint8_t inq_active; /* Bit Mask indicating type of inquiry is active */ bool no_inc_ssp; /* true, to stop inquiry on incoming SSP */ bool no_inc_ssp; /* true, to stop inquiry on incoming SSP */ bool registered_for_hci_events; void Init() { void Init() { p_remname_cmpl_cb = nullptr; p_remname_cmpl_cb = nullptr; Loading Loading @@ -299,6 +301,7 @@ struct tBTM_INQUIRY_VAR_ST { state = BTM_INQ_INACTIVE_STATE; state = BTM_INQ_INACTIVE_STATE; inq_active = 0; inq_active = 0; no_inc_ssp = BTM_NO_SSP_ON_INQUIRY; no_inc_ssp = BTM_NO_SSP_ON_INQUIRY; registered_for_hci_events = false; } } void Free() { void Free() { alarm_free(remote_name_timer); alarm_free(remote_name_timer); Loading Loading
system/main/shim/hci_layer.cc +0 −1 Original line number Original line Diff line number Diff line Loading @@ -63,7 +63,6 @@ namespace { bool register_event_code(bluetooth::hci::EventCode event_code) { bool register_event_code(bluetooth::hci::EventCode event_code) { switch (event_code) { switch (event_code) { // Inquiry // Inquiry case bluetooth::hci::EventCode::INQUIRY_COMPLETE: case bluetooth::hci::EventCode::INQUIRY_RESULT: case bluetooth::hci::EventCode::INQUIRY_RESULT: case bluetooth::hci::EventCode::INQUIRY_RESULT_WITH_RSSI: case bluetooth::hci::EventCode::INQUIRY_RESULT_WITH_RSSI: case bluetooth::hci::EventCode::EXTENDED_INQUIRY_RESULT: case bluetooth::hci::EventCode::EXTENDED_INQUIRY_RESULT: Loading
system/stack/btm/btm_inq.cc +44 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,8 @@ * * ******************************************************************************/ ******************************************************************************/ #include "hci_error_code.h" #include "neighbor_inquiry.h" #define LOG_TAG "bluetooth" #define LOG_TAG "bluetooth" #include <base/logging.h> #include <base/logging.h> Loading Loading @@ -253,6 +255,7 @@ void SendRemoteNameRequest(const RawAddress& raw_address) { HCI_MANDATARY_PAGE_SCAN_MODE, 0); HCI_MANDATARY_PAGE_SCAN_MODE, 0); } } static void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode); static void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode); static void on_incoming_hci_event(bluetooth::hci::EventView event); /******************************************************************************* /******************************************************************************* * * * Function BTM_SetDiscoverability * Function BTM_SetDiscoverability Loading Loading @@ -635,6 +638,16 @@ tBTM_STATUS BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb, return BTM_BUSY; return BTM_BUSY; } } if (btm_cb.btm_inq_vars.registered_for_hci_events == false) { bluetooth::shim::GetHciLayer()->RegisterEventHandler( bluetooth::hci::EventCode::INQUIRY_COMPLETE, get_main_thread()->Bind([](bluetooth::hci::EventView event) { on_incoming_hci_event(event); })); btm_cb.btm_inq_vars.registered_for_hci_events = true; } /*** Make sure the device is ready ***/ /*** Make sure the device is ready ***/ if (!BTM_IsDeviceUp()) { if (!BTM_IsDeviceUp()) { log::error("adapter is not up"); log::error("adapter is not up"); Loading Loading @@ -2183,6 +2196,37 @@ void btm_set_eir_uuid(const uint8_t* p_eir, tBTM_INQ_RESULTS* p_results) { } } } } static void on_inquiry_complete(bluetooth::hci::EventView event) { auto complete = bluetooth::hci::InquiryCompleteView::Create(event); ASSERT(complete.IsValid()); auto status = to_hci_status_code(static_cast<uint8_t>(complete.GetStatus())); btm_process_inq_complete(status, BTM_BR_INQUIRY_MASK); } /******************************************************************************* * * Function on_incoming_hci_event * * Description This function is called to process events from the HCI layer * * Parameters event - an EventView with the specific event * * Returns None * ******************************************************************************/ static void on_incoming_hci_event(bluetooth::hci::EventView event) { ASSERT(event.IsValid()); auto event_code = event.GetEventCode(); switch (event_code) { case bluetooth::hci::EventCode::INQUIRY_COMPLETE: on_inquiry_complete(event); break; default: LOG_WARN("Dropping unhandled event: %s", bluetooth::hci::EventCodeText(event_code).c_str()); } } namespace bluetooth { namespace bluetooth { namespace legacy { namespace legacy { namespace testing { namespace testing { Loading
system/stack/btm/neighbor_inquiry.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -266,6 +266,8 @@ struct tBTM_INQUIRY_VAR_ST { uint8_t inq_active; /* Bit Mask indicating type of inquiry is active */ uint8_t inq_active; /* Bit Mask indicating type of inquiry is active */ bool no_inc_ssp; /* true, to stop inquiry on incoming SSP */ bool no_inc_ssp; /* true, to stop inquiry on incoming SSP */ bool registered_for_hci_events; void Init() { void Init() { p_remname_cmpl_cb = nullptr; p_remname_cmpl_cb = nullptr; Loading Loading @@ -299,6 +301,7 @@ struct tBTM_INQUIRY_VAR_ST { state = BTM_INQ_INACTIVE_STATE; state = BTM_INQ_INACTIVE_STATE; inq_active = 0; inq_active = 0; no_inc_ssp = BTM_NO_SSP_ON_INQUIRY; no_inc_ssp = BTM_NO_SSP_ON_INQUIRY; registered_for_hci_events = false; } } void Free() { void Free() { alarm_free(remote_name_timer); alarm_free(remote_name_timer); Loading