commit 5281b6d075b186066522f96660bc5fae8095fe78 Author: Wolfgang Hottgenroth Date: Sun Aug 20 22:29:01 2017 +0200 initial diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..5fd7ebb --- /dev/null +++ b/.cproject @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f963cf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/Release/ diff --git a/.project b/.project new file mode 100644 index 0000000..f85ff19 --- /dev/null +++ b/.project @@ -0,0 +1,66 @@ + + + EspThermometer2 + + + + + + org.python.pydev.PyDevBuilder + + + + + io.sloeber.core.inoToCpp + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + io.sloeber.arduinonature + org.python.pydev.pythonNature + + + + core/core + 2 + ECLIPSE_HOME/arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/cores/esp8266 + + + core/variant + 2 + ECLIPSE_HOME/arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/variants/nodemcu + + + libraries/EEPROM + 2 + ECLIPSE_HOME/arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/libraries/EEPROM + + + libraries/ESP8266WebServer + 2 + ECLIPSE_HOME/arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WebServer + + + libraries/ESP8266WiFi + 2 + ECLIPSE_HOME/arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi + + + diff --git a/.pydevproject b/.pydevproject new file mode 100644 index 0000000..7ff1370 --- /dev/null +++ b/.pydevproject @@ -0,0 +1,5 @@ + + +python 2.7 +Default + diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml new file mode 100644 index 0000000..32709c0 --- /dev/null +++ b/.settings/language.settings.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/.settings/org.eclipse.cdt.core.prefs b/.settings/org.eclipse.cdt.core.prefs new file mode 100644 index 0000000..792f2ac --- /dev/null +++ b/.settings/org.eclipse.cdt.core.prefs @@ -0,0 +1,531 @@ +eclipse.preferences.version=1 +environment/project/io.sloeber.core.toolChain.release.936970421/A.ALT_SIZE_COMMAND/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.ALT_SIZE_COMMAND/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.ALT_SIZE_COMMAND/value="${A.COMPILER.PATH}${A.COMPILER.SIZE.CMD}" --format\=avr --mcu\=${A.BUILD.MCU} "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" +environment/project/io.sloeber.core.toolChain.release.936970421/A.ARCHITECTURE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.ARCHITECTURE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.ARCHITECTURE/value=ESP8266 +environment/project/io.sloeber.core.toolChain.release.936970421/A.ARCHIVE_FILE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.ARCHIVE_FILE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.ARCHIVE_FILE/value=arduino.ar +environment/project/io.sloeber.core.toolChain.release.936970421/A.ARCHIVE_FILE_PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.ARCHIVE_FILE_PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.ARCHIVE_FILE_PATH/value=${A.BUILD.PATH}/${A.ARCHIVE_FILE} +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.ARCH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.ARCH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.ARCH/value=ESP8266 +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.BOARD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.BOARD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.BOARD/value=ESP8266_NODEMCU +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.CORE.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.CORE.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.CORE.PATH/value=${A.RUNTIME.PLATFORM.PATH}/cores/${A.BUILD.CORE} +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.CORE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.CORE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.CORE/value=${A.JANTJE.BUILD_CORE} +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.DEBUG_LEVEL/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.DEBUG_LEVEL/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.DEBUG_LEVEL/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.DEBUG_PORT/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.DEBUG_PORT/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.DEBUG_PORT/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.EXTRA_FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.EXTRA_FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.EXTRA_FLAGS/value=-DESP8266 +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_FREQ/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_FREQ/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_FREQ/value=40 +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_LD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_LD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_LD/value=eagle.flash.4m1m.ld +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_MODE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_MODE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_MODE/value=dio +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_SIZE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_SIZE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.FLASH_SIZE/value=4M +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.F_CPU/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.F_CPU/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.F_CPU/value=160000000L +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.LWIP_FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.LWIP_FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.LWIP_FLAGS/value=-DLWIP_OPEN_SRC +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.LWIP_LIB/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.LWIP_LIB/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.LWIP_LIB/value=-llwip_gcc +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.MCU/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.MCU/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.MCU/value=esp8266 +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.PATH/value=${ProjDirPath}/${ConfigName} +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.PROJECT_NAME/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.PROJECT_NAME/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.PROJECT_NAME/value=${ProjName} +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_BLOCKSIZE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_BLOCKSIZE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_BLOCKSIZE/value=8192 +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_END/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_END/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_END/value=0x3FB000 +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_PAGESIZE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_PAGESIZE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_PAGESIZE/value=256 +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_START/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_START/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SPIFFS_START/value=0x300000 +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SYSTEM.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SYSTEM.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.SYSTEM.PATH/value=${A.RUNTIME.PLATFORM.PATH}/system +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.VARIANT.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.VARIANT.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.VARIANT.PATH/value=${A.RUNTIME.PLATFORM.PATH}/variants/${A.BUILD.VARIANT} +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.VARIANT/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.VARIANT/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.BUILD.VARIANT/value=${A.JANTJE.BUILD_VARIANT} +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AR.CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AR.CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AR.CMD/value=xtensa-lx106-elf-ar +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AR.EXTRA_FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AR.EXTRA_FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AR.EXTRA_FLAGS/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AR.FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AR.FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AR.FLAGS/value=cru +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AS.CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AS.CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.AS.CMD/value=xtensa-lx106-elf-as +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.CMD/value=xtensa-lx106-elf-gcc +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.CMD/value=xtensa-lx106-elf-gcc +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.EXTRA_FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.EXTRA_FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.EXTRA_FLAGS/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.FLAGS/value=-g ${A.COMPILER.WARNING_FLAGS} -Os -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-L${A.COMPILER.SDK.PATH}/lib" "-L${A.COMPILER.SDK.PATH}/ld" "-T${A.BUILD.FLASH_LD}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.LIBS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.LIBS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.ELF.LIBS/value=-lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lwps -laxtls -lsmartconfig -lmesh -lwpa2 ${A.BUILD.LWIP_LIB} -lstdc++ +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.EXTRA_FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.EXTRA_FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.EXTRA_FLAGS/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.C.FLAGS/value=-c ${A.COMPILER.WARNING_FLAGS} -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions\=4 -MMD -std\=gnu99 -ffunction-sections -fdata-sections +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPP.CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPP.CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPP.CMD/value=xtensa-lx106-elf-g++ +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPP.EXTRA_FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPP.EXTRA_FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPP.EXTRA_FLAGS/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPP.FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPP.FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPP.FLAGS/value=-c ${A.COMPILER.WARNING_FLAGS} -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions\=4 -std\=c++11 -MMD -ffunction-sections -fdata-sections +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPREPROCESSOR.FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPREPROCESSOR.FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.CPREPROCESSOR.FLAGS/value=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I${A.COMPILER.SDK.PATH}/include" "-I${A.COMPILER.SDK.PATH}/lwip/include" "-I${A.BUILD.PATH}/core" +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ELF2HEX.CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ELF2HEX.CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ELF2HEX.CMD/value=esptool +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ELF2HEX.EXTRA_FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ELF2HEX.EXTRA_FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ELF2HEX.EXTRA_FLAGS/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ELF2HEX.FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ELF2HEX.FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ELF2HEX.FLAGS/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ESPTOOL.CMD.WINDOWS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ESPTOOL.CMD.WINDOWS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ESPTOOL.CMD.WINDOWS/value=esptool.exe +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ESPTOOL.CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ESPTOOL.CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.ESPTOOL.CMD/value=esptool +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.OBJCOPY.EEP.EXTRA_FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.OBJCOPY.EEP.EXTRA_FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.OBJCOPY.EEP.EXTRA_FLAGS/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.PATH/value=${A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC.PATH}/bin/ +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.S.CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.S.CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.S.CMD/value=xtensa-lx106-elf-gcc +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.S.EXTRA_FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.S.EXTRA_FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.S.EXTRA_FLAGS/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.S.FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.S.FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.S.FLAGS/value=-c -g -x assembler-with-cpp -MMD -mlongcalls +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.SDK.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.SDK.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.SDK.PATH/value=${A.RUNTIME.PLATFORM.PATH}/tools/sdk +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.SIZE.CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.SIZE.CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.SIZE.CMD/value=xtensa-lx106-elf-size +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.ALL/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.ALL/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.ALL/value=-Wall -Wextra +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.DEFAULT/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.DEFAULT/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.DEFAULT/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.MORE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.MORE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.MORE/value=-Wall +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.NONE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.NONE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS.NONE/value=-w +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.COMPILER.WARNING_FLAGS/value=${A.COMPILER.WARNING_FLAGS.ALL} +environment/project/io.sloeber.core.toolChain.release.936970421/A.ESP8266.NETWORK.UPLOAD.TOOL/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.ESP8266.NETWORK.UPLOAD.TOOL/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.ESP8266.NETWORK.UPLOAD.TOOL/value=esp8266OTA +environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.DTS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.DTS/operation=replace +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.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.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 +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.BUILD_CORE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.BUILD_CORE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.BUILD_CORE/value=esp8266 +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.BUILD_VARIANT/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.BUILD_VARIANT/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.BUILD_VARIANT/value=nodemcu +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.CORE.REFERENCED.PLATFORM/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.CORE.REFERENCED.PLATFORM/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.CORE.REFERENCED.PLATFORM/value=${JANTJE.SELECTED.PLATFORM} +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.UPLOAD.TOOL/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.UPLOAD.TOOL/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.UPLOAD.TOOL/value=esptool +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.USED.BOARDS_FILE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.USED.BOARDS_FILE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.USED.BOARDS_FILE/value=${JANTJE.BOARDS_FILE} +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.VARIANT.REFERENCED.PLATFORM/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.VARIANT.REFERENCED.PLATFORM/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.JANTJE.VARIANT.REFERENCED.PLATFORM/value=${JANTJE.SELECTED.PLATFORM} +environment/project/io.sloeber.core.toolChain.release.936970421/A.NAME/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.NAME/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.NAME/value=NodeMCU 1.0 (ESP-12E Module) +environment/project/io.sloeber.core.toolChain.release.936970421/A.PACKAGES/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.PACKAGES/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.PACKAGES/value=${eclipse_home}/arduinoPlugin/packages +environment/project/io.sloeber.core.toolChain.release.936970421/A.PROGRAM.TOOL/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.PROGRAM.TOOL/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.PROGRAM.TOOL/value=${A.UPLOAD.TOOL} +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.AR.PATTERN.1/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.AR.PATTERN.1/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.AR.PATTERN.1/value="/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-ar" cru "/home/wn/workspace-arduino/EspThermometer2/Release/arduino.ar" +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.AR.PATTERN.2/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.AR.PATTERN.2/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.AR.PATTERN.2/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.AR.PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.AR.PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.AR.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.AR.CMD}" ${A.COMPILER.AR.FLAGS} ${A.COMPILER.AR.EXTRA_FLAGS} "${A.BUILD.PATH}/arduino.ar" "${A.OBJECT_FILE}" +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.COMBINE.PATTERN.1/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.COMBINE.PATTERN.1/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.COMBINE.PATTERN.1/value="/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-gcc" -g -Wall -Wextra -Os -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-L/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/lib" "-L/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/ld" "-Teagle.flash.4m1m.ld" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy -o "/home/wn/workspace-arduino/EspThermometer2/Release/EspThermometer2.elf" -Wl,--start-group +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.COMBINE.PATTERN.2/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.COMBINE.PATTERN.2/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.COMBINE.PATTERN.2/value=\ "/home/wn/workspace-arduino/EspThermometer2/Release/arduino.ar" -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lwps -laxtls -lsmartconfig -lmesh -lwpa2 -llwip_gcc -lstdc++ -Wl,--end-group "-L/home/wn/workspace-arduino/EspThermometer2/Release" +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.COMBINE.PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.COMBINE.PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.COMBINE.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.C.ELF.CMD}" ${A.COMPILER.C.ELF.FLAGS} ${A.COMPILER.C.ELF.EXTRA_FLAGS} -o "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" -Wl,--start-group ${A.OBJECT_FILES} "${A.BUILD.PATH}/arduino.ar" ${A.COMPILER.C.ELF.LIBS} -Wl,--end-group "-L${A.BUILD.PATH}" +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN.1/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN.1/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN.1/value="/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-gcc" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/include" "-I/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/lwip/include" "-I/home/wn/workspace-arduino/EspThermometer2/Release/core" -c -Wall -Wextra -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions\=4 -std\=gnu99 -ffunction-sections -fdata-sections -DF_CPU\=160000000L -DLWIP_OPEN_SRC -DARDUINO\=10802 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 '-DARDUINO_BOARD\="ESP8266_NODEMCU"' -DESP8266 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN.2/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN.2/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN.2/value=\ -o +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN.3/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN.3/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN.3/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.C.O.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.C.CMD}" ${A.COMPILER.CPREPROCESSOR.FLAGS} ${A.COMPILER.C.FLAGS} -DF_CPU\=${A.BUILD.F_CPU} ${A.BUILD.LWIP_FLAGS} ${A.BUILD.DEBUG_PORT} ${A.BUILD.DEBUG_LEVEL} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DARDUINO_${A.BUILD.BOARD} -DARDUINO_ARCH_${A.BUILD.ARCH} '-DARDUINO_BOARD\="${A.BUILD.BOARD}"' ${A.COMPILER.C.EXTRA_FLAGS} ${A.BUILD.EXTRA_FLAGS} ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}" +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN.1/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN.1/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN.1/value="/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/include" "-I/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/lwip/include" "-I/home/wn/workspace-arduino/EspThermometer2/Release/core" -c -Wall -Wextra -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions\=4 -std\=c++11 -ffunction-sections -fdata-sections -DF_CPU\=160000000L -DLWIP_OPEN_SRC -DARDUINO\=10802 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 '-DARDUINO_BOARD\="ESP8266_NODEMCU"' -DESP8266 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN.2/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN.2/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN.2/value=\ -o +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN.3/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN.3/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN.3/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.CPP.O.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.CPP.CMD}" ${A.COMPILER.CPREPROCESSOR.FLAGS} ${A.COMPILER.CPP.FLAGS} -DF_CPU\=${A.BUILD.F_CPU} ${A.BUILD.LWIP_FLAGS} ${A.BUILD.DEBUG_PORT} ${A.BUILD.DEBUG_LEVEL} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DARDUINO_${A.BUILD.BOARD} -DARDUINO_ARCH_${A.BUILD.ARCH} '-DARDUINO_BOARD\="${A.BUILD.BOARD}"' ${A.COMPILER.CPP.EXTRA_FLAGS} ${A.BUILD.EXTRA_FLAGS} ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}" +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.EEP.PATTERN.1/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.EEP.PATTERN.1/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.EEP.PATTERN.1/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.EEP.PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.EEP.PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.EEP.PATTERN/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.HEX.PATTERN.1/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.HEX.PATTERN.1/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.HEX.PATTERN.1/value="/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/tools/esptool/0.4.9/esptool" -eo "/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/bootloaders/eboot/eboot.elf" -bo "/home/wn/workspace-arduino/EspThermometer2/Release/EspThermometer2.bin" -bm dio -bf 40 -bz 4M -bs .text -bp 4096 -ec -eo "/home/wn/workspace-arduino/EspThermometer2/Release/EspThermometer2.elf" -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.HEX.PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.HEX.PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OBJCOPY.HEX.PATTERN/value="${A.RUNTIME.TOOLS.ESPTOOL.PATH}/${A.COMPILER.ESPTOOL.CMD}" -eo "${A.RUNTIME.PLATFORM.PATH}/bootloaders/eboot/eboot.elf" -bo "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.bin" -bm ${A.BUILD.FLASH_MODE} -bf ${A.BUILD.FLASH_FREQ} -bz ${A.BUILD.FLASH_SIZE} -bs .text -bp 4096 -ec -eo "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OUTPUT.SAVE_FILE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OUTPUT.SAVE_FILE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OUTPUT.SAVE_FILE/value=${A.BUILD.PROJECT_NAME}.${A.BUILD.VARIANT}.bin +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OUTPUT.TMP_FILE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OUTPUT.TMP_FILE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.OUTPUT.TMP_FILE/value=${A.BUILD.PROJECT_NAME}.bin +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN.1/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN.1/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN.1/value="/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-gcc" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/include" "-I/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/lwip/include" "-I/home/wn/workspace-arduino/EspThermometer2/Release/core" -c -g -x assembler-with-cpp -mlongcalls -DF_CPU\=160000000L -DLWIP_OPEN_SRC -DARDUINO\=10802 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 '-DARDUINO_BOARD\="ESP8266_NODEMCU"' -DESP8266 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN.2/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN.2/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN.2/value=\ -o +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN.3/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN.3/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN.3/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.S.O.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.C.CMD}" ${A.COMPILER.CPREPROCESSOR.FLAGS} ${A.COMPILER.S.FLAGS} -DF_CPU\=${A.BUILD.F_CPU} ${A.BUILD.LWIP_FLAGS} ${A.BUILD.DEBUG_PORT} ${A.BUILD.DEBUG_LEVEL} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DARDUINO_${A.BUILD.BOARD} -DARDUINO_ARCH_${A.BUILD.ARCH} '-DARDUINO_BOARD\="${A.BUILD.BOARD}"' ${A.COMPILER.C.EXTRA_FLAGS} ${A.BUILD.EXTRA_FLAGS} ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}" +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.PATTERN.1/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.PATTERN.1/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.PATTERN.1/value="/opt/eclipse/eclipse-arduino/eclipse//arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-size" -A "/home/wn/workspace-arduino/EspThermometer2/Release/EspThermometer2.elf" +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.SIZE.CMD}" -A "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.REGEX.DATA/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.REGEX.DATA/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.REGEX.DATA/value=^(?\:\\.data|\\.rodata|\\.bss)\\s+([0-9]+).* +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.REGEX/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.REGEX/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RECIPE.SIZE.REGEX/value=^(?\:\\.irom0\\.text|\\.text|\\.data|\\.rodata|)\\s+([0-9]+).* +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.HARDWARE.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.HARDWARE.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.HARDWARE.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/hardware/esp8266 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.IDE.VERSION/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.IDE.VERSION/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.IDE.VERSION/value=10802 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.PLATFORM.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.PLATFORM.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.PLATFORM.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ARDUINOOTA-1.1.1.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ARDUINOOTA-1.1.1.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ARDUINOOTA-1.1.1.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/arduinoOTA/1.1.1 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ARDUINOOTA.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ARDUINOOTA.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ARDUINOOTA.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/arduinoOTA/1.1.1 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ARDUINOOTA1.1.1.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ARDUINOOTA1.1.1.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ARDUINOOTA1.1.1.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/arduinoOTA/1.1.1 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVR-GCC-4.9.2-ATMEL3.5.4-ARDUINO2.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVR-GCC-4.9.2-ATMEL3.5.4-ARDUINO2.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVR-GCC-4.9.2-ATMEL3.5.4-ARDUINO2.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVR-GCC.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVR-GCC.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVR-GCC.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVR-GCC4.9.2-ATMEL3.5.4-ARDUINO2.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVR-GCC4.9.2-ATMEL3.5.4-ARDUINO2.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVR-GCC4.9.2-ATMEL3.5.4-ARDUINO2.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO9.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO9.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO9.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avrdude/6.3.0-arduino9 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVRDUDE.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVRDUDE.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVRDUDE.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avrdude/6.3.0-arduino9 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO9.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO9.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO9.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avrdude/6.3.0-arduino9 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ESPTOOL-0.4.9.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ESPTOOL-0.4.9.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ESPTOOL-0.4.9.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/esptool/0.4.9 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ESPTOOL.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ESPTOOL.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ESPTOOL.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/esptool/0.4.9 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ESPTOOL0.4.9.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ESPTOOL0.4.9.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.ESPTOOL0.4.9.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/esptool/0.4.9 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.MKSPIFFS-0.1.2.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.MKSPIFFS-0.1.2.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.MKSPIFFS-0.1.2.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/mkspiffs/0.1.2 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.MKSPIFFS.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.MKSPIFFS.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.MKSPIFFS.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/mkspiffs/0.1.2 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.MKSPIFFS0.1.2.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.MKSPIFFS0.1.2.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.MKSPIFFS0.1.2.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/mkspiffs/0.1.2 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC-1.20.0-26-GB404FB9-2.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC-1.20.0-26-GB404FB9-2.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC-1.20.0-26-GB404FB9-2.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2 +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC1.20.0-26-GB404FB9-2.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC1.20.0-26-GB404FB9-2.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC1.20.0-26-GB404FB9-2.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2 +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.DISABLEDTR/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.DISABLEDTR/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.DISABLEDTR/value=true +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.DISABLERTS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.DISABLERTS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.DISABLERTS/value=true +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.PORT.FILE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.PORT.FILE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.PORT.FILE/value=${A.SERIAL.PORT} +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.PORT/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.PORT/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.SERIAL.PORT/value=${JANTJE.COM_PORT} +environment/project/io.sloeber.core.toolChain.release.936970421/A.SOFTWARE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.SOFTWARE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.SOFTWARE/value=baeyens +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.AVRDUDE_REMOTE.UPLOAD.VERBOSE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.AVRDUDE_REMOTE.UPLOAD.VERBOSE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.AVRDUDE_REMOTE.UPLOAD.VERBOSE/value=-v +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESP8266OTA.UPLOAD.PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESP8266OTA.UPLOAD.PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESP8266OTA.UPLOAD.PATTERN/value=${A.TOOLS.ESPTOOL.UPLOAD.NETWORK_PATTERN} +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESP8266OTA/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESP8266OTA/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESP8266OTA/value=${A.TOOLS.ESPTOOL.NETWORK_CMD} +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.CMD.WINDOWS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.CMD.WINDOWS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.CMD.WINDOWS/value=esptool.exe +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.CMD/value=esptool +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.NETWORK.PASSWORD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.NETWORK.PASSWORD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.NETWORK.PASSWORD/value=${A.TOOLS.ESPTOOL.NETWORK.AUTH} +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.NETWORK_CMD.WINDOWS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.NETWORK_CMD.WINDOWS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.NETWORK_CMD.WINDOWS/value=python.exe +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.NETWORK_CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.NETWORK_CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.NETWORK_CMD/value=python +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.PATH/value=${A.RUNTIME.TOOLS.ESPTOOL.PATH} +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.NETWORK_PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.NETWORK_PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.NETWORK_PATTERN/value="${A.TOOLS.ESPTOOL.NETWORK_CMD}" "${A.RUNTIME.PLATFORM.PATH}/tools/espota.py" -i "${A.SERIAL.PORT}" -p "${A.TOOLS.ESPTOOL.NETWORK.PORT}" "--auth\=${A.TOOLS.ESPTOOL.NETWORK.PASSWORD}" -f "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.bin" +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PARAMS.QUIET/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PARAMS.QUIET/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PARAMS.QUIET/value= +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PARAMS.VERBOSE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PARAMS.VERBOSE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PARAMS.VERBOSE/value=-vv +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PATTERN/value="${A.TOOLS.ESPTOOL.PATH}/${A.TOOLS.ESPTOOL.CMD}" ${A.TOOLS.ESPTOOL.UPLOAD.VERBOSE} -cd ${A.UPLOAD.RESETMETHOD} -cb ${A.UPLOAD.SPEED} -cp "${A.SERIAL.PORT}" -ca 0x00000 -cf "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.bin" +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PROTOCOL/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PROTOCOL/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.ESPTOOL.UPLOAD.PROTOCOL/value=esp +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.MKSPIFFS.CMD.WINDOWS/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.MKSPIFFS.CMD.WINDOWS/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.MKSPIFFS.CMD.WINDOWS/value=mkspiffs.exe +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.MKSPIFFS.CMD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.MKSPIFFS.CMD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.MKSPIFFS.CMD/value=mkspiffs +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.MKSPIFFS.PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.MKSPIFFS.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.TOOLS.MKSPIFFS.PATH/value=${A.RUNTIME.TOOLS.MKSPIFFS.PATH} +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.MAXIMUM_DATA_SIZE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.MAXIMUM_DATA_SIZE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.MAXIMUM_DATA_SIZE/value=81920 +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.MAXIMUM_SIZE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.MAXIMUM_SIZE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.MAXIMUM_SIZE/value=1044464 +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.RESETMETHOD/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.RESETMETHOD/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.RESETMETHOD/value=nodemcu +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.SPEED/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.SPEED/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.SPEED/value=115200 +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.TOOL/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.TOOL/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.TOOL/value=esptool +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.WAIT_FOR_UPLOAD_PORT/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.WAIT_FOR_UPLOAD_PORT/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.UPLOAD.WAIT_FOR_UPLOAD_PORT/value=true +environment/project/io.sloeber.core.toolChain.release.936970421/A.VERSION/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/A.VERSION/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/A.VERSION/value=2.2.0 +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.ARCHITECTURE_ID/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.ARCHITECTURE_ID/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.ARCHITECTURE_ID/value=esp8266 +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.BOARDS_FILE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.BOARDS_FILE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.BOARDS_FILE/value=${eclipse_home}/arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/boards.txt +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.BOARD_ID/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.BOARD_ID/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.BOARD_ID/value=nodemcuv2 +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.BOARD_NAME/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.BOARD_NAME/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.BOARD_NAME/value=NodeMCU 1.0 (ESP-12E Module) +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.COM_PORT/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.COM_PORT/operation=replace +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.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= +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.COMPILE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.COMPILE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.COMPILE/value= +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.CPP.COMPILE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.CPP.COMPILE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.CPP.COMPILE/value= +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.MENU.CPUFREQUENCY/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.MENU.CPUFREQUENCY/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.MENU.CPUFREQUENCY/value=160 +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.MENU.FLASHSIZE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.MENU.FLASHSIZE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.MENU.FLASHSIZE/value=4M1M +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.MENU.UPLOADSPEED/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.MENU.UPLOADSPEED/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.MENU.UPLOADSPEED/value=115200 +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.OBJCOPY/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.OBJCOPY/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.OBJCOPY/value=${A.RECIPE.OBJCOPY.HEX.PATTERN} +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.OS_NAME/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.OS_NAME/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.OS_NAME/value=linux +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.PACKAGE_ID/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.PACKAGE_ID/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.PACKAGE_ID/value=esp8266 +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.PLATFORM_FILE/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.PLATFORM_FILE/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.PLATFORM_FILE/value=${eclipse_home}/arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/platform.txt +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.PROJECT_NAME/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.PROJECT_NAME/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.PROJECT_NAME/value= +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.SELECTED.PLATFORM/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.SELECTED.PLATFORM/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.SELECTED.PLATFORM/value=${eclipse_home}/arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0 +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.SIZE.SWITCH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.SIZE.SWITCH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.SIZE.SWITCH/value=${A.RECIPE.SIZE.PATTERN} +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.UPLOAD.PATTERN/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.UPLOAD.PATTERN/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.UPLOAD.PATTERN/value=${A.TOOLS.ESPTOOL.UPLOAD.PATTERN} +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.UPLOAD.PROTOCOL/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.UPLOAD.PROTOCOL/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.UPLOAD.PROTOCOL/value=Default +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.WARNING_LEVEL/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.WARNING_LEVEL/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.WARNING_LEVEL/value=true +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.WORKSPACE_LOCATION/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.WORKSPACE_LOCATION/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.WORKSPACE_LOCATION/value=/home/wn/workspace-arduino +environment/project/io.sloeber.core.toolChain.release.936970421/PATH/delimiter=\: +environment/project/io.sloeber.core.toolChain.release.936970421/PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.936970421/PATH/value=${A.COMPILER.PATH}${PathDelimiter}${A.BUILD.GENERIC.PATH}${PathDelimiter}${PATH} +environment/project/io.sloeber.core.toolChain.release.936970421/append=true +environment/project/io.sloeber.core.toolChain.release.936970421/appendContributed=true diff --git a/ConfigGenerator/configGen.py b/ConfigGenerator/configGen.py new file mode 100644 index 0000000..add0778 --- /dev/null +++ b/ConfigGenerator/configGen.py @@ -0,0 +1,24 @@ +#!/usr/bin/python + +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"} +] + + +h_file = Template(file="configuration_h.tmpl", searchList=[{"configItems":configItems}]) +open('configuration.h','w').write(str(h_file)) +c_file = Template(file="configuration_c.tmpl", searchList=[{"configItems":configItems}]) +open('configuration.cpp','w').write(str(c_file)) diff --git a/ConfigGenerator/configuration_c.tmpl b/ConfigGenerator/configuration_c.tmpl new file mode 100644 index 0000000..7eddabe --- /dev/null +++ b/ConfigGenerator/configuration_c.tmpl @@ -0,0 +1,65 @@ +#raw +#include + +#include +#include + +#include "configuration.h" +#end raw + + +tConfigBlock configBlock; +const uint32_t MAGIC = 0xC0DE0001; +extern ESP8266WebServer webServer; + +void configServeIndex() { + webServer.send(200, "text/html", "" + "" + " " + " ESP8266 Thermometer Configuration Page" + " " + " " + "

