How to view that Advertiser is connected

JamesWhiteside

I'm to view as the advertiser whether or not it has been connected to a central device.

I've looked through previous issues and the design as based on everything on Microsoft's docs on this :https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.genericattributeprofile.gattcommunicationstatus. However they by design made it so that the advertiser can't view whether or not its connected without any sort of read/write/notify action. I was wondering if anyone had any work-arounds to this?

       GattServiceProviderAdvertisingParameters advParameters = new GattServiceProviderAdvertisingParameters
        {
            // IsConnectable determines whether a call to publish will attempt to start advertising and 
            // put the service UUID in the ADV packet (best effort)
            IsConnectable = peripheralSupported,

            // IsDiscoverable determines whether a remote device can query the local device for support 
            // of this service
            IsDiscoverable = true,
            ServiceData = buffer
        };

I want to view "IsConnectable" however I am unable to do so.

Thanks,

JamesWhiteside

I figured it out and here's my solution in case anyone else comes across this problem. The WM_DeviceChange comment pointed me in the right direction. Eventually I came across:

DeviceInformationCollection ConnectedBluetoothDevices =
               await DeviceInformation.FindAllAsync(BluetoothLEDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected));

Which from that I was able to use:

 public static async void OnTimedEvent(Object source, ElapsedEventArgs e)
    {
        DeviceInformationCollection ConnectedBluetoothDevices =
               await DeviceInformation.FindAllAsync(BluetoothLEDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected));
        if(ConnectedBluetoothDevices.Count != 0)
        {
            Console.WriteLine("New Device Found.");
        } 
    }

I essentially put a check within a Timed Event to see if the connected BLE Devices incremented and if so, I wrote a message to the console.

For timers see: What is the best way to implement a "timer"?

I got the list of BLE devices code from here: Getting a list of already connected bluetooth devices on Windows 10

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Creating a view in Sql with connected tables

分類Dev

How to check if MQ is connected

分類Dev

How are these nested vectors connected?

分類Dev

The view connected with IBOutlet property in UITableViewCell can not change frame

分類Dev

TightVNC: How to list all connected users

分類Dev

Regex: How to ignore dots in connected words

分類Dev

How does an AWS IoT device show as "connected"

分類Dev

How is async interface connected to GWT.create?

分類Dev

How to drop a Redshfit database with connected users

分類Dev

How to detect if Chromecast is already connected on Android Sender?

分類Dev

How detect the devices connected to wif network

分類Dev

mvc signalr how to display all connected users

分類Dev

How to reliably detect if an external keyboard is connected on iOS 9?

分類Dev

Connected vertices from polygon, how to get the new polygons

分類Dev

How to count all the connected nodes (rows) in a graph on Postgres?

分類Dev

How to get all MAC addresses connected to WiFi with node.js?

分類Dev

how to shape tensor from fully connected to to 4-D

分類Dev

netlogo: how to get nodes that are connected with a link to a node N

分類Dev

In Altair, how to set the size of the connected points in a line chart?

分類Dev

How does a (2 or 3) dimensional Fully connected layer work?

分類Dev

How can I tell through the Stripe API if a connected account is complete?

分類Dev

How can a JavaScript app detect if a Leap Motion device is connected

分類Dev

How do I turn off WLAN automatically when LAN is connected?

分類Dev

How to authenticate Facebook User after receiving response.status === 'connected'?

分類Dev

How to check if a Windows 8.1 PC ever connected to the Internet?

分類Dev

How to detect click event of connected Bluetooth peripheral device (Selfie stick)?

分類Dev

How can I see my LAN when connected to a VPN?

分類Dev

How to disconnect wifi link, that was connected with wpa_supplicant

分類Dev

How to identify a client connected to AF_UNIX socket?

Related 関連記事

  1. 1

    Creating a view in Sql with connected tables

  2. 2

    How to check if MQ is connected

  3. 3

    How are these nested vectors connected?

  4. 4

    The view connected with IBOutlet property in UITableViewCell can not change frame

  5. 5

    TightVNC: How to list all connected users

  6. 6

    Regex: How to ignore dots in connected words

  7. 7

    How does an AWS IoT device show as "connected"

  8. 8

    How is async interface connected to GWT.create?

  9. 9

    How to drop a Redshfit database with connected users

  10. 10

    How to detect if Chromecast is already connected on Android Sender?

  11. 11

    How detect the devices connected to wif network

  12. 12

    mvc signalr how to display all connected users

  13. 13

    How to reliably detect if an external keyboard is connected on iOS 9?

  14. 14

    Connected vertices from polygon, how to get the new polygons

  15. 15

    How to count all the connected nodes (rows) in a graph on Postgres?

  16. 16

    How to get all MAC addresses connected to WiFi with node.js?

  17. 17

    how to shape tensor from fully connected to to 4-D

  18. 18

    netlogo: how to get nodes that are connected with a link to a node N

  19. 19

    In Altair, how to set the size of the connected points in a line chart?

  20. 20

    How does a (2 or 3) dimensional Fully connected layer work?

  21. 21

    How can I tell through the Stripe API if a connected account is complete?

  22. 22

    How can a JavaScript app detect if a Leap Motion device is connected

  23. 23

    How do I turn off WLAN automatically when LAN is connected?

  24. 24

    How to authenticate Facebook User after receiving response.status === 'connected'?

  25. 25

    How to check if a Windows 8.1 PC ever connected to the Internet?

  26. 26

    How to detect click event of connected Bluetooth peripheral device (Selfie stick)?

  27. 27

    How can I see my LAN when connected to a VPN?

  28. 28

    How to disconnect wifi link, that was connected with wpa_supplicant

  29. 29

    How to identify a client connected to AF_UNIX socket?

ホットタグ

アーカイブ