DHCP problem troubleshooter thread

If you have a problem obtaining an IP over DHCP (or if you are not), please provide the exact info below to help us nail down the mystery. We have never had any issues at GHI but others have reported issues and we need your help to get this resolved quickly.

  1. Make sure you are running the latest firmware on your device GHI Electronics – Where Hardware Meets Software
  2. Run the code the bottom of this post
  3. What device are you running? What revision of the board?
  4. What interface? WiFi RS21, ENC28 (external Ethernet) or J11D (internal Ethernet) and what revision of the board?
  5. Description of network setup. (Modem, router, device and how they connect)
  6. Network hardware. (How many routers, sub nets etc)
  7. Outcome. Please include what happens after both a soft reboot (redeploy) and hard reboot (reset button).

If you had to alter code for any reason, such as using another mainboard or module, please include that information.


// The following example is a Console Project running on CobraII using the onboard Wifi.
// References:
// GHI.Premium.Hardware.G120
// GHI.Premium.Net
// Microsoft.SPOT.Hardware
// Microsoft.SPOT.Native
// Microsoft.SPOT.Net
// mscorlib
    public class Program
    {
        public static GHINET.WiFiRS9110 wifi;

        public static void Main()
        {
            wifi = new GHINET.WiFiRS9110(Microsoft.SPOT.Hardware.SPI.SPI_module.SPI2, G120.Pin.P1_10, G120.Pin.P2_11, G120.Pin.P1_9, 4000);

            if (!wifi.IsOpen)
                wifi.Open();

            if (!wifi.NetworkInterface.IsDhcpEnabled)
                wifi.NetworkInterface.EnableDhcp();

            wifi.NetworkAddressChanged += new GHINET.NetworkInterfaceExtension.NetworkAddressChangedEventHandler(wifi_NetworkAddressChanged);
            wifi.WirelessConnectivityChanged += new GHINET.WiFiRS9110.WirelessConnectivityChangedEventHandler(wifi_WirelessConnectivityChanged);
            
            GHINET.NetworkInterfaceExtension.AssignNetworkingStackTo(wifi);

            GHINET.WiFiNetworkInfo[] scanResult = wifi.Scan();

            for (int i = 0; i < scanResult.Length; i++)
            {
                if (scanResult[i].SSID == "Access Point Name")
                {
                    wifi.Join(scanResult[i], "Access Point Password");
                    break;
                }
            }

            Thread.Sleep(-1);            
        }

        static void wifi_WirelessConnectivityChanged(object sender, GHINET.WiFiRS9110.WirelessConnectivityEventArgs e)
        {
            Debug.Print("Wireless is: " + (e.IsConnected ? "Connected" : "Disconnected"));

            Debug.Print("SSID: " + e.NetworkInformation.SSID);
            
            Debug.Print("WiFi Channel number: " + e.NetworkInformation.ChannelNumber);

            DisplayNetworkType(e.NetworkInformation);

            DisplayMACAddress(e.NetworkInformation);

            Debug.Print("RSSI: -" + e.NetworkInformation.RSSI + "dB");

            DisplaySecurityMode(e.NetworkInformation);
        }

        static void wifi_NetworkAddressChanged(object sender, EventArgs e)
        {
            Debug.Print("New address for the Wireless Network Interface ");

            Debug.Print("Is DhCp enabled: " + wifi.NetworkInterface.IsDhcpEnabled);
            Debug.Print("Is DynamicDnsEnabled enabled: " + wifi.NetworkInterface.IsDynamicDnsEnabled);
            Debug.Print("NetworkInterfaceType " + wifi.NetworkInterface.NetworkInterfaceType);
            Debug.Print("Network settings:");
            Debug.Print("IP Address: " + wifi.NetworkInterface.IPAddress);
            Debug.Print("Subnet Mask: " + wifi.NetworkInterface.SubnetMask);
            Debug.Print("Default Gateway: " + wifi.NetworkInterface.GatewayAddress);
            Debug.Print("Number of DNS servers:" + wifi.NetworkInterface.DnsAddresses.Length);
            for (int i = 0; i < wifi.NetworkInterface.DnsAddresses.Length; i++)
                Debug.Print("DNS Server " + i.ToString() + ":" + wifi.NetworkInterface.DnsAddresses[i]);
            Debug.Print("------------------------------------------------------");
        }

        #region Helpers
        static void DisplayNetworkType(GHINET.WiFiNetworkInfo info)
        {
            switch (info.networkType)
            {
                case GHINET.NetworkType.AccessPoint:
                    {
                        Debug.Print("Wireless Network Type: Access Point");
                        break;
                    }
                case GHINET.NetworkType.AdHoc:
                    {
                        Debug.Print("Wireless Network Type: Ad Hoc");
                        break;
                    }
            }
        }

        static void DisplayMACAddress(GHINET.WiFiNetworkInfo info)
        {
            string MAC = new string(null);
            int splitCount = 0;

            for (int i = 0; i < info.PhysicalAddress.Length; i++)
            {
                MAC += (info.PhysicalAddress[i].ToString("X"));

                if (splitCount < 5)
                {
                    MAC += ":";
                    splitCount++;
                }
            }

            Debug.Print("MAC Address: " + MAC);
        }

        static void DisplaySecurityMode(GHINET.WiFiNetworkInfo info)
        {
            switch (info.SecMode)
            {
                case GHINET.SecurityMode.Open:
                    {
                        Debug.Print("Wireless Security Mode: Open");
                        break;
                    }
                case GHINET.SecurityMode.WEP:
                    {
                        Debug.Print("Wireless Security Mode: WEP");
                        break;
                    }
                case GHINET.SecurityMode.WPA:
                    {
                        Debug.Print("Wireless Security Mode: WPA");
                        break;
                    }
                case GHINET.SecurityMode.WPA2:
                    {
                        Debug.Print("Wireless Security Mode: WPA2");
                        break;
                    }
            }
        }
        #endregion

    }

