µWebControl

  • Modernizing machines and equipment made easy.
  • Control and monitor your system via your smartphone or desktop browser.

  • Use the μWebGenerator or let us create a web application adapted to your needs.

Today, users expect a website for control and setup for each machine or system.

ELZET80 µWebControl offers an interface to HTTP communication that can be queried and operated not only by browsers, but also by smartphones, widgets, ERP systems, etc..

With the µWebGenerator you can even generate a web page from the C code without knowledge of HTML or JavaScript.

Supported by all µTasker boards and special solutions with Ethernet.

  • Operation
  • µTasker-Integration
  • Example: IO-Callback
  • Example: PC-Widget
  • Downloads

μWebControl offers you an own HTTP communication interface that you can use in every μTasker project (with Ethernet).

HTTP-GET requests of a special form are interpreted as commands and can be answered with any data.

μWebControl is placed in the web handler of μTasker and waits for requests of the following form:

http://*IPaddress*/*special_character**command*[=*data*]

The Webhanlder checks whether the first character of the query corresponds to the predefined special character.

If this is the case, the request is passed to the µWebControl main function fnHandleDynamicQuery.

This function checks whether a callback function has been registered for the current request. If this is not the case, an empty response is sent.

Example:

request: http://192.168.1.80/!sysInfo

Internally, the "sysInfo" command is extracted and checked whether a callback function is registered for it.

If a callback function is found, it is called and fills the response with the requested data (e.g., serial number, uptime, etc.).

Mount webhandler:

μWebControl is hooked into the web handler of μTasker (file: webinterface.c, function: fnHandleWeb)

The first code in the function is the following code:

if(ptrData[0] == '!'){// Check if the dynamic content page was requested
   return fnHandleDynamicQuery(ptrData, http_session);
}

The above code checks if an HTTP request starts with a predefined special character (here '!').

The fnHandleDynamicQuery function is the main function of the μWebControl code. It checks whether a callback function is stored for the request.

Register callback:

Two command arrays are defined in the dynamicContent.c file. The first array commands contains instructions that can be called without authentication, the second array authCommands contains commands that require authentication.

/*command storage
* CMD("commandString", callbackFunction)
* callbackFunction has to be like this:
* int callbackFunction(char * wrPtr, unsigned char message[], int * dynLen, char* query){}
*
*/
WEBCOMMAND commands[] = {
   CMD("login=",fnWebLogin),
   CMD("loginState",fnGetLoginState),
   CMD("gbv",fnGetWebVars),
   CMD("getPageDesc",fnGetPageDesc),
   CMD("curTm",fnGetCurrentTime),
   CMD("hdlVar=",fnWebHandler),
   CMD("clear",fnClearWebPars),
   CMD("btn",fnAddButton),
   CMD("getVals",fnGetValues),
};

WEBCOMMAND authCommands[] = {
   CMD("setTime=",fnSetTime),
};

Structure callback function:

The callback functions must correspond to the following function header:

int callbackFunction(char * wrPtr, unsigned char message[], int * dynLen, char* query);

  • wrPtr:   buffer to hold the data
  • message: The startaddress of wrPtr to calculate dynLen
  • dynLen:  an integer pointer to store the length of the data to send
  • query:   The request query

Example function fnGetIOStates:

The following function creates a page with the current states of the NET-3A4IO I/Os.

