From 3d97a540b55703a6df6b78c3269b598dd007e004 Mon Sep 17 00:00:00 2001 From: kidfromjupiter Date: Sat, 10 Jan 2026 11:23:19 +0000 Subject: [PATCH] Enabled BLE advertisements with extended + GATT server. --- internal/platform/implementation/linux/ble_v2_medium.cc | 9 +++++++-- .../implementation/linux/bluez_advertisement_monitor.h | 8 +++++--- internal/platform/implementation/linux/dbus.h | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/internal/platform/implementation/linux/ble_v2_medium.cc b/internal/platform/implementation/linux/ble_v2_medium.cc index a6d86523..bf1b082f 100644 --- a/internal/platform/implementation/linux/ble_v2_medium.cc +++ b/internal/platform/implementation/linux/ble_v2_medium.cc @@ -53,10 +53,10 @@ BleV2Medium::BleV2Medium(BluetoothAdapter &adapter) if (adv_monitor_manager_) { LOG(INFO) << __func__ - << ": Registering path / with AdvertisementMonitorManager at " + << ": Registering path /com/google/nearby/medium/ble/advertisement/monitor with AdvertisementMonitorManager at " << adv_monitor_manager_->getObjectPath(); try { - adv_monitor_manager_->RegisterMonitor("/"); + adv_monitor_manager_->RegisterMonitor("/com/google/nearby/medium/ble/advertisement/monitor"); } catch (const sdbus::Error &e) { DBUS_LOG_METHOD_CALL_ERROR(adv_monitor_manager_, "RegisterMonitor", e); } @@ -251,6 +251,7 @@ bool BleV2Medium::IsExtendedAdvertisementsAvailable() { bool BleV2Medium::StartLEDiscovery() { std::map filter; filter["Transport"] = "auto"; + filter["DuplicateData"] = true; auto &adapter = adapter_.GetBluezAdapterObject(); try { @@ -310,8 +311,12 @@ bool BleV2Medium::StartScanning(const Uuid &service_uuid, *system_bus_, service_uuid, tx_power_level, "or_patterns", devices_, std::move(callback)); try { + // why is this emitted? monitor->emitInterfacesAddedSignal( {org::bluez::AdvertisementMonitor1_adaptor::INTERFACE_NAME}); + + // adv_monitor_manager_ -> RegisterMonitor(monitor -> getObjectPath()); + LOG(INFO)<< __func__ << ": Registered advertisement monitor with path " << monitor -> getObjectPath(); } catch (const sdbus::Error &e) { LOG(ERROR) << __func__ diff --git a/internal/platform/implementation/linux/bluez_advertisement_monitor.h b/internal/platform/implementation/linux/bluez_advertisement_monitor.h index 24e57696..ea251f85 100644 --- a/internal/platform/implementation/linux/bluez_advertisement_monitor.h +++ b/internal/platform/implementation/linux/bluez_advertisement_monitor.h @@ -53,6 +53,7 @@ class AdvertisementMonitor final // Methods void Release() override {} void Activate() override { + LOG(INFO) <<__func__ << ": bluez advertisement monitor activated at path: " << getObjectPath(); if (start_scanning_result_callback_ != nullptr) { start_scanning_result_callback_(absl::OkStatus()); } @@ -63,9 +64,9 @@ class AdvertisementMonitor final // Properties std::string Type() override { return type_; }; - int16_t RSSILowThreshold() override { return 0; }; + int16_t RSSILowThreshold() override { return 127; }; int16_t RSSIHighThreshold() override { - return bluez::TxPowerLevelDbm(tx_power_level_); + return 127; } uint16_t RSSISamplingPeriod() override { // The Windows implementation uses a sampling interval of 2 seconds. @@ -77,7 +78,8 @@ class AdvertisementMonitor final return {{0, 0x16, {static_cast(service_id_data[3] & 0xFF), - static_cast(service_id_data[2] & 0xFF)}}}; + static_cast(service_id_data[2] & 0xFF)} + }}; }; std::shared_ptr devices_; diff --git a/internal/platform/implementation/linux/dbus.h b/internal/platform/implementation/linux/dbus.h index c0dfae9f..18e7ca4f 100644 --- a/internal/platform/implementation/linux/dbus.h +++ b/internal/platform/implementation/linux/dbus.h @@ -51,8 +51,10 @@ class RootObjectManager final : public sdbus::AdaptorInterfaces { public: + // only used in ble advertisement monitoring for now. + // TODO: Remove hardcodinged va explicit RootObjectManager(sdbus::IConnection &system_bus) - : AdaptorInterfaces(system_bus, "/") { + : AdaptorInterfaces(system_bus, "/com/google/nearby/medium/ble/advertisement/monitor") { registerAdaptor(); } ~RootObjectManager() { unregisterAdaptor(); }