chipKIT® Development Platform

Inspired by Arduino™

Digilent's Beta 2 WiFi Library

Created Tue, 10 Apr 2012 20:43:58 +0000 by KeithV


KeithV

Tue, 10 Apr 2012 20:43:58 +0000

Digilent just posted beta 2 of their DWIFIcK WiFi library. This library adds WiFi support to the DNETcK IP Network library (Digilent’s extension of the Ethernet library) and works with MRF24WB0MA WiFi transceiver

This is a beta version and there is no documentation for the WiFi class yet, however there are 8 examples that should make it clear on how to use the class.

To install the library:

  1. You must be using the release version of MPIDE, more specifically mpide-0023-windows-20111221. The newlib version of MPIDE has known issues at this time; so use at your own risk.

  2. Identify where your 3rd party libraries directory is, look under File->Preferences in MPIDE, and then look at the Sketchbook location. Under the Sketchbook location directory there should be a libraries subdirectory, this is where you will install DNETcK and DWIFIcK.

  3. Close MPIDE, you do not what it running.

  4. Navigate to your <Sketchbook location>/libraries directory. If the libraries subdirectory does not already exist under your sketchbook locaiton, create it.

  5. If you already have a DNETcK and/or DWIFIcK subdirectory, back them up and remove (delete) DNETcK AND DWIFIcK from the libraries directory. The beta release will replace both of these. It is important that both DNETcK and DWIFIcK be consistent!

  6. Download DWIFIcK Libs.zip to your <Sketchbook location>/libraries directory. DWIFIcK Libs.zip can be found at: http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,893&Prod=CHIPKIT-UNO32

  7. Unzip the library in place, both DNETcK and DWIFIcK directories should be created. (you can remove the .zip file once unzipped).

  8. Start MPIDE, you should see under sketch->import library the DNETcK and DWIFIcK libraries. Also under File->examples, you should see the DNETcK and DWIFIcK examples.

  9. This release normalizes the source for DNETcK to work either stand-alone for “wired” Ethernet applications, or in conjunction with DWIFIcK for “wireless” applications. You must first include the DNETcK header “before” the DWIFIcK header in your source. I fixed the previous restriction where DNETcK could not be installed concurrently with DWIFIcK, now they work together and DWIFIcK requires DNETcK. All existing DNETcK and DWIFIcK sketches should compile and run as before.

  10. The MRF24WB0MA is a 1&2Mbps device. That is within the Wireless-B range and will most likely show up on your router as Wireless-B (but does not have too). But more to the point, your router MUST support 1&2Mbps and must support a basic rate of 1&2Mbps. So what does this mean exactly? It is complicated, so I will just give some guidelines: a. First, just try to connect with your router’s default settings; there is a good chance it will just work. b. The Basic Rate is a speed that the router will transmit basic information such as the broadcast SSID and security info. Almost by specification, all routers are supposed to support basic rates of 1&2Mbps, and optionally higher ones if they like. However some routers have proprietary features that transmit this data at higher rates and some don’t even support the 1&2Mbps by default because almost no current devices run that slow anymore; except the MRF24WB0MA. If your router does not have a basic rate of 1&2 Mbps, the MRF24WB0MA will not connect. To solve this, some routers have options to specifically set the basic rate (so select 1&2Mbps). Other routers will do this if you select Wireless-B or Mixed Wireless B,G,&N. And then other routers will just support basic rates of 1&2Mbps by default and you can get away with just selecting Wireless-G or N. Another thing to try if things don’t work, try turning off all proprietary options, like QOS or speedup features. c. I found that my LinkSys just works. My Belkin I had to specify Mixed B,G, & N, and chipkit_Andy on the form had a NetGear that he had to install the DD-WRT open source Firmware to get the option to specify 1&2Mbps.

  11. WPA and WPA2 sound a lot alike, but they have very little in common. WPA was invented to “fix” WEP on existing hardware. WPA2 is the real fix and in most cases required new hardware. WPA is WEP on steroids; WPA2 is secure and is quickly becoming the standard. However from the users point of view WPA and WPA2 look similar, that is, you provide a SSID and passphrase and away you go. Most routers will support a mixed WPA/WPA2 mode, and the MRF24WB0MA WiFi MAL also supports mixed WPA/WPA2 mode. However, how the router and the MAL “determine” what to use when both are in mixed mode can get you in trouble. You would think that WPA2 would be selected, and that is typically the case. However, I have a router that has no problem (LinkSys) and one that has a terrible problem (Belkin). So by default I coded the MAL in WPA2 only mode, this seems to resolve most issues. However, if you are still having problems, put your router in WPA2 ONLY mode. If you need WPA, you can specify WPA with DWIFIcK but that requires you to use the long (explicit) form of the DWIFIcK::connect() to do that. Using the simpler overloaded SSID/PassPhrase DWIFIcK::connect() will put the MRF24WB0MA in WPA2 ONLY mode. a. Another issue with WPA/WPA2 to be aware of is that the passphrase is used to calculate a 32 byte key. This takes the MAL about 30 seconds to do. So when you use a passphrase expect the connection process to take 30s or more; this will appear like nothing is happening, but there is calculations going on. I provided an isConnected() method so you can loop and do other things while waiting for the connect. In fact, you must execute periodicTasks() in your loop in order for it to complete. Just look at the examples, this will become clear.

  12. Make sure your router has SSID Broadcast enabled. Most routers do by default. However, DWIFIcK currently does a passive scan and will only pick up your SSID if your router transmits it. A quick an easy way to know if you can see your router is to run the WiFiScan example and display in the serial monitor the results. You should see your router’s data, and you should see the SSID. If the SSID is blank, make sure you have SSID Broadcast turned ON.

  13. I have found that once you are connected, the code is very reliable. I have a server that has been up for several months now without failure. All of the DNETcK features are supported once WiFi is up and running. The most comprehensive example is the WiFiRemoteWOL example and shows everything from a WiFi Scan, to connection loss and reconnect as well as a complete restart of both the WiFi connection as well as a DHCP restart. For Simplicity, start with the WiFiScan and TCPEchoClient examples; from there it should be clear.

