From 0dac7594dc86d6e4b7e4bc371ff0f689df988950 Mon Sep 17 00:00:00 2001 From: agr Date: Tue, 14 Apr 2020 18:01:57 +0200 Subject: [PATCH] optimization, but too less Program: 33646 bytes (102.7% Full) --- Web_Net_Setup.ino | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Web_Net_Setup.ino b/Web_Net_Setup.ino index eee2720..b2ab3f2 100644 --- a/Web_Net_Setup.ino +++ b/Web_Net_Setup.ino @@ -65,6 +65,7 @@ //#define WEBDUINO_FAVICON_DATA "" // no favicon //#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 SET_DEFAULT // comment out if Arduino is not initialized with EEPROM Default Settings #define SERIAL_BAUD 9600 #include "SPI.h" // new include @@ -108,10 +109,11 @@ unsigned long loopcnt = 0; * 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 +#ifdef SET_DEFAULT + eeprom_config.use_dhcp = 1; // 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 @@ -157,8 +159,8 @@ void set_EEPROM_Default() { // set the default Webserver Port. In this case its Port 80 eeprom_config.mqttserverPort = 1883; -#ifdef DEBUG - Serial.println("Config reset"); +#else + eeprom_config.use_dhcp = 1; #endif } @@ -182,7 +184,6 @@ void read_EEPROM_Settings() { 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); } @@ -331,7 +332,7 @@ void setupNetwork() { Ethernet.begin(eeprom_config.mac, ip, dns_server, gateway, subnet); } else { if (Ethernet.begin(eeprom_config.mac) == 0) { - Serial.print("Failed to configure Ethernet using DHCP"); + Serial.print("Failed DHCP"); } Serial.println(Ethernet.localIP()); } @@ -354,7 +355,7 @@ P(Page_start) = "Web_i4a_Arduino_Page\n" P(Page_end) = ""; P(Http400) = "HTTP 400 - BAD REQUEST"; -P(Index) = "

index.html


This is your main site!
NETWORK SETUP
Sensor Daten"; +P(Index) = "

index.html


www.inet4all.at
NETWORK SETUP
Sensor Daten"; P(Form_eth_start) = "
"; P(Form_end) = ""; @@ -371,11 +372,11 @@ P(IP) = "IP : "; P(SUBNET) = "Subnet: "; P(GW) = "GW : "; P(DNS_SERVER) = "DNS : "; -P(WEB_PORT) = "Webserver port (1-65535): "; +P(WEB_PORT) = "Web port: "; P(DHCP_ACTIVE) = "Use DHCP: "; -P(DHCP_REFRESH) = "Renew interval for DHCP in minutes (1 - 255): "; -P(MQTT_SERVER) = "MQTT server: "; -P(MQTT_PORT) = "MQTTserver port (1-65535): "; +P(DHCP_REFRESH) = "Renew in min: "; +P(MQTT_SERVER) = "MQTT ip: "; +P(MQTT_PORT) = "MQTT port: "; P(Form_cb) = "New configuration stored!
Please use the reset button!
"; +P(Config_set) = "Config stored!
restart!

"; -P(DHCP_STATE_TIME) = "DHCP last renew timestamp (sec)"; -P(DHCP_STATE) = "DHCP renew return code (sec)"; +P(DHCP_STATE_TIME) = "DHCP last renew (sec)"; +P(DHCP_STATE) = "DHCP renew return code"; P(UPTIME) = "Uptime: ";