wifiRS21.NetworkInterface.Scan() causes reboot

Hi,

I’ve got a RS21 WiFi-Interface connected to a Spider via Port 6.
When calling wifiRS21.NetworkInterface.Scan(), the mainboard immediately reboots.
It’s reproducable using a completely new Gadgeteer Application (.NETMF 4.3) just with these two lines in code:

public partial class Program
{
	public void ProgramStarted()
	{
		this.wifiRS21.NetworkInterface.Open();
		var scan = this.wifiRS21.NetworkInterface.Scan();
	}
}

This makes the Spider-Board reboot immediately. What am I doing wrong? Firmware and Loader are both at the most current version.

I don’t use Gadgeteer myself but I think you should create a thread for the WiFi and then inside that to do the scan. Better to keep anything in ProgramStarted to just initialise calls and start threads to do the rest.

See if that sorts out your issues.

@ SaschaSchwegelbauer - sounds like a power supply issue. try powering board from a powered USB hub.

@ Dave McLaughlin - I’ve updated the test-code, but it does not help :frowning:

public partial class Program
{
  private Thread scanThread;

  public void ProgramStarted()
  {
    this.scanThread = new Thread(() =>
    {
      this.wifiRS21.NetworkInterface.Open();
      var scan = this.wifiRS21.NetworkInterface.Scan();
    });

    this.scanThread.Start();
  }
}

@ Mike - it’s already connected via a powered USB-Hub (made by “Anker”)

@ SaschaSchwegelbauer - Hi Sacha,
As mike already mentioned rebooting Points on a power issue. I would try to Exchange the Gadgeteer cables of the power module and the WiFi Module.
This code worked for me some months ago:


using GHI.Networking;
.....
.....
public partial class Program
    {
        void ProgramStarted()
        {
            wifiRS21.NetworkUp += wifiRS21_NetworkUp;
            wifiRS21.NetworkDown += wifiRS21_NetworkDown;
            wifiRS21.NetworkInterface.Open();
            wifiRS21.NetworkInterface.EnableDhcp();
            wifiRS21.NetworkInterface.EnableDynamicDns();
            WiFiRS9110.NetworkParameters[] scanResult = wifiRS21.NetworkInterface.Scan();
            for (int i = 0; i < scanResult.Length; i++)
            {
                    if (scanResult[i].Ssid == "MySSID")
                {
                    try
                    {
                        wifiRS21.NetworkInterface.Join(scanResult[i].Ssid, "MyPassword");
                    }
                    catch (WiFiRS9110.JoinException e)
                    {
                        Debug.Print("Error Message: " + e.Message);
                    }
                    break;
                }
            }
            while (wifiRS21.NetworkInterface.IPAddress == "0.0.0.0")
            {
                Thread.Sleep(500);
            }
            Debug.Print("Ip-Address = " + wifiRS21.NetworkInterface.IPAddress);
        }
        void wifiRS21_NetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Network is down!");
        }
        void wifiRS21_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Network is up!");
            
        }