int fnGetIOState(char * wrPtr, unsigned char message[], int * dynLen, char* query){
  long lTemp;

//first we display the three raw adc values 

  wrPtr = uStrcpy(wrPtr,"ADC1: ");
  wrPtr = fnBufferDec((fnGetADC3A4IO(0)),1,wrPtr);

  wrPtr = uStrcpy(wrPtr,"<br>ADC2: ");
  wrPtr = fnBufferDec((fnGetADC3A4IO(1)),1,wrPtr);

  wrPtr = uStrcpy(wrPtr,"<br>ADC3: ");
  wrPtr = fnBufferDec((fnGetADC3A4IO(2)),1,wrPtr);

//check if the 3A4IO is configured for PT100 or type K thermocouples and print it accordingly

  if(uc3A4IORange == RANGE_RTD_RAW){
    wrPtr = uStrcpy(wrPtr,"<br> PT100(ADC1): ");
    wrPtr = fnBufferDec(fnLinVal(fnGetADC3A4IO(0),0),1,wrPtr);
  }else if(uc3A4IORange == RANGE_TC_RAW){
    wrPtr = uStrcpy(wrPtr,"<br> Type K(ADC1): ");
    wrPtr = fnBufferDec(fnLinVal(fnGetADC3A4IO(0) + s3A4IO_ref_temp,1),1,wrPtr);
  }

//here we collect and print the states of the four outputs

  wrPtr = uStrcpy(wrPtr,"<br> OUTPUT1: ");
  wrPtr = fnBufferDec(fnGetOutput3A4IO(0),0,wrPtr);
  wrPtr = uStrcpy(wrPtr,"<br> OUTPUT2: ");
  wrPtr = fnBufferDec(fnGetOutput3A4IO(1),0,wrPtr);
  wrPtr = uStrcpy(wrPtr,"<br> OUTPUT3: ");
  wrPtr = fnBufferDec(fnGetOutput3A4IO(2),0,wrPtr);
  wrPtr = uStrcpy(wrPtr,"<br> OUTPUT4: ");
  wrPtr = fnBufferDec(fnGetOutput3A4IO(3),0,wrPtr);

 
//here we collect and print the states of the four inputs

  wrPtr = uStrcpy(wrPtr,"<br> Input1: ");
  wrPtr = fnBufferDec(fnGetInput3A4IO(0),0,wrPtr);
  wrPtr = uStrcpy(wrPtr,"<br> Input2: ");
  wrPtr = fnBufferDec(fnGetInput3A4IO(1),0,wrPtr);
  wrPtr = uStrcpy(wrPtr,"<br> Input3: ");
  wrPtr = fnBufferDec(fnGetInput3A4IO(2),0,wrPtr);
  wrPtr = uStrcpy(wrPtr,"<br> Input4: ");
  wrPtr = fnBufferDec(fnGetInput3A4IO(3),0,wrPtr);

//calculate the length of the generated content
  *dynLen = (wrPtr - (CHAR*) message);
  return 0;
}

 

The result looks like this:

 

ADC1: 12124
ADC2: 5125
ADC3: 12113
PT100(ADC1): 234
OUTPUT1: 0
OUTPUT2: 1
OUTPUT3: 0
OUTPUT4: 0
Input1: 1
Input2: 0
Input3: 1
Input4: 1

Example PC-Widget:

The PC widget is a small tool that serves to monitor your system.

The widget communicates with the hardware via the μWebControl interface, as well as the web page. ELZET80 devices are automatically detected via the "Device Discovery" mechanism and, if the widget interface is supported, displayed in the selection list.

The data to be mapped are defined in a structure in the μTasker program code.

For the example shown on the right, the definition looks like this:


        VALUE(iInput1,C8,0,"Input 1"),
        VALUE(iInput2,C8,0,"Input 2"),
        VALUE(iInput3,C8,0,"Input 3"),
        VALUE(iInput4,C8,0,"Input 4"),
        VALUE(iADC1,S16,(unit_ampere | exp_deci),"ADC1"),
        VALUE(iADC2,S16,0,"ADC2"),
        VALUE(iADC3,S16,0,"ADC3"),
        VALUE(sliderDemo,S16,(unit_hour| exp_none),"ADC3"),

The above code is structured as follows:

VALUE(Variable,Type,(Unit | Exponent),Display name)

 

Variable:

the variable in the C code whose value is mapped.

Type:

 

Data type of the variable Important for signed/unsigned presentation.

Unit | Exponent:

 

e.g. (unit_ampere | exp_deci) - > Unit: Ampere, Exponent: Deci (-1) Important for scaling the values ​​for the ad.

Display name:

The heading for the value displayed in the widget.

VALUE objects are read-only values, so it is not necessary to specify limits (Min / Max).

 

 

You can find the sample code for the PC widget under the "Downloads"-tab

Dls