Example Reply:

  1. Latest firmware 4.2.9.0
  2. No changes made to the code.
  3. CobraII WiFi RevB
  4. Interface: WiFi RS21. Onboard WiFi (no rev)

Modem - Router A (Subnet 1) DHCP Server
| |- FEZ Spider
| |- Cobra II
|
|------ Router B (Subnet 2) DHCP Server

  1. Linksys E3000 class and a Netgear N600 as DHCP servers acting on 2 subnets setup as segregated networks.
  2. DCHP Address obtained first try and every time after a soft or hard reboot.

I’ll run it tonight.

I am finalizing settings to test ISC under fedora 17 to attempt to reproduce this issue. However, there is one small part that needs clarification: When you have fedora ISC running with the DHCP server enabled, are you disabling the DHCP server in the Linsys E4200?

@ Gus -

I was going to try run your sample code to respond to this thread.

I have a new Cobra II that has factory installed 4.2.7.0.

I believe that you want 4.2.9.0 -

I cannot find a link that allows/shows how to upgrade firmware for Cobra II
(But then again I’m a poor searcher for topics)

I checked the WIKI but no topic is found or has broken links for “Update cobra II firmware”

Not a real issue for me at this time but I thought I’d let you know what my wifi network does
an inform you of the results.

Nothing for Cobra II with G120? See image

Use updater app that comes with the SDK for G120.

@ Architect -

Bit lost here… Use updater app that comes with the SDK for G120. Not really sure what that is.

All I have found to download shows…

SDK Version 1.0.0
November 29, 2012

Important Note: Requires .NET Micro Framework 4.2 QFE2 and Visual Studio 2010

• EMX v4.2.7.0, TinyBooter v4.2.7.0
• G120 v4.2.7.0, TinyBooter v4.2.7.0 <<<<<<<
• GHI Premium NETMF Library v4.2.7.0

Not 4.2.9.0

I tried a updater for G120 but that wanted me to jumper some pins on the G120?
Small pins for my old soldering iron!

Or do you mean download these? See image 2
As far as I know these are the 4.2.7.0 version.

Press the LDR0 and LDR1 buttons and then hit reset.

@ willgeorge, you need the NEW firmware. The thread with the “hidden” download location is in the “beta” forum section. The November firmware doesn’t have the fixes you need to test, so you need the new SDK, install it, then update the firmware before running this code.

