diff --git a/internal/platform/implementation/windows/ble_v2.cc b/internal/platform/implementation/windows/ble_v2.cc index afe45ecc..eb607be1 100644 --- a/internal/platform/implementation/windows/ble_v2.cc +++ b/internal/platform/implementation/windows/ble_v2.cc @@ -47,6 +47,7 @@ #include "winrt/Windows.Devices.Bluetooth.Advertisement.h" #include "winrt/Windows.Devices.Bluetooth.h" #include "winrt/Windows.Foundation.Collections.h" +#include "winrt/Windows.Storage.Streams.h" // NOLINT(misc-include-cleaner) namespace nearby { namespace windows { @@ -68,6 +69,8 @@ using ::winrt::Windows::Devices::Bluetooth::Advertisement:: BluetoothLEAdvertisementDataSection; using ::winrt::Windows::Devices::Bluetooth::Advertisement:: BluetoothLEAdvertisementDataTypes; +using ::winrt::Windows::Devices::Bluetooth::Advertisement:: + BluetoothLEAdvertisementFilter; // NOLINT(misc-include-cleaner) using ::winrt::Windows::Devices::Bluetooth::Advertisement:: BluetoothLEAdvertisementPublisher; using ::winrt::Windows::Devices::Bluetooth::Advertisement:: @@ -230,9 +233,19 @@ bool BleV2Medium::StartScanning(const Uuid& service_uuid, // Active mode indicates that scan request packets will be sent to query for // Scan Response watcher_.ScanningMode(BluetoothLEScanningMode::Active); - ::winrt::Windows::Devices::Bluetooth::BluetoothSignalStrengthFilter filter; - filter.SamplingInterval(TimeSpan(std::chrono::seconds(2))); - watcher_.SignalStrengthFilter(filter); + + BluetoothLEAdvertisementDataSection data_section; + data_section.DataType(0x16); + DataWriter data_writer; // NOLINT(misc-include-cleaner) + std::array service_id_data = service_uuid_.data(); + data_writer.WriteByte(service_id_data[3] & 0xff); + data_writer.WriteByte(service_id_data[2] & 0xff); + data_section.Data(data_writer.DetachBuffer()); + BluetoothLEAdvertisement advertisement; + advertisement.DataSections().Append(data_section); + BluetoothLEAdvertisementFilter advertisement_filter; + advertisement_filter.Advertisement(advertisement); + watcher_.AdvertisementFilter(advertisement_filter); watcher_.Start(); is_watcher_started_ = true;