How to scan Bluetooth devices with low energy (BLE) that are available / present?

I am working on a Windows Phone application that can scan BLE devices. I have implemented logic showing the right devices.

But the problem is that if I delete these devices or turn them off, even then my application will return its names as a result of scanning. I think it returns a cache result. How can I make sure that it will show only those devices that are available / present.

I tried to use additional properties, i.e. System.Devices.Aep.IsPresent, etc. in the scan, but they come in as zero as a result, regardless of the devices available or not.

Here is the code snippet I am using -

string[] requestedProperties = new string[] { "System.Devices.Aep.IsPresent"
                                                        , "System.Devices.Present"
                                                        , "System.Devices.Connected"
                                                        , "System.Devices.Paired"
                                                        , "System.Devices.Aep.IsConnected"
                                                        , "System.Devices.AepContainer.IsPresent"
                                                    };

diCollection = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(serviceUuid)
                                                , requestedProperties
                                                );

foreach (var diItem in diCollection)
{
    Debug.WriteLine("Discovered Device name - " + diItem.Name);
    Debug.WriteLine("Discovered Device Additional Properties Below");

    foreach (var item in diItem.Properties)
    {
        Debug.WriteLine("Key-{0} Value-{1}", item.Key, item.Value);
    }
}

Package.appxmanifest features are used here -

<Capabilities>
    <Capability Name="internetClientServer" />
    <DeviceCapability Name="bluetooth" />
</Capabilities>

, . - ?

.

-Jitender

+4
1

, Handheld, Windows Handheld 8.1.

https://docs.microsoft.com/en-us/windows/uwp/devices-sensors/device-information-properties

AssociationEndpoint , Windows Phone 8.1 ( ) - api .

, (, , , ).

, , , , . ~ 4-5 . , , . , , .

+1

Source: https://habr.com/ru/post/1653098/


All Articles