Serial Number=%S01
The 'S' is the Variable Group and the '01' is the VarValue in uppercase hex. During processing of this file, the HTTP Server encounters the ‘%S01’ string. After parsing it, the HTTP Server makes a callback to HTTPGetVar(httpInfo, val). The httpInfo->var.get.varRef will have the value HTTP_START_OF_VAR. The main user application implements HTTPGetVar as follows:
#include "projdefs.h" #include "net\http.h" ROM char SerialNumberStr[] = "123456SER"; WORD HTTPGetVar(HTTP_INFO* httpInfo, BYTE* val) { BYTE varValue, varGroup, ref; varValue = httpInfo->var.get.tagVal; //Variable Value of requested variable varGroup = httpInfo->var.get.tagGroup; //Variable Group of requested variable ref = httpInfo->var.get.varRef; //Current callback reference with respect // to 'var' variable. //In case requested var not found, set it to NULL character and return HTTP_END_OF_VAR *val = '\0'; //Identify variable group if (varGroup == 'S') { // Identify variable value. if ( varValue == 0x01 ) { // Serial Number is a NULL terminated string. // First of all determine, if this is very first call. if ( ref == HTTP_START_OF_VAR ) { // This is the first call. Initialize index to SerialNumber // string. We are using ref as our index. ref = (BYTE)0; } // Now access byte at current index and save it in buffer. *val = SerialNumberStr[(BYTE)ref]; // Did we reach end of string? if ( *val == ‘\0’ ) { // Yes, we are done transferring the string. // Return with HTTP_END_OF_VAR to notify HTTP server that we // are finished transferring the value. return HTTP_END_OF_VAR; } // Or else, increment array index and return it to HTTP server. (BYTE)ref++; // Since value of ref is not HTTP_END_OF_VAR, HTTP server will call // us again for rest of the value. return ref; } else { // Check for other variables values... } } }