Web server

myEthernet web server

The firmware for the myEthernet contains software for a embedded web server, that supports the sending of files to the pc via LAN and WAN as well as the assignment and the placement of states, values and configurations for the myEthernet.

Settings of the web server

The web server must have a definite and not yet used adress in the network. The settings will be saved in the file "config.cfg" on the microSD-card (must be placed in the root directory). If you power-up the myEthernet the file will be read and all stored settings will be used.

Example for config.cfg:

# that is a comment
; that is also a comment
#IP-adress
ip=192.168.20.98
#subnet mask
ipMask=255.255.255.0
#web server port
port=80
#Mac-adress
macAddr=2.0.0.2.8.100
twiMode=m24c
twiAddr=0xB0
sharedRamSize=128
sharedEepromSize=128

If no config.cfg exists or no microSD-card is inserted the following defaults values will be activated:
IP-address: 192.168.20.96
web server-port: 80
subnet-mask: 255.255.255.0
mac-adress: 2.0.0.2.8.100

Substitutions:

With the embedded web server of the myEthernet many analyses are possible. Therefor it uses it's own command- and substitution syntax. With the execution of these commands you can scan current values for several or all pins. Furthermore current pin-configurations and all possibilities from the pin-settings will be displayed.
Substitutions are realized in htm-files and can be used and placed in any combination with java script or HTML-elements.
Attention: If you would like to display the sign of degree °, then use the special sign for HTML °.

Syntax: °<type><pin no>~<count>~<divider>~<format>°

° ⇒ separator (degree)
<type> ⇒ scan value or configuration
  • c ... current configuration
  • C ... possible configuration
  • v ... current value
  • V ... current value of adjacent multiple pins
<pin no> ⇒ *, 0...23, virtual: 200-207, 210, 211, 1000...3999, 5000...7999
<count> ⇒ count of adjacent pins (physical or virtual) - only with type "V"
<divider> ⇒ divider for values of adjacent pins - only with type "V"
<format> ⇒ preformated value output, eg: "%d" "lm75"

Example:
var ledGruen="°c20°"; Displays the current configuration at pin 20 and assigns it to the variable "ledGruen" in the java script of a HTML-page

<body>°v*°</body> Displays all values of all pins on HTML-page

<body>°V200~2~&deg;C ~lm75°</body> returns preformated temperature data of TWI-sensor 200,201 (divider = °C)
Additional substitutions
Besides the scanning of the pins you can also readout information about the embedded web server and its current configuration.
Syntax: °i<parameter>°

° ⇒ separator (degree)
i ⇒ command for information request
<parameter> ⇒ information type
  • b ... buildnumber of firmware
  • h ... hardware info
  • i ... IP-address
  • m ... mac-adress (hexadecimal notation)
  • n ... subnet-mask (subnet)
  • p ... web server-port
  • t ... system time since start (seconds)
  • v ... version of firmware
  • Cs ... socket count
  • Cr ... socket receivebuffer size (byte)
  • Cg ... getrequest buffer size (byte)
  • Sr ... minimum of free heap memory
  • Sh ... size of heap memory
  • SU ... maximum of used heap memory
  • Sf ... sum of free heap memory
  • Su ... sum of used heap memory
  • Sp ... count of parts of heap memory fragments
  • SS ... maximum size of used stack memory
Comments:
syntax: °!<comment text>°

° ⇒ Separator (degree)
! ⇒ Sign for comments
The whole text betwenn the seperators will be removed.

Commands:

The Commands are instructions for the microcontroller of the myEthernet. They cause a modification of one or more pins. Thereby the output values and the setting of the pins can be controlled.
Unlike a substitution a command will be executed via a HTTP-Request. This is achievable with an input at an address bar of the web browser or with the help of a java script by using the XMLHttpRequest-object.

Syntax: <command>=°<type><pin-Nr>~<value>°

<command> ⇒ command for myEthernet
  • myConfigCmd ... change configuration
  • myChangeCmd ... change output value
= ⇒ Separator
° ⇒ separator (degree) with the code of characters «%B0»
<type> ⇒ change value or configuration
  • c ... change configuration
  • o ... change output
<pin-No> ⇒ 0...23, virtual: 100,101...
~ = Value association sign (tilde) with the code of characters «%7E»
<value> ⇒ new output value at decimal or hexa-decimal format i.e.: 0x20

Example:
http://192.168.20.98/?myConfigCmd=%B0c0%7E0x1%B0 set pin 0 to digital-ouput

http://192.168.20.98/?myChangeCmd=%B0o21%7E0%B0 switch off the red LED at pin 21

If many HTTP-requests taking place on the same pin it is necessary to send an extra parameter. This is needed to avoid the us of the browser cache. The previous modified example should be:

http://192.168.20.98/?myChangeCmd=%B0o21%7E0%B0&423801

The blue value is a random value and can be generated via java script.