ESP8266 Configuration Page

" + "
" + " " + #for $configItem in $configItems + #if $configItem.label != "_" + " " + " " + " " + #end if + #end for + " " + " " + " " + "
" + " " + " " + " " + "
" + " " + "
" + "
" + " " + "" + ""); +#ifdef DEBUG + Serial.println("indexHtml request served"); +#endif +} + +void configServeGetConfiguration() { + String arg; + + #for $configItem in $configItems + #if $configItem.label != "_" + arg = webServer.arg("$configItem.key"); + Serial.print("$configItem.key"); + Serial.println(arg); + #end if + #end for + + webServer.send(200, "text/html", "configuration saved"); +} + \ No newline at end of file diff --git a/ConfigGenerator/configuration_h.tmpl b/ConfigGenerator/configuration_h.tmpl new file mode 100644 index 0000000..613b13a --- /dev/null +++ b/ConfigGenerator/configuration_h.tmpl @@ -0,0 +1,15 @@ +typedef struct { +#for $configItem in $configItems +#if $configItem.type == 'C' + char ${configItem.key}[$configItem.length]; +#else if $configItem.type == 'I' + uint32_t $configItem.key; +#end if +#end for +} tConfigBlock; + +extern const uint32_t MAGIC; +extern tConfigBlock configBlock; + +void configServeIndex(); +void configServeGetConfiguration(); diff --git a/EspThermometer2.cpp b/EspThermometer2.cpp new file mode 100644 index 0000000..bdf6377 --- /dev/null +++ b/EspThermometer2.cpp @@ -0,0 +1,94 @@ +// Do not remove the include below +#include "EspThermometer2.h" +#include "defines.h" + +// #define ESP8266 + + +#include + +#include "configuration.h" +#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; + + + + + +#define CONFIG_SWITCH 4 +bool configMode = false; + + + +const uint16_t EEPROM_ADDR = 0; + + +uint32_t startTime = 0; + + +void setup() { + startTime = millis(); +#ifdef DEBUG + Serial.begin(115200); + Serial.println("Starting ..."); +#endif + + pinMode(CONFIG_SWITCH, INPUT_PULLUP); + + EEPROM.get(EEPROM_ADDR, configBlock); + + configMode = ((LOW == digitalRead(CONFIG_SWITCH)) || (configBlock.magic != MAGIC)); + + if (configMode) { +#ifdef DEBUG + Serial.println("Configuration mode"); +#endif + + setupConfiguration(); + } else { +#ifdef DEBUG + Serial.println("Production mode"); +#endif + + setupProduction(); + } + +#ifdef DEBUG + Serial.println("Started."); +#endif +} + +void loop() { + if (configMode) { + loopConfiguration(); + } else { + loopProduction(); + } +} + + diff --git a/EspThermometer2.h b/EspThermometer2.h new file mode 100644 index 0000000..7711278 --- /dev/null +++ b/EspThermometer2.h @@ -0,0 +1,22 @@ +// Only modify this file to include +// - function definitions (prototypes) +// - include files +// - extern variable definitions +// In the appropriate section + +#ifndef _EspThermometer2_H_ +#define _EspThermometer2_H_ +#include "Arduino.h" +//add your includes for the project EspThermometer2 here + + +//end of add your includes here + + +//add your function definitions for the project EspThermometer2 here + + + + +//Do not add code below this line +#endif /* _EspThermometer2_H_ */ diff --git a/configuration.cpp b/configuration.cpp new file mode 100644 index 0000000..9ef873e --- /dev/null +++ b/configuration.cpp @@ -0,0 +1,135 @@ +#include + +#include +#include + +#include "configuration.h" + + +tConfigBlock configBlock; +const uint32_t MAGIC = 0xC0DE0001; +extern ESP8266WebServer webServer; + +void configServeIndex() { + webServer.send(200, "text/html", "" + "" + " " + " ESP8266 Thermometer Configuration Page" + " " + " " + "

