chipKIT® Development Platform

Inspired by Arduino™

Networked blinky tutorial on the WF32

Created Tue, 24 Jun 2014 18:56:32 +0000 by Jay Weeks


Jay Weeks

Tue, 24 Jun 2014 18:56:32 +0000

I'm working on building a tutorial for the networked equivalent of the basic LED blinking tutorial on the WF32 (ie. blinking an LED based off input from a webpage), but I'm also very new to anything to do with networks so I'm trying to modify the HTTPsrv example instead of coding everything from scratch. I've got two ideas for how to do this but I'd like to get some feedback on them before I dig myself too deep.

I've sifted through the code enough to get a feel for how it works, but please correct me if I'm wrong. My understanding is that it works as two state machines, one for the server and one for the client. The server state machine in ProcessServer.cpp takes care of everything the server needs to have done, mostly to do with connecting and disconnecting. Then the client state machine in ProcessClient.cpp takes care of communication with the client and doing whatever it is they need.

Like I said, I have two ideas for how to attack this.

The first would be to make a new state or set of states within the client state machine which would take care of whatever IO functions I'd want to do (in this case blinking an LED). This is advantageous because it will keep the server from hanging when functions get bigger and bigger (assuming they're split up into appropriately small states).

My other idea is to make a sort of instruction variable that will get dealt with after the ProcessServer() call in the loop section of the WebServer.pde sketch exist. This is advantageous because it would allow new users (like me) to ignore all the complicated background code, and focus on their code in the familiar one-page sketch format they're probably used to.

Will either of these ideas work? Is there some other more standard or easier method I should be using instead, or am I on the right track?


Max44

Sat, 28 Jun 2014 19:38:35 +0000

Jay,

I bought a WF32 and set out to do the same thing. Maybe it's just me, but I found the Digilent method of parsing and rendering web pages in C/C++ to be very cumbersome. And not documented! I thought MicroChip's approach to interactive Web pages to be much more robust with documentation, tutorials, and examples. Plus it has the path to creating interactive Web pages using Javascript .... the way to go IMHO, even though I don't know the language. In fact, MicroChip's WiFiG demo is just what you're trying to do.

However, this means that you probably want to work in the MPLAB X environment using MicroChip libraries. I took the MicroChip WiFiG demo .... which has very similar hardware to the WF32 .... and got it running on the WF32. I modified it to toggle and display the user LEDs and read the state of the 2 user buttons.

Let me know if you want further information on the MicroChip demo. If you want to stay in MPIDE, you may take a look at the project at:

[url]http://chipkit.net/wifi-enabled-law-sprinkler-controller-chipkit-wf32/[/url]

Warning: It's quite complex!

Max