I should be able to get to this tomorrow night but again I haven’t had any problems getting an IP address with DHCP and getting to the internet. A number of my current experiments are sending data real time to COSM and ThingSpeak and sending twitter messages so I’d only be able to show working configurations with a number of different routers etc. but I’ll do some tests and post some results hopefully tomorrow night.

@ Steven -

Sorrry for the delay. I had figgure out what I was doing…
I could not get the sample test code to build as copied.
I needed to change a few things to have the references needed in order to build.
I did NOT change the basic structure of the code.
Only added references and needed to change code for Output port Pins.

//Needed to add this
using GHINET = GHI.Premium.Net; //Need to add a reference ‘GHI.Premium.Net
using GHIG120 = GHI.Premium.Hardware; //Needed to add a reference to GHI.Premium.Hardware.G120;

// Changed
wifi = new GHINET.WiFiRS9110(Microsoft.SPOT.Hardware.SPI.SPI_module.SPI2, G120.Pin.P1_10, G120.Pin.P2_11, G120.Pin.P1_9, 4000);
//Changed to
wifi = new GHINET.WiFiRS9110(Microsoft.SPOT.Hardware.SPI.SPI_module.SPI2, GHIG120.G120.Pin.P1_10, GHIG120.G120.Pin.P2_11, GHIG120.G120.Pin.P1_9, 4000);

//Probably more than you want but:

I have only a home network that more than a few wireless devices connect to.
My Router is a Belkin N750DB N+ (I do not use the 5GHz)

