implemented rssi and txpower reporting for bluetooth device

This commit is contained in:
Lasan Mahaliyana
2026-03-11 22:51:52 +05:30
parent b64b1bb186
commit 0e7ac98e43
2 changed files with 27 additions and 0 deletions
@@ -99,6 +99,30 @@ std::string BluetoothDevice::GetAddressType() const {
}
}
std::optional<int16_t> 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<int16_t> 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;
@@ -17,6 +17,7 @@
#include <atomic>
#include <memory>
#include <optional>
#include <sdbus-c++/Error.h>
#include <sdbus-c++/IConnection.h>
@@ -53,6 +54,8 @@ class BluetoothDevice : public api::BluetoothDevice {
std::string GetName() const override;
MacAddress GetMacAddress() const override;
std::string GetAddressType() const;
std::optional<int16_t> GetRssi() const;
std::optional<int16_t> GetTxPower() const;
MacAddress GetAddress() const { return last_known_address_; }