diff --git a/.cproject b/.cproject index 5fd7ebb..cd99176 100644 --- a/.cproject +++ b/.cproject @@ -86,6 +86,8 @@ - + + + diff --git a/.settings/org.eclipse.cdt.core.prefs b/.settings/org.eclipse.cdt.core.prefs index 792f2ac..be598d2 100644 --- a/.settings/org.eclipse.cdt.core.prefs +++ b/.settings/org.eclipse.cdt.core.prefs @@ -187,10 +187,10 @@ environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.DTS environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.DTS/value=3600 environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.LOCAL/delimiter=\: environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.LOCAL/operation=replace -environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.LOCAL/value=1503267971 +environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.LOCAL/value=1503268994 environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.UTC/delimiter=\: environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.UTC/operation=replace -environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.UTC/value=1503260771 +environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.UTC/value=1503261794 environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.ZONE/delimiter=\: environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.ZONE/operation=replace environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.ZONE/value=3600 @@ -472,7 +472,7 @@ environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.COM_PORT/ environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.COM_PORT/value=/dev/ttyUSB0 environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.ECLIPSE_LOCATION/delimiter=\: environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.ECLIPSE_LOCATION/operation=replace -environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.ECLIPSE_LOCATION/value=${eclipse_home}///////////////////////////////////////////////////////////////////////////////////////// +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.ECLIPSE_LOCATION/value=${eclipse_home}///////////////////////////////////////////////////////////////////////////////////////////// environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.C.COMPILE/delimiter=\: environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.C.COMPILE/operation=replace environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.C.COMPILE/value= diff --git a/ConfigGenerator/configGen.py b/ConfigGenerator/configGen.py index add0778..ca3964f 100644 --- a/ConfigGenerator/configGen.py +++ b/ConfigGenerator/configGen.py @@ -4,17 +4,18 @@ from Cheetah.Template import Template + configItems = [ - {"label":"_", "key":"magic", "type":"I"}, - {"label":"Wifi SSID", "key":"wifiSsid", "type":"C", "length":32}, - {"label":"Wifi Key", "key":"wifiKey", "type":"C", "length":64}, - {"label":"MQTT Broker", "key":"mqttBroker", "type":"C", "length":64}, - {"label":"MQTT Username", "key":"mqttUser", "type":"C", "length":32}, - {"label":"MQTT Password", "key":"mqttPass", "type":"C", "length":32}, - {"label":"MQTT ClientId", "key":"mqttClientId", "type":"C", "length":32}, - {"label":"MQTT Topic", "key":"mqttTopic", "type":"C", "length":64}, - {"label":"MQTT Port", "key":"mqttPort", "type":"I"}, - {"label":"Measure Period", "key":"measurePeriod", "type":"I"} + {"label":"_", "key":"magic", "type":"I", "default": ""}, + {"label":"Wifi SSID", "key":"wifiSsid", "type":"C", "length":32, "default":"EG-WLAN"}, + {"label":"Wifi Key", "key":"wifiKey", "type":"C", "length":64, "default":"shae3sheuthai2oluNgiqueiyahyumeiphughi8jequeil6taethooyeik1joh5"}, + {"label":"MQTT Broker", "key":"mqttBroker", "type":"C", "length":64, "default":"broker.hottis.de"}, + {"label":"MQTT Username", "key":"mqttUser", "type":"C", "length":32, "default":"esp1"}, + {"label":"MQTT Password", "key":"mqttPass", "type":"C", "length":32, "default":"geheim123"}, + {"label":"MQTT ClientId", "key":"mqttClientId", "type":"C", "length":32, "default":"espClient1"}, + {"label":"MQTT Topic", "key":"mqttTopic", "type":"C", "length":64, "default":"IoT/espThermometer2/espTherm1/measurement"}, + {"label":"MQTT Port", "key":"mqttPort", "type":"I", "default":8883}, + {"label":"Measure Period", "key":"measurePeriod", "type":"I", "default":300} ] diff --git a/ConfigGenerator/configuration_c.tmpl b/ConfigGenerator/configuration_c.tmpl index 7eddabe..7a85b22 100644 --- a/ConfigGenerator/configuration_c.tmpl +++ b/ConfigGenerator/configuration_c.tmpl @@ -12,8 +12,10 @@ tConfigBlock configBlock; const uint32_t MAGIC = 0xC0DE0001; extern ESP8266WebServer webServer; + void configServeIndex() { - webServer.send(200, "text/html", "" + webServer.send(200, "text/html", + "" "" " " @@ -29,7 +31,8 @@ void configServeIndex() { " " " " " " - " " + " " " " " " #end if @@ -43,7 +46,9 @@ void configServeIndex() { " " " " "" - ""); + ); + + #ifdef DEBUG Serial.println("indexHtml request served"); #endif @@ -62,4 +67,17 @@ void configServeGetConfiguration() { webServer.send(200, "text/html", "configuration saved"); } - \ No newline at end of file + +void showConfiguration() { + Serial.println("Configuration is"); + + #for $configItem in $configItems + #if $configItem.label != "_" + Serial.print("$configItem.key = "); + Serial.println(configBlock.$configItem.key); + + #end if + #end for + + Serial.println("---"); +} \ No newline at end of file diff --git a/ConfigGenerator/configuration_h.tmpl b/ConfigGenerator/configuration_h.tmpl index 613b13a..a39f3ea 100644 --- a/ConfigGenerator/configuration_h.tmpl +++ b/ConfigGenerator/configuration_h.tmpl @@ -13,3 +13,4 @@ extern tConfigBlock configBlock; void configServeIndex(); void configServeGetConfiguration(); +void showConfiguration(); \ No newline at end of file diff --git a/EspThermometer2.cpp b/EspThermometer2.cpp index bdf6377..20f2043 100644 --- a/EspThermometer2.cpp +++ b/EspThermometer2.cpp @@ -11,31 +11,13 @@ #include "productionMode.h" #include "configurationMode.h" + + ADC_MODE(ADC_VCC); -//const char* ssid = "EG-WLAN"; -//const char* password = "shae3sheuthai2oluNgiqueiyahyumeiphughi8jequeil6taethooyeik1joh5"; -//const char* ssid = "OG-WLAN"; -//const char* password = "ruc8Chimush2jaetaipeug7shuagh2eruimiemu9Sheik4ur8ooZ5eengeem9ea"; -//const char* ssid = "iPhone"; -//const char* password = "wollud123456"; -//const char* ssid = "WLan-KI-Pro"; -//const char* password = "sVAPHCmo"; - -//const char* mqttServer = "broker.hottis.de"; -//const uint16 mqttPort = 8883; -//const char* mqttUsername = "esp2"; -//const char* mqttPassword = "test1234"; -//const char* clientId = "espTherm2"; -//const char* topic = "IoT/espThermometer2/espTherm2/measurement"; -//const char* mqttServer = "172.16.2.15"; -//const char* mqttServer = "10.11.184.91"; - -//const uint16_t sleepTime = 300; - @@ -73,6 +55,9 @@ void setup() { } else { #ifdef DEBUG Serial.println("Production mode"); + Serial.println(); + Serial.println(); + showConfiguration(); #endif setupProduction(); diff --git a/configuration.cpp b/configuration.cpp index 9ef873e..82fa4e6 100644 --- a/configuration.cpp +++ b/configuration.cpp @@ -10,8 +10,10 @@ tConfigBlock configBlock; const uint32_t MAGIC = 0xC0DE0001; extern ESP8266WebServer webServer; + void configServeIndex() { - webServer.send(200, "text/html", "" + webServer.send(200, "text/html", + "" "" " " @@ -25,63 +27,72 @@ void configServeIndex() { " " " " " " - " " + " " " " " " " " " " " " " " - " " + " " " " " " " " " " " " " " - " " + " " " " " " " " " " " " " " - " " + " " " " " " " " " " " " " " - " " + " " " " " " " " " " " " " " - " " + " " " " " " " " " " " " " " - " " + " " " " " " " " " " " " " " - " " + " " " " " " " " " " " " " " - " " + " " " " " " " " @@ -93,7 +104,9 @@ void configServeIndex() { " " " " "" - ""); + ); + + #ifdef DEBUG Serial.println("indexHtml request served"); #endif @@ -132,4 +145,37 @@ void configServeGetConfiguration() { webServer.send(200, "text/html", "configuration saved"); } - \ No newline at end of file + +void showConfiguration() { + Serial.println("Configuration is"); + + 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("---"); +} \ No newline at end of file diff --git a/configuration.h b/configuration.h index 24642b3..88c7335 100644 --- a/configuration.h +++ b/configuration.h @@ -16,3 +16,4 @@ extern tConfigBlock configBlock; void configServeIndex(); void configServeGetConfiguration(); +void showConfiguration(); \ No newline at end of file