This works on the following hardware: Max32 with a WiFiShield (To be released shortly) Uno32 with a WiFiShield (To be released shortly) Max32 with PmodShield and PmodWiFi on connector JC Uno32 with PmodShield and PmodWiFi on connector JC MX3cK with PmodWiFi on connector JE MX4cK with PmodWiFi on connector JB MX7cK with PmodWiFi on connector JF

Let me know how it goes… The last beta pointed out some issues and I got them fixed… or so I think!


MGLSOFT

Tue, 10 Apr 2012 21:31:53 +0000

This works on the following hardware: Max32 with a WiFiShield (To be released shortly)

Hello KeithV !! Thanks for developing this library! For when it plans to launch the WifiShield? Interests me as it was to develop a project for my ...


KeithV

Wed, 11 Apr 2012 14:53:22 +0000

Well, I can't give an exact date because I don't know the manufacturing schedule. I do know that I have tested Rev B of the board and it works! There is discussion of Rev C of the board with some very minor tweaking and I don't know what the final outcome of that is yet. But this is very minor so the board should go into manufacturing soon. So what I am saying is, I have held a working board in my hands, so it will be soon.

If you are in a hurry, you can get a PmodShield and PmodWiFi and anything you develop there will work unaltered on the WiFiShield. I know that cost a little money, but there are always costs to advanced development.

Anyway, no promises, but I will see if I can get a feel of the manufacturing schedule.


MGLSOFT

Thu, 12 Apr 2012 01:37:54 +0000

OK, thanks...


MGLSOFT

Fri, 15 Jun 2012 11:47:15 +0000

Hey. For when you will be ready Wifi Shield? I can be a Beta tester, if you need ...


KeithV

Wed, 20 Jun 2012 17:43:37 +0000

You can get our first "release" of the WiFi code from:

http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,942&Prod=CHIPKIT-NETWORK-SHIELD

Make sure you delete any existing DNETcK or DWIFIcK directories under your libraries directory before installing this. There have been a lot of changes since the last beta and we have done some stress testing that went very well.

As for the WiFiShield, which works on both of the Uno32 and Max32, it is being manufactured right now, we are just waiting for the shipment to come in and get into the retail loop.


MGLSOFT

Wed, 20 Jun 2012 19:58:33 +0000

Fantastic news! Thank you very much!