Main Site Documentation

WiFi with DHCP - Error getting lease


#1

Hi All,

I’ve managed to get WiFi working after some time, however whenever I try to get a DHCP based IP address, I get an exception thrown as below:

Exception System.Exception - CLR_E_FAIL (1)

#### Message: 
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDhcp [IP: 000f] ####

Any ideas? The DHCP server works, as when connected via cable, DHCP is leased without issue.

Update:
I’ve confirmed when using manual IP settings it works ok. Just DHCP is causing an issue. With manual settings:
IP Address: 10.1.3.2
Subnet Mask: 255.255.0.0
Default Getway: 10.1.1.254
DNS Server: 203.0.178.191
Test DNS
www.ghielectronics.com: 207.58.176.212

The full MFDeploy output is below:
Connecting to EMX_EMX…Connected
Set MAC addr …
mac = 00:1A:F1:00:42:0D
Mac address Set
Set regional domain …
region = fcc
Set security …
setting PSK key …
security key set
Scan … for ssid "wlan-ap2 "
WiFi link is not available yet! Wrong AP settings?
Still waiting.
[0] bssid = 00:04:ED:A9:05:87
strength = ###…

    indicator = 148

    ssid = wlan-ap2

    channel = 7

AP selected = [0] 

Join …
succeeded
Authenticate …
succeeded
Associate …
succeeded
Connected …
WiFi link is ready!
Enable DHCP
Attempting to Enable DHCP
#### Exception System.Exception - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDhcp [IP: 000f] ####
#### WiFi_Example4._0.Program::Main [IP: 00fb] ####
DHCP Faild


#2

Does your switch have Ethernet and WiFi? If so, can you connect over Ethernet and see if you get a lease?


#3

Yes it has both, using Ethernet it works ok:

Enable DHCP
Network settings:
IP Address: 10.1.2.6
Subnet Mask: 255.255.0.0
Default Getway: 10.1.1.254
DNS Server: 10.1.1.254


#4

Does it take like 20 to 30 secods before raising the exception?

What router do you use?


#5

If it works with the static IP, I’d try restarting the router. Unplug it and leave it off for 30 seconds, then power it back on and try. The difference between the two interfaces is that each has its own MAC address, which is how the leases are given out. I’ve had several routers that would stop giving out leases to a specific MAC unless you restart them.

Not the solution, just something to try.


#6

You’ve just reminded me of an important point.

Make sure you have different MAC address for ethernet and the WiFi. I believe you are using the same router to test Ethernet and Wifi. The router might think it is a conflict in MAC addresses with two devices. Or better restart the router after changing the interface from Ethernet to Wifi.


#7

Yeah it seems to take around 30 seconds for it to throw the exception. I’ll try restart router and post back with result when I’m home in couple hours. Can I change the Mac of Ethernet / zerog? Assumed they would be different, will check this also.

Thanks for your help.


#8

No difference after restarting router :frowning:


#9

To answer your question, yes you can change the mac address in code is a property member under NetworkInterface class.

NetworkInterface[] netif = NetworkInterface.GetAllNetworkInterfaces();
byte[] newMAC = new byte[] { 0x00, 0x1A, 0xF1, 0x01, 0x42, 0x0C };
netif [0].PhysicalAddress = newMAC;

But be careful, WiFi and Ethernet uses the same network configuration in the system so updating the mac for one interface will affect the other interface. We hope to change this fact in future after supporting multiple network interfaces.

For your DHCP issue, What is your router’s model?


#10

I’ll try changing the mac address, not sure it will make a difference since restarted router to clear out lease history.

Router is billion 7404vgox.

Thanks again for you help.


#11

We don’t have tested this kind of routers. Not sure if ZeroG did.
These are couple hints that might help you out:

  1. Make sure that you have the latest firmware on your router.
  2. Try your system with a different router. Just to make sure that the system and your code is working.

Since you said DHCP worked with Ethernat, then most likely it should work or It might be a compatibility issue in ZeroG.
Both WiFi and Ethernet share the same DHCP client engine


#12

I have the same problem. Copied the example exactly. Only changing SSID & WEP/PassPhrase.

Same problem. I also get all the messages you describe in MFDeploy. Yes it takes about 30 sec to fail.

So then I verified my MAC Address settings w/ my router (motorola surfboard) the Cobra’s address is unique among the router, pc, and laptop that are connected.

I also checked the gateway logs; no errors.


#13

Skewworks,

Do you get the DHCP working if you connect FEZ Cobra through Ethernet?


#14

Yes. DHCP over ethernet works no problems.

Updating my Router settings to have NO security and the same for the WiFi module works; except when I call save settings it raises an error in NetworkChange_NetworkAvailabilityChanged which can be stepped over to continue.

Ideas?


#15

I’ve also gotten things working with WPA using a PassKey. I’d prefer WEP though; could you guide me on that?


#16

Have you tried to use a hex key with wep instead of a pass phrase?


#17

I have. I get an error saving doing that.

Say for example I’m running 64bit with key1 value of ff98c0e88f

                WiFiSettings.NetworkKey = new byte[] {0xff,0x98,0xc0,0xe8,0x8f};
                Wireless80211.SaveConfiguration(new Wireless80211[] { WiFiSettings }, false);

Fails on SaveConfiguration


#18

There is a common known issue with WEP “in general, not only on ZeroG”:

If you put a wrong passphrase with WEP, you will NOT get authentication failure. On the other hand, the system will not be able to communicate with the access point.


#19

So DHCP works fine when you’re using WPA but not WEP? Are you sure you tested WEP with a static IP and not just WPA? As Josef said, it may be a WEP issue unless you successfully tested WEP + static.

Unless you have a specific need to connect to WEP access points (there ARE a lot of them out there), WPA/WPA2 is generally the preferred encryption as it’s far more secure.