RANDOM_IDENTITY_ADDRESS = 0x3;
}
+enum BluetoothOwnAddressTypeEnum {
+ USE_PUBLIC_DEVICE_ADDRESS = 0x0;
+ USE_RANDOM_DEVICE_ADDRESS = 0x1;
+ RESOLVABLE_OR_PUBLIC_ADDRESS = 0x2;
+ RESOLVABLE_OR_RANDOM_ADDRESS = 0x3;
+}
+
message BluetoothAddressWithType {
BluetoothAddress address = 1;
BluetoothAddressTypeEnum type = 2;
advertisement=[gap_data],
interval_min=512,
interval_max=768,
- event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
- address_type=common.RANDOM_DEVICE_ADDRESS,
+ advertising_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
+ own_address_type=common.USE_RANDOM_DEVICE_ADDRESS,
peer_address_type=common.PUBLIC_DEVICE_OR_IDENTITY_ADDRESS,
peer_address=common.BluetoothAddress(address=bytes(b'A6:A5:A4:A3:A2:A1')),
channel_map=7,
advertisement=[gap_data],
interval_min=512,
interval_max=768,
- event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
- address_type=common.RANDOM_DEVICE_ADDRESS,
+ advertising_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
+ own_address_type=common.USE_RANDOM_DEVICE_ADDRESS,
channel_map=7,
filter_policy=le_advertising_facade.AdvertisingFilterPolicy.ALL_DEVICES)
request = le_advertising_facade.CreateAdvertiserRequest(config=config)
advertisement=[gap_data],
interval_min=512,
interval_max=768,
- event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
- address_type=common.RANDOM_DEVICE_ADDRESS,
+ advertising_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
+ own_address_type=common.USE_RANDOM_DEVICE_ADDRESS,
channel_map=7,
filter_policy=le_advertising_facade.AdvertisingFilterPolicy.ALL_DEVICES)
request = le_advertising_facade.CreateAdvertiserRequest(config=config)
advertisement=[gap_data],
interval_min=512,
interval_max=768,
- event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
- address_type=common.RANDOM_DEVICE_ADDRESS,
+ advertising_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
+ own_address_type=common.USE_RANDOM_DEVICE_ADDRESS,
channel_map=7,
filter_policy=le_advertising_facade.AdvertisingFilterPolicy.ALL_DEVICES)
request = le_advertising_facade.CreateAdvertiserRequest(config=config)
}
config->interval_max = static_cast<uint16_t>(config_proto.interval_max());
- config->event_type = static_cast<hci::AdvertisingType>(config_proto.event_type());
+ config->advertising_type = static_cast<hci::AdvertisingType>(config_proto.advertising_type());
- config->address_type = static_cast<::bluetooth::hci::AddressType>(config_proto.address_type());
+ config->own_address_type = static_cast<::bluetooth::hci::OwnAddressType>(config_proto.own_address_type());
config->peer_address_type = static_cast<::bluetooth::hci::PeerAddressType>(config_proto.peer_address_type());
int32 interval_min = 4;
// Unit: number of Bluetooth slots in 0.125 ms increment
int32 interval_max = 5;
- AdvertisingEventType event_type = 6;
- bluetooth.facade.BluetoothAddressTypeEnum address_type = 7;
+ AdvertisingEventType advertising_type = 6;
+ bluetooth.facade.BluetoothOwnAddressTypeEnum own_address_type = 7;
bluetooth.facade.BluetoothPeerAddressTypeEnum peer_address_type = 8;
bluetooth.facade.BluetoothAddress peer_address = 9;
int32 channel_map = 10;
RANDOM_IDENTITY_ADDRESS = 0x03,
}
+enum OwnAddressType : 8 {
+ PUBLIC_DEVICE_ADDRESS = 0x00,
+ RANDOM_DEVICE_ADDRESS = 0x01,
+ RESOLVABLE_OR_PUBLIC_ADDRESS = 0x02,
+ RESOLVABLE_OR_RANDOM_ADDRESS = 0x03,
+}
+
packet LeSetAdvertisingParameters : LeAdvertisingCommand (op_code = LE_SET_ADVERTISING_PARAMETERS) {
interval_min : 16,
interval_max : 16,
type : AdvertisingType,
- own_address_type : AddressType,
+ own_address_type : OwnAddressType,
peer_address_type : PeerAddressType,
peer_address : Address,
channel_map : 8,
CONNECT_LIST_AND_INITIATORS_IDENTITY = 0x03,
}
-enum OwnAddressType : 8 {
- PUBLIC_DEVICE_ADDRESS = 0x00,
- RANDOM_DEVICE_ADDRESS = 0x01,
- RESOLVABLE_OR_PUBLIC_ADDRESS = 0x02,
- RESOLVABLE_OR_RANDOM_ADDRESS = 0x03,
-}
-
packet LeSetScanParameters : LeScanningCommand (op_code = LE_SET_SCAN_PARAMETERS) {
le_scan_type : LeScanType,
le_scan_interval : 16, // 0x0004-0x4000 Default 0x10 (10ms)
interval_min : 16,
interval_max : 16,
type : AdvertisingType,
- own_address_type : AddressType,
+ own_address_type : OwnAddressType,
peer_address_type : PeerAddressType,
peer_address : Address,
channel_map : 8,
};
ExtendedAdvertisingConfig::ExtendedAdvertisingConfig(const AdvertisingConfig& config) : AdvertisingConfig(config) {
- switch (config.event_type) {
+ switch (config.advertising_type) {
case AdvertisingType::ADV_IND:
connectable = true;
scannable = true;
LOG_WARN("Unknown event type");
break;
}
- if (config.address_type == AddressType::PUBLIC_DEVICE_ADDRESS) {
- own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS;
- } else if (config.address_type == AddressType::RANDOM_DEVICE_ADDRESS) {
- own_address_type = OwnAddressType::RANDOM_DEVICE_ADDRESS;
- }
- // TODO(b/149221472): Support fragmentation
- operation = Operation::COMPLETE_ADVERTISEMENT;
}
struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallback {
hci::LeSetAdvertisingParametersBuilder::Create(
config.interval_min,
config.interval_max,
- config.event_type,
- config.address_type,
+ config.advertising_type,
+ config.own_address_type,
config.peer_address_type,
config.peer_address,
config.channel_map,
hci::LeMultiAdvtParamBuilder::Create(
config.interval_min,
config.interval_max,
- config.event_type,
- config.address_type,
+ config.advertising_type,
+ config.own_address_type,
config.peer_address_type,
config.peer_address,
config.channel_map,
advertising_sets_[id].current_address =
AddressWithType(controller_->GetMacAddress(), AddressType::PUBLIC_DEVICE_ADDRESS);
}
+
+ // TODO(b/149221472): Support fragmentation
+ auto operation = Operation::COMPLETE_ADVERTISEMENT;
if (!config.scan_response.empty()) {
le_advertising_interface_->EnqueueCommand(
- hci::LeSetExtendedAdvertisingScanResponseBuilder::Create(id, config.operation, config.fragment_preference,
- config.scan_response),
+ hci::LeSetExtendedAdvertisingScanResponseBuilder::Create(
+ id, operation, kFragment_preference, config.scan_response),
module_handler_->BindOnce(impl::check_status<LeSetExtendedAdvertisingScanResponseCompleteView>));
}
le_advertising_interface_->EnqueueCommand(
- hci::LeSetExtendedAdvertisingDataBuilder::Create(id, config.operation, config.fragment_preference,
- config.advertisement),
+ hci::LeSetExtendedAdvertisingDataBuilder::Create(id, operation, kFragment_preference, config.advertisement),
module_handler_->BindOnce(impl::check_status<LeSetExtendedAdvertisingDataCompleteView>));
EnabledSet curr_set;
case (AdvertisingApiType::EXTENDED): {
// TODO(b/149221472): Support fragmentation
auto operation = Operation::COMPLETE_ADVERTISEMENT;
- auto fragment_preference = FragmentPreference::CONTROLLER_SHOULD_NOT;
if (set_scan_rsp) {
le_advertising_interface_->EnqueueCommand(
hci::LeSetExtendedAdvertisingScanResponseBuilder::Create(
- advertiser_id, operation, fragment_preference, data),
+ advertiser_id, operation, kFragment_preference, data),
module_handler_->BindOnceOn(
this, &impl::check_status_with_id<LeSetExtendedAdvertisingScanResponseCompleteView>, advertiser_id));
} else {
le_advertising_interface_->EnqueueCommand(
- hci::LeSetExtendedAdvertisingDataBuilder::Create(advertiser_id, operation, fragment_preference, data),
+ hci::LeSetExtendedAdvertisingDataBuilder::Create(advertiser_id, operation, kFragment_preference, data),
module_handler_->BindOnceOn(
this, &impl::check_status_with_id<LeSetExtendedAdvertisingDataCompleteView>, advertiser_id));
}
const AdvertisingConfig& config, const common::Callback<void(Address, AddressType)>& scan_callback,
const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler) {
if (config.peer_address == Address::kEmpty) {
- if (config.address_type == hci::AddressType::PUBLIC_IDENTITY_ADDRESS ||
- config.address_type == hci::AddressType::RANDOM_IDENTITY_ADDRESS) {
+ if (config.own_address_type == hci::OwnAddressType::RESOLVABLE_OR_PUBLIC_ADDRESS ||
+ config.own_address_type == hci::OwnAddressType::RESOLVABLE_OR_RANDOM_ADDRESS) {
LOG_WARN("Peer address can not be empty");
return kInvalidId;
}
- if (config.event_type == hci::AdvertisingType::ADV_DIRECT_IND ||
- config.event_type == hci::AdvertisingType::ADV_DIRECT_IND_LOW) {
+ if (config.advertising_type == hci::AdvertisingType::ADV_DIRECT_IND ||
+ config.advertising_type == hci::AdvertisingType::ADV_DIRECT_IND_LOW) {
LOG_WARN("Peer address can not be empty for directed advertising");
return kInvalidId;
}
std::vector<GapData> scan_response;
uint16_t interval_min;
uint16_t interval_max;
- AdvertisingType event_type;
- AddressType address_type;
+ AdvertisingType advertising_type;
+ OwnAddressType own_address_type;
PeerAddressType peer_address_type;
Address peer_address;
uint8_t channel_map;
SecondaryPhyType secondary_advertising_phy;
uint8_t sid = 0x00;
Enable enable_scan_request_notifications = Enable::DISABLED;
- OwnAddressType own_address_type;
- Operation operation; // TODO(b/149221472): Support fragmentation
- FragmentPreference fragment_preference = FragmentPreference::CONTROLLER_SHOULD_NOT;
ExtendedAdvertisingConfig() = default;
ExtendedAdvertisingConfig(const AdvertisingConfig& config);
};
static constexpr AdvertiserId kInvalidId = 0xFF;
static constexpr uint8_t kInvalidHandle = 0xFF;
static constexpr uint8_t kAdvertisingSetIdMask = 0x0F;
+ static constexpr FragmentPreference kFragment_preference = FragmentPreference::CONTROLLER_SHOULD_NOT;
LeAdvertisingManager();
size_t GetNumberOfAdvertisingInstances() const;
// start advertising set
ExtendedAdvertisingConfig advertising_config{};
- advertising_config.event_type = AdvertisingType::ADV_IND;
- advertising_config.address_type = AddressType::PUBLIC_DEVICE_ADDRESS;
+ advertising_config.advertising_type = AdvertisingType::ADV_IND;
+ advertising_config.own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS;
std::vector<GapData> gap_data{};
GapData data_item{};
data_item.data_type_ = GapDataType::FLAGS;
TEST_F(LeAdvertisingManagerTest, create_advertiser_test) {
AdvertisingConfig advertising_config{};
- advertising_config.event_type = AdvertisingType::ADV_IND;
- advertising_config.address_type = AddressType::PUBLIC_DEVICE_ADDRESS;
+ advertising_config.advertising_type = AdvertisingType::ADV_IND;
+ advertising_config.own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS;
std::vector<GapData> gap_data{};
GapData data_item{};
data_item.data_type_ = GapDataType::FLAGS;
TEST_F(LeAndroidHciAdvertisingManagerTest, create_advertiser_test) {
AdvertisingConfig advertising_config{};
- advertising_config.event_type = AdvertisingType::ADV_IND;
- advertising_config.address_type = AddressType::PUBLIC_DEVICE_ADDRESS;
+ advertising_config.advertising_type = AdvertisingType::ADV_IND;
+ advertising_config.own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS;
std::vector<GapData> gap_data{};
GapData data_item{};
data_item.data_type_ = GapDataType::FLAGS;
TEST_F(LeExtendedAdvertisingManagerTest, create_advertiser_test) {
ExtendedAdvertisingConfig advertising_config{};
- advertising_config.event_type = AdvertisingType::ADV_IND;
- advertising_config.address_type = AddressType::PUBLIC_DEVICE_ADDRESS;
+ advertising_config.advertising_type = AdvertisingType::ADV_IND;
+ advertising_config.own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS;
std::vector<GapData> gap_data{};
GapData data_item{};
data_item.data_type_ = GapDataType::FLAGS;
TEST_F(LeExtendedAdvertisingAPITest, set_parameter) {
ExtendedAdvertisingConfig advertising_config{};
- advertising_config.event_type = AdvertisingType::ADV_IND;
- advertising_config.address_type = AddressType::PUBLIC_DEVICE_ADDRESS;
+ advertising_config.advertising_type = AdvertisingType::ADV_IND;
+ advertising_config.own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS;
std::vector<GapData> gap_data{};
GapData data_item{};
data_item.data_type_ = GapDataType::COMPLETE_LOCAL_NAME;
advertisement=[gap_data],
interval_min=512,
interval_max=768,
- event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
- address_type=common.RANDOM_DEVICE_ADDRESS,
+ advertising_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
+ own_address_type=common.USE_RANDOM_DEVICE_ADDRESS,
channel_map=7,
filter_policy=le_advertising_facade.AdvertisingFilterPolicy.ALL_DEVICES)
request = le_advertising_facade.CreateAdvertiserRequest(config=config)
advertisement=[gap_data],
interval_min=512,
interval_max=768,
- event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
- address_type=common.RANDOM_DEVICE_ADDRESS,
+ advertising_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
+ own_address_type=common.USE_RANDOM_DEVICE_ADDRESS,
channel_map=7,
filter_policy=le_advertising_facade.AdvertisingFilterPolicy.ALL_DEVICES)
request = le_advertising_facade.CreateAdvertiserRequest(config=config)
advertisement=[gap_data],
interval_min=512,
interval_max=768,
- event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
- address_type=common.RANDOM_DEVICE_ADDRESS,
+ advertising_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
+ own_address_type=common.USE_RANDOM_DEVICE_ADDRESS,
channel_map=7,
filter_policy=le_advertising_facade.AdvertisingFilterPolicy.ALL_DEVICES)
request = le_advertising_facade.CreateAdvertiserRequest(config=config)
advertisement=[gap_data],
interval_min=512,
interval_max=768,
- event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
- address_type=self.cert_address.type,
+ advertising_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
+ own_address_type=common.USE_PUBLIC_DEVICE_ADDRESS,
channel_map=7,
filter_policy=le_advertising_facade.AdvertisingFilterPolicy.ALL_DEVICES)
request = le_advertising_facade.CreateAdvertiserRequest(config=config)
advertisement=[gap_data],
interval_min=512,
interval_max=768,
- event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
- address_type=self.dut_address.type,
+ advertising_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
+ own_address_type=common.USE_PUBLIC_DEVICE_ADDRESS,
channel_map=7,
filter_policy=le_advertising_facade.AdvertisingFilterPolicy.ALL_DEVICES)
request = le_advertising_facade.CreateAdvertiserRequest(config=config)
offset += len + 1; // 1 byte for len
}
- config.operation = bluetooth::hci::Operation::COMPLETE_ADVERTISEMENT;
-
bluetooth::hci::AdvertiserId id =
bluetooth::shim::GetAdvertising()->ExtendedCreateAdvertiser(
reg_id, config, scan_callback, set_terminated_callback,