Cobra II wifi

I am trying to use the built in wifi on the Cobra II. I am using the example code below. When I debug the code it stops on this line:

 netif = new WiFiRS9110(SPI.SPI_module.SPI1, Cpu.Pin.GPIO_Pin1, Cpu.Pin.GPIO_Pin2, Cpu.Pin.GPIO_Pin3);

I uninstalled all of my .netmf, ghi and gadgeteer components, deleted the files and folders and installed the latest sdk. The error I get is exception in GHI.networking.dll. Any help is appreciated.

using GHI.Networking;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Net.NetworkInformation;
using System;
using System.Net;
using System.Threading;

public class Program
{
private static WiFiRS9110 netif;

public static void Main()
{
    netif = new WiFiRS9110(SPI.SPI_module.SPI1, Cpu.Pin.GPIO_Pin1, Cpu.Pin.GPIO_Pin2, Cpu.Pin.GPIO_Pin3);
    NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
    NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;

    
    netif.Open();
    netif.EnableDhcp();
    netif.EnableDynamicDns();
    netif.Join("randyphone", "uncertainty");

    while (netif.IPAddress == "0.0.0.0")
    {
        Debug.Print("Waiting for DHCP");
        Thread.Sleep(250);
    }

    //The network is now ready to use.
}

private static void NetworkChange_NetworkAddressChanged(object sender, Microsoft.SPOT.EventArgs e)
{
    Debug.Print("Network address changed");
}

private static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
{
    Debug.Print("Network availability: " + e.IsAvailable.ToString());
}

}

@ Randy Neal - The pins in the example document you got that code from are only examples. You need to replace them with the actual pins for your board. For the Cobra II WiFi, you want the following pins:


netif = new WiFiRS9110(SPI.SPI_module.SPI2, GHI.Pins.G120.P1_10, GHI.Pins.G120.P2_11, GHI.Pins.G120.P1_9);

1 Like