From 0e7ac98e43444fea6d44e4d75a350b02a01ed4bd Mon Sep 17 00:00:00 2001 From: Lasan Mahaliyana Date: Wed, 11 Mar 2026 22:51:52 +0530 Subject: [PATCH] implemented rssi and txpower reporting for bluetooth device --- .../linux/bluetooth_classic_device.cc | 24 +++++++++++++++++++ .../linux/bluetooth_classic_device.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/internal/platform/implementation/linux/bluetooth_classic_device.cc b/internal/platform/implementation/linux/bluetooth_classic_device.cc index 1b8dd78e..b74dce6b 100644 --- a/internal/platform/implementation/linux/bluetooth_classic_device.cc +++ b/internal/platform/implementation/linux/bluetooth_classic_device.cc @@ -99,6 +99,30 @@ std::string BluetoothDevice::GetAddressType() const { } } +std::optional BluetoothDevice::GetRssi() const { + auto device = device_; + if (device == nullptr) return std::nullopt; + + try { + return device->RSSI(); + } catch (const sdbus::Error& e) { + DBUS_LOG_PROPERTY_GET_ERROR(device, "RSSI", e); + return std::nullopt; + } +} + +std::optional BluetoothDevice::GetTxPower() const { + auto device = device_; + if (device == nullptr) return std::nullopt; + + try { + return device->TxPower(); + } catch (const sdbus::Error& e) { + DBUS_LOG_PROPERTY_GET_ERROR(device, "TxPower", e); + return std::nullopt; + } +} + bool BluetoothDevice::ConnectToProfile(absl::string_view service_uuid) { auto device = device_; if (device == nullptr) return false; diff --git a/internal/platform/implementation/linux/bluetooth_classic_device.h b/internal/platform/implementation/linux/bluetooth_classic_device.h index 03db8bf7..cd0aef92 100644 --- a/internal/platform/implementation/linux/bluetooth_classic_device.h +++ b/internal/platform/implementation/linux/bluetooth_classic_device.h @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -53,6 +54,8 @@ class BluetoothDevice : public api::BluetoothDevice { std::string GetName() const override; MacAddress GetMacAddress() const override; std::string GetAddressType() const; + std::optional GetRssi() const; + std::optional GetTxPower() const; MacAddress GetAddress() const { return last_known_address_; }