The task at hand was two-pronged – connecting an embedded system to an existing TCP/IP network, and developing a lightweight, simple web interface that can both send commands to the MCU (server) and send the status to the browser (client).
Software – First, a lightweight socket library was used. Low-level HTTP request parser and response formatter is written to handle HTTP GET and POST methods. GET allows return of a web resource (index.htm) and POST lets one submit data to the server (i.e. send form data to the server). Web resources (index.htm, favicon.ico) are converted to a C array using bin2c. To look up a requested resource a URI/resource lookup table can be created. When sending specific commands to the server, LEDs can be toggled by handling POST data parsing.
Functionality – By setting the IP address (192.168.1.233) in the firmware and entering it in the web browser, one can connect to the local network. Since Z1/Z2 are mapped to LED 1/LED0, it is easy to toggle between 0/1 by clicking Z1/Z2/Z3. The MCU embeds Z1/Z2/Z3 status in the web page.
Interfacing with the WIZnet W5100 Ethernet chip created a simple web server that supports URI lookup and serves up basic HTML and graphics files. Another accomplishment was being able to handle POST data from client to perform commands. One can also generate HTML files on-the-fly with embedded system status.
- EFM32ZG STK
- W5100 TCP/IP module (WIZ811MJ)
Further Development Scope:
It would be interesting to integrate this with a previous Hack-a-Gecko project (Speaker Selector IR blaster) and see how it affects results. Another possible avenue could be to add DHCP support. The FW robustness also leaves room for improvement – in terms of the code base needing clean up and the corner cases being handled better (buffer overflow).