|
|
@@ -1,4 +1,4 @@ |
|
|
|
/* Web_Net_Setup.pde - example for a webinterface to set the network configuration |
|
|
|
/* Web_Net_Setup.pde - example for a webinterface to set the network configuration |
|
|
|
Author: Matthias Maderer |
|
|
|
Date: 07.03.2013 |
|
|
|
Version: 1.0.1 |
|
|
@@ -13,7 +13,7 @@ For more informations about EEPROMAnything.h look at http://playground.arduino.c |
|
|
|
/* |
|
|
|
* With this example its possible to configure the network configuration of the |
|
|
|
* Arduino Ethernet Shield with a webinterface. Imagine like your router setup. |
|
|
|
* |
|
|
|
* |
|
|
|
* It's possible to configure the following network settings: |
|
|
|
* - MAC address |
|
|
|
* - IP address |
|
|
@@ -29,11 +29,11 @@ For more informations about EEPROMAnything.h look at http://playground.arduino.c |
|
|
|
* - Display DHCP renew timestamp |
|
|
|
* - Display Arduino uptime |
|
|
|
* - Display used RAM |
|
|
|
* |
|
|
|
* |
|
|
|
* You can configure default settings. This settings are used wenn no configuration is present. |
|
|
|
* Look at the function set_EEPROM_Default(). |
|
|
|
* |
|
|
|
* It is possible to connect a RESET button. If the button is pressed and the Arduino is turned on |
|
|
|
* It is possible to connect a RESET button. If the button is pressed and the Arduino is turned on |
|
|
|
* the default values would be restored too. |
|
|
|
* See #define RESET_PIN. |
|
|
|
* |
|
|
@@ -41,9 +41,9 @@ For more informations about EEPROMAnything.h look at http://playground.arduino.c |
|
|
|
* All settings are stored in EEPROM. This means they are permanent. |
|
|
|
* Please look at http://arduino.cc/en/Reference/EEPROM for a short description. |
|
|
|
* |
|
|
|
* |
|
|
|
* |
|
|
|
* To setup your arduino upload this sketch. |
|
|
|
* |
|
|
|
* |
|
|
|
* If you don't change the sourcecode the default IP address is http://192.168.0.111/ |
|
|
|
* Don't forget to change the IP of your network adapter to a suitable address (e.g. to IP 192.168.0.1, NETMASK 255.255.255.0)! |
|
|
|
* |
|
|
@@ -64,7 +64,7 @@ For more informations about EEPROMAnything.h look at http://playground.arduino.c |
|
|
|
|
|
|
|
|
|
|
|
#define WEBDUINO_FAVICON_DATA "" // no favicon |
|
|
|
//#define DEBUG //uncomment for serial debug output |
|
|
|
#define DEBUG //uncomment for serial debug output |
|
|
|
#define USE_SYSTEM_LIBRARY //comment out if you want to save some space (about 1 Byte). You wouldn't see uptime and free RAM if it's commented out. |
|
|
|
#define SERIAL_BAUD 9600 |
|
|
|
|
|
|
@@ -73,65 +73,73 @@ For more informations about EEPROMAnything.h look at http://playground.arduino.c |
|
|
|
#include "avr/pgmspace.h" // new include |
|
|
|
#include "Ethernet.h" |
|
|
|
#include "WebServer.h" |
|
|
|
#include <EEPROM.h> |
|
|
|
|
|
|
|
|
|
|
|
/* ############################################################################################################################################################# |
|
|
|
* Code for the EEPROM related things |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
#include <EEPROM.h> |
|
|
|
#include "EEPROMAnything.h" |
|
|
|
//#include <EEPROM.h> |
|
|
|
//#include "EEPROMAnything.h" |
|
|
|
|
|
|
|
#define RESET_PIN 40 //Connect a button to this PIN. If the button is hold, an the device is turned on the default ethernet settings are restored. |
|
|
|
|
|
|
|
/* structure which is stored in the eeprom. |
|
|
|
/* structure which is stored in the eeprom. |
|
|
|
* Look at "EEPROMAnything.h" for the functions storing and reading the struct |
|
|
|
*/ |
|
|
|
struct config_t |
|
|
|
#include "struct.h" |
|
|
|
|
|
|
|
int EEPROM_readAnything(int ee, config_t& value) |
|
|
|
{ |
|
|
|
byte config_set; |
|
|
|
byte use_dhcp; |
|
|
|
byte dhcp_refresh_minutes; |
|
|
|
byte mac[6]; |
|
|
|
byte ip[4]; |
|
|
|
byte gateway[4]; |
|
|
|
byte subnet[4]; |
|
|
|
byte dns_server[4]; |
|
|
|
unsigned int webserverPort; |
|
|
|
} eeprom_config; |
|
|
|
byte* p = (byte*)(void*)&value; |
|
|
|
unsigned int i; |
|
|
|
for (i = 0; i < sizeof(value); i++) |
|
|
|
*p++ = EEPROM.read(ee++); |
|
|
|
return i; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
int EEPROM_writeAnything(int ee, const config_t& value) |
|
|
|
{ |
|
|
|
const byte* p = (const byte*)(const void*)&value; |
|
|
|
unsigned int i; |
|
|
|
for (i = 0; i < sizeof(value); i++) |
|
|
|
EEPROM.write(ee++, *p++); |
|
|
|
return i; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* set_EEPROM_Default() function |
|
|
|
* |
|
|
|
* The default settings. |
|
|
|
* The default settings. |
|
|
|
* This settings are used when no config is present or the reset button is pressed. |
|
|
|
*/ |
|
|
|
void set_EEPROM_Default() { |
|
|
|
eeprom_config.config_set=1; // dont change! It's used to check if the config is already set |
|
|
|
|
|
|
|
|
|
|
|
eeprom_config.use_dhcp=0; // use DHCP per default |
|
|
|
eeprom_config.dhcp_refresh_minutes=60; // refresh the DHCP every 60 minutes |
|
|
|
|
|
|
|
|
|
|
|
// set the default MAC address. In this case its DE:AD:BE:EF:FE:ED |
|
|
|
eeprom_config.mac[0]=0xDE; |
|
|
|
eeprom_config.mac[0]=0xDE; |
|
|
|
eeprom_config.mac[1]=0xAD; |
|
|
|
eeprom_config.mac[2]=0xBE; |
|
|
|
eeprom_config.mac[3]=0xEF; |
|
|
|
eeprom_config.mac[4]=0xFE; |
|
|
|
eeprom_config.mac[5]=0xED; |
|
|
|
|
|
|
|
|
|
|
|
// set the default IP address for the arduino. In this case its 192.168.0.111 |
|
|
|
eeprom_config.ip[0]=192; |
|
|
|
eeprom_config.ip[1]=168; |
|
|
|
eeprom_config.ip[2]=0; |
|
|
|
eeprom_config.ip[3]=111; |
|
|
|
|
|
|
|
eeprom_config.ip[2]=1; |
|
|
|
eeprom_config.ip[3]=97; |
|
|
|
|
|
|
|
// set the default GATEWAY. In this case its 192.168.0.254 |
|
|
|
eeprom_config.gateway[0]=192; |
|
|
|
eeprom_config.gateway[1]=168; |
|
|
|
eeprom_config.gateway[2]=0; |
|
|
|
eeprom_config.gateway[3]=254; |
|
|
|
|
|
|
|
eeprom_config.gateway[2]=1; |
|
|
|
eeprom_config.gateway[3]=1; |
|
|
|
|
|
|
|
// set the default SUBNET. In this case its 255.255.255.0 |
|
|
|
eeprom_config.subnet[0]=255; |
|
|
|
eeprom_config.subnet[1]=255; |
|
|
@@ -141,15 +149,15 @@ void set_EEPROM_Default() { |
|
|
|
// set the default DNS SERVER. In this case its 192.168.0.254 |
|
|
|
eeprom_config.dns_server[0]=192; |
|
|
|
eeprom_config.dns_server[1]=168; |
|
|
|
eeprom_config.dns_server[2]=0; |
|
|
|
eeprom_config.dns_server[3]=254; |
|
|
|
eeprom_config.dns_server[2]=1; |
|
|
|
eeprom_config.dns_server[3]=1; |
|
|
|
|
|
|
|
// set the default Webserver Port. In this case its Port 80 |
|
|
|
eeprom_config.webserverPort=80; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println("Config reset"); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -165,18 +173,18 @@ void set_EEPROM_Default() { |
|
|
|
void read_EEPROM_Settings() { |
|
|
|
pinMode(RESET_PIN, INPUT); |
|
|
|
digitalWrite(RESET_PIN, HIGH); |
|
|
|
|
|
|
|
|
|
|
|
// read the current config |
|
|
|
EEPROM_readAnything(0, eeprom_config); |
|
|
|
|
|
|
|
|
|
|
|
// check if config is present or if reset button is pressed |
|
|
|
if (eeprom_config.config_set != 1 || digitalRead(RESET_PIN) == LOW) { |
|
|
|
// set default values |
|
|
|
set_EEPROM_Default(); |
|
|
|
|
|
|
|
|
|
|
|
// write the config to eeprom |
|
|
|
EEPROM_writeAnything(0, eeprom_config); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -195,7 +203,7 @@ void print_EEPROM_Settings() { |
|
|
|
} |
|
|
|
} |
|
|
|
Serial.println(); |
|
|
|
|
|
|
|
|
|
|
|
Serial.print("Subnet: "); |
|
|
|
for(int i = 0; i<4; i++) { |
|
|
|
Serial.print(eeprom_config.subnet[i]); |
|
|
@@ -204,7 +212,7 @@ void print_EEPROM_Settings() { |
|
|
|
} |
|
|
|
} |
|
|
|
Serial.println(); |
|
|
|
|
|
|
|
|
|
|
|
Serial.print("Gateway: "); |
|
|
|
for(int i = 0; i<4; i++) { |
|
|
|
Serial.print(eeprom_config.gateway[i]); |
|
|
@@ -222,7 +230,7 @@ void print_EEPROM_Settings() { |
|
|
|
} |
|
|
|
} |
|
|
|
Serial.println(); |
|
|
|
|
|
|
|
|
|
|
|
Serial.print("MAC: "); |
|
|
|
for (int a=0;a<6;a++) { |
|
|
|
Serial.print(eeprom_config.mac[a],HEX); |
|
|
@@ -231,17 +239,17 @@ void print_EEPROM_Settings() { |
|
|
|
} |
|
|
|
} |
|
|
|
Serial.println(); |
|
|
|
|
|
|
|
|
|
|
|
Serial.print("Webserver Port: "); |
|
|
|
Serial.println(eeprom_config.webserverPort); |
|
|
|
|
|
|
|
|
|
|
|
Serial.print("USE DHCP: "); |
|
|
|
Serial.println(eeprom_config.use_dhcp); |
|
|
|
|
|
|
|
|
|
|
|
Serial.print(" DHCP renew every "); |
|
|
|
Serial.print(eeprom_config.dhcp_refresh_minutes); |
|
|
|
Serial.println(" minutes"); |
|
|
|
|
|
|
|
|
|
|
|
Serial.print("Config Set: "); |
|
|
|
Serial.println(eeprom_config.config_set); |
|
|
|
|
|
|
@@ -260,7 +268,7 @@ byte dhcp_state; |
|
|
|
/** |
|
|
|
* renewDHCP() function |
|
|
|
* Renew the DHCP relase in a given interval. |
|
|
|
* |
|
|
|
* |
|
|
|
* Overview: |
|
|
|
* - Check if interval = 0 and set it to 1 |
|
|
|
* - Check if renew interval is reached and renew the lease |
|
|
@@ -269,7 +277,7 @@ void renewDHCP(int interval) { |
|
|
|
unsigned long interval_millis = interval * 60000; |
|
|
|
|
|
|
|
if (interval == 0 ) { |
|
|
|
interval = 1; |
|
|
|
interval = 1; |
|
|
|
} |
|
|
|
if (eeprom_config.use_dhcp==1) { |
|
|
|
if((millis() - last_dhcp_renew) > interval_millis) { |
|
|
@@ -288,22 +296,22 @@ void renewDHCP(int interval) { |
|
|
|
* - First of all read the EEPROM settings |
|
|
|
* - Display a link to the ethernet setup |
|
|
|
* - Check if DHCP should be used, if not create instaces of IPAddress for ip, gateway, subnet and dns_server |
|
|
|
* - Invoke Ethernet.begin with all parameters if no dhcp is active (Ethernet.begin(mac, ip, dns_server, gateway, subnet);). |
|
|
|
* - Invoke Ethernet.begin with all parameters if no dhcp is active (Ethernet.begin(mac, ip, dns_server, gateway, subnet);). |
|
|
|
* - If DHCP is used invoke only with mac (Ethernet.begin(mac);) and display the ip on the serial console. |
|
|
|
*/ |
|
|
|
void setupNetwork() { |
|
|
|
read_EEPROM_Settings(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
print_EEPROM_Settings(); |
|
|
|
#endif |
|
|
|
|
|
|
|
// byte mac[] = { eeprom_config.mac[0], eeprom_config.mac[1], eeprom_config.mac[2], eeprom_config.mac[3], eeprom_config.mac[4], eeprom_config.mac[5] }; |
|
|
|
|
|
|
|
// byte mac[] = { eeprom_config.mac[0], eeprom_config.mac[1], eeprom_config.mac[2], eeprom_config.mac[3], eeprom_config.mac[4], eeprom_config.mac[5] }; |
|
|
|
|
|
|
|
if (eeprom_config.use_dhcp != 1) { |
|
|
|
IPAddress ip(eeprom_config.ip[0], eeprom_config.ip[1], eeprom_config.ip[2], eeprom_config.ip[3]); |
|
|
|
IPAddress gateway (eeprom_config.gateway[0],eeprom_config.gateway[1],eeprom_config.gateway[2],eeprom_config.gateway[3]); |
|
|
|
IPAddress subnet (eeprom_config.subnet[0], eeprom_config.subnet[1], eeprom_config.subnet[2], eeprom_config.subnet[3]); |
|
|
|
IPAddress ip(eeprom_config.ip[0], eeprom_config.ip[1], eeprom_config.ip[2], eeprom_config.ip[3]); |
|
|
|
IPAddress gateway (eeprom_config.gateway[0],eeprom_config.gateway[1],eeprom_config.gateway[2],eeprom_config.gateway[3]); |
|
|
|
IPAddress subnet (eeprom_config.subnet[0], eeprom_config.subnet[1], eeprom_config.subnet[2], eeprom_config.subnet[3]); |
|
|
|
IPAddress dns_server (eeprom_config.dns_server[0], eeprom_config.dns_server[1], eeprom_config.dns_server[2], eeprom_config.dns_server[3]); |
|
|
|
Ethernet.begin(eeprom_config.mac, ip, dns_server, gateway, subnet); |
|
|
|
} else { |
|
|
@@ -398,13 +406,13 @@ void indexHTML(WebServer &server, WebServer::ConnectionType type, char *url_tail |
|
|
|
For a HEAD request, we just stop after outputting headers. */ |
|
|
|
if (type == WebServer::HEAD) |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
server.printP(Page_start); |
|
|
|
|
|
|
|
|
|
|
|
server.printP(Index); |
|
|
|
|
|
|
|
|
|
|
|
server.printP(Page_end); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -450,55 +458,55 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(name); |
|
|
|
server.print(name); |
|
|
|
Serial.print(" - "); |
|
|
|
Serial.print(" - "); |
|
|
|
server.print(" - "); |
|
|
|
Serial.println(value); |
|
|
|
server.print(value); |
|
|
|
server.print("<br>"); |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
param_number = atoi(name); |
|
|
|
|
|
|
|
|
|
|
|
// read MAC address |
|
|
|
if (param_number >=0 && param_number <=5) { |
|
|
|
eeprom_config.mac[param_number]=strtol(value,NULL,16); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// read IP address |
|
|
|
if (param_number >=6 && param_number <=9) { |
|
|
|
eeprom_config.ip[param_number-6]=atoi(value); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// read SUBNET |
|
|
|
if (param_number >=10 && param_number <=13) { |
|
|
|
eeprom_config.subnet[param_number-10]=atoi(value); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// read GATEWAY |
|
|
|
if (param_number >=14 && param_number <=17) { |
|
|
|
eeprom_config.gateway[param_number-14]=atoi(value); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// read DNS-SERVER |
|
|
|
if (param_number >=18 && param_number <=21) { |
|
|
|
eeprom_config.dns_server[param_number-18]=atoi(value); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// read WEBServer port |
|
|
|
if (param_number == 22) { |
|
|
|
eeprom_config.webserverPort=atoi(value); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// read DHCP ON/OFF |
|
|
|
if (param_number == 23) { |
|
|
|
eeprom_config.use_dhcp=atoi(value); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// read DHCP renew interval |
|
|
|
if (param_number == 24) { |
|
|
|
eeprom_config.dhcp_refresh_minutes=atoi(value); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
EEPROM_writeAnything(0, eeprom_config); |
|
|
@@ -506,13 +514,13 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
|
|
|
|
//print the form |
|
|
|
server.printP(Form_eth_start); |
|
|
|
|
|
|
|
|
|
|
|
if(params_present==true) { |
|
|
|
server.printP(Config_set); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
server.printP(table_start); |
|
|
|
|
|
|
|
|
|
|
|
// print the current MAC |
|
|
|
server.printP(table_tr_start); |
|
|
|
server.printP(table_td_start); |
|
|
@@ -524,7 +532,7 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
server.print(a); |
|
|
|
server.printP(Form_input_value); |
|
|
|
server.print(eeprom_config.mac[a],HEX); |
|
|
|
server.printP(Form_input_size2); |
|
|
|
server.printP(Form_input_size2); |
|
|
|
server.printP(Form_input_end); |
|
|
|
} |
|
|
|
server.printP(table_td_end); |
|
|
@@ -535,7 +543,7 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(IP); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
for (int a=0;a<4;a++) { |
|
|
|
server.printP(Form_input_text_start); |
|
|
|
server.print(a+6); |
|
|
@@ -546,14 +554,14 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
} |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_tr_end); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// print the current SUBNET |
|
|
|
server.printP(table_tr_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(SUBNET); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
for (int a=0;a<4;a++) { |
|
|
|
server.printP(Form_input_text_start); |
|
|
|
server.print(a+10); |
|
|
@@ -570,7 +578,7 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(GW); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
for (int a=0;a<4;a++) { |
|
|
|
server.printP(Form_input_text_start); |
|
|
|
server.print(a+14); |
|
|
@@ -587,7 +595,7 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(DNS_SERVER); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
for (int a=0;a<4;a++) { |
|
|
|
server.printP(Form_input_text_start); |
|
|
|
server.print(a+18); |
|
|
@@ -599,7 +607,7 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_tr_end); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// print the current webserver port |
|
|
|
server.printP(table_tr_start); |
|
|
|
server.printP(table_td_start); |
|
|
@@ -613,7 +621,7 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
server.printP(Form_input_end); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_tr_end); |
|
|
|
|
|
|
|
|
|
|
|
//print the current DHCP config |
|
|
|
server.printP(table_tr_start); |
|
|
|
server.printP(table_td_start); |
|
|
@@ -625,17 +633,17 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
if(eeprom_config.use_dhcp != 1) { |
|
|
|
server.printP(Form_cb_checked); |
|
|
|
} |
|
|
|
server.printP(Form_cb_off); |
|
|
|
|
|
|
|
server.printP(Form_cb_off); |
|
|
|
|
|
|
|
server.printP(Form_cb); |
|
|
|
server.print("1\""); |
|
|
|
if(eeprom_config.use_dhcp == 1) { |
|
|
|
server.printP(Form_cb_checked); |
|
|
|
} |
|
|
|
server.printP(Form_cb_on); |
|
|
|
server.printP(Form_cb_on); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_tr_end); |
|
|
|
|
|
|
|
|
|
|
|
//print the current DHCP renew time |
|
|
|
server.printP(table_tr_start); |
|
|
|
server.printP(table_td_start); |
|
|
@@ -654,16 +662,16 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
//print DHCP status |
|
|
|
if(eeprom_config.use_dhcp == 1) { |
|
|
|
server.printP(table_tr_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(DHCP_STATE); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.print(dhcp_state); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_tr_end); |
|
|
|
|
|
|
|
|
|
|
|
server.printP(table_tr_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(DHCP_STATE_TIME); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_td_start); |
|
|
@@ -671,36 +679,36 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_tr_end); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef USE_SYSTEM_LIBRARY |
|
|
|
//print uptime |
|
|
|
server.printP(table_tr_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(UPTIME); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.print(sys.uptime()); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_tr_end); |
|
|
|
server.printP(table_tr_end); |
|
|
|
|
|
|
|
server.printP(table_tr_start); |
|
|
|
server.printP(table_td_start); |
|
|
|
server.printP(RAM_1); |
|
|
|
server.printP(RAM_1); |
|
|
|
server.print(sys.ramFree()); |
|
|
|
server.printP(RAM_2); |
|
|
|
server.print(sys.ramSize()); |
|
|
|
server.printP(table_td_end); |
|
|
|
server.printP(table_tr_end); |
|
|
|
server.printP(table_tr_end); |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
server.printP(table_end); |
|
|
|
|
|
|
|
|
|
|
|
//print the send button |
|
|
|
server.printP(Form_input_send); |
|
|
|
server.printP(Form_input_send); |
|
|
|
server.printP(Form_end); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server.printP(Page_end); |
|
|
|
|
|
|
|
} |
|
|
@@ -720,9 +728,9 @@ void errorHTML(WebServer &server, WebServer::ConnectionType type, char *url_tail |
|
|
|
For a HEAD request, we just stop after outputting headers. */ |
|
|
|
if (type == WebServer::HEAD) |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
server.printP(Http400); |
|
|
|
|
|
|
|
|
|
|
|
server.printP(Page_end); |
|
|
|
} |
|
|
|
|
|
|
@@ -735,12 +743,12 @@ void errorHTML(WebServer &server, WebServer::ConnectionType type, char *url_tail |
|
|
|
void setup() |
|
|
|
{ |
|
|
|
Serial.begin(SERIAL_BAUD); |
|
|
|
|
|
|
|
|
|
|
|
/* initialize the Ethernet adapter with the settings from eeprom */ |
|
|
|
delay(200); // some time to settle |
|
|
|
setupNetwork(); |
|
|
|
delay(200); // some time to settle |
|
|
|
|
|
|
|
|
|
|
|
#define PREFIX "" |
|
|
|
webserver = new WebServer(PREFIX, eeprom_config.webserverPort); |
|
|
|
|
|
|
@@ -766,7 +774,7 @@ void setup() |
|
|
|
/** |
|
|
|
* loop() function |
|
|
|
* Runs forver .... |
|
|
|
* |
|
|
|
* |
|
|
|
* Overview: |
|
|
|
* - Renew the DHCP lease |
|
|
|
* - Serve web clients |