The only way I have found to use the WiFiRS9110 is to set it up in MAIN() .
I have tried using 4.3.7.10 and 4.3.8.0 and the exception is the same when moving out of Main()
If I move my code outside of main I always receive a hardware timeout exception.
(Not blaming the G120E Dev Board because I seem to recall having this problem using other boards in the past)
Is there a way around this exception? I would like to use the WiFiRS9110 much later in the application.
If nothing else… I would like to know why the code must be in Main()
Thanks!
I have the WiFiRS9110 module being setup in a thread on a G120 and it works fine.
I have a global for it but the actual assignment is done in the thread,
@ willgeorge - Can you post a small example just to be sure?
@ John -
Here you go!
This will run if in Main
This would not be the final code. For now it is just minimum code to see if I can get it to run outside of Main()
I can receive the time for awhile but at some point it stops. (I can fix this issue later)
if (usingWifi)
{
try
{
wifi = new WiFiRS9110(SPI.SPI_module.SPI2, myWiFi.SPI_CS, myWiFi.SPI_INTR, myWiFi.WIFI_RESET);
if (!wifi.Opened)
{
wifi.Open();
}
if (!wifi.NetworkInterface.IsDhcpEnabled)
{
wifi.NetworkInterface.EnableDhcp();
}
if (!wifi.NetworkInterface.IsDynamicDnsEnabled)
{
wifi.NetworkInterface.EnableDynamicDns();
}
wifi.Join(mySSID, myPassword);
}
catch (Exception e)
{
Debug.Print("wifi " + e.Message);
}
//
Methods outside of main()
private static void Program_OnInterrupt_LEFT(uint data1, uint data2, DateTime time)
{
Thread TesterThread = new Thread(Tester);
TesterThread.Start();
}
//
public static void Tester()
{
if (wifi == null)
{
wifi = new WiFiRS9110(SPI.SPI_module.SPI2, myWiFi.SPI_CS, myWiFi.SPI_INTR, myWiFi.WIFI_RESET);
wifi.Open(); // FAILS ON OPEN with hardware timeout exception
wifi.NetworkInterface.EnableDhcp();
wifi.NetworkInterface.EnableDynamicDns();
wifi.Join(mySSID, myPassword);
}
}
//
@ willgeorge - The following program worked fine for me. (Rename Main1 and Main2 as appropriate.)
using GHI.Networking;
using GHI.Pins;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using System.Threading;
public class Program {
public static void Main1() {
using (var netif = new WiFiRS9110(G120E.SpiBus.Spi2, G120E.Gpio.P3_30, G120E.Gpio.P2_30, G120E.Gpio.P4_31)) {
netif.Open();
Debug.Print("Passed.");
}
}
public static void Main2() {
var input = new InterruptPort(G120E.Gpio.P2_21, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
input.OnInterrupt += OnInterrupt;
Thread.Sleep(-1);
}
public static void OnInterrupt(uint data1, uint data2, System.DateTime time) {
new Thread(Tester).Start();
}
public static void Tester() {
using (var netif = new WiFiRS9110(G120E.SpiBus.Spi2, G120E.Gpio.P3_30, G120E.Gpio.P2_30, G120E.Gpio.P4_31)) {
netif.Open();
Debug.Print("Passed.");
}
}
}
@ John -
Thank You …
I will try it ASAP (Baby sitting at the moment)
As a note only. I used my code on my G400-D Dev Board and it worked fine.