std::string name, uint32_t numeric_value) {
bt_bdname_t legacy_name{0};
memcpy(legacy_name.name, name.data(), name.length());
- callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_PASSKEY_CONFIRMATION, numeric_value);
+ callback_(ToRawAddress(address.GetAddress()), legacy_name,
+ ((0x1F) << 8) /* COD_UNCLASSIFIED*/,
+ BT_SSP_VARIANT_PASSKEY_CONFIRMATION, numeric_value);
}
void DisplayYesNoDialog(const bluetooth::hci::AddressWithType& address,
std::string name) {
bt_bdname_t legacy_name{0};
memcpy(legacy_name.name, name.data(), name.length());
- callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_CONSENT, 0);
+ callback_(ToRawAddress(address.GetAddress()), legacy_name,
+ ((0x1F) << 8) /* COD_UNCLASSIFIED*/, BT_SSP_VARIANT_CONSENT, 0);
}
void DisplayEnterPasskeyDialog(const bluetooth::hci::AddressWithType& address, std::string name) {
bt_bdname_t legacy_name{0};
memcpy(legacy_name.name, name.data(), name.length());
- callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_PASSKEY_ENTRY, 0);
+ callback_(ToRawAddress(address.GetAddress()), legacy_name,
+ ((0x1F) << 8) /* COD_UNCLASSIFIED*/, BT_SSP_VARIANT_PASSKEY_ENTRY,
+ 0);
}
void DisplayPasskey(const bluetooth::hci::AddressWithType& address, std::string name, uint32_t passkey) {
bt_bdname_t legacy_name{0};
memcpy(legacy_name.name, name.data(), name.length());
- callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_PASSKEY_NOTIFICATION, passkey);
+ callback_(ToRawAddress(address.GetAddress()), legacy_name,
+ ((0x1F) << 8) /* COD_UNCLASSIFIED*/,
+ BT_SSP_VARIANT_PASSKEY_NOTIFICATION, passkey);
}
void SetLegacyCallback(std::function<void(RawAddress, bt_bdname_t, uint32_t, bt_ssp_variant_t, uint32_t)> callback) {
bond_state_none_cb_ = bond_state_none_cb;
}
void OnDeviceBonded(bluetooth::hci::AddressWithType device) {
- bond_state_bonded_cb_(RawAddress(device.GetAddress().address));
+ bond_state_bonded_cb_(ToRawAddress(device.GetAddress()));
}
void OnDeviceUnbonded(bluetooth::hci::AddressWithType device) {
- bond_state_none_cb_(RawAddress(device.GetAddress().address));
+ bond_state_none_cb_(ToRawAddress(device.GetAddress()));
}
void OnDeviceBondFailed(bluetooth::hci::AddressWithType device) {
- bond_state_none_cb_(RawAddress(device.GetAddress().address));
+ bond_state_none_cb_(ToRawAddress(device.GetAddress()));
}
std::function<void(RawAddress)> bond_state_bonding_cb_;
bluetooth::hci::InquiryResultView view) {
for (auto& response : view.GetInquiryResults()) {
btm_api_process_inquiry_result(
- RawAddress(response.bd_addr_.address),
+ ToRawAddress(response.bd_addr_),
static_cast<uint8_t>(response.page_scan_repetition_mode_),
response.class_of_device_.cod, response.clock_offset_);
}
bluetooth::hci::InquiryResultWithRssiView view) {
for (auto& response : view.GetInquiryResults()) {
btm_api_process_inquiry_result_with_rssi(
- RawAddress(response.address_.address),
+ ToRawAddress(response.address_),
static_cast<uint8_t>(response.page_scan_repetition_mode_),
response.class_of_device_.cod, response.clock_offset_, response.rssi_);
}
}
btm_api_process_extended_inquiry_result(
- RawAddress(view.GetAddress().address),
+ ToRawAddress(view.GetAddress()),
static_cast<uint8_t>(view.GetPageScanRepetitionMode()),
view.GetClassOfDevice().cod, view.GetClockOffset(), view.GetRssi(), data,
data_len);
LOG_DEBUG("%s Start read name from address:%s", __func__,
raw_address.ToString().c_str());
bluetooth::shim::GetName()->ReadRemoteNameRequest(
- hci::Address(raw_address.address), hci::PageScanRepetitionMode::R1,
+ ToGdAddress(raw_address), hci::PageScanRepetitionMode::R1,
0 /* clock_offset */, hci::ClockOffsetValid::INVALID,
base::Bind(
[](tBTM_CMPL_CB* callback, ReadRemoteName* classic_read_remote_name_,
hci::ErrorCode status, hci::Address address,
std::array<uint8_t, kRemoteDeviceNameLength> remote_name) {
- RawAddress raw_address(address.address);
+ RawAddress raw_address = ToRawAddress(address);
BtmRemoteDeviceName name{
.status = (static_cast<uint8_t>(status) == 0)
return;
}
- RawAddress raw_address(le_report->address_.address);
+ RawAddress raw_address = ToRawAddress(le_report->address_);
btm_ble_process_adv_addr(raw_address, &address_type);
btm_ble_process_adv_pkt_cont(
.legacy = false,
.continuing = !extended_le_report->complete_,
.truncated = extended_le_report->truncated_});
- RawAddress raw_address(le_report->address_.address);
+ RawAddress raw_address = ToRawAddress(le_report->address_);
if (address_type != BLE_ADDR_ANONYMOUS) {
btm_ble_process_adv_addr(raw_address, &address_type);
}
bluetooth::shim::GetSecurityModule()->GetSecurityManager();
switch (transport) {
case BT_TRANSPORT_BR_EDR:
- security_manager->CreateBond(
- ToAddressWithType(bd_addr.address, BLE_ADDR_PUBLIC));
+ security_manager->CreateBond(ToAddressWithType(bd_addr, BLE_ADDR_PUBLIC));
break;
case BT_TRANSPORT_LE:
security_manager->CreateBondLe(ToAddressWithType(bd_addr, addr_type));
namespace bluetooth {
+inline RawAddress ToRawAddress(const hci::Address& address) {
+ RawAddress ret;
+ ret.address[0] = address.address[5];
+ ret.address[1] = address.address[4];
+ ret.address[2] = address.address[3];
+ ret.address[3] = address.address[2];
+ ret.address[4] = address.address[1];
+ ret.address[5] = address.address[0];
+ return ret;
+}
+
+inline hci::Address ToGdAddress(const RawAddress& address) {
+ hci::Address ret;
+ ret.address[0] = address.address[5];
+ ret.address[1] = address.address[4];
+ ret.address[2] = address.address[3];
+ ret.address[3] = address.address[2];
+ ret.address[4] = address.address[1];
+ ret.address[5] = address.address[0];
+ return ret;
+}
+
inline hci::AddressWithType ToAddressWithType(const RawAddress& legacy_address,
tBLE_ADDR_TYPE legacy_type) {
- // Address and RawAddress are binary equivalent;
- hci::Address address(legacy_address.address);
+ hci::Address address = ToGdAddress(legacy_address);
hci::AddressType type;
if (legacy_type == BLE_ADDR_PUBLIC)
return hci::AddressWithType{address, type};
}
-} // namespace bluetooth
\ No newline at end of file
+} // namespace bluetooth