An ASCII ‘0’ flips the state of the physical blue LED.
If you’re wondering about AJAX, it is a method that
page to be modified without having to reload the entire
The ledxml(0) data element is represented by the XML
tags <ledblue> and </ledblue>. There are no
predetermined tags in XML. Therefore, we can create tags
that make the XML easy to read and understand.
XML. AJAX is not a programming language. It simply uses
existing web page access techniques to work its magic.
AJAX is used in this project to speed up the refresh rate of
the LED web page object.
We’ve already toggled the blue LED that is soldered
to the module’s circuit board. To update the LED on the
The heart of the newAJAXCommand is the
Clicking on the web page causes the HTTP2 server
component to order the execution of a callback function.
XMLHttpRequest object. Invoking XMLHttpRequest allows
the programmer to:
• Update a web page without reloading it.
• Request data from a web page after it has been
The callback order comes from encountering the
~ledxml(0)~ dynamic variable that makes up the entire
logical contents of the led.cgi file. The HTTPPrint_ledxml
callback function is executed by the PIC32 and sends the
current state of the physical blue LED to the web browser:
<?xml version=”1.0” encoding=”utf-8”?>
// LMX WiFi Blue LED Hardware Assignments
#define ledF3_TRIS (TRISFbits.TRISF3)
#define ledF3_IO (LATFbits.LATF3)
#define ledF3_ON() LATFCLR = BIT_3;
#define ledF3_OFF() LATFSET = BIT_3;
#define ledF3_INV() LATFINV = BIT_3;
• Receive data from a web page after it has been
• Send data to a server in the background.
Like AJAX, XML is not a programming language. XML
is used to format and store the data that is being thrown
about. Here’s what the XML looks like for the Wi-Fi
module’s blue LED:
void HTTPPrint_ledxml(WORD ledState)
ledState = ledF3_IO;
// Print the output
Now that the physical LED state is known by the web
code snippet flips the state of the logical LED on the web
page relative to the LED state data that was received:
if(getXMLValue(xmlData, ‘ledblue’) == ‘1’)
.style.color = “blue”;
.style.color = ‘#ddd’;
Here’s how it all fits together. The current logical state
of the PIC32’s RF3 I/O pin is determined and sent to the
web browser by the HTTPPrint_ledxml callback function.
The LMX module’s blue LED is illuminated by forcing the
I/O pin RF3 logically low. Thus, when the physical blue
LED is illuminated, the HTTPPrint_ledxml callback function
sends an ASCII ‘1’ (0x31).
Conversely, a logical high on RF3 says that the
physical blue LED is extinguished and the
HTTPPrint_ledxml callback function sends an ASCII ‘0’
■ Screenshot 2. Pretty cool stuff! Just think. If we can
monitor and control an LED using embedded web services,
we can use these concepts to monitor/control anything.
(0x30). The transmitted XML data is picked up by the web
ASCII 1 paints the web page LED (&bull) blue. Otherwise,
the web page LED is painted gray if an ASCII ‘0’ is
received. I captured the logical LED transitions in
70 January 2014