#include "stack/include/btm_ble_api.h"
const bt_event_mask_t BLE_EVENT_MASK = {
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x7f}};
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x7f}};
const bt_event_mask_t CLASSIC_EVENT_MASK = {HCI_DUMO_EVENT_MASK_EXT};
}
void SetAdvertisingEventObserver(
- AdvertisingEventObserver* observer) override {}
+ AdvertisingEventObserver* observer) override {
+ this->advertising_event_observer = observer;
+ }
void SetParameters(uint8_t adv_int_min, uint8_t adv_int_max,
uint8_t advertising_type, uint8_t own_address_type,
SendAdvCmd(HCI_LE_SET_EXT_ADVERTISING_ENABLE, param, cmd_length,
command_complete);
}
+
+ public:
+ void OnAdvertisingSetTerminated(uint8_t length, uint8_t* p) {
+ VLOG(1) << __func__;
+ LOG_ASSERT(p);
+ uint8_t status, advertising_handle, num_completed_adv_evt;
+ uint16_t conn_handle;
+
+ STREAM_TO_UINT8(status, p);
+ STREAM_TO_UINT8(advertising_handle, p);
+ STREAM_TO_UINT16(conn_handle, p);
+ STREAM_TO_UINT8(num_completed_adv_evt, p);
+
+ conn_handle = conn_handle & 0x0FFF; // only 12 bits meaningful
+
+ AdvertisingEventObserver* observer = this->advertising_event_observer;
+ if (observer)
+ observer->OnAdvertisingStateChanged(advertising_handle, 0x00,
+ conn_handle);
+ }
+
+ private:
+ AdvertisingEventObserver* advertising_event_observer = nullptr;
};
} // namespace
+void btm_le_on_advertising_set_terminated(uint8_t* p, uint16_t length) {
+ if (BleAdvertiserHciInterface::Get()) {
+ ((BleAdvertiserHciExtendedImpl*)BleAdvertiserHciInterface::Get())
+ ->OnAdvertisingSetTerminated(length, p);
+ }
+}
+
void BleAdvertiserHciInterface::Initialize() {
VLOG(1) << __func__;
LOG_ASSERT(instance == nullptr) << "Was already initialized.";
extern void btm_ble_set_conn_st(tBTM_BLE_CONN_ST new_st);
extern tBTM_STATUS btm_ble_start_adv(void);
extern tBTM_STATUS btm_ble_stop_adv(void);
+extern void btm_le_on_advertising_set_terminated(uint8_t* p, uint16_t length);
extern tBTM_STATUS btm_ble_start_scan(void);
extern void btm_ble_create_ll_conn_complete(uint8_t status);
void OnAdvertisingStateChanged(uint8_t inst_id, uint8_t reason,
uint16_t conn_handle) override {
AdvertisingInstance* p_inst = &adv_inst[inst_id];
- VLOG(1) << __func__ << " inst_id: 0x" << std::hex << inst_id
- << ", reason: 0x" << std::hex << reason << ", conn_handle: 0x"
- << std::hex << conn_handle;
+ VLOG(1) << __func__ << " inst_id: 0x" << std::hex << +inst_id
+ << ", reason: 0x" << std::hex << +reason << ", conn_handle: 0x"
+ << std::hex << +conn_handle;
#if (BLE_PRIVACY_SPT == TRUE)
if (BTM_BleLocalPrivacyEnabled() && inst_id <= BTM_BLE_MULTI_ADV_MAX) {
case HCI_BLE_DATA_LENGTH_CHANGE_EVT:
btu_ble_data_length_change_evt(p, hci_evt_len);
break;
+
+ case HCI_LE_ADVERTISING_SET_TERMINATED_EVT:
+ btm_le_on_advertising_set_terminated(p, hci_evt_len);
+ break;
}
break;
case HCI_VENDOR_SPECIFIC_EVT:
#define HCI_BLE_DATA_LENGTH_CHANGE_EVT 0x07
#define HCI_BLE_ENHANCED_CONN_COMPLETE_EVT 0x0a
#define HCI_BLE_DIRECT_ADV_EVT 0x0b
+#define HCI_LE_ADVERTISING_SET_TERMINATED_EVT 0x12
/* Definitions for LE Channel Map */
#define HCI_BLE_CHNL_MAP_SIZE 5