diff --git a/configuration.cpp b/configuration.cpp deleted file mode 100644 index b6474b5..0000000 --- a/configuration.cpp +++ /dev/null @@ -1,273 +0,0 @@ -#include - -#include -#include -#include - -#include "defines.h" -#include "configuration.h" - - -tConfigBlock configBlock; -const uint32_t MAGIC = 0xC0DE0006; -extern ESP8266WebServer webServer; - -bool configSaved = false; - -void configServeIndex() { - bool configValid = (configBlock.magic == MAGIC); - - if (! configValid) { - strcpy(configBlock.wifiSsid, "TV_WLAN"); - strcpy(configBlock.wifiKey, "ioweishauhodohtheexairiedaihohbiethiihahchietoovieziajuboneecai"); - strcpy(configBlock.mqttBroker, "172.16.2.15"); - strcpy(configBlock.mqttUser, "esp2"); - strcpy(configBlock.mqttPass, "geheim"); - strcpy(configBlock.mqttClientId, "Kitchen"); - strcpy(configBlock.mqttTopic, "IoT/espThermometer2/measurement"); - configBlock.mqttPort = 8883; - configBlock.measurePeriod = 300; - } - - String buffer = - "" - " " - " ESP8266 Thermometer Configuration Page" - " " - " " - "

ESP8266 Configuration Page

"; - - if (configSaved) { - configSaved = false; - buffer += "

Configuration saved

"; - } - - buffer += - "
" - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - "
" - " " - " " - " " - "
" - " " - " " - " " - "
" - " " - " " - " " - "
" - " " - " " - " " - "
" - " " - " " - " " - "
" - " " - " " - " " - "
" - " " - " " - " " - "
" - " " - " " - " " - "
" - " " - " " - " " - "
" - " " - "
" - "
" - " " - ""; - - webServer.send(200, "text/html", buffer); - - -#ifdef DEBUG - Serial.println("indexHtml request served"); -#endif -} - -void configServeGetConfiguration() { - String arg; - - arg = webServer.arg("wifiSsid"); - strcpy(configBlock.wifiSsid, arg.c_str()); - arg = webServer.arg("wifiKey"); - strcpy(configBlock.wifiKey, arg.c_str()); - arg = webServer.arg("mqttBroker"); - strcpy(configBlock.mqttBroker, arg.c_str()); - arg = webServer.arg("mqttUser"); - strcpy(configBlock.mqttUser, arg.c_str()); - arg = webServer.arg("mqttPass"); - strcpy(configBlock.mqttPass, arg.c_str()); - arg = webServer.arg("mqttClientId"); - strcpy(configBlock.mqttClientId, arg.c_str()); - arg = webServer.arg("mqttTopic"); - strcpy(configBlock.mqttTopic, arg.c_str()); - arg = webServer.arg("mqttPort"); - configBlock.mqttPort = atoi(arg.c_str()); - arg = webServer.arg("measurePeriod"); - configBlock.measurePeriod = atoi(arg.c_str()); - - configBlock.magic = MAGIC; - - showConfiguration(); - - EEPROM.begin(512); - EEPROM.put(EEPROM_ADDR, configBlock); - EEPROM.commit(); - - Serial.println("EEPROM saved"); - - configSaved = true; - webServer.sendHeader("Location", String("/"), true); - webServer.send(302, "text/plain", ""); - //webServer.send(200, "text/html", "configuration saved"); -} - -void showConfiguration() { - Serial.println("Configuration is"); - - Serial.print("magic = "); - Serial.println(configBlock.magic); - - Serial.print("wifiSsid = "); - Serial.println(configBlock.wifiSsid); - - Serial.print("wifiKey = "); - Serial.println(configBlock.wifiKey); - - Serial.print("mqttBroker = "); - Serial.println(configBlock.mqttBroker); - - Serial.print("mqttUser = "); - Serial.println(configBlock.mqttUser); - - Serial.print("mqttPass = "); - Serial.println(configBlock.mqttPass); - - Serial.print("mqttClientId = "); - Serial.println(configBlock.mqttClientId); - - Serial.print("mqttTopic = "); - Serial.println(configBlock.mqttTopic); - - Serial.print("mqttPort = "); - Serial.println(configBlock.mqttPort); - - Serial.print("measurePeriod = "); - Serial.println(configBlock.measurePeriod); - - - Serial.println("---"); -} diff --git a/configuration.h b/configuration.h deleted file mode 100644 index 88c7335..0000000 --- a/configuration.h +++ /dev/null @@ -1,19 +0,0 @@ -typedef struct { - uint32_t magic; - char wifiSsid[32]; - char wifiKey[64]; - char mqttBroker[64]; - char mqttUser[32]; - char mqttPass[32]; - char mqttClientId[32]; - char mqttTopic[64]; - uint32_t mqttPort; - uint32_t measurePeriod; -} tConfigBlock; - -extern const uint32_t MAGIC; -extern tConfigBlock configBlock; - -void configServeIndex(); -void configServeGetConfiguration(); -void showConfiguration(); \ No newline at end of file diff --git a/ds18b20/DallasTemperature.cpp b/libraries/ds18b20/DallasTemperature.cpp similarity index 100% rename from ds18b20/DallasTemperature.cpp rename to libraries/ds18b20/DallasTemperature.cpp diff --git a/ds18b20/DallasTemperature.h b/libraries/ds18b20/DallasTemperature.h similarity index 100% rename from ds18b20/DallasTemperature.h rename to libraries/ds18b20/DallasTemperature.h diff --git a/defines.h b/libraries/includes/defines.h similarity index 100% rename from defines.h rename to libraries/includes/defines.h diff --git a/onewire/OneWire.cpp b/libraries/onewire/OneWire.cpp similarity index 100% rename from onewire/OneWire.cpp rename to libraries/onewire/OneWire.cpp diff --git a/onewire/OneWire.h b/libraries/onewire/OneWire.h similarity index 100% rename from onewire/OneWire.h rename to libraries/onewire/OneWire.h diff --git a/pubsubclient/PubSubClient.cpp b/libraries/pubsubclient/PubSubClient.cpp similarity index 100% rename from pubsubclient/PubSubClient.cpp rename to libraries/pubsubclient/PubSubClient.cpp diff --git a/pubsubclient/PubSubClient.h b/libraries/pubsubclient/PubSubClient.h similarity index 100% rename from pubsubclient/PubSubClient.h rename to libraries/pubsubclient/PubSubClient.h