Share via

WifiDirect DeviceWatcher behavior clarification

Jason 1 Reputation point
2020-07-24T16:30:49.397+00:00

This question relates to UWP / WifiDirect. I am using the Microsoft UWP "WifiDirect" c# sample application (win 10).

The documentation for the DeviceWatcher states: "The DeviceWatcher raises an EnumerationCompleted event when the initial enumeration is complete, and continues to raise events if a device is added, updated, or removed."

This is not the behavior I see when using the WifiDirect protocol. With WifiDirect, once the EnumerationCompleted event fires, I no longer receive notifications. I must manually stop/start the watcher.

I found a post that indicates that for Bluetooth, the active device scan is cancelled after 30 seconds.

This sort of aligns with device Enumeration documentation that says "Bluetooth and Wi-Fi Direct do not support background scans, so by extension, they do not support a DeviceWatcherTrigger". This implies Bluetooth and Wifi Direct are only intended to run for short periods.

So, is the behavior described above for WifiDirect is "normal"? I assume it is, but would like clarification.

It would seem then, that if I wanted scanning 100% of the time, I would need to programmatically re-start my DeviceWatcher every time the EnumerationCompleted event fired.

Thanks!

Developer technologies | Universal Windows Platform (UWP)

1 answer

Sort by: Most helpful
  1. Fay Wang - MSFT 5,231 Reputation points
    2020-08-19T08:04:15.677+00:00

    Hello,

    Welcome to Microsoft Q&A!

    If a query is left running past EnumerationCompleted, it will continue scanning, but with a delay of a few seconds between each individual scan. These delays will increase over time. The specific values of these delays are undocumented and subject to change from release to release. So, it's expected behavior that the scan is not running continuously. However, the remote device should still be discovered if you allow a moment for the next scan to be triggered.

    Bluetooth and Wi-Fi Direct do not support background scans, so by extension, they do not support a DeviceWatcherTrigger

    The quoted text regarding DeviceWatcherTrigger refers to backgrounds scans, which isn't relevant to the foreground scanning case you're discussing.

    The system doesn't provide any guarantees as to scan timing if the DeviceWatcher is restarted every time the EnumerationCompleted event is raised. The underlying implementation may adjust its timing if there are other scans running concurrently on the system.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.