Windows 10 IoT on Raspberry Pi 3B - how to reset WiFi adapter?

yesyes 1 Reputation point
2020-10-17T13:13:44.263+00:00

Hi,
I'm running Windows 10 IoT v.10.0.17763.1518 on a Raspberry Pi 3B with my own (rather simple) UWP app.
It receives data from my home automation system over WiFi and displays it. (UDP packets, the Pi only receives, never sends)

Recently (2-3 months ago) I started having problems. When I boot the Pi it all works fine but a while later (a few minutes to a few hours at most) the Pi loses WiFi connection and I receive no more data. I think this started after a forced Win10 IoT update, but I'm not 100% sure.

I have now started looking into this and found this archived MSDN forum post:
https://social.msdn.microsoft.com/Forums/en-US/5103dfcd-c4d8-47b0-8b2d-7249ddbdfe23/windows-10-iot-wifi-reconnect-problem?forum=WindowsIoT

Marcin Michalak posted his solution and code. He restarts / resets the WiFi adapter.
Unfortunately the code he posted does not include the implementation for TryToResetWIFIAsync() .

So my question is: Does anyone know how I can reset the WiFi adapter from my code?
I've searched for hours but could not find the answer.
The post is archived, so I can't ask there either.

Thanks!
Chris

Windows for IoT
Windows for IoT
A family of Microsoft operating systems designed for use in Internet of Things (IoT) devices.
381 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Sean Liming 4,511 Reputation points
    2020-10-17T16:13:05.12+00:00

    Power cycle the wifi router as sometimes the router developed issues. You might want to reload the image to verify that the update caused the problem.

    Here is something on GitHub to enable and disable the adapter: Using C# to Disable and Enable a Network Adapter

    The other solution is to use devcon.exe. You might want to try this before writing the code.

    Regards,

    Sean Liming

    0 comments No comments

  2. yesyes 1 Reputation point
    2020-10-18T17:12:47.73+00:00

    Hi Sean. Thanks for your reply.

    > Power cycle the wifi router as sometimes the router developed issues.

    Tried that but it didn't help. The Pi has 2 Unifi access points within range on the same SSID. So even if one didn't work, it could choose the other (I guess it depends on how exactly the first one "didn't work").

    > You might want to reload the image to verify that the update caused the problem.

    This is indeed something I could try. Will do soon. I guess I have to be quick before it runs the update again. I could give it the wrong default gateway IP to stop it accessing the internet for testing... (not in "production" though as I need it to get the current internet time as it also displays time and date).

    > Here is something on GitHub to enable and disable the adapter: Using C# to Disable and Enable a Network Adapter

    Thanks for that. I manually tried the netsh commands that this code runs but that doesn't work. It shows this error:

    netsh interface>set interface Wi-Fi disable
    The supplied kernel information version is invalid.
    netsh interface>
    
    
    netsh interface>set interface Wi-Fi enable
    The supplied kernel information version is invalid.
    netsh interface>
    

    I assume "Wi-Fi" is the interface name according to this:

    netsh interface>show interface
    Admin State    State          Type             Interface Name
    -------------------------------------------------------------------------
    Enabled        Connected      Dedicated        Ethernet
    Enabled        Disconnected   Dedicated        Wi-Fi
    netsh interface>
    

    When the issue happened and I open the Device Portal (point the browser to RPi IP:8080) the drop-down list of WiFi adapters (Connectivity -> Network) is empty. That looks to me like the adapter is gone. (so not an issue with the access point)

    > The other solution is to use devcon.exe. You might want to try this before writing the code.

    I've had a look at this but this looks over my head.

    I think the best solution for me here is to use Raspian Linux and write the app again. I had chosen Win10 IoT 3 years ago because I have zero experience coding on Linux. I guess now is the time for that to change... ;)


  3. Michael Xu 336 Reputation points
    2020-10-19T03:35:32.627+00:00

    @yesyes , there may be some reasons why the device lost the wifi connection,such as the signal is too weak. Have you tried to set WiFiReconnectionKind as automatic?


  4. yesyes 1 Reputation point
    2020-10-26T12:01:39.43+00:00

    Oh the irony! ;-)

    Since I started working on a new Linux based solution for this several days ago, the issue has not happened again on the Win10 IoT Raspberry Pi. I even restarted all WiFi APs yesterday (firmware update), so the Pi must have switched APs at least twice.

    Unfortunately there is no Windows Update history on Win10 IoT (or not that I know of) so I can't tell if MS pushed out another update that fixed it. Or if it was something else (a neighbour's WiFi perhaps?).

    0 comments No comments