From 9984218e1527bf7406c2a5cbbb7e09bd412768c3 Mon Sep 17 00:00:00 2001 From: agr Date: Wed, 8 Apr 2020 10:49:27 +0200 Subject: [PATCH] working --- .cproject | 3 + .project | 7 +- .settings/language.settings.xml | 2 +- .settings/org.eclipse.cdt.core.prefs | 66 ++++++++++++++----- Web_Net_Setup.ino | 98 ++++++++++++++++++++++------ sensor.cpp | 9 +++ sensor.h | 15 +++++ struct.h | 9 +++ 8 files changed, 172 insertions(+), 37 deletions(-) create mode 100644 sensor.cpp create mode 100644 sensor.h diff --git a/.cproject b/.cproject index a425935..e279948 100644 --- a/.cproject +++ b/.cproject @@ -24,6 +24,7 @@ + @@ -34,6 +35,7 @@ + @@ -44,6 +46,7 @@ + diff --git a/.project b/.project index cf72a26..ce4ae9c 100644 --- a/.project +++ b/.project @@ -39,7 +39,7 @@ core/variant 2 - ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.8.2/variants/eightanaloginputs + ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.8.2/variants/mega libraries/EEPROM @@ -51,6 +51,11 @@ 2 ECLIPSE_HOME/arduinoPlugin/libraries/Ethernet/2.0.0 + + libraries/PubSubClient + 2 + ECLIPSE_HOME/arduinoPlugin/libraries/PubSubClient/2.7.0 + libraries/SPI 2 diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 9f6c658..9969d91 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -4,7 +4,7 @@ - + diff --git a/.settings/org.eclipse.cdt.core.prefs b/.settings/org.eclipse.cdt.core.prefs index f2136ad..5269f99 100644 --- a/.settings/org.eclipse.cdt.core.prefs +++ b/.settings/org.eclipse.cdt.core.prefs @@ -13,10 +13,10 @@ environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.EXT environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.EXTENDED_FUSES/value=0xFD environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.FILE/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.FILE/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.FILE/value=atmega/ATmegaBOOT_168_atmega328.hex +environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.FILE/value=stk500v2/stk500boot_v2_mega2560.hex environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.HIGH_FUSES/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.HIGH_FUSES/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.HIGH_FUSES/value=0xDA +environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.HIGH_FUSES/value=0xD8 environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.LOCK_BITS/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.LOCK_BITS/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/A.BOOTLOADER.LOCK_BITS/value=0x0F @@ -34,7 +34,7 @@ environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.ARCH/ope environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.ARCH/value=AVR environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.BOARD/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.BOARD/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.BOARD/value=AVR_NANO +environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.BOARD/value=AVR_MEGA2560 environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.CORE.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.CORE.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.CORE.PATH/value=C\:\\Sloeber\\arduinoPlugin\\packages\\arduino\\hardware\\avr\\1.8.2\\cores\\arduino @@ -49,7 +49,7 @@ environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.F_CPU/op environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.F_CPU/value=16000000L environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.MCU/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.MCU/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.MCU/value=atmega328p +environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.MCU/value=atmega2560 environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.PATH/value=${ProjDirPath}/${ConfigName} @@ -67,10 +67,10 @@ environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.USB_MANU environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.USB_MANUFACTURER/value=\\"Unknown\\" environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.VARIANT.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.VARIANT.PATH/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.VARIANT.PATH/value=C\:\\Sloeber\\arduinoPlugin\\packages\\arduino\\hardware\\avr\\1.8.2\\variants\\eightanaloginputs +environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.VARIANT.PATH/value=C\:\\Sloeber\\arduinoPlugin\\packages\\arduino\\hardware\\avr\\1.8.2\\variants\\mega environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.VARIANT/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.VARIANT/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.VARIANT/value=eightanaloginputs +environment/project/io.sloeber.core.toolChain.release.613547860/A.BUILD.VARIANT/value=mega environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.AR.CMD/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.AR.CMD/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.AR.CMD/value=avr-gcc-ar @@ -91,7 +91,7 @@ environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.C.ELF environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.C.ELF.EXTRA_FLAGS/value= environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.C.ELF.FLAGS/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.C.ELF.FLAGS/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.C.ELF.FLAGS/value=${A.COMPILER.WARNING_FLAGS} -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections +environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.C.ELF.FLAGS/value=${A.COMPILER.WARNING_FLAGS} -Os -Wl,--gc-sections,--relax environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.C.EXTRA_FLAGS/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.C.EXTRA_FLAGS/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/A.COMPILER.C.EXTRA_FLAGS/value= @@ -160,10 +160,28 @@ environment/project/io.sloeber.core.toolChain.release.613547860/A.ESP8266.NETWOR environment/project/io.sloeber.core.toolChain.release.613547860/A.ESP8266.NETWORK.UPLOAD.TOOL/value=esp8266OTA environment/project/io.sloeber.core.toolChain.release.613547860/A.NAME/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.NAME/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.NAME/value=Arduino Nano +environment/project/io.sloeber.core.toolChain.release.613547860/A.NAME/value=Arduino Mega or Mega 2560 environment/project/io.sloeber.core.toolChain.release.613547860/A.PACKAGES/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.PACKAGES/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/A.PACKAGES/value=${eclipse_home}/arduinoPlugin/packages +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.0/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.0/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.0/value=0x0010 +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.1/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.1/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.1/value=0x0042 +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.2/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.2/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.2/value=0x0010 +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.3/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.3/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.3/value=0x0042 +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.4/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.4/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.4/value=0x0210 +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.5/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.5/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.PID.5/value=0x0242 environment/project/io.sloeber.core.toolChain.release.613547860/A.PREPROC.INCLUDES.FLAGS/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.PREPROC.INCLUDES.FLAGS/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/A.PREPROC.INCLUDES.FLAGS/value=-w -x c++ -M -MG -MP @@ -406,16 +424,16 @@ environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.ALTID/o environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.ALTID/value=no_altID environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.MAXIMUM_DATA_SIZE/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.MAXIMUM_DATA_SIZE/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.MAXIMUM_DATA_SIZE/value=2048 +environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.MAXIMUM_DATA_SIZE/value=8192 environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.MAXIMUM_SIZE/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.MAXIMUM_SIZE/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.MAXIMUM_SIZE/value=30720 +environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.MAXIMUM_SIZE/value=253952 environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.PROTOCOL/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.PROTOCOL/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.PROTOCOL/value=arduino +environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.PROTOCOL/value=wiring environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.SPEED/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.SPEED/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.SPEED/value=57600 +environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.SPEED/value=115200 environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.TOOL/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.TOOL/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.TOOL/value=avrdude @@ -425,6 +443,24 @@ environment/project/io.sloeber.core.toolChain.release.613547860/A.UPLOAD.USBID/v environment/project/io.sloeber.core.toolChain.release.613547860/A.VERSION/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/A.VERSION/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/A.VERSION/value=1.8.2 +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.0/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.0/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.0/value=0x2341 +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.1/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.1/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.1/value=0x2341 +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.2/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.2/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.2/value=0x2A03 +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.3/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.3/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.3/value=0x2A03 +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.4/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.4/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.4/value=0x2341 +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.5/delimiter=; +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.5/operation=replace +environment/project/io.sloeber.core.toolChain.release.613547860/A.VID.5/value=0x2341 environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.ARCHITECTURE_ID/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.ARCHITECTURE_ID/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.ARCHITECTURE_ID/value=avr @@ -433,10 +469,10 @@ environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.BOARDS_FI environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.BOARDS_FILE/value=C\:\\Sloeber\\arduinoPlugin\\packages\\arduino\\hardware\\avr\\1.8.2\\boards.txt environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.BOARD_ID/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.BOARD_ID/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.BOARD_ID/value=nano +environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.BOARD_ID/value=mega environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.BOARD_NAME/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.BOARD_NAME/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.BOARD_NAME/value=Arduino Nano +environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.BOARD_NAME/value=Arduino Mega or Mega 2560 environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.COM_PORT/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.COM_PORT/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.COM_PORT/value=COM4 @@ -469,7 +505,7 @@ environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.MAKE_LOCA environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.MAKE_LOCATION/value=C\:\\Sloeber\\arduinoPlugin\\tools\\make\\ environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.MENU/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.MENU/operation=replace -environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.MENU/value=cpu\=atmega328old +environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.MENU/value=cpu\=atmega2560 environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.OBJCOPY/delimiter=; environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.OBJCOPY/operation=replace environment/project/io.sloeber.core.toolChain.release.613547860/JANTJE.OBJCOPY/value=${A.RECIPE.OBJCOPY.EEP.PATTERN}\n\t${A.RECIPE.OBJCOPY.HEX.PATTERN} diff --git a/Web_Net_Setup.ino b/Web_Net_Setup.ino index e53cac1..83c3210 100644 --- a/Web_Net_Setup.ino +++ b/Web_Net_Setup.ino @@ -90,23 +90,9 @@ For more informations about EEPROMAnything.h look at http://playground.arduino.c */ #include "struct.h" -// int EEPROM_readAnything(int ee, config_t& value) -//{ -// 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; -//} +//MQTT intern include +//#include "mqttintern.h" + /** * set_EEPROM_Default() function @@ -128,13 +114,13 @@ void set_EEPROM_Default() { 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 + // set the default IP address for the arduino. In this case its 192.168.1.97 eeprom_config.ip[0]=192; eeprom_config.ip[1]=168; eeprom_config.ip[2]=1; eeprom_config.ip[3]=97; - // set the default GATEWAY. In this case its 192.168.0.254 + // set the default GATEWAY. In this case its 192.168.1.1 eeprom_config.gateway[0]=192; eeprom_config.gateway[1]=168; eeprom_config.gateway[2]=1; @@ -146,7 +132,7 @@ void set_EEPROM_Default() { eeprom_config.subnet[2]=255; eeprom_config.subnet[3]=0; - // set the default DNS SERVER. In this case its 192.168.0.254 + // set the default DNS SERVER. In this case its 192.168.1.1 eeprom_config.dns_server[0]=192; eeprom_config.dns_server[1]=168; eeprom_config.dns_server[2]=1; @@ -155,6 +141,14 @@ void set_EEPROM_Default() { // set the default Webserver Port. In this case its Port 80 eeprom_config.webserverPort=80; + // set the default MQTT SERVER. In this case its 192.168.1.35 + eeprom_config.mqtt_server[0]=192; + eeprom_config.mqtt_server[1]=168; + eeprom_config.mqtt_server[2]=1; + eeprom_config.mqtt_server[3]=35; + + // set the default Webserver Port. In this case its Port 80 + eeprom_config.mqttserverPort=1883; #ifdef DEBUG Serial.println("Config reset"); #endif @@ -231,6 +225,15 @@ void print_EEPROM_Settings() { } Serial.println(); + Serial.print("MQTT Server: "); + for(int i = 0; i<4; i++) { + Serial.print(eeprom_config.mqtt_server[i]); + if (i<3) { + Serial.print('.'); + } + } + Serial.println(); + Serial.print("MAC: "); for (int a=0;a<6;a++) { Serial.print(eeprom_config.mac[a],HEX); @@ -239,6 +242,8 @@ void print_EEPROM_Settings() { } } Serial.println(); + Serial.print("MQTTserver Port: "); + Serial.println(eeprom_config.mqttserverPort); Serial.print("Webserver Port: "); Serial.println(eeprom_config.webserverPort); @@ -360,6 +365,8 @@ P(DNS_SERVER) = "DNS server: "; P(WEB_PORT) = "Webserver port (1-65535): "; 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(Form_cb) = "=25 && param_number <=28) { + eeprom_config.mqtt_server[param_number-25]=atoi(value); + } + + // read MQTTServer port + if (param_number == 29) { + eeprom_config.mqttserverPort=atoi(value); + } + } } EEPROM_writeAnything(0, eeprom_config); @@ -644,6 +661,8 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t 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); @@ -659,6 +678,39 @@ void setupNetHTML(WebServer &server, WebServer::ConnectionType type, char *url_t server.printP(table_td_end); server.printP(table_tr_end); + + // print the current MQTT-SERVER + server.printP(table_tr_start); + server.printP(table_td_start); + server.printP(MQTT_SERVER); + server.printP(table_td_end); + server.printP(table_td_start); + for (int a=0;a<4;a++) { + server.printP(Form_input_text_start); + server.print(a+25); + server.printP(Form_input_value); + server.print(eeprom_config.mqtt_server[a]); + server.printP(Form_input_size3); + server.printP(Form_input_end); + } + server.printP(table_td_end); + server.printP(table_tr_end); + + + // print the current mqttserver port + server.printP(table_tr_start); + server.printP(table_td_start); + server.printP(MQTT_PORT); + server.printP(table_td_end); + server.printP(table_td_start); + server.printP(Form_input_text_start); + server.print(29); + server.printP(Form_input_value); + server.print(eeprom_config.mqttserverPort); + server.printP(Form_input_end); + server.printP(table_td_end); + server.printP(table_tr_end); + //print DHCP status if(eeprom_config.use_dhcp == 1) { server.printP(table_tr_start); @@ -769,6 +821,12 @@ void setup() /* start the webserver */ webserver->begin(); + + + MQTTclient.setServer(eeprom_config.mqtt_server, eeprom_config.mqttserverPort); + //MQTTclient.setCallback(MQTTcallback); + + } /** diff --git a/sensor.cpp b/sensor.cpp new file mode 100644 index 0000000..6a6e84a --- /dev/null +++ b/sensor.cpp @@ -0,0 +1,9 @@ +/* + * sensor.cpp + * + * Created on: 07.04.2020 + * Author: agr + */ + + +#include "sensor.h" diff --git a/sensor.h b/sensor.h new file mode 100644 index 0000000..b76b173 --- /dev/null +++ b/sensor.h @@ -0,0 +1,15 @@ +/* + * sensor.h + * + * Created on: 07.04.2020 + * Author: agr + */ + +#ifndef SENSOR_H_ +#define SENSOR_H_ + + + + + +#endif /* SENSOR_H_ */ diff --git a/struct.h b/struct.h index b55849e..ee1bb11 100644 --- a/struct.h +++ b/struct.h @@ -9,6 +9,10 @@ #define STRUCT_H_ + +#include +#include + struct config_t { byte config_set; @@ -20,6 +24,8 @@ struct config_t byte subnet[4]; byte dns_server[4]; unsigned int webserverPort; + byte mqtt_server[4]; + unsigned int mqttserverPort; } eeprom_config; int EEPROM_readAnything(int ee, config_t& value) @@ -40,5 +46,8 @@ int EEPROM_readAnything(int ee, config_t& value) return i; } + EthernetClient MQTTethClient; + PubSubClient MQTTclient(MQTTethClient); + #endif /* STRUCT_H_ */