mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
upstream changes applied to linux impl
This commit is contained in:
@@ -69,7 +69,7 @@ std::shared_ptr<BluetoothDevice> BluetoothDevices::get_device_by_path(
|
||||
return devices_by_path_[device_object_path];
|
||||
}
|
||||
std::shared_ptr<BluetoothDevice> BluetoothDevices::get_device_by_unique_id(
|
||||
api::ble_v2::BlePeripheral::UniqueId id)
|
||||
api::ble::BlePeripheral::UniqueId id)
|
||||
{
|
||||
// converting from stoull to mac again
|
||||
id &= 0x0000FFFFFFFFFFFFULL; // keep 48 bits
|
||||
@@ -77,17 +77,22 @@ std::shared_ptr<BluetoothDevice> BluetoothDevices::get_device_by_unique_id(
|
||||
oss << std::hex << std::setfill('0') << std::setw(12) << id;
|
||||
std::string hex = oss.str(); // e.g. "aabbccddeeff"
|
||||
|
||||
std::string mac;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (i) mac.push_back(':');
|
||||
mac.append(hex.substr(i * 2, 2));
|
||||
MacAddress addr;
|
||||
{
|
||||
std::string mac;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (i) mac.push_back(':');
|
||||
mac.append(hex.substr(i * 2, 2));
|
||||
}
|
||||
MacAddress::FromString(mac, addr);
|
||||
}
|
||||
return get_device_by_address(mac);
|
||||
|
||||
return get_device_by_address(addr);
|
||||
}
|
||||
std::shared_ptr<BluetoothDevice> BluetoothDevices::get_device_by_address(
|
||||
const std::string &addr) {
|
||||
const MacAddress &addr) {
|
||||
auto device_object_path =
|
||||
bluez::device_object_path(adapter_object_path_, addr);
|
||||
bluez::device_object_path(adapter_object_path_, addr.ToString());
|
||||
return get_device_by_path(device_object_path);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user