mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Enabled BLE advertisements with extended + GATT server.
This commit is contained in:
@@ -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<std::string, sdbus::Variant> 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__
|
||||
|
||||
@@ -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<uint8_t>(service_id_data[3] & 0xFF),
|
||||
static_cast<uint8_t>(service_id_data[2] & 0xFF)}}};
|
||||
static_cast<uint8_t>(service_id_data[2] & 0xFF)}
|
||||
}};
|
||||
};
|
||||
|
||||
std::shared_ptr<BluetoothDevices> devices_;
|
||||
|
||||
@@ -51,8 +51,10 @@ class RootObjectManager final
|
||||
: public sdbus::AdaptorInterfaces<sdbus::ObjectManager_adaptor,
|
||||
sdbus::Properties_adaptor> {
|
||||
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(); }
|
||||
|
||||
Reference in New Issue
Block a user