Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
8063ea8
Improved OTA, FSBrowser added
InnuendoPi Jan 7, 2019
3892119
maint VS Code
InnuendoPi Jan 7, 2019
fdf3db1
review
InnuendoPi Jan 8, 2019
e089812
EventManager added
InnuendoPi Jan 8, 2019
87df42a
reworked EventManager
InnuendoPi Jan 10, 2019
a88037f
reworked EventManager
InnuendoPi Jan 10, 2019
4fd9741
reworked EventManager
InnuendoPi Jan 10, 2019
0732983
reworked EventManager
InnuendoPi Jan 10, 2019
032a2b8
reworked EventManager - CRC check added
InnuendoPi Jan 10, 2019
83ac106
reworked EventManager - CRC check added
InnuendoPi Jan 10, 2019
8beec6d
merged pull #2 from Pedela
InnuendoPi Jan 10, 2019
f065075
rebuild from scratch due to broken libs
InnuendoPi Jan 11, 2019
96b97bf
MQTT pub induction and actors added
InnuendoPi Jan 12, 2019
066e838
Pedelas commits merged
InnuendoPi Jan 14, 2019
efe8a8a
Removed test debugutils, cleanup code
InnuendoPi Jan 15, 2019
cee8885
Reboot and save button (Pedelas #4)
InnuendoPi Jan 18, 2019
15d5d3f
Reboot and save button (Pedelas #4)
InnuendoPi Jan 18, 2019
38097a9
Changed OLED lib to Adafruit_GFX, Changed EM handling, Changed WebIf
InnuendoPi Jan 23, 2019
c4cbba7
Improve display output, reworked display init, Fixed NTP, cleanup code
InnuendoPi Jan 24, 2019
7032ca5
Improved performance setup, loop and Webif, Added screens AP and STA …
InnuendoPi Jan 24, 2019
4fe62be
Added Misc menu: clear WiFi settings, Clear config reset to defaults …
InnuendoPi Jan 25, 2019
c3a1b9d
Replaced delay command (induction), Typo EM
InnuendoPi Jan 25, 2019
462d893
Update README.md
InnuendoPi Jan 25, 2019
21b974d
Add files via upload
InnuendoPi Jan 25, 2019
5d52153
Add files via upload
InnuendoPi Jan 25, 2019
115846e
Update README.md
InnuendoPi Jan 25, 2019
62a12cb
cleanup
InnuendoPi Jan 25, 2019
fd41bdc
Delete README.md
InnuendoPi Jan 25, 2019
99ecf03
cleanup
InnuendoPi Jan 25, 2019
a733d1b
.
InnuendoPi Jan 25, 2019
0af225e
.
InnuendoPi Jan 25, 2019
b89e427
EM: Activate WAIT_ON_ERROR delay
InnuendoPi Jan 25, 2019
ce9a502
Update README.md
InnuendoPi Jan 25, 2019
16c401b
Update README.md
InnuendoPi Jan 25, 2019
609d8db
Fixed: typo compare Wifi status; Removed: test code publishmqtt (caus…
InnuendoPi Jan 26, 2019
1d7734c
Optimzed EM (timestamp), reworked no-display environment
InnuendoPi Jan 26, 2019
981c73e
New: added config options via WebIf menu; Cleanup: removed defines de…
InnuendoPi Jan 27, 2019
c76381c
Added: Display OTA Update progress; Replaced: mqttreconnect; Fixed: N…
InnuendoPi Jan 28, 2019
a1789ac
Add infos
InnuendoPi Jan 28, 2019
cb827c6
Fixed: Typo delay replacement (if-while); Added: config menu items; F…
InnuendoPi Jan 30, 2019
a238daa
Add files via upload
InnuendoPi Feb 2, 2019
a2b4976
Delete spiffs.bin
InnuendoPi Feb 2, 2019
ff67c7b
Add files via upload
InnuendoPi Feb 2, 2019
8324262
Delete MQTTDevice.ino.bin
InnuendoPi Feb 2, 2019
146697b
Delete MQTTDevice.spiffs.bin
InnuendoPi Feb 2, 2019
7eec200
Add: Web update firmware and spiffs
InnuendoPi Feb 2, 2019
c19383b
Merge branch 'master' of https://github.com/InnuendoPi/MQTTDevice
InnuendoPi Feb 2, 2019
c953ec0
Add: Web update firmware and spiffs
InnuendoPi Feb 2, 2019
bda262f
Add: actors now individual switchable on error event
InnuendoPi Feb 3, 2019
46f5bf7
Small fix
InnuendoPi Feb 9, 2019
4e40ddb
Changes to work with VSCode; Fix: delays
InnuendoPi Feb 11, 2019
cbe88bb
VSCode
InnuendoPi Feb 11, 2019
08fe949
VSCode
InnuendoPi Feb 11, 2019
a76b747
mDNS tcp service added
InnuendoPi Feb 12, 2019
4deb67d
Fixed: read config bug could crash device
Mar 7, 2019
d9001b6
update infos
Mar 7, 2019
fda5d45
Typo icons
Mar 8, 2019
07d2904
Delete settings.json
InnuendoPi Mar 8, 2019
c0f3370
Delete tasks.json
InnuendoPi Mar 8, 2019
75a0819
minor code cleanup
Mar 8, 2019
ace1da9
minor code cleanup
Mar 8, 2019
ec85352
minor code cleanup
Mar 8, 2019
1047f30
Code cleanup
Mar 9, 2019
d7f74ce
Code cleanup
Mar 9, 2019
cc0115d
Code cleanup
Mar 9, 2019
a2d3a8f
Bugfix: read config atol conversion
Apr 26, 2019
b3a8262
Fixed: Read/Write large configs failed
Aug 20, 2019
6501164
Typo
Aug 20, 2019
844d408
Typo
Aug 20, 2019
e13a357
Minor changes
Aug 20, 2019
96debfe
Fixed JSON buffersize and cleanup
Aug 21, 2019
5f5ff77
Added: temp offset; Fixed: OTA; code cleanup
Aug 24, 2019
12307e3
.
Aug 24, 2019
001a9e0
.
Aug 24, 2019
94a22a8
Update infos
Aug 25, 2019
491a849
Fixed: Write display config; Fixed: temp publish mqtt
Aug 26, 2019
3ebc6c2
Small fix Version
Aug 26, 2019
d056006
Version 1.033: Fixed sensor value while unplugged (-127.0°C)
Aug 26, 2019
cf40ccd
Fixed: Timeset EUR; Fixed: Display Init; Removed: Adafruit libs from,…
Aug 27, 2019
3603313
Update readme
Aug 27, 2019
f80a5d5
Update readme
Aug 27, 2019
946a0e7
Update readme
Aug 27, 2019
11e83a5
Code cleanup, reworked display information, minor changes
Aug 28, 2019
26d7e98
Added information
Aug 28, 2019
4f94488
Added information
Aug 28, 2019
82c553b
Added information
Aug 28, 2019
77389fb
Added information
Aug 28, 2019
8e9245d
Added information
Aug 28, 2019
cd51cd2
Added information
Aug 28, 2019
35c7c35
New Event handling WLAN, MQTT PArt 1
Aug 29, 2019
9f7241c
New Event handling WLAN, MQTT PArt 2
Aug 29, 2019
b70ddc7
New Event handling WLAN, MQTT PArt 2
Aug 29, 2019
e29a909
Event handling WLAN, MQTT Part 3; Code cleanup
Aug 31, 2019
51355f5
Event handling WLAN, MQTT Part 4; Fixed: Missmatched induction event;…
Sep 2, 2019
e0e9250
Improved read write config, Improved event handling, Fixed display, F…
Sep 16, 2019
f65d514
Added: Telnetserver; Improved: WebIf; Removed Debug and test code
Sep 17, 2019
0b03d82

Sep 17, 2019
af09cd0
Code cleanup, removed test code
Sep 18, 2019
d504a0d
Added: Simulation
Sep 24, 2019
cf41681
Added: Simulation
Sep 24, 2019
9dd1aed
Added: Simulation
Sep 24, 2019
2a2955a
Added: Simulation
Sep 25, 2019
3414b48
Improved: sensor handling and display output; Code cleanup
Oct 5, 2019
02c71db
Improved: sensor handling and display output; Code cleanup
Oct 5, 2019
b00eaf3
Improved: sensor handling and display output; Code cleanup
Oct 5, 2019
49f8bc4
Improved: sensor handling and display output; Code cleanup
Oct 5, 2019
8b9ef1c
Fix: typo
Oct 6, 2019
77789f9
Fixed: typo
Oct 7, 2019
1a1d988
Add comment How to flash
Oct 7, 2019
8efa32c
Code cleanup
Oct 9, 2019
45ea1a6
Cleanup
Oct 15, 2019
3a33a56
Update ArduinoJson 6
Oct 19, 2019
2be9f32
Update ArduinoJson 6
Oct 19, 2019
277b094
Update ArduinoJson 6
Oct 19, 2019
278e3a9
Update ArduinoJson 6
Oct 19, 2019
d86f741
Add: TCP server support (Tozzi)
Oct 20, 2019
c8baf8e
Added: TCP Server support; Fix: handlemqtt Json
Oct 27, 2019
5c77a08
Added: TCP Server support; Fix: handlemqtt Json
Oct 27, 2019
c02cb1c
Added: TCP Server support; Fix: handlemqtt Json
Oct 27, 2019
e0c187d
Added: TCP Server support; Fix: handlemqtt Json
Oct 27, 2019
0c37093
Added: TCP Server support; Fix: handlemqtt Json
Oct 27, 2019
a9dcc86
Initial commit
Oct 27, 2019
8cc36bd
Init
Oct 27, 2019
a9637e2
Init
Oct 27, 2019
9ba9e9d
Added readme info
Oct 27, 2019
d1517ac
Added readme info typo
Oct 27, 2019
f1d519a
Added: check input; Added: target tempt to webif, Reworked: debug output
Oct 29, 2019
451b75b
Improved: MQTT reconnect und Speicherverbrauch; Korrektur Winterzeit CET
Nov 1, 2019
31c030b
Fix: Sensor EM
Dec 24, 2019
795d767
Readme added
Dec 24, 2019
aa951f6
Update ESP8266 libs; Fixed typo index.html
Jan 1, 2020
3b572a6
Update ESP8266 libs; Fixed typo index.html
Jan 1, 2020
74639e2
1.060 - Fixed long standing WLAN/mDNS bug
Jan 4, 2020
f42ba59
Update README.md
InnuendoPi Feb 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
.DS_Store
.DS_Store
.DS_Store
.gitattributes
.gitignore
.vscode/launch.json
data/config.json
build/core
build/preproc
build/sketch
build/libraries
build/arduino.ar
build/build.options.json
build/MQTTDevice.ino.elf
build/MQTTDevice.ino.map
build/includes.cache
build/local.eagle.app.v6.common.ld
7 changes: 7 additions & 0 deletions .vscode/arduino.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sketch": "MQTTDevice.ino",
"board": "esp8266:esp8266:d1_mini",
"configuration": "xtal=80,vt=flash,exception=disabled,ssl=all,eesz=4M3M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600",
"output": "./build",
"port": "COM3"
}
27 changes: 27 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}\\**",
"C:\\Arduino\\libraries\\**",
"C:\\Users\\pn010.TEAM\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\**",
"C:\\Users\\pn010.TEAM\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.2\\**"
],
"browse": {
"limitSymbolsToIncludedHeaders": false,
"databaseFilename": ""
},
"defines": [
"_DEBUG",
"UNICODE"
],
"compilerPath": "C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64",
"forcedInclude": []
}
],
"version": 4
}
32 changes: 32 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"telemetry.enableTelemetry": false,
"arduino.path": "C:/Program Files (x86)/Arduino",
"arduino.commandPath": "arduino_debug.exe",
"arduino.logLevel": "info",
"arduino.enableUSBDetection": true,
"arduino.disableTestingOpen": false,
"arduino.skipHeaderProvider": false,
"arduino.additionalUrls": [
"http://arduino.esp8266.com/stable/package_esp8266com_index.json"
],
"arduino.defaultBaudRate": 115200,
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"C_Cpp.intelliSenseEngine": "Tag Parser",
"C_Cpp.default.intelliSenseMode": "msvc-x64",
"editor.formatOnType":true,
"esp8266fs.mkspiffs.debugLevel": 0,
"esp8266fs.esptool.executable": "C:/Arduino/tools/esptool.exe",
"esp8266fs.mkspiffs.executable": "C:/Arduino/tools/mkspiffs.exe",
"esp8266fs.spiffsImage": "C:/Arduino/git/MQTTDevice/build/MQTTDevice.spiffs.bin",
"esp8266fs.dataFiles": "C:/Arduino/git/MQTTDevice/data",
"esp8266fs.preferencesPath": "C:/Users/pn010.TEAM/AppData/Local/Arduino15",
"esp8266fs.logLevel": "normal",
"esp8266fs.mkspiffs.allFiles": false,
"files.associations": {
"initializer_list": "cpp",
"*.tcc": "cpp",
"string": "cpp",
"fstream": "cpp"
},
"terminal.integrated.windowsEnableConpty": false,
}
210 changes: 154 additions & 56 deletions 0_SETUP.ino
Original file line number Diff line number Diff line change
@@ -1,95 +1,193 @@
void setup() {
void setup()
{
Serial.begin(115200);

// Sensoren Starten
DS18B20.begin();

// Dateisystem laden
while (!Serial)
{
yield(); // wait for serial port to connect. Needed for native USB port only
}
// Set device name
snprintf(mqtt_clientid, 25, "ESP8266-%08X", mqtt_chip_key);

// Event Queues
gEM.addListener(EventManager::kEventUser0, listenerSystem);
gEM.addListener(EventManager::kEventUser1, listenerSensors);
gEM.addListener(EventManager::kEventUser2, listenerActors);
gEM.addListener(EventManager::kEventUser3, listenerInduction);

Serial.println("");
Serial.println("*** SYSINFO: Start setup MQTTDevice");
// Load filesystem
ESP.wdtFeed();
if (!SPIFFS.begin()) {
if (!SPIFFS.begin())
{
Serial.println("SPIFFS Mount failed");
}

// Einstellungen laden
ESP.wdtFeed();
loadConfig();
else if (SPIFFS.exists("/config.json")) // Load configuration
{
loadConfig();
}
else
Serial.println("*** SYSINFO: Config file not found. Use defaults ...");

// WiFi Manager
ESP.wdtFeed();
WiFiManagerParameter cstm_mqtthost("host", "cbpi ip", mqtthost, 16);
wifiManager.setDebugOutput(false);
wifiManager.setMinimumSignalQuality(10);
wifiManager.setConfigPortalTimeout(300);
wifiManager.setAPCallback(configModeCallback);
WiFiManagerParameter cstm_mqtthost("host", "MQTT broker IP", mqtthost, 16);
wifiManager.setSaveConfigCallback(saveConfigCallback);
wifiManager.addParameter(&cstm_mqtthost);
wifiManager.autoConnect("MQTTDevice");
wifiManager.autoConnect(mqtt_clientid);
strcpy(mqtthost, cstm_mqtthost.getValue());
WiFi.setSleepMode(WIFI_NONE_SLEEP);
WiFi.mode(WIFI_STA);
WiFi.setAutoConnect(true);
WiFi.setAutoReconnect(true);

// Änderungen speichern
ESP.wdtFeed();
saveConfig();
// Start Webserver
setupServer();

// set pins as used
pins_used[ONE_WIRE_BUS] = true;
if (useDisplay)
{
pins_used[SDA] = true;
pins_used[SDL] = true;
}

// Start sensors
DS18B20.begin();

// Telnet
if (startTEL)
cbpiEventSystem(EM_TELSET); // Telnet

// Load mDNS
if (startMDNS)
cbpiEventSystem(EM_MDNSET);

// ArduinoOTA aktivieren
setupOTA();

// MQTT starten
client.setServer(mqtthost, 1883);
client.setCallback(mqttcallback);
// Init Arduino Over The Air
if (startOTA)
setupOTA();

// Webserver starten
// Display Start Screen
dispStartScreen();

// // Save configuration
// ESP.wdtFeed();
// saveConfig();

// Start MQTT
ESP.wdtFeed();
setupServer();
}
cbpiEventSystem(EM_MQTTCON); // MQTT connect
cbpiEventSystem(EM_MQTTSUB); // MQTT subscribe

void setupServer() {
ESP.wdtFeed();
cbpiEventSystem(EM_WLAN); // Check WLAN
cbpiEventSystem(EM_MQTT); // Check MQTT
cbpiEventSystem(EM_NTP); // NTP handle
cbpiEventSystem(EM_MDNS); // MDNS handle

while (gEM.getNumEventsInQueue()) // Eventmanager process all queued events
{
gEM.processEvent();
}
}

void setupServer()
{
server.on("/", handleRoot);

server.on("/setupActor", handleSetActor); // Einstellen der Aktoren
server.on("/setupSensor", handleSetSensor); // Einstellen der Sensoren

server.on("/reqSensors", handleRequestSensors); // Liste der Sensoren ausgeben
server.on("/reqActors", handleRequestActors); // Liste der Aktoren ausgeben
server.on("/reqInduction", handleRequestInduction);

server.on("/reqSearchSensorAdresses", handleRequestSensorAddresses);
server.on("/reqPins", handlereqPins);
server.on("/reqSensor", handleRequestSensor); // Infos der Sensoren für WebConfig
server.on("/reqActor", handleRequestActor); // Infos der Aktoren für WebConfig
server.on("/reqIndu", handleRequestIndu); // Infos der Indu für WebConfig
server.on("/setSensor", handleSetSensor); // Sensor ändern
server.on("/setActor", handleSetActor); // Aktor ändern
server.on("/setIndu", handleSetIndu); // Indu ändern
server.on("/delSensor", handleDelSensor); // Sensor löschen
server.on("/delActor", handleDelActor); // Aktor löschen
server.on("/reboot", rebootDevice); // reboots the whole Device
server.on("/OTA", OTA);
//server.on("/reconmqtt", reconMQTT); // Reconnect MQTT
server.on("/simulation", startSIM); // Simulation
server.on("/reqDisplay", handleRequestDisplay);
server.on("/reqDisp", handleRequestDisp); // Infos Display für WebConfig
server.on("/setDisp", handleSetDisp); // Display ändern
server.on("/reqMiscSet", handleRequestMiscSet);
server.on("/reqMisc", handleRequestMisc); // Misc Infos für WebConfig
server.on("/setMisc", handleSetMisc); // Misc ändern

// FSBrowser initialisieren
server.on("/list", HTTP_GET, handleFileList); // list directory
server.on("/edit", HTTP_GET, []() { // load editor
if (!handleFileRead("/edit.htm"))
{
server.send(404, "text/plain", "FileNotFound");
}
});
server.on("/edit", HTTP_PUT, handleFileCreate); // create file
server.on("/edit", HTTP_DELETE, handleFileDelete); // delete file
server.on("/edit", HTTP_POST, []() {
server.send(200, "text/plain", "");
},
handleFileUpload);

server.on("/reqSensor", handleRequestSensor); // Infos der Sensoren für WebConfig
server.on("/reqActor", handleRequestActor); // Infos der Aktoren für WebConfig
server.on("/reqIndu", handleRequestIndu); // Infos der Indu für WebConfig

server.on("/setSensor", handleSetSensor); // Sensor Ändern
server.on("/setActor", handleSetActor); // Aktor ändern
server.on("/setIndu", handleSetIndu); // Indu ändenr

server.on("/delSensor", handleDelSensor); // Sensor löschen
server.on("/delActor", handleDelActor); // Aktor löschen

server.onNotFound(handleWebRequests); // Sonstiges
server.onNotFound(handleWebRequests); // Sonstiges

httpUpdate.setup(&server); // ESP8266HTTPUpdateServer.cpp https://github.com/esp8266/Arduino/pull/3732/files
server.begin();
}


void setupOTA() {
Serial.print("Configuring OTA device...");
TelnetServer.begin(); //Necesary to make Arduino Software autodetect OTA device
void setupOTA()
{
ArduinoOTA.setHostname(mqtt_clientid);
ArduinoOTA.onStart([]() {
Serial.println("OTA starting...");
String type;
if (ArduinoOTA.getCommand() == U_FLASH)
{
type = "sketch";
DBG_PRINTLN("OTA starting - updateing sketch");
}
else
{ // U_SPIFFS
type = "filesystem";
DBG_PRINTLN("OTA starting - updateing SPIFFS");
//SPIFFS.end();
}
if (useDisplay)
showDispOTA(0, 100);
});
ArduinoOTA.onEnd([]() {
Serial.println("OTA update finished!");
Serial.println("Rebooting...");
DBG_PRINTLN("OTA update finished!");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("OTA in progress: %u%%\r\n", (progress / (total / 100)));
if (useDisplay)
showDispOTA(progress, total);
DBG_PRINT("OTA in progress: ");
DBG_PRINTLN((progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
if (useDisplay)
showDispOTAEr(String(error));
DBG_PRINT("Error: ");
DBG_PRINTLN(error);
if (error == OTA_AUTH_ERROR)
DBG_PRINTLN("Auth Failed");
else if (error == OTA_BEGIN_ERROR)
DBG_PRINTLN("Begin Failed");
else if (error == OTA_CONNECT_ERROR)
DBG_PRINTLN("Connect Failed");
else if (error == OTA_RECEIVE_ERROR)
DBG_PRINTLN("Receive Failed");
else if (error == OTA_END_ERROR)
DBG_PRINTLN("End Failed");
});
ArduinoOTA.begin();
Serial.println("OTA OK");
}
Loading