Debugging output (First try. I am using C# Express 2010)

Found debugger!

Create TS.

Loading start at a0e856b0, end a0e9ce0c

Assembly: mscorlib (4.2.0.0) Assembly: Microsoft.SPOT.Native (4.2.0.0) Assembly: Microsoft.SPOT.Hardware (4.2.0.0)
Assembly: Microsoft.SPOT.Hardware.PWM (4.2.0.1) Assembly: Microsoft.SPOT.Security.PKCS11 (4.2.0.0)
Assembly: System.Security (4.2.0.0) Loading Deployment Assemblies.

Attaching deployed file.

Assembly: GHI.Premium.Hardware.G120 (4.2.9.0) Attaching deployed file.

Assembly: GHI.Premium.Net (4.2.9.0) Attaching deployed file.

Assembly: MFConsoleApplicationWiFiTest (1.0.0.0) Attaching deployed file.

Assembly: Microsoft.SPOT.Net (4.2.0.0) Resolving.

GC: 1msec 302328 bytes used, 7037340 bytes available

Type 0F (STRING ): 24 bytes

Type 15 (FREEBLOCK ): 7037340 bytes

Type 17 (ASSEMBLY ): 13860 bytes

Type 1E (BINARY_BLOB_HEAD ): 288372 bytes

Type 34 (APPDOMAIN_HEAD ): 72 bytes

GC: performing heap compaction…

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\mscorlib.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Native.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Security.PKCS11.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Security.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Hardware.G120.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Net.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\Will George\documents\visual studio 2010\Projects\MFConsoleApplicationWiFiTest\MFConsoleApplicationWiFiTest\bin\Debug\le\MFConsoleApplicationWiFiTest.exe’, Symbols loaded.
The thread ‘’ (0x2) has exited with code 0 (0x0).
RS9110 firmware version Number is 4.4.5
RS9110 driver version Number is 4.4.5
New address for the Wireless Network Interface
Is DhCp enabled: True
Is DynamicDnsEnabled enabled: False
NetworkInterfaceType 71
Network settings:
IP Address: 192.168.2.5
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.2.1
Number of DNS servers:1
DNS Server 0:192.168.2.1

Wireless is: Connected
SSID: belkin.006
WiFi Channel number: 1
Wireless Network Type: Access Point
MAC Address: 08:86:3B:3F:20:06
RSSI: -60dB
Wireless Security Mode: WPA2
New address for the Wireless Network Interface
Is DhCp enabled: True
Is DynamicDnsEnabled enabled: False
NetworkInterfaceType 71
Network settings:
IP Address: 0.0.0.0
Subnet Mask: 0.0.0.0
Default Gateway: 0.0.0.0
Number of DNS servers:1
DNS Server 0:192.168.2.1

New address for the Wireless Network Interface
Is DhCp enabled: True
Is DynamicDnsEnabled enabled: False
NetworkInterfaceType 71
Network settings:
IP Address: 192.168.2.5
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.2.1
Number of DNS servers:1
DNS Server 0:192.168.2.1

//Cobra II reset button pressed
//Output from MFDeploy4.2

Connecting to G120_G120…Connected
Deploy with PortBooter Command
Deploy with PortBooter Complete
Found debugger!
Create TS.
Loading start at a0e856b0, end a0e9ce0c
Assembly: mscorlib (4.2.0.0) Assembly: Microsoft.SPOT.Native (4.2.0.0) Assembly: Microsoft.SPOT.Hardware (4.2.0.0) Assembly: Microsoft.SPOT.Hardware.PWM (4.2.0.1) Assembly: Microsoft.SPOT.Security.PKCS11 (4.2.0.0) Assembly: System.Security (4.2.0.0) Loading Deployment Assemblies.
Attaching deployed file.
Assembly: GHI.Premium.Hardware.G120 (4.2.9.0) Attaching deployed file.
Assembly: GHI.Premium.Net (4.2.9.0) Attaching deployed file.
Assembly: MFConsoleApplicationWiFiTest (1.0.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Net (4.2.0.0) Resolving.
GC: 1msec 298284 bytes used, 7041384 bytes available
Type 0F (STRING ): 24 bytes
Type 15 (FREEBLOCK ): 7041384 bytes
Type 17 (ASSEMBLY ): 13860 bytes
Type 1E (BINARY_BLOB_HEAD ): 284328 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
GC: performing heap compaction…
Ready.
RS9110 firmware version Number is 4.4.5
RS9110 driver version Number is 4.4.5
Wireless is: Connected
SSID: belkin.006
WiFi Channel number: 1
Wireless Network Type: Access Point
MAC Address: 08:86:3B:3F:20:06
RSSI: -62dB
Wireless Security Mode: WPA2
New address for the Wireless Network Interface
Is DhCp enabled: True
Is DynamicDnsEnabled enabled: False
NetworkInterfaceType 71
Network settings:
IP Address: 192.168.2.5
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.2.1
Number of DNS servers:1
DNS Server 0:192.168.2.1

Have a GREAT day!

EDIT: I’ll send the modified code if wanted. Don’t think I changed anything important for your test.

Guess I messed up…

  1. Latest firmware 4.2.9.0
  2. Minor changes made to the code.
  3. Cobra II WiFi RevB
  4. Interface: WiFi RS21. Onboard WiFi (no rev) //Not sure - WiFi module label shows RS9110-N-11-22-04
  5. The same information received first try and every time after a soft or hard reboot.

andre.m You can yell at me! - I take no offence if I get corrected…

@ Brett -

Thank you… I found it from your info.

@ willgeorge - So to verify, you have no problem with DHCP, and can get an IP address every time? Also, could we get your network information? Such as what router you are using and how your network is set up?

I have a router/Cobra II combination that is obtaining a DHCP address but is freezing when trying to create a Socket object. I will be packing up both and sending to GHI/Gus on Tuesday.

The Router is a Cisco E3000.

@ Steven -

I have only a home network that more than a few diferent type wireless devices connect to.
My internet connection is through my wireless Belkin router that is connected by Ethernet to a Comcast cable modem.

My Router is a Belkin N750DB N+ Using 2.4GHz. (I never use the 5GHz)

I never have any problems connecting any wireless device to the belkin.
(At least for the devices I have tried)

I have/had a Cisco Access Point but that thing died last month…

All the devices I have connect wireless except for a netgear wnce2001 that connects to my PC/Spider by ethernet.
I do not have a cell phone so I have no idea if that works.

My edits:
using System;
using System.Threading;
using Microsoft.SPOT;
using GHINET = GHI.Premium.Net;
using GHIG120 = GHI.Premium.Hardware;
using G120 = GHI.Premium.Hardware.G120;

ALSO added the Cobra II reference.

Edit: results for first deploy from VS:

‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Hardware.G120.dll’
The thread ‘’ (0x2) has exited with code 0 (0x0).
RS9110 firmware version Number is 4.4.5
RS9110 driver version Number is 4.4.5
Found 2 networks
Scan result 0 = InTheBay
Sleeping…
Wireless is: Connected
SSID: InTheBay
WiFi Channel number: 1
Wireless Network Type: Access Point
MAC Address: 00:04:ED:1D:A4:25
RSSI: -72dB
Wireless Security Mode: WPA2

(after 10 mins the network address change has not triggered, so DHCP is failing).

Same results from MFDeploy after hard reset:

Connecting to G120_G120…Connected
RS9110 firmware version Number is 4.4.5
RS9110 driver version Number is 4.4.5
Found 1 networks
Scan result 0 = InTheBay
Sleeping…
Wireless is: Connected
SSID: InTheBay
WiFi Channel number: 1
Wireless Network Type: Access Point
MAC Address: 00:04:ED:1D:A4:25
RSSI: -74dB
Wireless Security Mode: WPA2

  1. What device are you running? What revision of the board?
    Cobra II Wifi, Rev B
  2. What interface? WiFi RS21, ENC28 (external Ethernet) or J11D (internal Ethernet) and what revision of the board?
    Wifi onboard, no separate revision
  3. Description of network setup. (Modem, router, device and how they connect)
    Billion 7404VNPX ADSL Modem/router/wifi AP all-in-1
  4. Network hardware. (How many routers, sub nets etc)
    only single Billion device on the network, one subnet 192.168.2.x
  5. Outcome. Please include what happens after both a soft reboot (redeploy) and hard reboot (reset button).
    Fail.

A question to you Andre. When you power up your EMX and receive a valid IP from DHCP… What happens when you shut down your (power off) EMX and power up again… Do you always receive a valid IP after power up?

I have completed testing my EMX Development System and RS21:

  1. Make sure you are running the latest firmware on your device GHI Electronics – Where Hardware Meets Software

Confirmed installation 4.2.9.0 on EMX Development System using RS21 (RS9110-N-11-22-04)

  1. Run the code the bottom of this post

Output below 100% ok

  1. What device are you running? What revision of the board?

On EMX Development System using RS9110-N-11-22-04

  1. What interface? WiFi RS21, ENC28 (external Ethernet) or J11D (internal Ethernet) and what revision of the board?

Wifi RS21 (RS9110-N-11-22-04)

  1. Description of network setup. (Modem, router, device and how they connect)

TP-LINK model WR1043ND through Smoothwall by cable to internet.

  1. Network hardware. (How many routers, sub nets etc)

One router one sub net.

  1. Outcome. Please include what happens after both a soft reboot (redeploy) and hard reboot (reset button).

A Restart within the Debugger 100% ok. Powered down and reconnected board: able to immediately ping board. Reset board: able to immediately ping board. Redeployed code (F5) same result 100% ok.

Output:

Found debugger!

Create TS.

Loading start at a0e00000, end a0e1383c

Assembly: mscorlib (4.2.0.0) Assembly: Microsoft.SPOT.Native (4.2.0.0) Assembly: Microsoft.SPOT.Security.PKCS11 (4.2
.0.0) Assembly: System.Security (4.2.0.0) Loading Deployment Assemblies.

Attaching deployed file.

Assembly: Microsoft.SPOT.Graphics (4.2.0.0) Attaching deployed file.

Assembly: GHI.Premium.Hardware.EMX (4.2.9.0) Attaching deployed file.

Assembly: GHI.Premium.Net (4.2.9.0) Attaching deployed file.

Assembly: GHIwifiDHCP429 (1.0.0.0) Attaching deployed file.

Assembly: Microsoft.SPOT.Net (4.2.0.0) Attaching deployed file.

Assembly: Microsoft.SPOT.Hardware (4.2.0.0) Resolving.

GC: 1msec 18060 bytes used, 7321608 bytes available

Type 0F (STRING ): 24 bytes

Type 15 (FREEBLOCK ): 7321608 bytes

Type 17 (ASSEMBLY ): 13920 bytes

Type 1E (BINARY_BLOB_HEAD ): 4044 bytes

Type 34 (APPDOMAIN_HEAD ): 72 bytes

GC: performing heap compaction…

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\mscorlib.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Native.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Security.PKCS11.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Security.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Graphics.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Hardware.EMX.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Net.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Programming\Projects\GHIwifiDHCP429\GHIwifiDHCP429\bin\Debug\le\GHIwifiDHCP429.exe’, Symbols loaded.
The thread ‘’ (0x2) has exited with code 0 (0x0).
RS9110 firmware version Number is 4.4.5
RS9110 driver version Number is 4.4.5
Wireless is: Connected
SSID: KGNETGEAR
WiFi Channel number: 11
Wireless Network Type: Access Point
MAC Address: 64:70:02:40:69:3A
RSSI: -50dB
Wireless Security Mode: WPA2
New address for the Wireless Network Interface
Is DhCp enabled: True
Is DynamicDnsEnabled enabled: False
NetworkInterfaceType 71
Network settings:
IP Address: 192.168.1.5
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.1.1
Number of DNS servers:2
DNS Server 0:8.8.8.8
DNS Server 1:8.8.4.4

Made only minor changes to the code.

Made further changes to the code which is in Codeshare: http://www.tinyclr.com/codeshare/entry/657. Added loop to connect and disconnect several times.

Great to see the improvement. Many thanks to everyone. Next test sockets!

Best regards, Kevin.

I wanted to update some information.

I did a few tests and I’ll just state what I found that I did not notice before.

I changed the code to display the IP address received and output that to the T35 display.
I supressed all the other messages because they always seemed to be the same.

Shown only for information:


 static int ctr = 0;

        static void wifi_NetworkAddressChanged(object sender, EventArgs e)
        {
            string tmp = string.Empty;
            if (ctr == 0)
            {
                tmp = "NetworkAddressChanged------- ";
                display.SimpleGraphics.DisplayText(tmp + ctr.ToString(), small, Colors.Black, 4, 91);
                tmp = string.Empty;
                tmp = ("IP Address: " + (wifi.NetworkInterface.IPAddress));
                display.SimpleGraphics.DisplayText(tmp + ctr.ToString(), small, Colors.Black, 4, 102);
            }

            if (ctr == 1)
            {
                tmp = string.Empty;
                tmp = "NetworkAddressChanged------- ";
                display.SimpleGraphics.DisplayText(tmp + ctr.ToString(), small, Colors.Black, 4, 113);
                tmp = string.Empty;
                tmp = ("IP Address: " + (wifi.NetworkInterface.IPAddress));
                display.SimpleGraphics.DisplayText(tmp + ctr.ToString(), small, Colors.Black, 4, 124);
            }
            if (ctr == 2)
            {
                tmp = string.Empty;
                tmp = "NetworkAddressChanged------- ";
                display.SimpleGraphics.DisplayText(tmp + ctr.ToString(), small, Colors.Black, 4, 135);
                tmp = string.Empty;
                tmp = ("IP Address: " + (wifi.NetworkInterface.IPAddress));
                display.SimpleGraphics.DisplayText(tmp + ctr.ToString(), small, Colors.Black, 4, 146);
            }
            if (ctr == 3)
            {
                tmp = string.Empty;
                tmp = "NetworkAddressChanged------- ";
                display.SimpleGraphics.DisplayText(tmp + ctr.ToString(), small, Colors.Black, 4, 157);
                tmp = string.Empty;
                tmp = ("IP Address: " + (wifi.NetworkInterface.IPAddress));
                display.SimpleGraphics.DisplayText(tmp + ctr.ToString(), small, Colors.Black, 4, 168);
            }
                        
            ctr++;

            //tmp = ("Is DhCp enabled: " + (wifi.NetworkInterface.IsDhcpEnabled).ToString());
            //display.SimpleGraphics.DisplayText(tmp, small, Colors.Black, 4, 91);
            
            //tmp = ("Is DhCp enabled: " + (wifi.NetworkInterface.IsDhcpEnabled).ToString());
            //display.SimpleGraphics.DisplayText(tmp, small, Colors.Black, 4, 102);
            //tmp = ("Is DynamicDnsEnabled enabled: " + (wifi.NetworkInterface.IsDynamicDnsEnabled).ToString());
            //display.SimpleGraphics.DisplayText(tmp, small, Colors.Black, 4, 113);
            //tmp = ("NetworkInterfaceType " + (wifi.NetworkInterface.NetworkInterfaceType).ToString());
            //display.SimpleGraphics.DisplayText(tmp, small, Colors.Black, 4, 124);

            //tmp = ("IP Address: " + (wifi.NetworkInterface.IPAddress));
            //display.SimpleGraphics.DisplayText(tmp, small, Colors.Black, 4, 135);
            //tmp = ("Subnet Mask: " + (wifi.NetworkInterface.SubnetMask));
            //display.SimpleGraphics.DisplayText(tmp, small, Colors.Black, 4, 146);

            //tmp = ("IP Address: " + (wifi.NetworkInterface.IPAddress));
            //display.SimpleGraphics.DisplayText(tmp, small, Colors.Black, 4, 157);

            //tmp = ("Default Gateway: " + (wifi.NetworkInterface.GatewayAddress));
            //display.SimpleGraphics.DisplayText(tmp, small, Colors.Black, 4, 157);
            //tmp = ("Number of DNS servers:" + (wifi.NetworkInterface.DnsAddresses.Length).ToString());
            //display.SimpleGraphics.DisplayText(tmp, small, Colors.Black, 4, 168);

            //uint line = 179;
            //Could run out of LCD height here...
            for (int i = 0; i < wifi.NetworkInterface.DnsAddresses.Length; i++)
            {
                //tmp = ("DNS Server " + i.ToString() + ":" + wifi.NetworkInterface.DnsAddresses[i]);
                //display.SimpleGraphics.DisplayText(tmp, small, Colors.Black, 4, line);
                //line += 11;
            }
        }
        //


  1. If debugging using Visual Studio, I always receive only one (1) wifi_NetworkAddressChanged( ) event.

    NetworkAddressChanged------- 0
    IP Address: 192.168.2.50

  2. If NOT DEBUGGING using Visual Studio, I ALWAYS receive three (3) wifi_NetworkAddressChanged( ) events.
    Event counts (ctr) - 0, 1, 2

  3. I never receive more than three events but I always three events.

    NetworkAddressChanged------- 0
    IP Address: 192.168.2.50 <<<<<<<<

    NetworkAddressChanged------- 1
    IP Address: 0.0.0.01 <<<<<<<<

    NetworkAddressChanged------- 2
    IP Address: 192.168.2.52 <<<<<<<<

I am using my Auxillary power supply (2.5A at 12VDC) to power the Cobra II

  • While not debugging I have tried with and without the USB cable plugged into my PC.

  • Restarting using the Cobra II ‘reset’ button.

  • Restarting by removing and then reinserting the power supply.

I have commented before (in the form) about receiving more than one Network Address Changed event.
As I recall it was while using 4.1 with the WiFi device for my Spider. I ‘think’ I received two (2) events.
The first event being 0.0.0.0 and then on the second event I received a valid IP I could use.

I am going to check about the address - IP Address: 0.0.0.01 Not sure if it is really .01?
Maybe something left over in a string. With my Spider the first event was always 0.0.0.0 and the second event was a valid IP.

Hope the Info is useful…

EDIT: I added tmp = string.Empty; before reusing the string. The IP Address: 0.0.0.01 remain the same.

@ willgeorge: I have also seen this before. The code I have just placed in codeshare http://www.tinyclr.com/codeshare/entry/657 has a Thread.Sleep on line 61. This was necessary to obtain a stable result from wifi.NetworkInterface.IPAddress. It probably only needs a much smaller delay. Also the exact timing of events seems to effect the output during lines 142 to 150. Definitely end of day here. Will re-read your note tomorrow. Kevin.