mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
implemented rssi and txpower reporting for bluetooth device
This commit is contained in:
@@ -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_; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user