How to send data structure from MCU to embedded Web Server
I'm setting up an embedded Web Server on STM32F4 MCU.
My program variables are stored into one big data structure. For instance, if I need to access to the temperature of my board, I'd simply check the value of Variables.Temperatures.BoardTemperature.
I used the ad.cgi example as a base to extract data from my software variable and have them on the web server. Here is an example of how I proceeded :
On a .cgi file I'd call the CGI function :
c g 1 size=’10’ id=’TempValue’ value=’%1d’> In my HTTP_Server_CGI.c, I process the data using the netCGI_Script function :
Switch (env[0]) {
case 'g' :
len = (uint32_t)sprintf(buf, &env[4], Variables.Temperatures.BoardTemperature);
}Finally, I'd use a .cgx file to update this value :
t <form>
t <text>
t <id>TempValue</id>
c <value>TempValue</value>
t </form> Finally, using the already written updateForm function, I'd update values of my form every 500 ms.
Altough this method work fine I'm not willing to use it because of the incredible amount of code it generates. I have over 800 variables I need to update constantly. Writing 2400 line of code for simple data transfer seems odd.
I want to fetch the whole Acquisition structure from my server into my web page, and process the incoming data with JavaScript in order to use minimal HTTP requests between the MCU & Web Server. How is this possible ? Can XML handle large data or implementing JSON data structure would fit better ?