ESP8266 Configuration Page

" + "
" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "
" + " " + " " + " " + "
" + " " + " " + " " + "
" + " " + " " + " " + "
" + " " + " " + " " + "
" + " " + " " + " " + "
" + " " + " " + " " + "
" + " " + " " + " " + "
" + " " + " " + " " + "
" + " " + " " + " " + "
" + " " + "
" + "
" + " " + "" + ""); +#ifdef DEBUG + Serial.println("indexHtml request served"); +#endif +} + +void configServeGetConfiguration() { + String arg; + + arg = webServer.arg("wifiSsid"); + Serial.print("wifiSsid"); + Serial.println(arg); + arg = webServer.arg("wifiKey"); + Serial.print("wifiKey"); + Serial.println(arg); + arg = webServer.arg("mqttBroker"); + Serial.print("mqttBroker"); + Serial.println(arg); + arg = webServer.arg("mqttUser"); + Serial.print("mqttUser"); + Serial.println(arg); + arg = webServer.arg("mqttPass"); + Serial.print("mqttPass"); + Serial.println(arg); + arg = webServer.arg("mqttClientId"); + Serial.print("mqttClientId"); + Serial.println(arg); + arg = webServer.arg("mqttTopic"); + Serial.print("mqttTopic"); + Serial.println(arg); + arg = webServer.arg("mqttPort"); + Serial.print("mqttPort"); + Serial.println(arg); + arg = webServer.arg("measurePeriod"); + Serial.print("measurePeriod"); + Serial.println(arg); + + webServer.send(200, "text/html", "configuration saved"); +} + \ No newline at end of file diff --git a/configuration.h b/configuration.h new file mode 100644 index 0000000..24642b3 --- /dev/null +++ b/configuration.h @@ -0,0 +1,18 @@ +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(); diff --git a/configurationMode.cpp b/configurationMode.cpp new file mode 100644 index 0000000..0f5cc54 --- /dev/null +++ b/configurationMode.cpp @@ -0,0 +1,57 @@ +/* + * configurationMode.cpp + * + * Created on: Aug 20, 2017 + * Author: wn + */ + +#include "defines.h" + +#include +#include +#include +#include + + +#include "configurationMode.h" +#include "configuration.h" + + +const char* CONFIG_SSID = "espTherm"; + + +ESP8266WebServer webServer(80); + + + +void configServeNotFound() { + webServer.send(404, "text/plain", "page not found"); +#ifdef DEBUG + Serial.println("page not found served"); +#endif +} + + + +void setupConfiguration() { + WiFi.mode(WIFI_AP); + WiFi.softAP(CONFIG_SSID); +#ifdef DEBUG + Serial.println("AP started"); +#endif + + webServer.on("/", configServeIndex); + webServer.on("/config", configServeGetConfiguration); + webServer.onNotFound(configServeNotFound); + webServer.begin(); +#ifdef DEBUG + Serial.println("Webserver started"); +#endif +} + +void loopConfiguration() { + webServer.handleClient(); +} + + + diff --git a/configurationMode.h b/configurationMode.h new file mode 100644 index 0000000..898422d --- /dev/null +++ b/configurationMode.h @@ -0,0 +1,17 @@ +/* + * configurationMode.h + * + * Created on: Aug 20, 2017 + * Author: wn + */ + +#ifndef CONFIGURATIONMODE_H_ +#define CONFIGURATIONMODE_H_ + + + +void setupConfiguration(); +void loopConfiguration(); + + +#endif /* CONFIGURATIONMODE_H_ */ diff --git a/defines.h b/defines.h new file mode 100644 index 0000000..494ceee --- /dev/null +++ b/defines.h @@ -0,0 +1,18 @@ +/* + * defines.h + * + * Created on: Aug 20, 2017 + * Author: wn + */ + +#ifndef DEFINES_H_ +#define DEFINES_H_ + +#define DEBUG +//#define SLEEP + + + + + +#endif /* DEFINES_H_ */ diff --git a/ds18b20/DallasTemperature.cpp b/ds18b20/DallasTemperature.cpp new file mode 100644 index 0000000..73c9b42 --- /dev/null +++ b/ds18b20/DallasTemperature.cpp @@ -0,0 +1,848 @@ +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. + +#include "DallasTemperature.h" + + +#if ARDUINO >= 100 +#include "Arduino.h" +#else +extern "C" { +#include "WConstants.h" +} +#endif + +// OneWire commands +#define STARTCONVO 0x44 // Tells device to take a temperature reading and put it on the scratchpad +#define COPYSCRATCH 0x48 // Copy EEPROM +#define READSCRATCH 0xBE // Read EEPROM +#define WRITESCRATCH 0x4E // Write to EEPROM +#define RECALLSCRATCH 0xB8 // Reload from last known +#define READPOWERSUPPLY 0xB4 // Determine if device needs parasite power +#define ALARMSEARCH 0xEC // Query bus for devices with an alarm condition + +// Scratchpad locations +#define TEMP_LSB 0 +#define TEMP_MSB 1 +#define HIGH_ALARM_TEMP 2 +#define LOW_ALARM_TEMP 3 +#define CONFIGURATION 4 +#define INTERNAL_BYTE 5 +#define COUNT_REMAIN 6 +#define COUNT_PER_C 7 +#define SCRATCHPAD_CRC 8 + +// Device resolution +#define TEMP_9_BIT 0x1F // 9 bit +#define TEMP_10_BIT 0x3F // 10 bit +#define TEMP_11_BIT 0x5F // 11 bit +#define TEMP_12_BIT 0x7F // 12 bit + +DallasTemperature::DallasTemperature() {} +DallasTemperature::DallasTemperature(OneWire* _oneWire) + +#if REQUIRESALARMS +: _AlarmHandler(&defaultAlarmHandler) +#endif +{ + setOneWire(_oneWire); +} + +bool DallasTemperature::validFamily(const uint8_t* deviceAddress){ + switch (deviceAddress[0]){ + case DS18S20MODEL: + case DS18B20MODEL: + case DS1822MODEL: + case DS1825MODEL: + case DS28EA00MODEL: + return true; + default: + return false; + } +} + +void DallasTemperature::setOneWire(OneWire* _oneWire){ + + _wire = _oneWire; + devices = 0; + parasite = false; + bitResolution = 9; + waitForConversion = true; + checkForConversion = true; + +} + +// initialise the bus +void DallasTemperature::begin(void){ + + DeviceAddress deviceAddress; + + _wire->reset_search(); + devices = 0; // Reset the number of devices when we enumerate wire devices + + while (_wire->search(deviceAddress)){ + + if (validAddress(deviceAddress)){ + + if (!parasite && readPowerSupply(deviceAddress)) parasite = true; + + bitResolution = max(bitResolution, getResolution(deviceAddress)); + + devices++; + } + } + +} + +// returns the number of devices found on the bus +uint8_t DallasTemperature::getDeviceCount(void){ + return devices; +} + +// returns true if address is valid +bool DallasTemperature::validAddress(const uint8_t* deviceAddress){ + return (_wire->crc8(deviceAddress, 7) == deviceAddress[7]); +} + +// finds an address at a given index on the bus +// returns true if the device was found +bool DallasTemperature::getAddress(uint8_t* deviceAddress, uint8_t index){ + + uint8_t depth = 0; + + _wire->reset_search(); + + while (depth <= index && _wire->search(deviceAddress)) { + if (depth == index && validAddress(deviceAddress)) return true; + depth++; + } + + return false; + +} + +// attempt to determine if the device at the given address is connected to the bus +bool DallasTemperature::isConnected(const uint8_t* deviceAddress){ + + ScratchPad scratchPad; + return isConnected(deviceAddress, scratchPad); + +} + +// attempt to determine if the device at the given address is connected to the bus +// also allows for updating the read scratchpad +bool DallasTemperature::isConnected(const uint8_t* deviceAddress, uint8_t* scratchPad) +{ + bool b = readScratchPad(deviceAddress, scratchPad); + return b && (_wire->crc8(scratchPad, 8) == scratchPad[SCRATCHPAD_CRC]); +} + +bool DallasTemperature::readScratchPad(const uint8_t* deviceAddress, uint8_t* scratchPad){ + + // send the reset command and fail fast + int b = _wire->reset(); + if (b == 0) return false; + + _wire->select(deviceAddress); + _wire->write(READSCRATCH); + + // Read all registers in a simple loop + // byte 0: temperature LSB + // byte 1: temperature MSB + // byte 2: high alarm temp + // byte 3: low alarm temp + // byte 4: DS18S20: store for crc + // DS18B20 & DS1822: configuration register + // byte 5: internal use & crc + // byte 6: DS18S20: COUNT_REMAIN + // DS18B20 & DS1822: store for crc + // byte 7: DS18S20: COUNT_PER_C + // DS18B20 & DS1822: store for crc + // byte 8: SCRATCHPAD_CRC + for(uint8_t i = 0; i < 9; i++){ + scratchPad[i] = _wire->read(); + } + + b = _wire->reset(); + return (b == 1); +} + + +void DallasTemperature::writeScratchPad(const uint8_t* deviceAddress, const uint8_t* scratchPad){ + + _wire->reset(); + _wire->select(deviceAddress); + _wire->write(WRITESCRATCH); + _wire->write(scratchPad[HIGH_ALARM_TEMP]); // high alarm temp + _wire->write(scratchPad[LOW_ALARM_TEMP]); // low alarm temp + + // DS1820 and DS18S20 have no configuration register + if (deviceAddress[0] != DS18S20MODEL) _wire->write(scratchPad[CONFIGURATION]); + + _wire->reset(); + + // save the newly written values to eeprom + _wire->select(deviceAddress); + _wire->write(COPYSCRATCH, parasite); + delay(20); // <--- added 20ms delay to allow 10ms long EEPROM write operation (as specified by datasheet) + + if (parasite) delay(10); // 10ms delay + _wire->reset(); + +} + +bool DallasTemperature::readPowerSupply(const uint8_t* deviceAddress){ + + bool ret = false; + _wire->reset(); + _wire->select(deviceAddress); + _wire->write(READPOWERSUPPLY); + if (_wire->read_bit() == 0) ret = true; + _wire->reset(); + return ret; + +} + + +// set resolution of all devices to 9, 10, 11, or 12 bits +// if new resolution is out of range, it is constrained. +void DallasTemperature::setResolution(uint8_t newResolution){ + + bitResolution = constrain(newResolution, 9, 12); + DeviceAddress deviceAddress; + for (int i=0; i newResolution)){ + bitResolution = newResolution; + DeviceAddress deviceAddr; + for (int i=0; iread_bit(); + return (b == 1); +} + +// sends command for all devices on the bus to perform a temperature conversion +void DallasTemperature::requestTemperatures(){ + + _wire->reset(); + _wire->skip(); + _wire->write(STARTCONVO, parasite); + + // ASYNC mode? + if (!waitForConversion) return; + blockTillConversionComplete(bitResolution); + +} + +// sends command for one device to perform a temperature by address +// returns FALSE if device is disconnected +// returns TRUE otherwise +bool DallasTemperature::requestTemperaturesByAddress(const uint8_t* deviceAddress){ + + uint8_t bitResolution = getResolution(deviceAddress); + if (bitResolution == 0){ + return false; //Device disconnected + } + + _wire->reset(); + _wire->select(deviceAddress); + _wire->write(STARTCONVO, parasite); + + // ASYNC mode? + if (!waitForConversion) return true; + + blockTillConversionComplete(bitResolution); + + return true; + +} + + +// Continue to check if the IC has responded with a temperature +void DallasTemperature::blockTillConversionComplete(uint8_t bitResolution){ + + int delms = millisToWaitForConversion(bitResolution); + if (checkForConversion && !parasite){ + unsigned long now = millis(); + while(!isConversionComplete() && (millis() - delms < now)); + } else { + delay(delms); + } + +} + +// returns number of milliseconds to wait till conversion is complete (based on IC datasheet) +int16_t DallasTemperature::millisToWaitForConversion(uint8_t bitResolution){ + + switch (bitResolution){ + case 9: + return 94; + case 10: + return 188; + case 11: + return 375; + default: + return 750; + } + +} + + +// sends command for one device to perform a temp conversion by index +bool DallasTemperature::requestTemperaturesByIndex(uint8_t deviceIndex){ + + DeviceAddress deviceAddress; + getAddress(deviceAddress, deviceIndex); + + return requestTemperaturesByAddress(deviceAddress); + +} + +// Fetch temperature for device index +float DallasTemperature::getTempCByIndex(uint8_t deviceIndex){ + + DeviceAddress deviceAddress; + if (!getAddress(deviceAddress, deviceIndex)){ + return DEVICE_DISCONNECTED_C; + } + + return getTempC((uint8_t*)deviceAddress); + +} + +// Fetch temperature for device index +float DallasTemperature::getTempFByIndex(uint8_t deviceIndex){ + + DeviceAddress deviceAddress; + + if (!getAddress(deviceAddress, deviceIndex)){ + return DEVICE_DISCONNECTED_F; + } + + return getTempF((uint8_t*)deviceAddress); + +} + +// reads scratchpad and returns fixed-point temperature, scaling factor 2^-7 +int16_t DallasTemperature::calculateTemperature(const uint8_t* deviceAddress, uint8_t* scratchPad){ + + int16_t fpTemperature = + (((int16_t) scratchPad[TEMP_MSB]) << 11) | + (((int16_t) scratchPad[TEMP_LSB]) << 3); + + /* + DS1820 and DS18S20 have a 9-bit temperature register. + + Resolutions greater than 9-bit can be calculated using the data from + the temperature, and COUNT REMAIN and COUNT PER °C registers in the + scratchpad. The resolution of the calculation depends on the model. + + While the COUNT PER °C register is hard-wired to 16 (10h) in a + DS18S20, it changes with temperature in DS1820. + + After reading the scratchpad, the TEMP_READ value is obtained by + truncating the 0.5°C bit (bit 0) from the temperature data. The + extended resolution temperature can then be calculated using the + following equation: + + COUNT_PER_C - COUNT_REMAIN + TEMPERATURE = TEMP_READ - 0.25 + -------------------------- + COUNT_PER_C + + Hagai Shatz simplified this to integer arithmetic for a 12 bits + value for a DS18S20, and James Cameron added legacy DS1820 support. + + See - http://myarduinotoy.blogspot.co.uk/2013/02/12bit-result-from-ds18s20.html + */ + + if (deviceAddress[0] == DS18S20MODEL){ + fpTemperature = ((fpTemperature & 0xfff0) << 3) - 16 + + ( + ((scratchPad[COUNT_PER_C] - scratchPad[COUNT_REMAIN]) << 7) / + scratchPad[COUNT_PER_C] + ); + } + + return fpTemperature; +} + + +// returns temperature in 1/128 degrees C or DEVICE_DISCONNECTED_RAW if the +// device's scratch pad cannot be read successfully. +// the numeric value of DEVICE_DISCONNECTED_RAW is defined in +// DallasTemperature.h. It is a large negative number outside the +// operating range of the device +int16_t DallasTemperature::getTemp(const uint8_t* deviceAddress){ + + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)) return calculateTemperature(deviceAddress, scratchPad); + return DEVICE_DISCONNECTED_RAW; + +} + +// returns temperature in degrees C or DEVICE_DISCONNECTED_C if the +// device's scratch pad cannot be read successfully. +// the numeric value of DEVICE_DISCONNECTED_C is defined in +// DallasTemperature.h. It is a large negative number outside the +// operating range of the device +float DallasTemperature::getTempC(const uint8_t* deviceAddress){ + return rawToCelsius(getTemp(deviceAddress)); +} + +// returns temperature in degrees F or DEVICE_DISCONNECTED_F if the +// device's scratch pad cannot be read successfully. +// the numeric value of DEVICE_DISCONNECTED_F is defined in +// DallasTemperature.h. It is a large negative number outside the +// operating range of the device +float DallasTemperature::getTempF(const uint8_t* deviceAddress){ + return rawToFahrenheit(getTemp(deviceAddress)); +} + +// returns true if the bus requires parasite power +bool DallasTemperature::isParasitePowerMode(void){ + return parasite; +} + + +// IF alarm is not used one can store a 16 bit int of userdata in the alarm +// registers. E.g. an ID of the sensor. +// See github issue #29 + +// note if device is not connected it will fail writing the data. +void DallasTemperature::setUserData(const uint8_t* deviceAddress, int16_t data) +{ + // return when stored value == new value + if(getUserData(deviceAddress) == data) return; + + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)) + { + scratchPad[HIGH_ALARM_TEMP] = data >> 8; + scratchPad[LOW_ALARM_TEMP] = data & 255; + writeScratchPad(deviceAddress, scratchPad); + } +} + +int16_t DallasTemperature::getUserData(const uint8_t* deviceAddress) +{ + int16_t data = 0; + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)) + { + data = scratchPad[HIGH_ALARM_TEMP] << 8; + data += scratchPad[LOW_ALARM_TEMP]; + } + return data; +} + +// note If address cannot be found no error will be reported. +int16_t DallasTemperature::getUserDataByIndex(uint8_t deviceIndex) +{ + DeviceAddress deviceAddress; + getAddress(deviceAddress, deviceIndex); + return getUserData((uint8_t*) deviceAddress); +} + +void DallasTemperature::setUserDataByIndex(uint8_t deviceIndex, int16_t data) +{ + DeviceAddress deviceAddress; + getAddress(deviceAddress, deviceIndex); + setUserData((uint8_t*) deviceAddress, data); +} + + +// Convert float Celsius to Fahrenheit +float DallasTemperature::toFahrenheit(float celsius){ + return (celsius * 1.8) + 32; +} + +// Convert float Fahrenheit to Celsius +float DallasTemperature::toCelsius(float fahrenheit){ + return (fahrenheit - 32) * 0.555555556; +} + +// convert from raw to Celsius +float DallasTemperature::rawToCelsius(int16_t raw){ + + if (raw <= DEVICE_DISCONNECTED_RAW) + return DEVICE_DISCONNECTED_C; + // C = RAW/128 + return (float)raw * 0.0078125; + +} + +// convert from raw to Fahrenheit +float DallasTemperature::rawToFahrenheit(int16_t raw){ + + if (raw <= DEVICE_DISCONNECTED_RAW) + return DEVICE_DISCONNECTED_F; + // C = RAW/128 + // F = (C*1.8)+32 = (RAW/128*1.8)+32 = (RAW*0.0140625)+32 + return ((float)raw * 0.0140625) + 32; + +} + +#if REQUIRESALARMS + +/* + +ALARMS: + +TH and TL Register Format + +BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0 +S 2^6 2^5 2^4 2^3 2^2 2^1 2^0 + +Only bits 11 through 4 of the temperature register are used +in the TH and TL comparison since TH and TL are 8-bit +registers. If the measured temperature is lower than or equal +to TL or higher than or equal to TH, an alarm condition exists +and an alarm flag is set inside the DS18B20. This flag is +updated after every temperature measurement; therefore, if the +alarm condition goes away, the flag will be turned off after +the next temperature conversion. + +*/ + +// sets the high alarm temperature for a device in degrees Celsius +// accepts a float, but the alarm resolution will ignore anything +// after a decimal point. valid range is -55C - 125C +void DallasTemperature::setHighAlarmTemp(const uint8_t* deviceAddress, char celsius){ + + // return when stored value == new value + if(getHighAlarmTemp(deviceAddress) == celsius) return; + + // make sure the alarm temperature is within the device's range + if (celsius > 125) celsius = 125; + else if (celsius < -55) celsius = -55; + + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)){ + scratchPad[HIGH_ALARM_TEMP] = (uint8_t)celsius; + writeScratchPad(deviceAddress, scratchPad); + } + +} + +// sets the low alarm temperature for a device in degrees Celsius +// accepts a float, but the alarm resolution will ignore anything +// after a decimal point. valid range is -55C - 125C +void DallasTemperature::setLowAlarmTemp(const uint8_t* deviceAddress, char celsius){ + + // return when stored value == new value + if(getLowAlarmTemp(deviceAddress) == celsius) return; + + // make sure the alarm temperature is within the device's range + if (celsius > 125) celsius = 125; + else if (celsius < -55) celsius = -55; + + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)){ + scratchPad[LOW_ALARM_TEMP] = (uint8_t)celsius; + writeScratchPad(deviceAddress, scratchPad); + } + +} + +// returns a char with the current high alarm temperature or +// DEVICE_DISCONNECTED for an address +char DallasTemperature::getHighAlarmTemp(const uint8_t* deviceAddress){ + + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)) return (char)scratchPad[HIGH_ALARM_TEMP]; + return DEVICE_DISCONNECTED_C; + +} + +// returns a char with the current low alarm temperature or +// DEVICE_DISCONNECTED for an address +char DallasTemperature::getLowAlarmTemp(const uint8_t* deviceAddress){ + + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)) return (char)scratchPad[LOW_ALARM_TEMP]; + return DEVICE_DISCONNECTED_C; + +} + +// resets internal variables used for the alarm search +void DallasTemperature::resetAlarmSearch(){ + + alarmSearchJunction = -1; + alarmSearchExhausted = 0; + for(uint8_t i = 0; i < 7; i++){ + alarmSearchAddress[i] = 0; + } + +} + +// This is a modified version of the OneWire::search method. +// +// Also added the OneWire search fix documented here: +// http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295 +// +// Perform an alarm search. If this function returns a '1' then it has +// enumerated the next device and you may retrieve the ROM from the +// OneWire::address variable. If there are no devices, no further +// devices, or something horrible happens in the middle of the +// enumeration then a 0 is returned. If a new device is found then +// its address is copied to newAddr. Use +// DallasTemperature::resetAlarmSearch() to start over. +bool DallasTemperature::alarmSearch(uint8_t* newAddr){ + + uint8_t i; + char lastJunction = -1; + uint8_t done = 1; + + if (alarmSearchExhausted) return false; + if (!_wire->reset()) return false; + + // send the alarm search command + _wire->write(0xEC, 0); + + for(i = 0; i < 64; i++){ + + uint8_t a = _wire->read_bit( ); + uint8_t nota = _wire->read_bit( ); + uint8_t ibyte = i / 8; + uint8_t ibit = 1 << (i & 7); + + // I don't think this should happen, this means nothing responded, but maybe if + // something vanishes during the search it will come up. + if (a && nota) return false; + + if (!a && !nota){ + if (i == alarmSearchJunction){ + // this is our time to decide differently, we went zero last time, go one. + a = 1; + alarmSearchJunction = lastJunction; + }else if (i < alarmSearchJunction){ + + // take whatever we took last time, look in address + if (alarmSearchAddress[ibyte] & ibit){ + a = 1; + }else{ + // Only 0s count as pending junctions, we've already exhausted the 0 side of 1s + a = 0; + done = 0; + lastJunction = i; + } + }else{ + // we are blazing new tree, take the 0 + a = 0; + alarmSearchJunction = i; + done = 0; + } + // OneWire search fix + // See: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295 + } + + if (a) alarmSearchAddress[ibyte] |= ibit; + else alarmSearchAddress[ibyte] &= ~ibit; + + _wire->write_bit(a); + } + + if (done) alarmSearchExhausted = 1; + for (i = 0; i < 8; i++) newAddr[i] = alarmSearchAddress[i]; + return true; + +} + +// returns true if device address might have an alarm condition +// (only an alarm search can verify this) +bool DallasTemperature::hasAlarm(const uint8_t* deviceAddress){ + + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)){ + + char temp = calculateTemperature(deviceAddress, scratchPad) >> 7; + + // check low alarm + if (temp <= (char)scratchPad[LOW_ALARM_TEMP]) return true; + + // check high alarm + if (temp >= (char)scratchPad[HIGH_ALARM_TEMP]) return true; + } + + // no alarm + return false; + +} + +// returns true if any device is reporting an alarm condition on the bus +bool DallasTemperature::hasAlarm(void){ + + DeviceAddress deviceAddress; + resetAlarmSearch(); + return alarmSearch(deviceAddress); + +} + +// runs the alarm handler for all devices returned by alarmSearch() +void DallasTemperature::processAlarms(void){ + + resetAlarmSearch(); + DeviceAddress alarmAddr; + + while (alarmSearch(alarmAddr)){ + + if (validAddress(alarmAddr)){ + _AlarmHandler(alarmAddr); + } + + } +} + +// sets the alarm handler +void DallasTemperature::setAlarmHandler(AlarmHandler *handler){ + _AlarmHandler = handler; +} + +// The default alarm handler +void DallasTemperature::defaultAlarmHandler(const uint8_t* deviceAddress){} + +#endif + +#if REQUIRESNEW + +// MnetCS - Allocates memory for DallasTemperature. Allows us to instance a new object +void* DallasTemperature::operator new(unsigned int size){ // Implicit NSS obj size + + void * p; // void pointer + p = malloc(size); // Allocate memory + memset((DallasTemperature*)p,0,size); // Initialise memory + + //!!! CANT EXPLICITLY CALL CONSTRUCTOR - workaround by using an init() methodR - workaround by using an init() method + return (DallasTemperature*) p; // Cast blank region to NSS pointer +} + +// MnetCS 2009 - Free the memory used by this instance +void DallasTemperature::operator delete(void* p){ + + DallasTemperature* pNss = (DallasTemperature*) p; // Cast to NSS pointer + pNss->~DallasTemperature(); // Destruct the object + + free(p); // Free the memory +} + +#endif diff --git a/ds18b20/DallasTemperature.h b/ds18b20/DallasTemperature.h new file mode 100644 index 0000000..fca68bd --- /dev/null +++ b/ds18b20/DallasTemperature.h @@ -0,0 +1,245 @@ +#ifndef DallasTemperature_h +#define DallasTemperature_h + +#define DALLASTEMPLIBVERSION "3.7.7" // To be deprecated + +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. + +// set to true to include code for new and delete operators +#ifndef REQUIRESNEW +#define REQUIRESNEW false +#endif + +// set to true to include code implementing alarm search functions +#ifndef REQUIRESALARMS +#define REQUIRESALARMS true +#endif + +#include +#include + +// Model IDs +#define DS18S20MODEL 0x10 // also DS1820 +#define DS18B20MODEL 0x28 +#define DS1822MODEL 0x22 +#define DS1825MODEL 0x3B +#define DS28EA00MODEL 0x42 + +// Error Codes +#define DEVICE_DISCONNECTED_C -127 +#define DEVICE_DISCONNECTED_F -196.6 +#define DEVICE_DISCONNECTED_RAW -7040 + +typedef uint8_t DeviceAddress[8]; + +class DallasTemperature +{ +public: + + DallasTemperature(); + DallasTemperature(OneWire*); + + void setOneWire(OneWire*); + + // initialise bus + void begin(void); + + // returns the number of devices found on the bus + uint8_t getDeviceCount(void); + + // returns true if address is valid + bool validAddress(const uint8_t*); + + // returns true if address is of the family of sensors the lib supports. + bool validFamily(const uint8_t* deviceAddress); + + // finds an address at a given index on the bus + bool getAddress(uint8_t*, uint8_t); + + // attempt to determine if the device at the given address is connected to the bus + bool isConnected(const uint8_t*); + + // attempt to determine if the device at the given address is connected to the bus + // also allows for updating the read scratchpad + bool isConnected(const uint8_t*, uint8_t*); + + // read device's scratchpad + bool readScratchPad(const uint8_t*, uint8_t*); + + // write device's scratchpad + void writeScratchPad(const uint8_t*, const uint8_t*); + + // read device's power requirements + bool readPowerSupply(const uint8_t*); + + // get global resolution + uint8_t getResolution(); + + // set global resolution to 9, 10, 11, or 12 bits + void setResolution(uint8_t); + + // returns the device resolution: 9, 10, 11, or 12 bits + uint8_t getResolution(const uint8_t*); + + // set resolution of a device to 9, 10, 11, or 12 bits + bool setResolution(const uint8_t*, uint8_t, bool skipGlobalBitResolutionCalculation = false); + + // sets/gets the waitForConversion flag + void setWaitForConversion(bool); + bool getWaitForConversion(void); + + // sets/gets the checkForConversion flag + void setCheckForConversion(bool); + bool getCheckForConversion(void); + + // sends command for all devices on the bus to perform a temperature conversion + void requestTemperatures(void); + + // sends command for one device to perform a temperature conversion by address + bool requestTemperaturesByAddress(const uint8_t*); + + // sends command for one device to perform a temperature conversion by index + bool requestTemperaturesByIndex(uint8_t); + + // returns temperature raw value (12 bit integer of 1/128 degrees C) + int16_t getTemp(const uint8_t*); + + // returns temperature in degrees C + float getTempC(const uint8_t*); + + // returns temperature in degrees F + float getTempF(const uint8_t*); + + // Get temperature for device index (slow) + float getTempCByIndex(uint8_t); + + // Get temperature for device index (slow) + float getTempFByIndex(uint8_t); + + // returns true if the bus requires parasite power + bool isParasitePowerMode(void); + + // Is a conversion complete on the wire? + bool isConversionComplete(void); + + int16_t millisToWaitForConversion(uint8_t); + +#if REQUIRESALARMS + + typedef void AlarmHandler(const uint8_t*); + + // sets the high alarm temperature for a device + // accepts a char. valid range is -55C - 125C + void setHighAlarmTemp(const uint8_t*, char); + + // sets the low alarm temperature for a device + // accepts a char. valid range is -55C - 125C + void setLowAlarmTemp(const uint8_t*, char); + + // returns a signed char with the current high alarm temperature for a device + // in the range -55C - 125C + char getHighAlarmTemp(const uint8_t*); + + // returns a signed char with the current low alarm temperature for a device + // in the range -55C - 125C + char getLowAlarmTemp(const uint8_t*); + + // resets internal variables used for the alarm search + void resetAlarmSearch(void); + + // search the wire for devices with active alarms + bool alarmSearch(uint8_t*); + + // returns true if ia specific device has an alarm + bool hasAlarm(const uint8_t*); + + // returns true if any device is reporting an alarm on the bus + bool hasAlarm(void); + + // runs the alarm handler for all devices returned by alarmSearch() + void processAlarms(void); + + // sets the alarm handler + void setAlarmHandler(const AlarmHandler *); + + // The default alarm handler + static void defaultAlarmHandler(const uint8_t*); + +#endif + + // if no alarm handler is used the two bytes can be used as user data + // example of such usage is an ID. + // note if device is not connected it will fail writing the data. + // note if address cannot be found no error will be reported. + // in short use carefully + void setUserData(const uint8_t*, int16_t ); + void setUserDataByIndex(uint8_t, int16_t ); + int16_t getUserData(const uint8_t* ); + int16_t getUserDataByIndex(uint8_t ); + + // convert from Celsius to Fahrenheit + static float toFahrenheit(float); + + // convert from Fahrenheit to Celsius + static float toCelsius(float); + + // convert from raw to Celsius + static float rawToCelsius(int16_t); + + // convert from raw to Fahrenheit + static float rawToFahrenheit(int16_t); + +#if REQUIRESNEW + + // initialize memory area + void* operator new (unsigned int); + + // delete memory reference + void operator delete(void*); + +#endif + +private: + typedef uint8_t ScratchPad[9]; + + // parasite power on or off + bool parasite; + + // used to determine the delay amount needed to allow for the + // temperature conversion to take place + uint8_t bitResolution; + + // used to requestTemperature with or without delay + bool waitForConversion; + + // used to requestTemperature to dynamically check if a conversion is complete + bool checkForConversion; + + // count of devices on the bus + uint8_t devices; + + // Take a pointer to one wire instance + OneWire* _wire; + + // reads scratchpad and returns the raw temperature + int16_t calculateTemperature(const uint8_t*, uint8_t*); + + void blockTillConversionComplete(uint8_t); + +#if REQUIRESALARMS + + // required for alarmSearch + uint8_t alarmSearchAddress[8]; + char alarmSearchJunction; + uint8_t alarmSearchExhausted; + + // the alarm handler function pointer + AlarmHandler *_AlarmHandler; + +#endif + +}; +#endif diff --git a/onewire/OneWire.cpp b/onewire/OneWire.cpp new file mode 100644 index 0000000..3b6fa82 --- /dev/null +++ b/onewire/OneWire.cpp @@ -0,0 +1,597 @@ +/* +Copyright (c) 2007, Jim Studt (original old version - many contributors since) + +The latest version of this library may be found at: + http://www.pjrc.com/teensy/td_libs_OneWire.html + +OneWire has been maintained by Paul Stoffregen (paul@pjrc.com) since +January 2010. + +DO NOT EMAIL for technical support, especially not for ESP chips! +All project support questions must be posted on public forums +relevant to the board or chips used. If using Arduino, post on +Arduino's forum. If using ESP, post on the ESP community forums. +There is ABSOLUTELY NO TECH SUPPORT BY PRIVATE EMAIL! + +Github's issue tracker for OneWire should be used only to report +specific bugs. DO NOT request project support via Github. All +project and tech support questions must be posted on forums, not +github issues. If you experience a problem and you are not +absolutely sure it's an issue with the library, ask on a forum +first. Only use github to report issues after experts have +confirmed the issue is with OneWire rather than your project. + +Back in 2010, OneWire was in need of many bug fixes, but had +been abandoned the original author (Jim Studt). None of the known +contributors were interested in maintaining OneWire. Paul typically +works on OneWire every 6 to 12 months. Patches usually wait that +long. If anyone is interested in more actively maintaining OneWire, +please contact Paul (this is pretty much the only reason to use +private email about OneWire). + +OneWire is now very mature code. No changes other than adding +definitions for newer hardware support are anticipated. + +Version 2.3: + Unknown chip fallback mode, Roger Clark + Teensy-LC compatibility, Paul Stoffregen + Search bug fix, Love Nystrom + +Version 2.2: + Teensy 3.0 compatibility, Paul Stoffregen, paul@pjrc.com + Arduino Due compatibility, http://arduino.cc/forum/index.php?topic=141030 + Fix DS18B20 example negative temperature + Fix DS18B20 example's low res modes, Ken Butcher + Improve reset timing, Mark Tillotson + Add const qualifiers, Bertrik Sikken + Add initial value input to crc16, Bertrik Sikken + Add target_search() function, Scott Roberts + +Version 2.1: + Arduino 1.0 compatibility, Paul Stoffregen + Improve temperature example, Paul Stoffregen + DS250x_PROM example, Guillermo Lovato + PIC32 (chipKit) compatibility, Jason Dangel, dangel.jason AT gmail.com + Improvements from Glenn Trewitt: + - crc16() now works + - check_crc16() does all of calculation/checking work. + - Added read_bytes() and write_bytes(), to reduce tedious loops. + - Added ds2408 example. + Delete very old, out-of-date readme file (info is here) + +Version 2.0: Modifications by Paul Stoffregen, January 2010: +http://www.pjrc.com/teensy/td_libs_OneWire.html + Search fix from Robin James + http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 + Use direct optimized I/O in all cases + Disable interrupts during timing critical sections + (this solves many random communication errors) + Disable interrupts during read-modify-write I/O + Reduce RAM consumption by eliminating unnecessary + variables and trimming many to 8 bits + Optimize both crc8 - table version moved to flash + +Modified to work with larger numbers of devices - avoids loop. +Tested in Arduino 11 alpha with 12 sensors. +26 Sept 2008 -- Robin James +http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 + +Updated to work with arduino-0008 and to include skip() as of +2007/07/06. --RJL20 + +Modified to calculate the 8-bit CRC directly, avoiding the need for +the 256-byte lookup table to be loaded in RAM. Tested in arduino-0010 +-- Tom Pollard, Jan 23, 2008 + +Jim Studt's original library was modified by Josh Larios. + +Tom Pollard, pollard@alum.mit.edu, contributed around May 20, 2008 + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Much of the code was inspired by Derek Yerger's code, though I don't +think much of that remains. In any event that was.. + (copyleft) 2006 by Derek Yerger - Free to distribute freely. + +The CRC code was excerpted and inspired by the Dallas Semiconductor +sample code bearing this copyright. +//--------------------------------------------------------------------------- +// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES +// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name of Dallas Semiconductor +// shall not be used except as stated in the Dallas Semiconductor +// Branding Policy. +//-------------------------------------------------------------------------- +*/ + +#include "OneWire.h" + + +OneWire::OneWire(uint8_t pin) +{ + pinMode(pin, INPUT); + bitmask = PIN_TO_BITMASK(pin); + baseReg = PIN_TO_BASEREG(pin); +#if ONEWIRE_SEARCH + reset_search(); +#endif +} + + +// Perform the onewire reset function. We will wait up to 250uS for +// the bus to come high, if it doesn't then it is broken or shorted +// and we return a 0; +// +// Returns 1 if a device asserted a presence pulse, 0 otherwise. +// +uint8_t OneWire::reset(void) +{ + IO_REG_TYPE mask = bitmask; + volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; + uint8_t r; + uint8_t retries = 125; + + noInterrupts(); + DIRECT_MODE_INPUT(reg, mask); + interrupts(); + // wait until the wire is high... just in case + do { + if (--retries == 0) return 0; + delayMicroseconds(2); + } while ( !DIRECT_READ(reg, mask)); + + noInterrupts(); + DIRECT_WRITE_LOW(reg, mask); + DIRECT_MODE_OUTPUT(reg, mask); // drive output low + interrupts(); + delayMicroseconds(480); + noInterrupts(); + DIRECT_MODE_INPUT(reg, mask); // allow it to float + delayMicroseconds(70); + r = !DIRECT_READ(reg, mask); + interrupts(); + delayMicroseconds(410); + return r; +} + +// +// Write a bit. Port and bit is used to cut lookup time and provide +// more certain timing. +// +void OneWire::write_bit(uint8_t v) +{ + IO_REG_TYPE mask=bitmask; + volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; + + if (v & 1) { + noInterrupts(); + DIRECT_WRITE_LOW(reg, mask); + DIRECT_MODE_OUTPUT(reg, mask); // drive output low + delayMicroseconds(10); + DIRECT_WRITE_HIGH(reg, mask); // drive output high + interrupts(); + delayMicroseconds(55); + } else { + noInterrupts(); + DIRECT_WRITE_LOW(reg, mask); + DIRECT_MODE_OUTPUT(reg, mask); // drive output low + delayMicroseconds(65); + DIRECT_WRITE_HIGH(reg, mask); // drive output high + interrupts(); + delayMicroseconds(5); + } +} + +// +// Read a bit. Port and bit is used to cut lookup time and provide +// more certain timing. +// +uint8_t OneWire::read_bit(void) +{ + IO_REG_TYPE mask=bitmask; + volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; + uint8_t r; + + noInterrupts(); + DIRECT_MODE_OUTPUT(reg, mask); + DIRECT_WRITE_LOW(reg, mask); + delayMicroseconds(3); + DIRECT_MODE_INPUT(reg, mask); // let pin float, pull up will raise + delayMicroseconds(10); + r = DIRECT_READ(reg, mask); + interrupts(); + delayMicroseconds(53); + return r; +} + +// +// Write a byte. The writing code uses the active drivers to raise the +// pin high, if you need power after the write (e.g. DS18S20 in +// parasite power mode) then set 'power' to 1, otherwise the pin will +// go tri-state at the end of the write to avoid heating in a short or +// other mishap. +// +void OneWire::write(uint8_t v, uint8_t power /* = 0 */) { + uint8_t bitMask; + + for (bitMask = 0x01; bitMask; bitMask <<= 1) { + OneWire::write_bit( (bitMask & v)?1:0); + } + if ( !power) { + noInterrupts(); + DIRECT_MODE_INPUT(baseReg, bitmask); + DIRECT_WRITE_LOW(baseReg, bitmask); + interrupts(); + } +} + +void OneWire::write_bytes(const uint8_t *buf, uint16_t count, bool power /* = 0 */) { + for (uint16_t i = 0 ; i < count ; i++) + write(buf[i]); + if (!power) { + noInterrupts(); + DIRECT_MODE_INPUT(baseReg, bitmask); + DIRECT_WRITE_LOW(baseReg, bitmask); + interrupts(); + } +} + +// +// Read a byte +// +uint8_t OneWire::read() { + uint8_t bitMask; + uint8_t r = 0; + + for (bitMask = 0x01; bitMask; bitMask <<= 1) { + if ( OneWire::read_bit()) r |= bitMask; + } + return r; +} + +void OneWire::read_bytes(uint8_t *buf, uint16_t count) { + for (uint16_t i = 0 ; i < count ; i++) + buf[i] = read(); +} + +// +// Do a ROM select +// +void OneWire::select(const uint8_t rom[8]) +{ + uint8_t i; + + write(0x55); // Choose ROM + + for (i = 0; i < 8; i++) write(rom[i]); +} + +// +// Do a ROM skip +// +void OneWire::skip() +{ + write(0xCC); // Skip ROM +} + +void OneWire::depower() +{ + noInterrupts(); + DIRECT_MODE_INPUT(baseReg, bitmask); + interrupts(); +} + +#if ONEWIRE_SEARCH + +// +// You need to use this function to start a search again from the beginning. +// You do not need to do it for the first search, though you could. +// +void OneWire::reset_search() +{ + // reset the search state + LastDiscrepancy = 0; + LastDeviceFlag = FALSE; + LastFamilyDiscrepancy = 0; + for(int i = 7; ; i--) { + ROM_NO[i] = 0; + if ( i == 0) break; + } +} + +// Setup the search to find the device type 'family_code' on the next call +// to search(*newAddr) if it is present. +// +void OneWire::target_search(uint8_t family_code) +{ + // set the search state to find SearchFamily type devices + ROM_NO[0] = family_code; + for (uint8_t i = 1; i < 8; i++) + ROM_NO[i] = 0; + LastDiscrepancy = 64; + LastFamilyDiscrepancy = 0; + LastDeviceFlag = FALSE; +} + +// +// Perform a search. If this function returns a '1' then it has +// enumerated the next device and you may retrieve the ROM from the +// OneWire::address variable. If there are no devices, no further +// devices, or something horrible happens in the middle of the +// enumeration then a 0 is returned. If a new device is found then +// its address is copied to newAddr. Use OneWire::reset_search() to +// start over. +// +// --- Replaced by the one from the Dallas Semiconductor web site --- +//-------------------------------------------------------------------------- +// Perform the 1-Wire Search Algorithm on the 1-Wire bus using the existing +// search state. +// Return TRUE : device found, ROM number in ROM_NO buffer +// FALSE : device not found, end of search +// +uint8_t OneWire::search(uint8_t *newAddr, bool search_mode /* = true */) +{ + uint8_t id_bit_number; + uint8_t last_zero, rom_byte_number, search_result; + uint8_t id_bit, cmp_id_bit; + + unsigned char rom_byte_mask, search_direction; + + // initialize for search + id_bit_number = 1; + last_zero = 0; + rom_byte_number = 0; + rom_byte_mask = 1; + search_result = 0; + + // if the last call was not the last one + if (!LastDeviceFlag) + { + // 1-Wire reset + if (!reset()) + { + // reset the search + LastDiscrepancy = 0; + LastDeviceFlag = FALSE; + LastFamilyDiscrepancy = 0; + return FALSE; + } + + // issue the search command + if (search_mode == true) { + write(0xF0); // NORMAL SEARCH + } else { + write(0xEC); // CONDITIONAL SEARCH + } + + // loop to do the search + do + { + // read a bit and its complement + id_bit = read_bit(); + cmp_id_bit = read_bit(); + + // check for no devices on 1-wire + if ((id_bit == 1) && (cmp_id_bit == 1)) + break; + else + { + // all devices coupled have 0 or 1 + if (id_bit != cmp_id_bit) + search_direction = id_bit; // bit write value for search + else + { + // if this discrepancy if before the Last Discrepancy + // on a previous next then pick the same as last time + if (id_bit_number < LastDiscrepancy) + search_direction = ((ROM_NO[rom_byte_number] & rom_byte_mask) > 0); + else + // if equal to last pick 1, if not then pick 0 + search_direction = (id_bit_number == LastDiscrepancy); + + // if 0 was picked then record its position in LastZero + if (search_direction == 0) + { + last_zero = id_bit_number; + + // check for Last discrepancy in family + if (last_zero < 9) + LastFamilyDiscrepancy = last_zero; + } + } + + // set or clear the bit in the ROM byte rom_byte_number + // with mask rom_byte_mask + if (search_direction == 1) + ROM_NO[rom_byte_number] |= rom_byte_mask; + else + ROM_NO[rom_byte_number] &= ~rom_byte_mask; + + // serial number search direction write bit + write_bit(search_direction); + + // increment the byte counter id_bit_number + // and shift the mask rom_byte_mask + id_bit_number++; + rom_byte_mask <<= 1; + + // if the mask is 0 then go to new SerialNum byte rom_byte_number and reset mask + if (rom_byte_mask == 0) + { + rom_byte_number++; + rom_byte_mask = 1; + } + } + } + while(rom_byte_number < 8); // loop until through all ROM bytes 0-7 + + // if the search was successful then + if (!(id_bit_number < 65)) + { + // search successful so set LastDiscrepancy,LastDeviceFlag,search_result + LastDiscrepancy = last_zero; + + // check for last device + if (LastDiscrepancy == 0) + LastDeviceFlag = TRUE; + + search_result = TRUE; + } + } + + // if no device found then reset counters so next 'search' will be like a first + if (!search_result || !ROM_NO[0]) + { + LastDiscrepancy = 0; + LastDeviceFlag = FALSE; + LastFamilyDiscrepancy = 0; + search_result = FALSE; + } else { + for (int i = 0; i < 8; i++) newAddr[i] = ROM_NO[i]; + } + return search_result; + } + +#endif + +#if ONEWIRE_CRC +// The 1-Wire CRC scheme is described in Maxim Application Note 27: +// "Understanding and Using Cyclic Redundancy Checks with Maxim iButton Products" +// + +#if ONEWIRE_CRC8_TABLE +// This table comes from Dallas sample code where it is freely reusable, +// though Copyright (C) 2000 Dallas Semiconductor Corporation +static const uint8_t PROGMEM dscrc_table[] = { + 0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65, + 157,195, 33,127,252,162, 64, 30, 95, 1,227,189, 62, 96,130,220, + 35,125,159,193, 66, 28,254,160,225,191, 93, 3,128,222, 60, 98, + 190,224, 2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255, + 70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89, 7, + 219,133,103, 57,186,228, 6, 88, 25, 71,165,251,120, 38,196,154, + 101, 59,217,135, 4, 90,184,230,167,249, 27, 69,198,152,122, 36, + 248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91, 5,231,185, + 140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205, + 17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80, + 175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238, + 50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115, + 202,148,118, 40,171,245, 23, 73, 8, 86,180,234,105, 55,213,139, + 87, 9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22, + 233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168, + 116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53}; + +// +// Compute a Dallas Semiconductor 8 bit CRC. These show up in the ROM +// and the registers. (note: this might better be done without to +// table, it would probably be smaller and certainly fast enough +// compared to all those delayMicrosecond() calls. But I got +// confused, so I use this table from the examples.) +// +uint8_t OneWire::crc8(const uint8_t *addr, uint8_t len) +{ + uint8_t crc = 0; + + while (len--) { + crc = pgm_read_byte(dscrc_table + (crc ^ *addr++)); + } + return crc; +} +#else +// +// Compute a Dallas Semiconductor 8 bit CRC directly. +// this is much slower, but much smaller, than the lookup table. +// +uint8_t OneWire::crc8(const uint8_t *addr, uint8_t len) +{ + uint8_t crc = 0; + + while (len--) { +#if defined(__AVR__) + crc = _crc_ibutton_update(crc, *addr++); +#else + uint8_t inbyte = *addr++; + for (uint8_t i = 8; i; i--) { + uint8_t mix = (crc ^ inbyte) & 0x01; + crc >>= 1; + if (mix) crc ^= 0x8C; + inbyte >>= 1; + } +#endif + } + return crc; +} +#endif + +#if ONEWIRE_CRC16 +bool OneWire::check_crc16(const uint8_t* input, uint16_t len, const uint8_t* inverted_crc, uint16_t crc) +{ + crc = ~crc16(input, len, crc); + return (crc & 0xFF) == inverted_crc[0] && (crc >> 8) == inverted_crc[1]; +} + +uint16_t OneWire::crc16(const uint8_t* input, uint16_t len, uint16_t crc) +{ +#if defined(__AVR__) + for (uint16_t i = 0 ; i < len ; i++) { + crc = _crc16_update(crc, input[i]); + } +#else + static const uint8_t oddparity[16] = + { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; + + for (uint16_t i = 0 ; i < len ; i++) { + // Even though we're just copying a byte from the input, + // we'll be doing 16-bit computation with it. + uint16_t cdata = input[i]; + cdata = (cdata ^ crc) & 0xff; + crc >>= 8; + + if (oddparity[cdata & 0x0F] ^ oddparity[cdata >> 4]) + crc ^= 0xC001; + + cdata <<= 6; + crc ^= cdata; + cdata <<= 1; + crc ^= cdata; + } +#endif + return crc; +} +#endif + +#endif diff --git a/onewire/OneWire.h b/onewire/OneWire.h new file mode 100644 index 0000000..189855c --- /dev/null +++ b/onewire/OneWire.h @@ -0,0 +1,376 @@ +#ifndef OneWire_h +#define OneWire_h + +#include + +#if defined(__AVR__) +#include +#endif + +#if ARDUINO >= 100 +#include "Arduino.h" // for delayMicroseconds, digitalPinToBitMask, etc +#else +#include "WProgram.h" // for delayMicroseconds +#include "pins_arduino.h" // for digitalPinToBitMask, etc +#endif + +// You can exclude certain features from OneWire. In theory, this +// might save some space. In practice, the compiler automatically +// removes unused code (technically, the linker, using -fdata-sections +// and -ffunction-sections when compiling, and Wl,--gc-sections +// when linking), so most of these will not result in any code size +// reduction. Well, unless you try to use the missing features +// and redesign your program to not need them! ONEWIRE_CRC8_TABLE +// is the exception, because it selects a fast but large algorithm +// or a small but slow algorithm. + +// you can exclude onewire_search by defining that to 0 +#ifndef ONEWIRE_SEARCH +#define ONEWIRE_SEARCH 1 +#endif + +// You can exclude CRC checks altogether by defining this to 0 +#ifndef ONEWIRE_CRC +#define ONEWIRE_CRC 1 +#endif + +// Select the table-lookup method of computing the 8-bit CRC +// by setting this to 1. The lookup table enlarges code size by +// about 250 bytes. It does NOT consume RAM (but did in very +// old versions of OneWire). If you disable this, a slower +// but very compact algorithm is used. +#ifndef ONEWIRE_CRC8_TABLE +#define ONEWIRE_CRC8_TABLE 1 +#endif + +// You can allow 16-bit CRC checks by defining this to 1 +// (Note that ONEWIRE_CRC must also be 1.) +#ifndef ONEWIRE_CRC16 +#define ONEWIRE_CRC16 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif + +// Platform specific I/O definitions + +#if defined(__AVR__) +#define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin))) +#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) +#define IO_REG_TYPE uint8_t +#define IO_REG_ASM asm("r30") +#define DIRECT_READ(base, mask) (((*(base)) & (mask)) ? 1 : 0) +#define DIRECT_MODE_INPUT(base, mask) ((*((base)+1)) &= ~(mask)) +#define DIRECT_MODE_OUTPUT(base, mask) ((*((base)+1)) |= (mask)) +#define DIRECT_WRITE_LOW(base, mask) ((*((base)+2)) &= ~(mask)) +#define DIRECT_WRITE_HIGH(base, mask) ((*((base)+2)) |= (mask)) + +#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) +#define PIN_TO_BASEREG(pin) (portOutputRegister(pin)) +#define PIN_TO_BITMASK(pin) (1) +#define IO_REG_TYPE uint8_t +#define IO_REG_ASM +#define DIRECT_READ(base, mask) (*((base)+512)) +#define DIRECT_MODE_INPUT(base, mask) (*((base)+640) = 0) +#define DIRECT_MODE_OUTPUT(base, mask) (*((base)+640) = 1) +#define DIRECT_WRITE_LOW(base, mask) (*((base)+256) = 1) +#define DIRECT_WRITE_HIGH(base, mask) (*((base)+128) = 1) + +#elif defined(__MKL26Z64__) +#define PIN_TO_BASEREG(pin) (portOutputRegister(pin)) +#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) +#define IO_REG_TYPE uint8_t +#define IO_REG_ASM +#define DIRECT_READ(base, mask) ((*((base)+16) & (mask)) ? 1 : 0) +#define DIRECT_MODE_INPUT(base, mask) (*((base)+20) &= ~(mask)) +#define DIRECT_MODE_OUTPUT(base, mask) (*((base)+20) |= (mask)) +#define DIRECT_WRITE_LOW(base, mask) (*((base)+8) = (mask)) +#define DIRECT_WRITE_HIGH(base, mask) (*((base)+4) = (mask)) + +#elif defined(__SAM3X8E__) || defined(__SAM3A8C__) || defined(__SAM3A4C__) +// Arduino 1.5.1 may have a bug in delayMicroseconds() on Arduino Due. +// http://arduino.cc/forum/index.php/topic,141030.msg1076268.html#msg1076268 +// If you have trouble with OneWire on Arduino Due, please check the +// status of delayMicroseconds() before reporting a bug in OneWire! +#define PIN_TO_BASEREG(pin) (&(digitalPinToPort(pin)->PIO_PER)) +#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) +#define IO_REG_TYPE uint32_t +#define IO_REG_ASM +#define DIRECT_READ(base, mask) (((*((base)+15)) & (mask)) ? 1 : 0) +#define DIRECT_MODE_INPUT(base, mask) ((*((base)+5)) = (mask)) +#define DIRECT_MODE_OUTPUT(base, mask) ((*((base)+4)) = (mask)) +#define DIRECT_WRITE_LOW(base, mask) ((*((base)+13)) = (mask)) +#define DIRECT_WRITE_HIGH(base, mask) ((*((base)+12)) = (mask)) +#ifndef PROGMEM +#define PROGMEM +#endif +#ifndef pgm_read_byte +#define pgm_read_byte(addr) (*(const uint8_t *)(addr)) +#endif + +#elif defined(__PIC32MX__) +#define PIN_TO_BASEREG(pin) (portModeRegister(digitalPinToPort(pin))) +#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) +#define IO_REG_TYPE uint32_t +#define IO_REG_ASM +#define DIRECT_READ(base, mask) (((*(base+4)) & (mask)) ? 1 : 0) //PORTX + 0x10 +#define DIRECT_MODE_INPUT(base, mask) ((*(base+2)) = (mask)) //TRISXSET + 0x08 +#define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) = (mask)) //TRISXCLR + 0x04 +#define DIRECT_WRITE_LOW(base, mask) ((*(base+8+1)) = (mask)) //LATXCLR + 0x24 +#define DIRECT_WRITE_HIGH(base, mask) ((*(base+8+2)) = (mask)) //LATXSET + 0x28 + +#elif defined(ARDUINO_ARCH_ESP8266) +// Special note: I depend on the ESP community to maintain these definitions and +// submit good pull requests. I can not answer any ESP questions or help you +// resolve any problems related to ESP chips. Please do not contact me and please +// DO NOT CREATE GITHUB ISSUES for ESP support. All ESP questions must be asked +// on ESP community forums. +#define PIN_TO_BASEREG(pin) ((volatile uint32_t*) GPO) +#define PIN_TO_BITMASK(pin) (1 << pin) +#define IO_REG_TYPE uint32_t +#define IO_REG_ASM +#define DIRECT_READ(base, mask) ((GPI & (mask)) ? 1 : 0) //GPIO_IN_ADDRESS +#define DIRECT_MODE_INPUT(base, mask) (GPE &= ~(mask)) //GPIO_ENABLE_W1TC_ADDRESS +#define DIRECT_MODE_OUTPUT(base, mask) (GPE |= (mask)) //GPIO_ENABLE_W1TS_ADDRESS +#define DIRECT_WRITE_LOW(base, mask) (GPOC = (mask)) //GPIO_OUT_W1TC_ADDRESS +#define DIRECT_WRITE_HIGH(base, mask) (GPOS = (mask)) //GPIO_OUT_W1TS_ADDRESS + +#elif defined(__SAMD21G18A__) +#define PIN_TO_BASEREG(pin) portModeRegister(digitalPinToPort(pin)) +#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) +#define IO_REG_TYPE uint32_t +#define IO_REG_ASM +#define DIRECT_READ(base, mask) (((*((base)+8)) & (mask)) ? 1 : 0) +#define DIRECT_MODE_INPUT(base, mask) ((*((base)+1)) = (mask)) +#define DIRECT_MODE_OUTPUT(base, mask) ((*((base)+2)) = (mask)) +#define DIRECT_WRITE_LOW(base, mask) ((*((base)+5)) = (mask)) +#define DIRECT_WRITE_HIGH(base, mask) ((*((base)+6)) = (mask)) + +#elif defined(RBL_NRF51822) +#define PIN_TO_BASEREG(pin) (0) +#define PIN_TO_BITMASK(pin) (pin) +#define IO_REG_TYPE uint32_t +#define IO_REG_ASM +#define DIRECT_READ(base, pin) nrf_gpio_pin_read(pin) +#define DIRECT_WRITE_LOW(base, pin) nrf_gpio_pin_clear(pin) +#define DIRECT_WRITE_HIGH(base, pin) nrf_gpio_pin_set(pin) +#define DIRECT_MODE_INPUT(base, pin) nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL) +#define DIRECT_MODE_OUTPUT(base, pin) nrf_gpio_cfg_output(pin) + +#elif defined(__arc__) /* Arduino101/Genuino101 specifics */ + +#include "scss_registers.h" +#include "portable.h" +#include "avr/pgmspace.h" + +#define GPIO_ID(pin) (g_APinDescription[pin].ulGPIOId) +#define GPIO_TYPE(pin) (g_APinDescription[pin].ulGPIOType) +#define GPIO_BASE(pin) (g_APinDescription[pin].ulGPIOBase) +#define DIR_OFFSET_SS 0x01 +#define DIR_OFFSET_SOC 0x04 +#define EXT_PORT_OFFSET_SS 0x0A +#define EXT_PORT_OFFSET_SOC 0x50 + +/* GPIO registers base address */ +#define PIN_TO_BASEREG(pin) ((volatile uint32_t *)g_APinDescription[pin].ulGPIOBase) +#define PIN_TO_BITMASK(pin) pin +#define IO_REG_TYPE uint32_t +#define IO_REG_ASM + +static inline __attribute__((always_inline)) +IO_REG_TYPE directRead(volatile IO_REG_TYPE *base, IO_REG_TYPE pin) +{ + IO_REG_TYPE ret; + if (SS_GPIO == GPIO_TYPE(pin)) { + ret = READ_ARC_REG(((IO_REG_TYPE)base + EXT_PORT_OFFSET_SS)); + } else { + ret = MMIO_REG_VAL_FROM_BASE((IO_REG_TYPE)base, EXT_PORT_OFFSET_SOC); + } + return ((ret >> GPIO_ID(pin)) & 0x01); +} + +static inline __attribute__((always_inline)) +void directModeInput(volatile IO_REG_TYPE *base, IO_REG_TYPE pin) +{ + if (SS_GPIO == GPIO_TYPE(pin)) { + WRITE_ARC_REG(READ_ARC_REG((((IO_REG_TYPE)base) + DIR_OFFSET_SS)) & ~(0x01 << GPIO_ID(pin)), + ((IO_REG_TYPE)(base) + DIR_OFFSET_SS)); + } else { + MMIO_REG_VAL_FROM_BASE((IO_REG_TYPE)base, DIR_OFFSET_SOC) &= ~(0x01 << GPIO_ID(pin)); + } +} + +static inline __attribute__((always_inline)) +void directModeOutput(volatile IO_REG_TYPE *base, IO_REG_TYPE pin) +{ + if (SS_GPIO == GPIO_TYPE(pin)) { + WRITE_ARC_REG(READ_ARC_REG(((IO_REG_TYPE)(base) + DIR_OFFSET_SS)) | (0x01 << GPIO_ID(pin)), + ((IO_REG_TYPE)(base) + DIR_OFFSET_SS)); + } else { + MMIO_REG_VAL_FROM_BASE((IO_REG_TYPE)base, DIR_OFFSET_SOC) |= (0x01 << GPIO_ID(pin)); + } +} + +static inline __attribute__((always_inline)) +void directWriteLow(volatile IO_REG_TYPE *base, IO_REG_TYPE pin) +{ + if (SS_GPIO == GPIO_TYPE(pin)) { + WRITE_ARC_REG(READ_ARC_REG(base) & ~(0x01 << GPIO_ID(pin)), base); + } else { + MMIO_REG_VAL(base) &= ~(0x01 << GPIO_ID(pin)); + } +} + +static inline __attribute__((always_inline)) +void directWriteHigh(volatile IO_REG_TYPE *base, IO_REG_TYPE pin) +{ + if (SS_GPIO == GPIO_TYPE(pin)) { + WRITE_ARC_REG(READ_ARC_REG(base) | (0x01 << GPIO_ID(pin)), base); + } else { + MMIO_REG_VAL(base) |= (0x01 << GPIO_ID(pin)); + } +} + +#define DIRECT_READ(base, pin) directRead(base, pin) +#define DIRECT_MODE_INPUT(base, pin) directModeInput(base, pin) +#define DIRECT_MODE_OUTPUT(base, pin) directModeOutput(base, pin) +#define DIRECT_WRITE_LOW(base, pin) directWriteLow(base, pin) +#define DIRECT_WRITE_HIGH(base, pin) directWriteHigh(base, pin) + +#else +#define PIN_TO_BASEREG(pin) (0) +#define PIN_TO_BITMASK(pin) (pin) +#define IO_REG_TYPE unsigned int +#define IO_REG_ASM +#define DIRECT_READ(base, pin) digitalRead(pin) +#define DIRECT_WRITE_LOW(base, pin) digitalWrite(pin, LOW) +#define DIRECT_WRITE_HIGH(base, pin) digitalWrite(pin, HIGH) +#define DIRECT_MODE_INPUT(base, pin) pinMode(pin,INPUT) +#define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin,OUTPUT) +#warning "OneWire. Fallback mode. Using API calls for pinMode,digitalRead and digitalWrite. Operation of this library is not guaranteed on this architecture." + +#endif + + +class OneWire +{ + private: + IO_REG_TYPE bitmask; + volatile IO_REG_TYPE *baseReg; + +#if ONEWIRE_SEARCH + // global search state + unsigned char ROM_NO[8]; + uint8_t LastDiscrepancy; + uint8_t LastFamilyDiscrepancy; + uint8_t LastDeviceFlag; +#endif + + public: + OneWire( uint8_t pin); + + // Perform a 1-Wire reset cycle. Returns 1 if a device responds + // with a presence pulse. Returns 0 if there is no device or the + // bus is shorted or otherwise held low for more than 250uS + uint8_t reset(void); + + // Issue a 1-Wire rom select command, you do the reset first. + void select(const uint8_t rom[8]); + + // Issue a 1-Wire rom skip command, to address all on bus. + void skip(void); + + // Write a byte. If 'power' is one then the wire is held high at + // the end for parasitically powered devices. You are responsible + // for eventually depowering it by calling depower() or doing + // another read or write. + void write(uint8_t v, uint8_t power = 0); + + void write_bytes(const uint8_t *buf, uint16_t count, bool power = 0); + + // Read a byte. + uint8_t read(void); + + void read_bytes(uint8_t *buf, uint16_t count); + + // Write a bit. The bus is always left powered at the end, see + // note in write() about that. + void write_bit(uint8_t v); + + // Read a bit. + uint8_t read_bit(void); + + // Stop forcing power onto the bus. You only need to do this if + // you used the 'power' flag to write() or used a write_bit() call + // and aren't about to do another read or write. You would rather + // not leave this powered if you don't have to, just in case + // someone shorts your bus. + void depower(void); + +#if ONEWIRE_SEARCH + // Clear the search state so that if will start from the beginning again. + void reset_search(); + + // Setup the search to find the device type 'family_code' on the next call + // to search(*newAddr) if it is present. + void target_search(uint8_t family_code); + + // Look for the next device. Returns 1 if a new address has been + // returned. A zero might mean that the bus is shorted, there are + // no devices, or you have already retrieved all of them. It + // might be a good idea to check the CRC to make sure you didn't + // get garbage. The order is deterministic. You will always get + // the same devices in the same order. + uint8_t search(uint8_t *newAddr, bool search_mode = true); +#endif + +#if ONEWIRE_CRC + // Compute a Dallas Semiconductor 8 bit CRC, these are used in the + // ROM and scratchpad registers. + static uint8_t crc8(const uint8_t *addr, uint8_t len); + +#if ONEWIRE_CRC16 + // Compute the 1-Wire CRC16 and compare it against the received CRC. + // Example usage (reading a DS2408): + // // Put everything in a buffer so we can compute the CRC easily. + // uint8_t buf[13]; + // buf[0] = 0xF0; // Read PIO Registers + // buf[1] = 0x88; // LSB address + // buf[2] = 0x00; // MSB address + // WriteBytes(net, buf, 3); // Write 3 cmd bytes + // ReadBytes(net, buf+3, 10); // Read 6 data bytes, 2 0xFF, 2 CRC16 + // if (!CheckCRC16(buf, 11, &buf[11])) { + // // Handle error. + // } + // + // @param input - Array of bytes to checksum. + // @param len - How many bytes to use. + // @param inverted_crc - The two CRC16 bytes in the received data. + // This should just point into the received data, + // *not* at a 16-bit integer. + // @param crc - The crc starting value (optional) + // @return True, iff the CRC matches. + static bool check_crc16(const uint8_t* input, uint16_t len, const uint8_t* inverted_crc, uint16_t crc = 0); + + // Compute a Dallas Semiconductor 16 bit CRC. This is required to check + // the integrity of data received from many 1-Wire devices. Note that the + // CRC computed here is *not* what you'll get from the 1-Wire network, + // for two reasons: + // 1) The CRC is transmitted bitwise inverted. + // 2) Depending on the endian-ness of your processor, the binary + // representation of the two-byte return value may have a different + // byte order than the two bytes you get from 1-Wire. + // @param input - Array of bytes to checksum. + // @param len - How many bytes to use. + // @param crc - The crc starting value (optional) + // @return The CRC16, as defined by Dallas Semiconductor. + static uint16_t crc16(const uint8_t* input, uint16_t len, uint16_t crc = 0); +#endif +#endif +}; + +#endif diff --git a/productionMode.cpp b/productionMode.cpp new file mode 100644 index 0000000..716f1e6 --- /dev/null +++ b/productionMode.cpp @@ -0,0 +1,172 @@ +/* + * production.cpp + * + * Created on: Aug 20, 2017 + * Author: wn + */ +#include "defines.h" + +#define MQTT_MAX_PACKET_SIZE 256 + + +#include +#include +#include +#include +#include + +#include "configuration.h" + + + +WiFiClientSecure espClient; +PubSubClient client(espClient); + +#define ONE_WIRE_BUS 2 +OneWire oneWire(ONE_WIRE_BUS); +DallasTemperature sensors(&oneWire); + +extern uint32_t startTime; + + +void setup_wifi() { + delay(10); + + // We start by connecting to a WiFi network +#ifdef DEBUG + Serial.println(); + Serial.print("Connecting to "); + Serial.println(configBlock.wifiSsid); +#endif + + WiFi.begin(configBlock.wifiSsid, configBlock.wifiKey); + + while (WiFi.status() != WL_CONNECTED) { + delay(50); +#ifdef DEBUG + Serial.print("."); +#endif + } + +#ifdef DEBUG + Serial.println(""); + Serial.println("WiFi connected"); + Serial.println("IP address: "); + Serial.println(WiFi.localIP()); +#endif +} + + + +void setupProduction() { + setup_wifi(); + client.setServer(configBlock.mqttBroker, configBlock.mqttPort); + + sensors.begin(); +#ifdef DEBUG + uint8_t num = sensors.getDeviceCount(); + Serial.print("device count: "); + Serial.println(num); +#endif + + sensors.setResolution(12); +} + +void reconnect() { + // Loop until we're reconnected + while (!client.connected()) { +#ifdef DEBUG + Serial.print("Attempting MQTT connection..."); +#endif + // Attempt to connect + //char clientId[128]; + //snprintf(clientId, 127, "esp%s", WiFi.macAddress().c_str()); + if (client.connect(configBlock.mqttClientId, configBlock.mqttUser, configBlock.mqttPass)) { +#ifdef DEBUG + Serial.println("connected"); +#endif + // Once connected, publish an announcement... + //client.publish("IoT/espThermometer/status", "hello world"); + } else { +#ifdef DEBUG + Serial.print("failed, rc="); + Serial.print(client.state()); + Serial.println(" try again in 5 seconds"); +#endif + // Wait 5 seconds before retrying + delay(5000); + } + } +} + + +void mqtt_connect() { + if (!client.connected()) { + reconnect(); + } + client.loop(); +} + + +void read_thermometer() { + sensors.requestTemperatures(); + + float t = sensors.getTempCByIndex(0); +#ifdef DEBUG + Serial.print(t); + Serial.println(); +#endif + + int16_t t1 = (int)t; + int16_t t2 = (int)((t - t1)*100); + + + uint16_t vcc = ESP.getVcc(); + uint16_t v1 = vcc / 1000; + uint16_t v2 = (vcc - v1 * 1000); +#ifdef DEBUG + Serial.print(vcc); + Serial.println(); +#endif + + + uint32_t duration = millis() - startTime; + + //char topic[128]; + //snprintf(topic, 127, "IoT/espThermometer2/%s/measurement", WiFi.macAddress().c_str()); + char payload[128]; + snprintf(payload, 127, "%s %d.%d %d.%d %ld", configBlock.mqttClientId, t1, t2, v1, v2, duration); +#ifdef DEBUG + Serial.println(payload); +#endif + client.publish(configBlock.mqttTopic, payload, true); + + +} + +void loopProduction() { + static uint32_t lastMillis = 0; + mqtt_connect(); + + uint32_t currentMillis = millis(); + if (currentMillis - lastMillis > 1000) { + lastMillis = currentMillis; + + read_thermometer(); + + + +#ifdef SLEEP +#ifdef DEBUG + Serial.println("Sleeping"); +#endif + client.disconnect(); + ESP.deepSleep(configBlock.sleepTime * 1000000); +#endif + } + +} + + + + diff --git a/productionMode.h b/productionMode.h new file mode 100644 index 0000000..305ba93 --- /dev/null +++ b/productionMode.h @@ -0,0 +1,16 @@ +/* + * productionMode.h + * + * Created on: Aug 20, 2017 + * Author: wn + */ + +#ifndef PRODUCTIONMODE_H_ +#define PRODUCTIONMODE_H_ + + +void setupProduction(); +void loopProduction(); + + +#endif /* PRODUCTIONMODE_H_ */ diff --git a/pubsubclient/PubSubClient.cpp b/pubsubclient/PubSubClient.cpp new file mode 100644 index 0000000..89d0f05 --- /dev/null +++ b/pubsubclient/PubSubClient.cpp @@ -0,0 +1,670 @@ +/* + PubSubClient.cpp - A simple client for MQTT. + Nick O'Leary + http://knolleary.net +*/ + +#include "PubSubClient.h" +#include "Arduino.h" + +#ifdef ESP8266 + #define INIT_FINGERPRINT() this->fingerprint = NULL; +#else + #define INIT_FINGERPRINT() +#endif + +PubSubClient::PubSubClient() { + this->_state = MQTT_DISCONNECTED; + this->_client = NULL; + this->stream = NULL; + setCallback(NULL); + this->_available = 0; + INIT_FINGERPRINT() +} + +PubSubClient::PubSubClient(Client& client) { + this->_state = MQTT_DISCONNECTED; + setClient(client); + this->stream = NULL; + this->_available = 0; + INIT_FINGERPRINT() +} + +#ifdef ESP8266 +PubSubClient::PubSubClient(WiFiClientSecure& client, const char* fingerprint) { + this->_state = MQTT_DISCONNECTED; + setClient(client); + this->stream = NULL; + this->_available = 0; + this->fingerprint = fingerprint; +} +#endif + +PubSubClient::PubSubClient(IPAddress addr, uint16_t port, Client& client) { + this->_state = MQTT_DISCONNECTED; + setServer(addr, port); + setClient(client); + this->stream = NULL; + this->_available = 0; + INIT_FINGERPRINT() +} +PubSubClient::PubSubClient(IPAddress addr, uint16_t port, Client& client, Stream& stream) { + this->_state = MQTT_DISCONNECTED; + setServer(addr,port); + setClient(client); + setStream(stream); + this->_available = 0; + INIT_FINGERPRINT() +} +PubSubClient::PubSubClient(IPAddress addr, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client) { + this->_state = MQTT_DISCONNECTED; + setServer(addr, port); + setCallback(callback); + setClient(client); + this->stream = NULL; + this->_available = 0; + INIT_FINGERPRINT() +} +PubSubClient::PubSubClient(IPAddress addr, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client, Stream& stream) { + this->_state = MQTT_DISCONNECTED; + setServer(addr,port); + setCallback(callback); + setClient(client); + setStream(stream); + this->_available = 0; + INIT_FINGERPRINT() +} + +PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, Client& client) { + this->_state = MQTT_DISCONNECTED; + setServer(ip, port); + setClient(client); + this->stream = NULL; + this->_available = 0; + INIT_FINGERPRINT() +} +PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, Client& client, Stream& stream) { + this->_state = MQTT_DISCONNECTED; + setServer(ip,port); + setClient(client); + setStream(stream); + this->_available = 0; + INIT_FINGERPRINT() +} +PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client) { + this->_state = MQTT_DISCONNECTED; + setServer(ip, port); + setCallback(callback); + setClient(client); + this->stream = NULL; + this->_available = 0; + INIT_FINGERPRINT() +} +PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client, Stream& stream) { + this->_state = MQTT_DISCONNECTED; + setServer(ip,port); + setCallback(callback); + setClient(client); + setStream(stream); + this->_available = 0; + INIT_FINGERPRINT() +} + +PubSubClient::PubSubClient(const char* domain, uint16_t port, Client& client) { + this->_state = MQTT_DISCONNECTED; + setServer(domain,port); + setClient(client); + this->stream = NULL; + this->_available = 0; + INIT_FINGERPRINT() +} +PubSubClient::PubSubClient(const char* domain, uint16_t port, Client& client, Stream& stream) { + this->_state = MQTT_DISCONNECTED; + setServer(domain,port); + setClient(client); + setStream(stream); + this->_available = 0; + INIT_FINGERPRINT() +} +PubSubClient::PubSubClient(const char* domain, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client) { + this->_state = MQTT_DISCONNECTED; + setServer(domain,port); + setCallback(callback); + setClient(client); + this->stream = NULL; + this->_available = 0; + INIT_FINGERPRINT() +} +PubSubClient::PubSubClient(const char* domain, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client, Stream& stream) { + this->_state = MQTT_DISCONNECTED; + setServer(domain,port); + setCallback(callback); + setClient(client); + setStream(stream); + this->_available = 0; + INIT_FINGERPRINT() +} + +boolean PubSubClient::connect(const char *id) { + return connect(id,NULL,NULL,0,0,0,0); +} + +boolean PubSubClient::connect(const char *id, const char *user, const char *pass) { + return connect(id,user,pass,0,0,0,0); +} + +boolean PubSubClient::connect(const char *id, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage) { + return connect(id,NULL,NULL,willTopic,willQos,willRetain,willMessage); +} + +boolean PubSubClient::connect(const char *id, const char *user, const char *pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage) { + if (!connected()) { + int result = 0; + + if (domain != NULL) { + result = _client->connect(this->domain, this->port); + } else { + result = _client->connect(this->ip, this->port); + } + +#ifdef ESP8266 + if (fingerprint != NULL) { + if (domain != NULL) { + // there's only one way to set fingerprint: using the WiFiClientSecure-based constructor, so this cast is safe + if (!static_cast(_client)->verify(fingerprint, domain)) { + _state = MQTT_TLS_BAD_SERVER_CREDENTIALS; + return false; + } + } + else { + char buffer[16]; // IPv4 only (which is what IPAddress supports anyway) + + ip.toString().toCharArray(buffer, 16); + + if (!static_cast(_client)->verify(fingerprint, buffer)) { + _state = MQTT_TLS_BAD_SERVER_CREDENTIALS; + return false; + } + } + } +#endif + + if (result == 1) { + nextMsgId = 1; + // Leave room in the buffer for header and variable length field + uint16_t length = 5; + unsigned int j; + +#if MQTT_VERSION == MQTT_VERSION_3_1 + uint8_t d[9] = {0x00,0x06,'M','Q','I','s','d','p', MQTT_VERSION}; +#define MQTT_HEADER_VERSION_LENGTH 9 +#elif MQTT_VERSION == MQTT_VERSION_3_1_1 + uint8_t d[7] = {0x00,0x04,'M','Q','T','T',MQTT_VERSION}; +#define MQTT_HEADER_VERSION_LENGTH 7 +#endif + for (j = 0;j>1); + } + } + + buffer[length++] = v; + + buffer[length++] = ((MQTT_KEEPALIVE) >> 8); + buffer[length++] = ((MQTT_KEEPALIVE) & 0xFF); + length = writeString(id,buffer,length); + if (willTopic) { + length = writeString(willTopic,buffer,length); + length = writeString(willMessage,buffer,length); + } + + if(user != NULL) { + length = writeString(user,buffer,length); + if(pass != NULL) { + length = writeString(pass,buffer,length); + } + } + + write(MQTTCONNECT,buffer,length-5); + + lastInActivity = lastOutActivity = millis(); + + while (!available()) { + unsigned long t = millis(); + if (t-lastInActivity >= ((int32_t) MQTT_SOCKET_TIMEOUT*1000UL)) { + _state = MQTT_CONNECTION_TIMEOUT; + _client->stop(); + return false; + } + } + uint8_t llen; + uint16_t len = readPacket(&llen); + + if (len == 4) { + if (buffer[3] == 0) { + lastInActivity = millis(); + pingOutstanding = false; + _state = MQTT_CONNECTED; + return true; + } else { + _state = buffer[3]; + } + } + _client->stop(); + } else { + _state = MQTT_CONNECT_FAILED; + } + return false; + } + return true; +} + +// return and cache the available number of bytes in the client; +// remember to reduce the available count when consuming the buffer +int PubSubClient::available() { + if (_available == 0) { + _available = _client->available(); + } + return _available; +} + +// reads a byte into result +boolean PubSubClient::readByte(uint8_t * result) { + uint32_t previousMillis = millis(); + while(!available()) { + uint32_t currentMillis = millis(); + if(currentMillis - previousMillis >= ((int32_t) MQTT_SOCKET_TIMEOUT * 1000)){ + return false; + } + } + *result = _client->read(); + _available -= 1; + return true; +} + +// reads a byte into result[*index] and increments index +boolean PubSubClient::readByte(uint8_t * result, uint16_t * index){ + uint16_t current_index = *index; + uint8_t * write_address = &(result[current_index]); + if(readByte(write_address)){ + *index = current_index + 1; + return true; + } + return false; +} + +uint16_t PubSubClient::readPacket(uint8_t* lengthLength) { + uint16_t len = 0; + if(!readByte(buffer, &len)) return 0; + bool isPublish = (buffer[0]&0xF0) == MQTTPUBLISH; + uint32_t multiplier = 1; + uint16_t length = 0; + uint8_t digit = 0; + uint16_t skip = 0; + uint8_t start = 0; + + do { + if(!readByte(&digit)) return 0; + buffer[len++] = digit; + length += (digit & 127) * multiplier; + multiplier *= 128; + } while ((digit & 128) != 0); + *lengthLength = len-1; + + if (isPublish) { + // Read in topic length to calculate bytes to skip over for Stream writing + if(!readByte(buffer, &len)) return 0; + if(!readByte(buffer, &len)) return 0; + skip = (buffer[*lengthLength+1]<<8)+buffer[*lengthLength+2]; + start = 2; + if (buffer[0]&MQTTQOS1) { + // skip message id + skip += 2; + } + } + + for (uint16_t i = start;istream) { + if (isPublish && len-*lengthLength-2>skip) { + this->stream->write(digit); + } + } + if (len < MQTT_MAX_PACKET_SIZE) { + buffer[len] = digit; + } + len++; + } + + if (!this->stream && len > MQTT_MAX_PACKET_SIZE) { + len = 0; // This will cause the packet to be ignored. + } + + return len; +} + +boolean PubSubClient::loop() { + if (connected()) { + do { + unsigned long t = millis(); + if ((t - lastInActivity > MQTT_KEEPALIVE*1000UL) || (t - lastOutActivity > MQTT_KEEPALIVE*1000UL)) { + if (pingOutstanding) { + this->_state = MQTT_CONNECTION_TIMEOUT; + _client->stop(); + return false; + } else { + buffer[0] = MQTTPINGREQ; + buffer[1] = 0; + _client->write(buffer,2); + lastOutActivity = t; + lastInActivity = t; + pingOutstanding = true; + } + } + + if (available()) { + uint8_t llen; + uint16_t len = readPacket(&llen); + uint16_t msgId = 0; + uint8_t *payload; + if (len > 0) { + lastInActivity = t; + uint8_t type = buffer[0]&0xF0; + if (type == MQTTPUBLISH) { + if (callback) { + uint16_t tl = (buffer[llen+1]<<8)+buffer[llen+2]; /* topic length in bytes */ + memmove(buffer+llen+2,buffer+llen+3,tl); /* move topic inside buffer 1 byte to front */ + buffer[llen+2+tl] = 0; /* end the topic as a 'C' string with \x00 */ + char *topic = (char*) buffer+llen+2; + // msgId only present for QOS>0 + if ((buffer[0]&0x06) == MQTTQOS1) { + msgId = (buffer[llen+3+tl]<<8)+buffer[llen+3+tl+1]; + payload = buffer+llen+3+tl+2; + callback(topic,payload,len-llen-3-tl-2); + + buffer[0] = MQTTPUBACK; + buffer[1] = 2; + buffer[2] = (msgId >> 8); + buffer[3] = (msgId & 0xFF); + _client->write(buffer,4); + lastOutActivity = t; + + } else { + payload = buffer+llen+3+tl; + callback(topic,payload,len-llen-3-tl); + } + } + } else if (type == MQTTPINGREQ) { + buffer[0] = MQTTPINGRESP; + buffer[1] = 0; + _client->write(buffer,2); + } else if (type == MQTTPINGRESP) { + pingOutstanding = false; + } + } + } + } while (_available > 0); // can't leave data in the buffer, or subsequent publish() calls + // may fail (axTLS is only half-duplex, so writes will fail, to + // avoid losing information) + return true; + } + return false; +} + +boolean PubSubClient::publish(const char* topic, const char* payload) { + return publish(topic,(const uint8_t*)payload,strlen(payload),false); +} + +boolean PubSubClient::publish(const char* topic, const char* payload, boolean retained) { + return publish(topic,(const uint8_t*)payload,strlen(payload),retained); +} + +boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength) { + return publish(topic, payload, plength, false); +} + +boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength, boolean retained) { + if (connected()) { + if (MQTT_MAX_PACKET_SIZE < 5 + 2+strlen(topic) + plength) { + // Too long + return false; + } + // Leave room in the buffer for header and variable length field + uint16_t length = 5; + length = writeString(topic,buffer,length); + uint16_t i; + for (i=0;i 0) { + digit |= 0x80; + } + buffer[pos++] = digit; + llen++; + } while(len>0); + + pos = writeString(topic,buffer,pos); + + rc += _client->write(buffer,pos); + + for (i=0;iwrite((char)pgm_read_byte_near(payload + i)); + } + + lastOutActivity = millis(); + + return rc == tlen + 4 + plength; +} + +boolean PubSubClient::write(uint8_t header, uint8_t* buf, uint16_t length) { + uint8_t lenBuf[4]; + uint8_t llen = 0; + uint8_t digit; + uint8_t pos = 0; + uint16_t rc; + uint16_t len = length; + do { + digit = len % 128; + len = len / 128; + if (len > 0) { + digit |= 0x80; + } + lenBuf[pos++] = digit; + llen++; + } while(len>0); + + buf[4-llen] = header; + for (int i=0;i 0) && result) { + bytesToWrite = (bytesRemaining > MQTT_MAX_TRANSFER_SIZE)?MQTT_MAX_TRANSFER_SIZE:bytesRemaining; + rc = _client->write(writeBuf,bytesToWrite); + result = (rc == bytesToWrite); + bytesRemaining -= rc; + writeBuf += rc; + } + return result; +#else + rc = _client->write(buf+(4-llen),length+1+llen); + lastOutActivity = millis(); + return (rc == 1+llen+length); +#endif +} + +boolean PubSubClient::subscribe(const char* topic) { + return subscribe(topic, 0); +} + +boolean PubSubClient::subscribe(const char* topic, uint8_t qos) { + if (qos < 0 || qos > 1) { + return false; + } + if (MQTT_MAX_PACKET_SIZE < 9 + strlen(topic)) { + // Too long + return false; + } + if (connected()) { + // Leave room in the buffer for header and variable length field + uint16_t length = 5; + nextMsgId++; + if (nextMsgId == 0) { + nextMsgId = 1; + } + buffer[length++] = (nextMsgId >> 8); + buffer[length++] = (nextMsgId & 0xFF); + length = writeString((char*)topic, buffer,length); + buffer[length++] = qos; + return write(MQTTSUBSCRIBE|MQTTQOS1,buffer,length-5); + } + return false; +} + +boolean PubSubClient::unsubscribe(const char* topic) { + if (MQTT_MAX_PACKET_SIZE < 9 + strlen(topic)) { + // Too long + return false; + } + if (connected()) { + uint16_t length = 5; + nextMsgId++; + if (nextMsgId == 0) { + nextMsgId = 1; + } + buffer[length++] = (nextMsgId >> 8); + buffer[length++] = (nextMsgId & 0xFF); + length = writeString(topic, buffer,length); + return write(MQTTUNSUBSCRIBE|MQTTQOS1,buffer,length-5); + } + return false; +} + +void PubSubClient::disconnect() { + buffer[0] = MQTTDISCONNECT; + buffer[1] = 0; + _client->write(buffer,2); + _state = MQTT_DISCONNECTED; + _client->stop(); + lastInActivity = lastOutActivity = millis(); +} + +uint16_t PubSubClient::writeString(const char* string, uint8_t* buf, uint16_t pos) { + const char* idp = string; + uint16_t i = 0; + pos += 2; + while (*idp) { + buf[pos++] = *idp++; + i++; + } + buf[pos-i-2] = (i >> 8); + buf[pos-i-1] = (i & 0xFF); + return pos; +} + + +boolean PubSubClient::connected() { + boolean rc; + if (_client == NULL ) { + rc = false; + } else { + rc = (int)_client->connected(); + if (!rc) { + if (this->_state == MQTT_CONNECTED) { + this->_state = MQTT_CONNECTION_LOST; + _client->flush(); + _client->stop(); + } + } + } + return rc; +} + +PubSubClient& PubSubClient::setServer(uint8_t * ip, uint16_t port) { + IPAddress addr(ip[0],ip[1],ip[2],ip[3]); + return setServer(addr,port); +} + +PubSubClient& PubSubClient::setServer(IPAddress ip, uint16_t port) { + this->ip = ip; + this->port = port; + this->domain = NULL; + return *this; +} + +PubSubClient& PubSubClient::setServer(const char * domain, uint16_t port) { + this->domain = domain; + this->port = port; + return *this; +} + +PubSubClient& PubSubClient::setCallback(MQTT_CALLBACK_SIGNATURE) { + this->callback = callback; + return *this; +} + +PubSubClient& PubSubClient::setClient(Client& client){ + this->_client = &client; + return *this; +} + +PubSubClient& PubSubClient::setStream(Stream& stream){ + this->stream = &stream; + return *this; +} + +int PubSubClient::state() { + return this->_state; +} diff --git a/pubsubclient/PubSubClient.h b/pubsubclient/PubSubClient.h new file mode 100644 index 0000000..16bf8d3 --- /dev/null +++ b/pubsubclient/PubSubClient.h @@ -0,0 +1,160 @@ +/* + PubSubClient.h - A simple client for MQTT. + Nick O'Leary + http://knolleary.net +*/ + +#ifndef PubSubClient_h +#define PubSubClient_h + +#include +#include "IPAddress.h" +#include "Client.h" +#include "Stream.h" + +#ifdef ESP8266 +#include "WiFiClientSecure.h" +#endif + +#define MQTT_VERSION_3_1 3 +#define MQTT_VERSION_3_1_1 4 + +// MQTT_VERSION : Pick the version +//#define MQTT_VERSION MQTT_VERSION_3_1 +#ifndef MQTT_VERSION +#define MQTT_VERSION MQTT_VERSION_3_1_1 +#endif + +// MQTT_MAX_PACKET_SIZE : Maximum packet size +#ifndef MQTT_MAX_PACKET_SIZE +#define MQTT_MAX_PACKET_SIZE 128 +#endif + +// MQTT_KEEPALIVE : keepAlive interval in Seconds +#ifndef MQTT_KEEPALIVE +#define MQTT_KEEPALIVE 15 +#endif + +// MQTT_SOCKET_TIMEOUT: socket timeout interval in Seconds +#ifndef MQTT_SOCKET_TIMEOUT +#define MQTT_SOCKET_TIMEOUT 15 +#endif + +// MQTT_MAX_TRANSFER_SIZE : limit how much data is passed to the network client +// in each write call. Needed for the Arduino Wifi Shield. Leave undefined to +// pass the entire MQTT packet in each write call. +//#define MQTT_MAX_TRANSFER_SIZE 80 + +// Possible values for client.state() +#define MQTT_TLS_BAD_SERVER_CREDENTIALS -5 +#define MQTT_CONNECTION_TIMEOUT -4 +#define MQTT_CONNECTION_LOST -3 +#define MQTT_CONNECT_FAILED -2 +#define MQTT_DISCONNECTED -1 +#define MQTT_CONNECTED 0 +#define MQTT_CONNECT_BAD_PROTOCOL 1 +#define MQTT_CONNECT_BAD_CLIENT_ID 2 +#define MQTT_CONNECT_UNAVAILABLE 3 +#define MQTT_CONNECT_BAD_CREDENTIALS 4 +#define MQTT_CONNECT_UNAUTHORIZED 5 + +#define MQTTCONNECT 1 << 4 // Client request to connect to Server +#define MQTTCONNACK 2 << 4 // Connect Acknowledgment +#define MQTTPUBLISH 3 << 4 // Publish message +#define MQTTPUBACK 4 << 4 // Publish Acknowledgment +#define MQTTPUBREC 5 << 4 // Publish Received (assured delivery part 1) +#define MQTTPUBREL 6 << 4 // Publish Release (assured delivery part 2) +#define MQTTPUBCOMP 7 << 4 // Publish Complete (assured delivery part 3) +#define MQTTSUBSCRIBE 8 << 4 // Client Subscribe request +#define MQTTSUBACK 9 << 4 // Subscribe Acknowledgment +#define MQTTUNSUBSCRIBE 10 << 4 // Client Unsubscribe request +#define MQTTUNSUBACK 11 << 4 // Unsubscribe Acknowledgment +#define MQTTPINGREQ 12 << 4 // PING Request +#define MQTTPINGRESP 13 << 4 // PING Response +#define MQTTDISCONNECT 14 << 4 // Client is Disconnecting +#define MQTTReserved 15 << 4 // Reserved + +#define MQTTQOS0 (0 << 1) +#define MQTTQOS1 (1 << 1) +#define MQTTQOS2 (2 << 1) + +#ifdef ESP8266 +#include +#define MQTT_CALLBACK_SIGNATURE std::function callback +#else +#define MQTT_CALLBACK_SIGNATURE void (*callback)(char*, uint8_t*, unsigned int) +#endif + +class PubSubClient { +private: + Client* _client; + uint8_t buffer[MQTT_MAX_PACKET_SIZE]; + uint16_t nextMsgId; + unsigned long lastOutActivity; + unsigned long lastInActivity; + int _available; + bool pingOutstanding; + MQTT_CALLBACK_SIGNATURE; + int available(); + uint16_t readPacket(uint8_t*); + boolean readByte(uint8_t * result); + boolean readByte(uint8_t * result, uint16_t * index); + boolean write(uint8_t header, uint8_t* buf, uint16_t length); + uint16_t writeString(const char* string, uint8_t* buf, uint16_t pos); + IPAddress ip; + const char* domain; + uint16_t port; + Stream* stream; + int _state; + +#ifdef ESP8266 + const char* fingerprint; +#endif + +public: + PubSubClient(); + PubSubClient(Client& client); + PubSubClient(IPAddress, uint16_t, Client& client); + PubSubClient(IPAddress, uint16_t, Client& client, Stream&); + PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client); + PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&); + PubSubClient(uint8_t *, uint16_t, Client& client); + PubSubClient(uint8_t *, uint16_t, Client& client, Stream&); + PubSubClient(uint8_t *, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client); + PubSubClient(uint8_t *, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&); + PubSubClient(const char*, uint16_t, Client& client); + PubSubClient(const char*, uint16_t, Client& client, Stream&); + PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client); + PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&); + +#ifdef ESP8266 + PubSubClient(WiFiClientSecure& client, const char* fingerprint); +#endif + + PubSubClient& setServer(IPAddress ip, uint16_t port); + PubSubClient& setServer(uint8_t * ip, uint16_t port); + PubSubClient& setServer(const char * domain, uint16_t port); + PubSubClient& setCallback(MQTT_CALLBACK_SIGNATURE); + PubSubClient& setClient(Client& client); + PubSubClient& setStream(Stream& stream); + + boolean connect(const char* id); + boolean connect(const char* id, const char* user, const char* pass); + boolean connect(const char* id, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage); + boolean connect(const char* id, const char* user, const char* pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage); + void disconnect(); + boolean publish(const char* topic, const char* payload); + boolean publish(const char* topic, const char* payload, boolean retained); + boolean publish(const char* topic, const uint8_t * payload, unsigned int plength); + boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained); + boolean publish_P(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained); + boolean subscribe(const char* topic); + boolean subscribe(const char* topic, uint8_t qos); + boolean unsubscribe(const char* topic); + boolean loop(); + boolean connected(); + int state(); +}; + + +#endif