Merge branch 'development' into pre-release

This commit is contained in:
Theo Arends 2020-04-14 12:39:19 +02:00
commit 1c91a3a4f7
42 changed files with 1194 additions and 354 deletions

1
.gitignore vendored
View File

@ -24,3 +24,4 @@ platformio_override.ini
.vscode/c_cpp_properties.json
.vscode/launch.json
*.bak
*.code-workspace

View File

@ -117,6 +117,8 @@
| USE_AHT1x | - | - | - | - | - | - | - |
| USE_HDC1080 | - | - | - | - | - | - | - |
| USE_WEMOS_MOTOR_V1 | - | - | - | - | x | - | - |
| USE_IAQ | - | - | - | - | x | - | - |
| USE_AS3935 | - | - | - | - | x | - | - |
| | | | | | | | |
| Feature or Sensor | minimal | lite | tasmota | knx | sensors | ir | display | Remarks
| USE_SPI | - | - | - | - | - | - | x |

View File

@ -69,6 +69,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Add Zigbee command ``ZbConfig`` and configuration in Settings
- Add commands ``CounterDebounceLow`` and ``CounterDebounceHigh`` to control debouncing (#8021)
- Add commands ``NrfPage``, ``NrfIgnore``, ``NrfScan`` and ``NrfBeacon`` to NRF24 Bluetooth driver (#8075)
- Add commands ``GlobalTemp`` and ``GlobalHum`` to init sensor data (#8152)
- Add command ``SetOption41 <x>`` to force sending gratuitous ARP every <x> seconds
- Add command ``SetOption90 1`` to disable non-json MQTT messages (#8044)
- Add command ``SetOption91 1`` to enable fading at startup / power on
@ -78,6 +79,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Add command ``DevGroupName`` to specify up to four Device Group Names (#8087)
- Add command ``DevGroupSend`` to send an update to a Device Group (#8093)
- Add command ``Ping`` (#7176)
- Add command ``Palette`` to add the ability to specify a palette of colors (#8150)
- Add support for unreachable (unplugged) Zigbee devices in Philips Hue emulation and Alexa
- Add support for 64x48 SSD1306 OLED (#6740)
- Add support for Seven Segment display using HT16K33 (#8116)

View File

@ -87,7 +87,7 @@ bool NtpServer::processOneRequest(uint32_t utc, uint32_t millisecs)
packet.swapEndian();
timeServerPort_.beginPacket(timeServerPort_.remoteIP(), timeServerPort_.remotePort());
timeServerPort_.write(packet.packet(), NtpPacket::PACKET_SIZE);
timeServerPort_.write((const uint8_t *)packet.packet(), NtpPacket::PACKET_SIZE);
timeServerPort_.endPacket();
processed = true;

View File

@ -34,9 +34,9 @@ String ESP_getResetInfo(void)
return String(PSTR("0"));
}
String ESP_getBootVersion(void)
uint32_t ESP_getBootVersion(void)
{
return String(PSTR("Unknown"));
return 1;
}
bool ESP_rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size)
@ -59,15 +59,32 @@ uint32_t ESP_getFlashChipId()
return 0;
}
uint32_t ESP_getChipId()
{
uint32_t id = 0;
for (uint32_t i = 0; i < 17; i = i +8) {
id |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}
return id;
}
String String_ESP_getChipId()
{
uint64_t mac = ESP.getEfuseMac();
return String(uint32_t(mac >> 32)) + String(uint32_t(mac));
}
/*
uint64_t ESP_getChipId()
uint32_t ESP_getFlashChipRealSize()
{
return ESP.getEfuseMac();
return ESP.getFlashChipSize();
}
uint32_t ESP_getSketchSize(void)
{
static uint32_t sketchsize = 0;
if (!sketchsize) {
sketchsize = ESP.getSketchSize(); // This takes almost 2 seconds on an ESP32
}
return sketchsize;
}
*/

View File

@ -34,13 +34,16 @@
#define ESP_flashReadHeader(offset, data, size) ESP32_flashRead(offset, data, size)
#define ESP_flashRead(offset, data, size) ESP32_flashRead(offset, data, size)
String ESP_getResetReason(void);
String ESP_getBootVersion(void);
uint32_t ESP_getBootVersion(void);
bool ESP_rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size);
bool ESP_rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size);
void ESP_reset();
String ESP_getResetInfo(void);
uint32_t ESP_getFlashChipId();
uint32_t ESP_getChipId();
String String_ESP_getChipId();
uint32_t ESP_getFlashChipRealSize();
uint32_t ESP_getSketchSize();
// Analog
inline void analogWrite(uint8_t pin, int val)

View File

@ -1,109 +0,0 @@
;
; Example PlatformIO Project Configuration Override for ESP32 ***
; Changes done here override settings in platformio.ini ***
;
; to build Tasmota ESP32 copy to platformio_override.ini ***
;
; Please visit documentation for the options and examples
; http://docs.platformio.org/en/stable/projectconf.html
;
[platformio]
; *** Build/upload environment
;monitor_port = COM5
default_envs =
; *** Uncomment the line(s) below to select version(s)
tasmota
tasmota32
; tasmota32-minimal
; tasmota32-lite
; tasmota32-knx
; tasmota32-sensors
; tasmota32-display
; tasmota32-ir
; tasmota32-ircustom
; tasmota32-DE
; tasmota32-NL
[env32]
; uncomment this for all other tasmota32 builds
[env:tasmota32]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
; uncomment this for all other tasmota32 builds
;[env:tasmota32]
[env:tasmota32-minimal]
build_flags = ${common.build_flags} -DFIRMWARE_MINIMAL
[env:tasmota32-lite]
build_flags = ${common.build_flags} -DFIRMWARE_LITE
[env:tasmota32-knx]
build_flags = ${common.build_flags} -DFIRMWARE_KNX_NO_EMULATION
[env:tasmota32-sensors]
build_flags = ${common.build_flags} -DFIRMWARE_SENSORS
[env:tasmota32-display]
build_flags = ${common.build_flags} -DFIRMWARE_DISPLAYS
[env:tasmota32-ir]
build_flags = ${common.build_flags} ${irremoteesp8266_full.build_flags} -DFIRMWARE_IR
[env:tasmota32-ircustom]
build_flags = ${common.build_flags} ${irremoteesp8266_full.build_flags}
[env:tasmota32-DE]
build_flags = ${common.build_flags} -DMY_LANGUAGE=de-DE
[env:tasmota32-NL]
build_flags = ${common.build_flags} -DMY_LANGUAGE=nl-NL
[common32]
platform = espressif32@1.12.0
platform_packages =
board = wemos_d1_mini32
board_build.ldscript = esp32_out.ld
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_cpu = ${common.board_build.f_cpu}
build_unflags = ${common.build_unflags}
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
upload_speed = 921600
extra_scripts = ${common.extra_scripts}
build_flags =
-D BUFFER_LENGTH=128
-D MQTT_MAX_PACKET_SIZE=1200
-D uint32=uint32_t
-D uint16=uint16_t
-D uint8=uint8_t
-D sint8_t=int8_t
-D sint32_t=int32_t
-D sint16_t=int16_t
-D memcpy_P=memcpy
-D memcmp_P=memcmp
; -D USE_CONFIG_OVERRIDE
lib_extra_dirs =
libesp32
lib_ignore =
ESP MQTT
TasmotaMqtt
ILI9488
RA8876
SSD3115
cc1101
FrogmoreScd30
ArduinoNTPd

View File

@ -11,6 +11,7 @@
[platformio]
extra_configs = platformio_tasmota_env32.ini
; *** Build/upload environment
default_envs =
@ -24,6 +25,14 @@ default_envs =
; tasmota-sensors
; tasmota-display
; tasmota-ir
; tasmota32
; tasmota32-minimal
; tasmota32-lite
; tasmota32-knx
; tasmota32-sensors
; tasmota32-display
; tasmota32-ir
; tasmota32-ircustom
[common]
@ -33,15 +42,6 @@ build_flags = ${core_active.build_flags}
; *** Use settings from file user_config_override.h
-DUSE_CONFIG_OVERRIDE
; *** Optional Firmware configurations
; -DFIRMWARE_MINIMAL
; -DFIRMWARE_SENSORS
; -DFIRMWARE_LITE
; -DFIRMWARE_KNX_NO_EMULATION
; -DFIRMWARE_DISPLAYS
; -DFIRMWARE_IR
; -DFIRMWARE_IR_CUSTOM
; *** Optional Debug messages
; -DDEBUG_TASMOTA_CORE
; -DDEBUG_TASMOTA_DRIVER
@ -70,9 +70,6 @@ extra_scripts = ${scripts_defaults.extra_scripts}
[core_active]
; Select one core set for platform and build_flags
;platform = ${core_2_6_1.platform}
;platform_packages = ${core_2_6_1.platform_packages}
;build_flags = ${core_2_6_1.build_flags}
;platform = ${core_2_6_3.platform}
;platform_packages = ${core_2_6_3.platform_packages}
@ -87,51 +84,6 @@ build_flags = ${tasmota_feature_stage.build_flags}
;build_flags = ${core_stage.build_flags}
[core_2_6_1]
; *** Esp8266 core for Arduino version 2.6.1
platform = espressif8266@2.3.0
platform_packages =
build_flags = ${esp82xx_defaults.build_flags}
-Wl,-Teagle.flash.1m.ld
-DBEARSSL_SSL_BASIC
; NONOSDK221
; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK221
; NONOSDK22x_190313
; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_190313
; NONOSDK22x_190703 = 2.2.1+100-dev(38a443e) (Tasmota default) (Firmware 2K smaller than NONOSDK22x_191105)
-DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_190703
; NONOSDK22x_191024 = 2.2.1+111-dev(5ab15d1)
; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_191024
; NONOSDK22x_191105 = 2.2.1+113-dev(bb83b9b)
; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_191105
; NONOSDK3V0 (known issues)
; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3
; lwIP 1.4
; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
; lwIP 2 - Low Memory
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
; lwIP 2 - Higher Bandwidth
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
; lwIP 2 - Higher Bandwidth Low Memory no Features
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH
; lwIP 2 - Higher Bandwidth no Features (Tasmota default)
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
; lwIP 2 - Higher Bandwidth IPv6 (use ONLY if you need IPv6, experimental!)
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_HIGHER_BANDWIDTH
; VTABLES in Flash (Tasmota default)
-DVTABLES_IN_FLASH
; VTABLES in Heap
; -DVTABLES_IN_DRAM
; VTABLES in IRAM
; -DVTABLES_IN_IRAM
; enable one option set -> No exception recommended
; No exception code in firmware
-fno-exceptions
-lstdc++
; Exception code in firmware /needs much space! 90k
; -fexceptions
; -lstdc++-exc
[core_2_6_3]
; *** Esp8266 core for Arduino version 2.6.3
platform = espressif8266@2.4.0
@ -268,3 +220,42 @@ build_flags = ${esp82xx_defaults.build_flags}
; *** Debug version used for PlatformIO Home Project Inspection
[env:tasmota-debug]
build_type = debug
; *** Experimental ESP32 Tasmota version ***
; *** expect the unexpected. Many features not working!!! ***
[common32]
platform = espressif32@1.12.0
platform_packages =
board = wemos_d1_mini32
board_build.ldscript = esp32_out.ld
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_cpu = ${common.board_build.f_cpu}
build_unflags = ${common.build_unflags}
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
upload_speed = 921600
extra_scripts = ${common.extra_scripts}
build_flags =
-D BUFFER_LENGTH=128
-D MQTT_MAX_PACKET_SIZE=1200
-D uint32=uint32_t
-D uint16=uint16_t
-D uint8=uint8_t
-D sint8_t=int8_t
-D sint32_t=int32_t
-D sint16_t=int16_t
-D memcpy_P=memcpy
-D memcmp_P=memcmp
; -D USE_CONFIG_OVERRIDE
lib_extra_dirs =
libesp32
lib_ignore =
ILI9488
SSD3115
cc1101

View File

@ -0,0 +1,539 @@
[env:tasmota32]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags}
[env:tasmota32-minimal]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DFIRMWARE_MINIMAL
[env:tasmota32-lite]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DFIRMWARE_LITE
[env:tasmota32-knx]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DFIRMWARE_KNX_NO_EMULATION
[env:tasmota32-sensors]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DFIRMWARE_SENSORS
[env:tasmota32-display]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DFIRMWARE_DISPLAYS
[env:tasmota32-ir]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} ${irremoteesp8266_full.build_flags} -DFIRMWARE_IR
[env:tasmota32-ircustom]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} ${irremoteesp8266_full.build_flags}
[env:tasmota32-BG]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=bg-BG
[env:tasmota32-BR]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=pt-BR
[env:tasmota32-CN]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=zh-CN
[env:tasmota32-CZ]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=cs-CZ
[env:tasmota32-DE]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=de-DE
[env:tasmota32-ES]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=es-ES
[env:tasmota32-FR]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=fr-FR
[env:tasmota32-GR]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=el-GR
[env:tasmota32-HE]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=he-HE
[env:tasmota32-HU]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=hu-HU
[env:tasmota32-IT]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=it-IT
[env:tasmota32-KO]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=ko-KO
[env:tasmota32-NL]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=nl-NL
[env:tasmota32-PL]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=pl-PL
[env:tasmota32-PT]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=pt-PT
[env:tasmota32-RO]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=ro-RO
[env:tasmota32-RU]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=ru-RU
[env:tasmota32-SE]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=sv-SE
[env:tasmota32-SK]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=sk-SK
[env:tasmota32-TR]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=tr-TR
[env:tasmota32-TW]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=zh-TW
[env:tasmota32-UK]
framework = ${common.framework}
platform = ${common32.platform}
platform_packages = ${common32.platform_packages}
board = ${common32.board}
board_build.ldscript = ${common32.board_build.ldscript}
board_build.flash_mode = ${common32.board_build.flash_mode}
board_build.f_cpu = ${common32.board_build.f_cpu}
monitor_speed = ${common32.monitor_speed}
upload_port = ${common32.upload_port}
upload_resetmethod = ${common32.upload_resetmethod}
upload_speed = ${common32.upload_speed}
extra_scripts = ${common32.extra_scripts}
lib_extra_dirs = ${common32.lib_extra_dirs}
lib_ignore = ${common32.lib_ignore}
build_unflags = ${common32.build_unflags}
build_flags = ${common32.build_flags} -DMY_LANGUAGE=uk-UA

View File

@ -28,11 +28,16 @@
- Add command ``DevGroupName`` to specify up to four Device Group Names (#8087)
- Add command ``DevGroupSend`` to send an update to a Device Group (#8093)
- Add command ``Ping`` (#7176)
- Add command ``Palette`` to add the ability to specify a palette of colors (#8150)
- Add commands ``GlobalTemp`` and ``GlobalHum`` to init sensor data (#8152)
- Add quick wifi reconnect using saved AP parameters when ``SetOption56 0`` (#3189)
- Add more accuracy to GPS NTP server (#8088)
- Add support for an iAQ sensor (#8107)
- Add support for Seven Segment display using HT16K33 (#8116)
- Add support for AS3935 Lightning Sensor by device111 (#8130)
- Fix prevent multiple pings to run concurrently
- Fix Scheme 2-4 brightness when SetOption68 1 (#8058)
- Add ``DimmerRange`` for PWM lights (#8120)
### 8.2.0.2 20200328

View File

@ -22,7 +22,7 @@
#include "my_user_config.h"
//#ifdef USE_MQTT_TLS
#if defined(USE_MQTT_TLS) || defined (USE_SENDMAIL)
#if defined ESP8266 && (defined(USE_MQTT_TLS) || defined (USE_SENDMAIL))
//#define DEBUG_TLS

View File

@ -308,6 +308,8 @@
#define D_JSON_BASE "BASE"
#define D_CMND_TEMPOFFSET "TempOffset"
#define D_CMND_HUMOFFSET "HumOffset"
#define D_CMND_GLOBAL_TEMP "GlobalTemp"
#define D_CMND_GLOBAL_HUM "GlobalHum"
// Commands xdrv_01_mqtt.ino
#define D_CMND_MQTTLOG "MqttLog"
@ -389,6 +391,7 @@
#define D_CMND_LED "Led"
#define D_CMND_LEDTABLE "LedTable"
#define D_CMND_FADE "Fade"
#define D_CMND_PALETTE "Palette"
#define D_CMND_PIXELS "Pixels"
#define D_CMND_RGBWWTABLE "RGBWWTable"
#define D_CMND_ROTATION "Rotation"

View File

@ -70,6 +70,7 @@
#define WIFI_CONFIG_TOOL WIFI_RETRY // [WifiConfig] Default tool if wifi fails to connect (default option: 4 - WIFI_RETRY)
// (WIFI_RESTART, WIFI_MANAGER, WIFI_RETRY, WIFI_WAIT, WIFI_SERIAL, WIFI_MANAGER_RESET_ONLY)
// The configuration can be changed after first setup using WifiConfig 0, 2, 4, 5, 6 and 7.
#define WIFI_ARP_INTERVAL 0 // [SetOption41] Send gratuitous ARP interval
#define WIFI_SCAN_AT_RESTART false // [SetOption56] Scan wifi network at restart for configured AP's
#define WIFI_SCAN_REGULARLY false // [SetOption57] Scan wifi network every 44 minutes for configured AP's
@ -436,6 +437,7 @@
#define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code)
#define USE_SONOFF_L1 // Add support for Sonoff L1 led control
#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller (+0k3 code)
#define USE_LIGHT_PALETTE // Add support for color palette (+0k7 code)
// -- Counter input -------------------------------
#define USE_COUNTER // Enable inputs as counter (+0k8 code)

View File

@ -8,7 +8,11 @@
#include <base64.h>
//#include <core_version.h>
#ifdef ESP8266
#include "WiFiClientSecureLightBearSSL.h"
#else
#include <WiFiClientSecure.h>
#endif
class SendEmail
{
@ -20,12 +24,17 @@ class SendEmail
const int timeout;
const bool ssl;
const int auth_used;
#ifdef ESP8266
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
WiFiClient* client;
#else
// use bear ssl
BearSSL::WiFiClientSecure_light *client;
#endif
#else
WiFiClient *client;
#endif
String readClient();
void a3_to_a4(unsigned char * a4, unsigned char * a3);
int base64_encode(char *output, const char *input, int inputLen);

View File

@ -174,12 +174,17 @@ exit:
return status;
}
#ifdef ESP8266
void script_send_email_body(BearSSL::WiFiClientSecure_light *client);
SendEmail::SendEmail(const String& host, const int port, const String& user, const String& passwd, const int timeout, const int auth_used) :
host(host), port(port), user(user), passwd(passwd), timeout(timeout), ssl(ssl), auth_used(auth_used), client(new BearSSL::WiFiClientSecure_light(1024,1024)) {
}
#else
void script_send_email_body(WiFiClient *client);
SendEmail::SendEmail(const String& host, const int port, const String& user, const String& passwd, const int timeout, const int auth_used) :
host(host), port(port), user(user), passwd(passwd), timeout(timeout), ssl(ssl), auth_used(auth_used), client(new WiFiClientSecure()) {
}
#endif
String SendEmail::readClient() {
delay(0);

View File

@ -731,6 +731,7 @@ void SettingsDefaultSet2(void)
Settings.flag3.use_wifi_scan = WIFI_SCAN_AT_RESTART;
Settings.flag3.use_wifi_rescan = WIFI_SCAN_REGULARLY;
Settings.wifi_output_power = 170;
Settings.param[P_ARP_GRATUITOUS] = WIFI_ARP_INTERVAL;
ParseIp(&Settings.ip_address[0], WIFI_IP_ADDRESS);
ParseIp(&Settings.ip_address[1], WIFI_GATEWAY);
ParseIp(&Settings.ip_address[2], WIFI_SUBNETMASK);

View File

@ -562,6 +562,7 @@ char* GetPowerDevice(char* dest, uint32_t idx, size_t size)
void GetEspHardwareType(void)
{
#ifdef ESP8266
// esptool.py get_efuses
uint32_t efuse1 = *(uint32_t*)(0x3FF00050);
uint32_t efuse2 = *(uint32_t*)(0x3FF00054);
@ -572,16 +573,23 @@ void GetEspHardwareType(void)
if (is_8285 && (ESP.getFlashChipRealSize() > 1048576)) {
is_8285 = false; // ESP8285 can only have 1M flash
}
#else
is_8285 = false; // ESP8285 can only have 1M flash
#endif
}
String GetDeviceHardware(void)
{
char buff[10];
#ifdef ESP8266
if (is_8285) {
strcpy_P(buff, PSTR("ESP8285"));
} else {
strcpy_P(buff, PSTR("ESP8266EX"));
}
#else
strcpy_P(buff, PSTR("ESP32"));
#endif
return String(buff);
}
@ -1127,8 +1135,13 @@ void ModuleGpios(myio *gp)
uint32_t j = 0;
for (uint32_t i = 0; i < sizeof(mycfgio); i++) {
#ifdef ESP8266
if (6 == i) { j = 9; }
if (8 == i) { j = 12; }
#endif // ESP8266
#ifdef ESP32
if (6 == i) { j = 12; }
#endif // ESP32
dest[j] = src[i];
j++;
}
@ -1166,7 +1179,12 @@ void SetModuleType(void)
bool FlashPin(uint32_t pin)
{
#ifdef ESP8266
return (((pin > 5) && (pin < 9)) || (11 == pin));
#endif // ESP8266
#ifdef ESP32
return ((pin > 5) && (pin < 12));
#endif // ESP32
}
uint8_t ValidPin(uint32_t pin, uint32_t gpio)
@ -1175,12 +1193,14 @@ uint8_t ValidPin(uint32_t pin, uint32_t gpio)
return GPIO_NONE; // Disable flash pins GPIO6, GPIO7, GPIO8 and GPIO11
}
#ifdef ESP8266
// if (!is_8285 && !Settings.flag3.user_esp8285_enable) { // SetOption51 - Enable ESP8285 user GPIO's
if ((WEMOS == Settings.module) && !Settings.flag3.user_esp8285_enable) { // SetOption51 - Enable ESP8285 user GPIO's
if ((pin == 9) || (pin == 10)) {
return GPIO_NONE; // Disable possible flash GPIO9 and GPIO10
}
}
#endif // ESP8266
return gpio;
}
@ -1264,7 +1284,11 @@ bool JsonTemplate(const char* dataBuf)
if (strlen(dataBuf) < 9) { return false; } // Workaround exception if empty JSON like {} - Needs checks
#ifdef ESP8266
StaticJsonBuffer<400> jb; // 331 from https://arduinojson.org/v5/assistant/
#else
StaticJsonBuffer<800> jb; // 654 from https://arduinojson.org/v5/assistant/
#endif
JsonObject& obj = jb.parseObject(dataBuf);
if (!obj.success()) { return false; }

View File

@ -27,7 +27,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
D_CMND_SERIALDELIMITER "|" D_CMND_IPADDRESS "|" D_CMND_NTPSERVER "|" D_CMND_AP "|" D_CMND_SSID "|" D_CMND_PASSWORD "|" D_CMND_HOSTNAME "|" D_CMND_WIFICONFIG "|"
D_CMND_FRIENDLYNAME "|" D_CMND_SWITCHMODE "|" D_CMND_INTERLOCK "|" D_CMND_TELEPERIOD "|" D_CMND_RESET "|" D_CMND_TIME "|" D_CMND_TIMEZONE "|" D_CMND_TIMESTD "|"
D_CMND_TIMEDST "|" D_CMND_ALTITUDE "|" D_CMND_LEDPOWER "|" D_CMND_LEDSTATE "|" D_CMND_LEDMASK "|" D_CMND_WIFIPOWER "|" D_CMND_TEMPOFFSET "|" D_CMND_HUMOFFSET "|"
D_CMND_SPEEDUNIT "|"
D_CMND_SPEEDUNIT "|" D_CMND_GLOBAL_TEMP "|" D_CMND_GLOBAL_HUM "|"
#ifdef USE_I2C
D_CMND_I2CSCAN "|" D_CMND_I2CDRIVER "|"
#endif
@ -50,7 +50,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
&CmndSerialDelimiter, &CmndIpAddress, &CmndNtpServer, &CmndAp, &CmndSsid, &CmndPassword, &CmndHostname, &CmndWifiConfig,
&CmndFriendlyname, &CmndSwitchMode, &CmndInterlock, &CmndTeleperiod, &CmndReset, &CmndTime, &CmndTimezone, &CmndTimeStd,
&CmndTimeDst, &CmndAltitude, &CmndLedPower, &CmndLedState, &CmndLedMask, &CmndWifiPower, &CmndTempOffset, &CmndHumOffset,
&CmndSpeedUnit,
&CmndSpeedUnit, &CmndGlobalTemp, &CmndGlobalHum,
#ifdef USE_I2C
&CmndI2cScan, CmndI2cDriver,
#endif
@ -422,7 +422,7 @@ void CmndStatus(void)
if ((0 == payload) || (2 == payload)) {
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS2_FIRMWARE "\":{\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_BUILDDATETIME "\":\"%s\",\""
D_JSON_BOOTVERSION "\":%d,\"" D_JSON_COREVERSION "\":\"" ARDUINO_ESP8266_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\","
D_JSON_BOOTVERSION "\":%d,\"" D_JSON_COREVERSION "\":\"" ARDUINO_CORE_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\","
"\"Hardware\":\"%s\""
"%s}}"),
my_version, my_image, GetBuildDateAndTime().c_str(),
@ -447,8 +447,8 @@ void CmndStatus(void)
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS4_MEMORY "\":{\"" D_JSON_PROGRAMSIZE "\":%d,\"" D_JSON_FREEMEMORY "\":%d,\"" D_JSON_HEAPSIZE "\":%d,\""
D_JSON_PROGRAMFLASHSIZE "\":%d,\"" D_JSON_FLASHSIZE "\":%d,\"" D_JSON_FLASHCHIPID "\":\"%06X\",\"" D_JSON_FLASHMODE "\":%d,\""
D_JSON_FEATURES "\":[\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\"]"),
ESP.getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP.getFreeHeap()/1024,
ESP.getFlashChipSize()/1024, ESP.getFlashChipRealSize()/1024, ESP_getFlashChipId(), ESP.getFlashChipMode(),
ESP_getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP.getFreeHeap()/1024,
ESP.getFlashChipSize()/1024, ESP_getFlashChipRealSize()/1024, ESP_getFlashChipId(), ESP.getFlashChipMode(),
LANGUAGE_LCID, feature_drv1, feature_drv2, feature_sns1, feature_sns2, feature5, feature6);
XsnsDriverState();
ResponseAppend_P(PSTR(",\"Sensors\":"));
@ -576,6 +576,33 @@ void CmndHumOffset(void)
ResponseCmndFloat((float)(Settings.hum_comp) / 10, 1);
}
void CmndGlobalTemp(void)
{
if (XdrvMailbox.data_len > 0) {
float temperature = CharToFloat(XdrvMailbox.data);
if (!isnan(temperature) && Settings.flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit
temperature = (temperature - 32) / 1.8; // Celsius
}
if ((temperature >= -50.0) && (temperature <= 100.0)) {
ConvertTemp(temperature);
global_update = 1; // Keep global values just entered valid
}
}
ResponseCmndFloat(global_temperature, 1);
}
void CmndGlobalHum(void)
{
if (XdrvMailbox.data_len > 0) {
float humidity = CharToFloat(XdrvMailbox.data);
if ((humidity >= 0.0) && (humidity <= 100.0)) {
ConvertHumidity(humidity);
global_update = 1; // Keep global values just entered valid
}
}
ResponseCmndFloat(global_humidity, 1);
}
void CmndSleep(void)
{
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 251)) {
@ -1087,8 +1114,13 @@ void CmndTemplate(void)
SettingsUpdateText(SET_TEMPLATE_NAME, "Merged");
uint32_t j = 0;
for (uint32_t i = 0; i < sizeof(mycfgio); i++) {
#ifdef ESP8266
if (6 == i) { j = 9; }
if (8 == i) { j = 12; }
#endif // ESP8266
#ifdef ESP32
if (6 == i) { j = 12; }
#endif // ESP32
if (my_module.io[j] > GPIO_NONE) {
Settings.user_template.gp.io[i] = my_module.io[j];
}

View File

@ -37,6 +37,7 @@
\*********************************************************************************************/
#ifdef USE_FLOG
#ifdef ESP8266
class FLOG
@ -400,7 +401,7 @@ void FLOG::stopRecording(void){
if(k%128 == 0){ // give control to the system every x iteration, TODO: This will fail, when record/entry-size is not 8
// DEBUG_SENSOR_LOG(PSTR("FLOG: now loop(), %u bytes left"), Flog->bytes_left);
OsWatchLoop();
delay(sleep);
delay(ssleep);
}
k+=size;
if(bytes_left>7){
@ -419,7 +420,7 @@ void FLOG::stopRecording(void){
_readSector(next_sector);
bytes_left = sector.header.buf_pointer - sizeof(sector.header);
OsWatchLoop();
delay(sleep);
delay(ssleep);
}
running_download = false;
// Callback 3: create a footer or simply finish the download with an empty payload
@ -429,4 +430,5 @@ void FLOG::stopRecording(void){
_initBuffer();
}
#endif // ESP8266
#endif // USE_FLOG

View File

@ -367,7 +367,7 @@ void RtcSecond(void)
if ((Rtc.ntp_sync_minute > 59) && (uptime_minute > 2)) {
Rtc.ntp_sync_minute = 1; // If sync prepare for a new cycle
}
uint8_t offset = (uptime < 30) ? RtcTime.second : (((ESP.getChipId() & 0xF) * 3) + 3) ; // First try ASAP to sync. If fails try once every 60 seconds based on chip id
uint8_t offset = (uptime < 30) ? RtcTime.second : (((ESP_getChipId() & 0xF) * 3) + 3) ; // First try ASAP to sync. If fails try once every 60 seconds based on chip id
if ( (((offset == RtcTime.second) && ( (RtcTime.year < 2016) || // Never synced
(Rtc.ntp_sync_minute == uptime_minute))) || // Re-sync every hour
ntp_force_sync ) ) { // Forced sync

View File

@ -39,14 +39,14 @@ char* Format(char* output, const char* input, int size)
char tmp[size];
if (strchr(token, 'd')) {
snprintf_P(tmp, size, PSTR("%s%c0%dd"), output, '%', digits);
snprintf_P(output, size, tmp, ESP.getChipId() & 0x1fff); // %04d - short chip ID in dec, like in hostname
snprintf_P(output, size, tmp, ESP_getChipId() & 0x1fff); // %04d - short chip ID in dec, like in hostname
} else {
snprintf_P(tmp, size, PSTR("%s%c0%dX"), output, '%', digits);
snprintf_P(output, size, tmp, ESP.getChipId()); // %06X - full chip ID in hex
snprintf_P(output, size, tmp, ESP_getChipId()); // %06X - full chip ID in hex
}
} else {
if (strchr(token, 'd')) {
snprintf_P(output, size, PSTR("%s%d"), output, ESP.getChipId()); // %d - full chip ID in dec
snprintf_P(output, size, PSTR("%s%d"), output, ESP_getChipId()); // %d - full chip ID in dec
digits = 8;
}
}
@ -61,10 +61,10 @@ char* Format(char* output, const char* input, int size)
char* GetOtaUrl(char *otaurl, size_t otaurl_size)
{
if (strstr(SettingsText(SET_OTAURL), "%04d") != nullptr) { // OTA url contains placeholder for chip ID
snprintf(otaurl, otaurl_size, SettingsText(SET_OTAURL), ESP.getChipId() & 0x1fff);
snprintf(otaurl, otaurl_size, SettingsText(SET_OTAURL), ESP_getChipId() & 0x1fff);
}
else if (strstr(SettingsText(SET_OTAURL), "%d") != nullptr) { // OTA url contains placeholder for chip ID
snprintf_P(otaurl, otaurl_size, SettingsText(SET_OTAURL), ESP.getChipId());
snprintf_P(otaurl, otaurl_size, SettingsText(SET_OTAURL), ESP_getChipId());
}
else {
strlcpy(otaurl, SettingsText(SET_OTAURL), otaurl_size);
@ -824,6 +824,13 @@ void PerformEverySecond(void)
// Wifi keep alive to send Gratuitous ARP
wifiKeepAlive();
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
#ifdef ESP32
if (11 == uptime) { // Perform one-time ESP32 houskeeping
ESP_getSketchSize(); // Init sketchsize as it can take up to 2 seconds
}
#endif
}
/*-------------------------------------------------------------------------------------------*\

View File

@ -655,7 +655,7 @@ void WifiConnect(void)
WifiSetOutputPower();
WiFi.persistent(false); // Solve possible wifi init errors
Wifi.status = 0;
Wifi.retry_init = WIFI_RETRY_OFFSET_SEC + (ESP.getChipId() & 0xF); // Add extra delay to stop overrun by simultanous re-connects
Wifi.retry_init = WIFI_RETRY_OFFSET_SEC + (ESP_getChipId() & 0xF); // Add extra delay to stop overrun by simultanous re-connects
Wifi.retry = Wifi.retry_init;
Wifi.counter = 1;

View File

@ -41,14 +41,14 @@
* Power Type
\*********************************************************************************************/
#ifdef ESP8266
//#ifdef ESP8266
typedef unsigned long power_t; // Power (Relay) type
const uint32_t POWER_MASK = 0xffffffffUL; // Power (Relay) full mask
#endif // ESP8266
#ifdef ESP32
typedef uint64_t power_t; // Power (Relay) type
const uint64_t POWER_MASK = 0xffffffffffffffffull; // Power (Relay) full mask
#endif // ESP32
//#endif // ESP8266
//#ifdef ESP32
//typedef uint64_t power_t; // Power (Relay) type
//const uint64_t POWER_MASK = 0xffffffffffffffffull; // Power (Relay) full mask
//#endif // ESP32
/*********************************************************************************************\
* Constants

View File

@ -276,7 +276,7 @@ void setup(void)
Format(mqtt_topic, SettingsText(SET_MQTT_TOPIC), sizeof(mqtt_topic));
if (strstr(SettingsText(SET_HOSTNAME), "%") != nullptr) {
SettingsUpdateText(SET_HOSTNAME, WIFI_HOSTNAME);
snprintf_P(my_hostname, sizeof(my_hostname)-1, SettingsText(SET_HOSTNAME), mqtt_topic, ESP.getChipId() & 0x1FFF);
snprintf_P(my_hostname, sizeof(my_hostname)-1, SettingsText(SET_HOSTNAME), mqtt_topic, ESP_getChipId() & 0x1FFF);
} else {
snprintf_P(my_hostname, sizeof(my_hostname)-1, SettingsText(SET_HOSTNAME));
}
@ -290,7 +290,7 @@ void setup(void)
SetPowerOnState();
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_ESP8266_RELEASE), PROJECT, SettingsText(SET_FRIENDLYNAME1), my_version, my_image);
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_CORE_RELEASE), PROJECT, SettingsText(SET_FRIENDLYNAME1), my_version, my_image);
#ifdef FIRMWARE_MINIMAL
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION));
#endif // FIRMWARE_MINIMAL

View File

@ -6,7 +6,7 @@
// Modul
#undef MODULE
#define MODULE WEMOS // [Module] Select default model
#endif
#endif // ESP32
#ifdef ESP8266
// ESP8266
@ -17,6 +17,9 @@
#define ESP_reset() ESP.reset()
#define ESP_getBootVersion() ESP.getBootVersion()
#define ESP_getFlashChipId() ESP.getFlashChipId()
#define ESP_getFlashChipRealSize() ESP.getFlashChipRealSize()
#define ESP_getSketchSize() ESP.getSketchSize()
#define ESP_getChipId() ESP.getChipId()
//
// we need different ESP_flashRead for ESP32
//
@ -28,4 +31,4 @@
//
// Serial minimal type to hold the config
#define SerConfu8 uint8_t
#endif // ESP32
#endif // ESP8266

View File

@ -70,6 +70,7 @@
#define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code)
#define USE_SONOFF_L1 // Add support for Sonoff L1 led control
#define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller
#define USE_LIGHT_PALETTE // Add support for color palette (+0k9 code)
#define USE_COUNTER // Enable counters
#undef USE_ADC_VCC // Add Analog input on selected devices
@ -332,7 +333,8 @@
#undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code)
#undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code)
#undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control
#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller
#undef USE_ELECTRIQ_MOODL // Disable support for ElectriQ iQ-wifiMOODL RGBW LED controller
#undef USE_LIGHT_PALETTE // Disable support for color palette (+0k9 code)
#undef USE_ENERGY_SENSOR // Disable energy sensors (-14k code)
#undef USE_PZEM004T // Disable PZEM004T energy sensor
@ -444,7 +446,8 @@
#undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code)
#undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code)
#undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control
#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller
#undef USE_ELECTRIQ_MOODL // Disable support for ElectriQ iQ-wifiMOODL RGBW LED controller
#undef USE_LIGHT_PALETTE // Disable support for color palette (+0k9 code)
#undef USE_COUNTER // Disable counters
#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices
@ -563,7 +566,8 @@
#undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code)
#undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code)
#undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control
#undef USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller
#undef USE_ELECTRIQ_MOODL // Disable support for ElectriQ iQ-wifiMOODL RGBW LED controller
#undef USE_LIGHT_PALETTE // Disable support for color palette (+0k9 code)
#undef USE_COUNTER // Disable counters
#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices

View File

@ -117,8 +117,19 @@ extern "C" void resetPins();
#define MESSZ (MQTT_MAX_PACKET_SIZE -TOPSZ -7) // Max number of characters in JSON message string
#endif
#ifdef ESP8266
#ifndef ARDUINO_ESP8266_RELEASE
#define ARDUINO_ESP8266_RELEASE "STAGE"
#define ARDUINO_CORE_RELEASE "STAGE"
#else
#define ARDUINO_CORE_RELEASE ARDUINO_ESP8266_RELEASE
#endif
#endif
#ifdef ESP32
#ifndef ARDUINO_ESP32_RELEASE
#define ARDUINO_CORE_RELEASE "STAGE"
#else
#define ARDUINO_CORE_RELEASE ARDUINO_ESP32_RELEASE
#endif
#endif
#ifdef USE_PWM_DIMMER_REMOTE

View File

@ -703,6 +703,8 @@ const char kAdc0Names[] PROGMEM =
#define MAX_GPIO_PIN 17 // Number of supported GPIO
#define MIN_FLASH_PINS 4 // Number of flash chip pins unusable for configuration (GPIO6, 7, 8 and 11)
#define ADC0_PIN 17 // Pin number of ADC0
#define WEMOS_MODULE 17 // Wemos module
const char PINS_WEMOS[] PROGMEM = "D3TXD4RXD2D1flashcFLFLolD6D7D5D8D0A0";
@ -710,13 +712,17 @@ const char PINS_WEMOS[] PROGMEM = "D3TXD4RXD2D1flashcFLFLolD6D7D5D8D0A0";
// esp32 has more pins
#define USER_MODULE 255
#define MAX_GPIO_PIN 44 // Number of supported GPIO
#define MIN_FLASH_PINS 4 // Number of flash chip pins unusable for configuration (GPIO6, 7, 8 and 11)
#define MAX_GPIO_PIN 40 // Number of supported GPIO
#define MIN_FLASH_PINS 6 // Number of flash chip pins unusable for configuration (GPIO6, 7, 8, 9, 10 and 11)
#define ADC0_PIN 36 // Pin number of ADC0
#define WEMOS_MODULE 0 // Wemos module
const char PINS_WEMOS[] PROGMEM = "00010203040506070809101112131415161718192021222324252627282930313233343536373839";
const char PINS_WEMOS[] PROGMEM = "00TX02RX04050607080910111213141516171819202122232425262728293031A4A5A6A7A03738A3";
#endif // ESP8266
#define MAX_USER_PINS MAX_GPIO_PIN-MIN_FLASH_PINS
/********************************************************************************************/
typedef struct MYIO {

View File

@ -71,12 +71,12 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
GPIO_USER, //3 IO RXD0 GPIO3, U0RXD, CLK_OUT2
GPIO_USER, //4 IO GPIO4, ADC2_CH0, TOUCH0, RTC_GPIO10, HSPIHD, HS2_DATA1, SD_DATA1, EMAC_TX_ER
GPIO_USER, //5 IO GPIO5, VSPICS0, HS1_DATA6, EMAC_RX_CLK
0, //6
0, //7
0, //8
0, //9
0, //10
0, //11
// 0, //6
// 0, //7
// 0, //8
// 0, //9
// 0, //10
// 0, //11
GPIO_USER, //12 (I)O GPIO12, ADC2_CH5, TOUCH5, RTC_GPIO15, MTDI, HSPIQ, HS2_DATA2, SD_DATA2, EMAC_TXD3 (If driven High, flash voltage (VDD_SDIO) is 1.8V not default 3.3V. Has internal pull-down, so unconnected = Low = 3.3V. May prevent flashing and/or booting if 3.3V flash is connected and pulled high. See ESP32 datasheet for more details.)
GPIO_USER, //13 IO GPIO13, ADC2_CH4, TOUCH4, RTC_GPIO14, MTCK, HSPID, HS2_DATA3, SD_DATA3, EMAC_RX_ER
GPIO_USER, //14 IO GPIO14, ADC2_CH6, TOUCH6, RTC_GPIO16, MTMS, HSPICLK, HS2_CLK, SD_CLK, EMAC_TXD2
@ -113,12 +113,12 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
GPIO_USER, //3 IO RXD0 GPIO3, U0RXD, CLK_OUT2
GPIO_USER, //4 IO GPIO4, ADC2_CH0, TOUCH0, RTC_GPIO10, HSPIHD, HS2_DATA1, SD_DATA1, EMAC_TX_ER
GPIO_USER, //5 IO GPIO5, VSPICS0, HS1_DATA6, EMAC_RX_CLK
0, //6
0, //7
0, //8
0, //9
0, //10
0, //11
// 0, //6
// 0, //7
// 0, //8
// 0, //9
// 0, //10
// 0, //11
GPIO_USER, //12 (I)O GPIO12, ADC2_CH5, TOUCH5, RTC_GPIO15, MTDI, HSPIQ, HS2_DATA2, SD_DATA2, EMAC_TXD3 (If driven High, flash voltage (VDD_SDIO) is 1.8V not default 3.3V. Has internal pull-down, so unconnected = Low = 3.3V. May prevent flashing and/or booting if 3.3V flash is connected and pulled high. See ESP32 datasheet for more details.)
GPIO_USER, //13 IO GPIO13, ADC2_CH4, TOUCH4, RTC_GPIO14, MTCK, HSPID, HS2_DATA3, SD_DATA3, EMAC_RX_ER
GPIO_USER, //14 IO GPIO14, ADC2_CH6, TOUCH6, RTC_GPIO16, MTMS, HSPICLK, HS2_CLK, SD_CLK, EMAC_TXD2

View File

@ -261,15 +261,22 @@ const char HTTP_SCRIPT_TEMPLATE[] PROGMEM =
"as=o.shift();" // Complete ADC0 list
"g=o.shift().split(',');" // Array separator
"j=0;"
"for(i=0;i<13;i++){" // Supports 13 GPIOs
// "for(i=0;i<13;i++){" // Supports 13 GPIOs
"for(i=0;i<" STR(MAX_USER_PINS) ";i++){" // Supports 13 GPIOs
#ifdef ESP8266
"if(6==i){j=9;}"
"if(8==i){j=12;}"
#endif
#ifdef ESP32
"if(6==i){j=12;}"
#endif
"sk(g[i],j);" // Set GPIO
"j++;"
"}"
"g=o.shift();" // FLAG
"os=as;"
"sk(g&15,17);" // Set ADC0
// "sk(g&15,17);" // Set ADC0
"sk(g&15," STR(ADC0_PIN) ");" // Set ADC0
"g>>=4;"
"for(i=0;i<" STR(GPIO_FLAG_USED) ";i++){"
"p=(g>>i)&1;"
@ -288,7 +295,8 @@ const char HTTP_SCRIPT_TEMPLATE[] PROGMEM =
"function x2(a){"
"os=a.responseText;"
"sk(17,99);" // 17 = WEMOS
// "sk(17,99);" // 17 = WEMOS
"sk(" STR(WEMOS_MODULE) ",99);" // 17 = WEMOS
"st(" STR(USER_MODULE) ");"
"}"
@ -313,12 +321,14 @@ const char HTTP_SCRIPT_MODULE2[] PROGMEM =
"}"
"function x3(a){" // ADC0
"os=a.responseText;"
"sk(%d,17);"
// "sk(%d,17);"
"sk(%d," STR(ADC0_PIN) ");"
"}"
"function sl(){"
"ld('md?m=1',x1);" // ?m related to WebServer->hasArg("m")
"ld('md?g=1',x2);" // ?g related to WebServer->hasArg("g")
"if(eb('g17')){"
// "if(eb('g17')){"
"if(eb('g" STR(ADC0_PIN) "')){"
"ld('md?a=1',x3);" // ?a related to WebServer->hasArg("a")
"}"
"}"
@ -1467,7 +1477,8 @@ void HandleTemplateConfiguration(void)
WSContentSend_P(PSTR("}1")); // Field separator
for (uint32_t i = 0; i < sizeof(cmodule); i++) { // 17,148,29,149,7,255,255,255,138,255,139,255,255
if ((i < 6) || ((i > 8) && (i != 11))) { // Ignore flash pins GPIO06, 7, 8 and 11
// if ((i < 6) || ((i > 8) && (i != 11))) { // Ignore flash pins GPIO06, 7, 8 and 11
if (!FlashPin(i)) {
WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", cmodule.io[i]);
}
}
@ -1489,13 +1500,16 @@ void HandleTemplateConfiguration(void)
"</table>"
"<hr/>"));
WSContentSend_P(HTTP_TABLE100);
for (uint32_t i = 0; i < 17; i++) {
if ((i < 6) || ((i > 8) && (i != 11))) { // Ignore flash pins GPIO06, 7, 8 and 11
for (uint32_t i = 0; i < MAX_GPIO_PIN; i++) {
// if ((i < 6) || ((i > 8) && (i != 11))) { // Ignore flash pins GPIO06, 7, 8 and 11
if (!FlashPin(i)) {
WSContentSend_P(PSTR("<tr><td><b><font color='#%06x'>" D_GPIO "%d</font></b></td><td%s><select id='g%d'></select></td></tr>"),
((9==i)||(10==i)) ? WebColor(COL_TEXT_WARNING) : WebColor(COL_TEXT), i, (0==i) ? " style='width:200px'" : "", i);
}
}
#ifdef ESP8266
WSContentSend_P(PSTR("<tr><td><b><font color='#%06x'>" D_ADC "0</font></b></td><td><select id='g17'></select></td></tr>"), WebColor(COL_TEXT));
#endif
WSContentSend_P(PSTR("</table>"));
gpio_flag flag = ModuleFlag();
if (flag.data > ADC0_USER) {
@ -1510,15 +1524,20 @@ void TemplateSaveSettings(void)
{
char tmp[TOPSZ]; // WebGetArg NAME and GPIO/BASE/FLAG byte value
char webindex[5]; // WebGetArg name
char svalue[200]; // Template command string
char svalue[300]; // Template command string
WebGetArg("s1", tmp, sizeof(tmp)); // NAME
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_TEMPLATE " {\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), tmp);
uint32_t j = 0;
for (uint32_t i = 0; i < sizeof(Settings.user_template.gp); i++) {
#ifdef ESP8266
if (6 == i) { j = 9; }
if (8 == i) { j = 12; }
#endif // ESP8266
#ifdef ESP32
if (6 == i) { j = 12; }
#endif // ESP32
snprintf_P(webindex, sizeof(webindex), PSTR("g%d"), j);
WebGetArg(webindex, tmp, sizeof(tmp)); // GPIO
uint8_t gpio = atoi(tmp);
@ -1526,7 +1545,8 @@ void TemplateSaveSettings(void)
j++;
}
WebGetArg("g17", tmp, sizeof(tmp)); // FLAG - ADC0
// WebGetArg("g17", tmp, sizeof(tmp)); // FLAG - ADC0
WebGetArg("g" STR(ADC0_PIN), tmp, sizeof(tmp)); // FLAG - ADC0
uint32_t flag = atoi(tmp);
for (uint32_t i = 0; i < GPIO_FLAG_USED; i++) {
snprintf_P(webindex, sizeof(webindex), PSTR("c%d"), i);
@ -1656,7 +1676,8 @@ void ModuleSaveSettings(void)
}
}
#ifndef USE_ADC_VCC
WebGetArg("g17", tmp, sizeof(tmp));
// WebGetArg("g17", tmp, sizeof(tmp));
WebGetArg("g" STR(ADC0_PIN), tmp, sizeof(tmp));
Settings.my_adc0 = (!strlen(tmp)) ? 0 : atoi(tmp);
gpios += F(", " D_ADC "0 "); gpios += String(Settings.my_adc0);
#endif // USE_ADC_VCC
@ -2099,7 +2120,7 @@ void HandleInformation(void)
WSContentSend_P(PSTR("<table style='width:100%%'><tr><th>"));
WSContentSend_P(PSTR(D_PROGRAM_VERSION "}2%s%s"), my_version, my_image);
WSContentSend_P(PSTR("}1" D_BUILD_DATE_AND_TIME "}2%s"), GetBuildDateAndTime().c_str());
WSContentSend_P(PSTR("}1" D_CORE_AND_SDK_VERSION "}2" ARDUINO_ESP8266_RELEASE "/%s"), ESP.getSdkVersion());
WSContentSend_P(PSTR("}1" D_CORE_AND_SDK_VERSION "}2" ARDUINO_CORE_RELEASE "/%s"), ESP.getSdkVersion());
WSContentSend_P(PSTR("}1" D_UPTIME "}2%s"), GetUptime().c_str());
WSContentSend_P(PSTR("}1" D_FLASH_WRITE_COUNT "}2%d at 0x%X"), Settings.save_flag, GetSettingsAddress());
WSContentSend_P(PSTR("}1" D_BOOT_COUNT "}2%d"), Settings.bootcount);
@ -2174,11 +2195,11 @@ void HandleInformation(void)
#endif // USE_DISCOVERY
WSContentSend_P(PSTR("}1}2&nbsp;")); // Empty line
WSContentSend_P(PSTR("}1" D_ESP_CHIP_ID "}2%d"), ESP.getChipId());
WSContentSend_P(PSTR("}1" D_ESP_CHIP_ID "}2%d"), ESP_getChipId());
WSContentSend_P(PSTR("}1" D_FLASH_CHIP_ID "}20x%06X"), ESP_getFlashChipId());
WSContentSend_P(PSTR("}1" D_FLASH_CHIP_SIZE "}2%dkB"), ESP.getFlashChipRealSize() / 1024);
WSContentSend_P(PSTR("}1" D_FLASH_CHIP_SIZE "}2%dkB"), ESP_getFlashChipRealSize() / 1024);
WSContentSend_P(PSTR("}1" D_PROGRAM_FLASH_SIZE "}2%dkB"), ESP.getFlashChipSize() / 1024);
WSContentSend_P(PSTR("}1" D_PROGRAM_SIZE "}2%dkB"), ESP.getSketchSize() / 1024);
WSContentSend_P(PSTR("}1" D_PROGRAM_SIZE "}2%dkB"), ESP_getSketchSize() / 1024);
WSContentSend_P(PSTR("}1" D_FREE_PROGRAM_SPACE "}2%dkB"), ESP.getFreeSketchSpace() / 1024);
WSContentSend_P(PSTR("}1" D_FREE_MEMORY "}2%dkB"), freeMem / 1024);
WSContentSend_P(PSTR("</td></tr></table>"));

View File

@ -374,7 +374,7 @@ void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic, bool retain
MqttPublish(stopic, retained);
#ifdef USE_MQTT_AWS_IOT
if ((prefix > 0) && (Settings.flag4.awsiot_shadow)) { // placeholder for SetOptionXX
if ((prefix > 0) && (Settings.flag4.awsiot_shadow) && (Mqtt.connected)) { // placeholder for SetOptionXX
// compute the target topic
char *topic = SettingsText(SET_MQTT_TOPIC);
char topic2[strlen(topic)+1]; // save buffer onto stack

View File

@ -131,12 +131,20 @@ const uint8_t LIGHT_COLOR_SIZE = 25; // Char array scolor size
const char kLightCommands[] PROGMEM = "|" // No prefix
D_CMND_COLOR "|" D_CMND_COLORTEMPERATURE "|" D_CMND_DIMMER "|" D_CMND_DIMMER_RANGE "|" D_CMND_LEDTABLE "|" D_CMND_FADE "|"
D_CMND_RGBWWTABLE "|" D_CMND_SCHEME "|" D_CMND_SPEED "|" D_CMND_WAKEUP "|" D_CMND_WAKEUPDURATION "|"
D_CMND_WHITE "|" D_CMND_CHANNEL "|" D_CMND_HSBCOLOR "|UNDOCA" ;
D_CMND_WHITE "|" D_CMND_CHANNEL "|" D_CMND_HSBCOLOR
#ifdef USE_LIGHT_PALETTE
"|" D_CMND_PALETTE
#endif // USE_LIGHT_PALETTE
"|UNDOCA" ;
void (* const LightCommand[])(void) PROGMEM = {
&CmndColor, &CmndColorTemperature, &CmndDimmer, &CmndDimmerRange, &CmndLedTable, &CmndFade,
&CmndRgbwwTable, &CmndScheme, &CmndSpeed, &CmndWakeup, &CmndWakeupDuration,
&CmndWhite, &CmndChannel, &CmndHsbColor, &CmndUndocA };
&CmndWhite, &CmndChannel, &CmndHsbColor,
#ifdef USE_LIGHT_PALETTE
&CmndPalette,
#endif // USE_LIGHT_PALETTE
&CmndUndocA };
// Light color mode, either RGB alone, or white-CT alone, or both only available if ct_rgb_linked is false
enum LightColorModes {
@ -276,11 +284,18 @@ struct LIGHT {
#ifdef USE_DEVICE_GROUPS
bool devgrp_no_channels_out = false; // don't share channels with device group (e.g. if scheme set by other device)
#endif // USE_DEVICE_GROUPS
#ifdef USE_LIGHT_PALETTE
uint8_t palette_count = 0; // palette entry count
uint8_t * palette; // dynamically allocated palette color array
#endif // USE_LIGHT_PALETTE
uint16_t fade_start_10[LST_MAX] = {0,0,0,0,0};
uint16_t fade_cur_10[LST_MAX];
uint16_t fade_end_10[LST_MAX]; // 10 bits resolution target channel values
uint16_t fade_duration = 0; // duration of fade in milliseconds
uint32_t fade_start = 0; // fade start time in milliseconds, compared to millis()
uint16_t pwm_min = 0; // minimum value for PWM, from DimmerRange, 0..1023
uint16_t pwm_max = 1023; // maxumum value for PWM, from DimmerRange, 0..1023
} Light;
power_t LightPower(void)
@ -1258,6 +1273,25 @@ bool LightModuleInit(void)
return (light_type > LT_BASIC);
}
// compute actual PWM min/max values from DimmerRange
// must be called when DimmerRange is changed or LedTable
void LightCalcPWMRange(void) {
uint16_t pwm_min, pwm_max;
pwm_min = change8to10(LightStateClass::DimmerToBri(Settings.dimmer_hw_min)); // default 0
pwm_max = change8to10(LightStateClass::DimmerToBri(Settings.dimmer_hw_max)); // default 100
if (Settings.light_correction) {
pwm_min = ledGamma10_10(pwm_min); // apply gamma correction
pwm_max = ledGamma10_10(pwm_max); // 0..1023
}
pwm_min = pwm_min > 0 ? changeUIntScale(pwm_min, 1, 1023, 1, Settings.pwm_range) : 0; // adapt range but keep zero and non-zero values
pwm_max = changeUIntScale(pwm_max, 1, 1023, 1, Settings.pwm_range); // pwm_max cannot be zero
Light.pwm_min = pwm_min;
Light.pwm_max = pwm_max;
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("LightCalcPWMRange %d %d - %d %d"), Settings.dimmer_hw_min, Settings.dimmer_hw_max, Light.pwm_min, Light.pwm_max);
}
void LightInit(void)
{
Light.device = devices_present;
@ -1279,6 +1313,7 @@ void LightInit(void)
// if RGBW or RGBCW, and SetOption37 >= 128, we manage RGB and W separately
Light.device--; // we take the last two devices as lights
}
LightCalcPWMRange();
#ifdef DEBUG_LIGHT
AddLog_P2(LOG_LEVEL_DEBUG_MORE, "LightInit Light.pwm_multi_channels=%d Light.subtype=%d Light.device=%d devices_present=%d",
Light.pwm_multi_channels, Light.subtype, Light.device, devices_present);
@ -1287,6 +1322,7 @@ void LightInit(void)
light_controller.setSubType(Light.subtype);
light_controller.loadSettings();
light_controller.setAlexaCTRange(Settings.flag4.alexa_ct_range);
light_controller.calcLevels(); // calculate the initial values (#8058)
if (LST_SINGLE == Light.subtype) {
Settings.light_color[0] = 255; // One channel only supports Dimmer but needs max color
@ -1453,7 +1489,9 @@ void LightSetSignal(uint16_t lo, uint16_t hi, uint16_t value)
// convert channels to string, use Option 17 to foce decimal, unless force_hex
char* LightGetColor(char* scolor, boolean force_hex = false)
{
light_controller.calcLevels();
if ((0 == Settings.light_scheme) || (!Light.pwm_multi_channels)) {
light_controller.calcLevels(); // recalculate levels only if Scheme 0, otherwise we mess up levels
}
scolor[0] = '\0';
for (uint32_t i = 0; i < Light.subtype; i++) {
if (!force_hex && Settings.flag.decimal_text) { // SetOption17 - Switch between decimal or hexadecimal output
@ -1625,6 +1663,22 @@ void LightPreparePower(power_t channels = 0xFFFFFFFF) { // 1 = only RGB, 2 =
LightState(0);
}
#ifdef USE_LIGHT_PALETTE
void LightSetPaletteEntry(void)
{
uint8_t bri = light_state.getBri();
uint8_t * palette_entry = &Light.palette[Light.wheel * LST_MAX];
for (int i = 0; i < LST_MAX; i++) {
Light.new_color[i] = changeUIntScale(palette_entry[i], 0, 255, 0, bri);
}
light_state.setChannelsRaw(Light.new_color);
if (!Light.pwm_multi_channels) {
light_state.setCW(Light.new_color[3], Light.new_color[4], true);
if (Light.new_color[0] || Light.new_color[1] || Light.new_color[2]) light_state.addRGBMode();
}
}
#endif // USE_LIGHT_PALETTE
void LightCycleColor(int8_t direction)
{
// if (Light.strip_timer_counter % (Settings.light_speed * 2)) { return; } // Speed 1: 24sec, 2: 48sec, 3: 72sec, etc
@ -1632,6 +1686,23 @@ void LightCycleColor(int8_t direction)
if (Light.strip_timer_counter % (Settings.light_speed - 2)) { return; } // Speed 4: 24sec, 5: 36sec, 6: 48sec, etc
}
#ifdef USE_LIGHT_PALETTE
if (Light.palette_count) {
if (0 == direction) {
Light.wheel = random(Light.palette_count);
}
else {
Light.wheel += direction;
if (Light.wheel >= Light.palette_count) {
Light.wheel = 0;
if (direction < 0) Light.wheel = Light.palette_count - 1;
}
}
LightSetPaletteEntry();
return;
}
#endif // USE_LIGHT_PALETTE
if (0 == direction) {
if (Light.random == Light.wheel) {
Light.random = random(255);
@ -1654,9 +1725,14 @@ void LightCycleColor(int8_t direction)
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("LGT: random %d, wheel %d, hue %d"), Light.random, Light.wheel, hue);
if (!Light.pwm_multi_channels) {
uint8_t sat;
light_state.getHSB(nullptr, &sat, nullptr); // Allow user control over Saturation
light_state.setHS(hue, sat);
} else {
light_state.setHS(hue, 255);
light_state.setBri(255); // If multi-channel, force bri to max, it will be later dimmed to correct value
}
light_controller.calcLevels(Light.new_color);
}
@ -1764,13 +1840,20 @@ void LightAnimate(void)
}
break;
case LS_CYCLEUP:
LightCycleColor(1);
break;
case LS_CYCLEDN:
LightCycleColor(-1);
break;
case LS_RANDOM:
LightCycleColor(0);
if (LS_CYCLEUP == Settings.light_scheme) {
LightCycleColor(1);
} else if (LS_CYCLEDN == Settings.light_scheme) {
LightCycleColor(-1);
} else {
LightCycleColor(0);
}
if (Light.pwm_multi_channels) { // See #8058
Light.new_color[0] = changeUIntScale(Light.new_color[0], 0, 255, 0, Settings.light_color[0]);
Light.new_color[1] = changeUIntScale(Light.new_color[1], 0, 255, 0, Settings.light_color[1]);
Light.new_color[2] = changeUIntScale(Light.new_color[2], 0, 255, 0, Settings.light_color[2]);
}
break;
default:
XlgtCall(FUNC_SET_SCHEME);
@ -1845,13 +1928,9 @@ void LightAnimate(void)
}
// final adjusments for PMW, post-gamma correction
uint16_t min = 1;
#ifdef USE_PWM_DIMMER
if (PWM_DIMMER == my_module_type) min = Settings.dimmer_hw_min;
#endif // USE_PWM_DIMMER
for (uint32_t i = 0; i < LST_MAX; i++) {
// scale from 0..1023 to 0..pwm_range, but keep any non-zero value to at least 1
cur_col_10[i] = (cur_col_10[i] > 0) ? changeUIntScale(cur_col_10[i], 1, 1023, min, Settings.pwm_range) : 0;
cur_col_10[i] = (cur_col_10[i] > 0) ? changeUIntScale(cur_col_10[i], 1, 1023, 1, Settings.pwm_range) : 0;
}
// apply port remapping on both 8 bits and 10 bits versions
@ -2026,7 +2105,9 @@ void LightSetOutputs(const uint16_t *cur_col_10) {
for (uint32_t i = 0; i < (Light.subtype - Light.pwm_offset); i++) {
if (pin[GPIO_PWM1 +i] < 99) {
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d 10 bits %d"), i, cur_col_10[i]);
analogWrite(pin[GPIO_PWM1 +i], bitRead(pwm_inverted, i) ? Settings.pwm_range - cur_col_10[(i + Light.pwm_offset)] : cur_col_10[(i + Light.pwm_offset)]);
uint16_t cur_col = cur_col_10[i + Light.pwm_offset];
cur_col = cur_col > 0 ? changeUIntScale(cur_col, 0, Settings.pwm_range, Light.pwm_min, Light.pwm_max) : 0; // shrink to the range of pwm_min..pwm_max
analogWrite(pin[GPIO_PWM1 +i], bitRead(pwm_inverted, i) ? Settings.pwm_range - cur_col : cur_col);
}
}
}
@ -2187,6 +2268,15 @@ void LightHandleDevGroupItem(void)
break;
case DGR_ITEM_LIGHT_FIXED_COLOR:
if (Light.subtype >= LST_RGBW) {
send_state = true;
#ifdef USE_LIGHT_PALETTE
if (Light.palette_count) {
Light.wheel = value % Light.palette_count;
LightSetPaletteEntry();
break;
}
#endif // !USE_LIGHT_PALETTE
value = value % MAX_FIXED_COLOR;
if (value) {
bool save_decimal_text = Settings.flag.decimal_text;
char str[16];
@ -2206,7 +2296,6 @@ void LightHandleDevGroupItem(void)
Light.power = 0xff;
restore_power = true;
}
send_state = true;
}
break;
case DGR_ITEM_LIGHT_FADE:
@ -2252,6 +2341,9 @@ bool LightColorEntry(char *buffer, uint32_t buffer_length)
char *str;
uint32_t entry_type = 0; // Invalid
uint8_t value = Light.fixed_color_index;
#ifdef USE_LIGHT_PALETTE
if (Light.palette_count) value = Light.wheel;
#endif // USE_LIGHT_PALETTE
if (buffer[0] == '#') { // Optional hexadecimal entry
buffer++;
@ -2260,14 +2352,32 @@ bool LightColorEntry(char *buffer, uint32_t buffer_length)
if (Light.subtype >= LST_RGB) {
char option = (1 == buffer_length) ? buffer[0] : '\0';
if (('+' == option) && (Light.fixed_color_index < MAX_FIXED_COLOR)) {
value++;
if ('+' == option) {
#ifdef USE_LIGHT_PALETTE
if (Light.palette_count || Light.fixed_color_index < MAX_FIXED_COLOR) {
#else // USE_LIGHT_PALETTE
if (Light.fixed_color_index < MAX_FIXED_COLOR) {
#endif // !USE_LIGHT_PALETTE
value++;
}
}
else if (('-' == option) && (Light.fixed_color_index > 1)) {
value--;
else if ('-' == option) {
#ifdef USE_LIGHT_PALETTE
if (Light.palette_count || Light.fixed_color_index > 1) {
#else // USE_LIGHT_PALETTE
if (Light.fixed_color_index > 1) {
#endif // !USE_LIGHT_PALETTE
value--;
}
} else {
value = atoi(buffer);
#ifdef USE_LIGHT_PALETTE
value--;
#endif // USE_LIGHT_PALETTE
}
#ifdef USE_LIGHT_PALETTE
if (Light.palette_count) value = value % Light.palette_count;
#endif // USE_LIGHT_PALETTE
}
memset(&Light.entry_color, 0x00, sizeof(Light.entry_color));
@ -2292,6 +2402,13 @@ bool LightColorEntry(char *buffer, uint32_t buffer_length)
}
entry_type = 1; // Hexadecimal
}
#ifdef USE_LIGHT_PALETTE
else if (Light.palette_count) {
Light.wheel = value;
memcpy_P(&Light.entry_color, &Light.palette[value * LST_MAX], LST_MAX);
entry_type = 1; // Hexadecimal
}
#endif // USE_LIGHT_PALETTE
else if ((Light.subtype >= LST_RGB) && (value > 0) && (value <= MAX_FIXED_COLOR)) {
Light.fixed_color_index = value;
memcpy_P(&Light.entry_color, &kFixedColor[value -1], 3);
@ -2328,14 +2445,22 @@ void CmndSupportColor(void)
valid_entry = LightColorEntry(XdrvMailbox.data, XdrvMailbox.data_len);
if (valid_entry) {
if (XdrvMailbox.index <= 2) { // Color(1), 2
uint32_t old_bri = light_state.getBri();
// change all channels to specified values
light_controller.changeChannels(Light.entry_color);
if (2 == XdrvMailbox.index) {
// If Color2, set back old brightness
light_controller.changeBri(old_bri);
#ifdef USE_LIGHT_PALETTE
if (Light.palette_count && XdrvMailbox.index == 2) {
LightSetPaletteEntry();
}
else {
#endif // USE_LIGHT_PALETTE
uint32_t old_bri = light_state.getBri();
// change all channels to specified values
light_controller.changeChannels(Light.entry_color);
if (2 == XdrvMailbox.index) {
// If Color2, set back old brightness
light_controller.changeBri(old_bri);
}
#ifdef USE_LIGHT_PALETTE
}
#endif // USE_LIGHT_PALETTE
Settings.light_scheme = 0;
#ifdef USE_DEVICE_GROUPS
LightUpdateScheme();
@ -2504,6 +2629,9 @@ void CmndScheme(void)
uint32_t parm[2];
if (ParseParameters(2, parm) > 1) {
Light.wheel = parm[1];
#ifdef USE_LIGHT_PALETTE
Light.wheel--;
#endif // USE_LIGHT_PALETTE
}
Settings.light_scheme = XdrvMailbox.payload;
#ifdef USE_DEVICE_GROUPS
@ -2641,9 +2769,8 @@ void CmndDimmerRange(void)
Settings.dimmer_hw_min = parm[1];
Settings.dimmer_hw_max = parm[0];
}
#ifdef ESP8266
if (PWM_DIMMER != my_module_type) restart_flag = 2;
#endif // ESP8266
LightCalcPWMRange();
Light.update = true;
}
Response_P(PSTR("{\"" D_CMND_DIMMER_RANGE "\":{\"Min\":%d,\"Max\":%d}}"), Settings.dimmer_hw_min, Settings.dimmer_hw_max);
}
@ -2664,6 +2791,7 @@ void CmndLedTable(void)
Settings.light_correction ^= 1;
break;
}
LightCalcPWMRange();
Light.update = true;
}
ResponseCmndStateText(Settings.light_correction);
@ -2747,6 +2875,67 @@ void CmndWakeupDuration(void)
ResponseCmndNumber(Settings.light_wakeup);
}
#ifdef USE_LIGHT_PALETTE
void CmndPalette(void)
{
uint8_t * palette_entry;
char * p;
// Palette Color[ ...]
if (XdrvMailbox.data_len) {
Light.wheel = 0;
Light.palette_count = 0;
if (Light.palette) {
free(Light.palette);
Light.palette = nullptr;
}
if (XdrvMailbox.data_len > 1 || XdrvMailbox.data[0] != '0') {
uint8_t palette_count = 0;
char * color = XdrvMailbox.data;
if (!(Light.palette = (uint8_t *)malloc(255 * Light.subtype))) return;
palette_entry = Light.palette;
for (;;) {
p = strchr(color, ' ');
if (p) *p = 0;
color = Trim(color);
if (*color && LightColorEntry(color, strlen(color))) {
memcpy(palette_entry, Light.entry_color, Light.subtype);
palette_entry += Light.subtype;
palette_count++;
}
if (!p) break;
color = p + 1;
}
if (!(Light.palette = (uint8_t *)realloc(Light.palette, palette_count * Light.subtype))) return;
Light.palette_count = palette_count;
}
}
char palette_str[5 * Light.subtype * Light.palette_count + 3];
p = palette_str;
*p++ = '[';
if (Light.palette_count) {
palette_entry = Light.palette;
for (int entry = 0; entry < Light.palette_count; entry++) {
if (Settings.flag.decimal_text) { // SetOption17 - Switch between decimal or hexadecimal output
*p++ = '"';
}
memcpy(Light.current_color, palette_entry, Light.subtype);
LightGetColor(p);
p += strlen(p);
if (Settings.flag.decimal_text) { // SetOption17 - Switch between decimal or hexadecimal output
*p++ = '"';
}
*p++ = ',';
}
p--;
}
*p++ = ']';
*p = 0;
ResponseCmndChar(palette_str);
}
#endif // USE_LIGHT_PALETTE
void CmndUndocA(void)
{
// Theos legacy status

View File

@ -476,6 +476,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
RulesVarReplace(commands, stemp, SettingsText(SET_MEM1 +i));
}
RulesVarReplace(commands, F("%TIME%"), String(MinutesPastMidnight()));
RulesVarReplace(commands, F("%UTCTIME%"), String(UtcTime()));
RulesVarReplace(commands, F("%UPTIME%"), String(MinutesUptime()));
RulesVarReplace(commands, F("%TIMESTAMP%"), GetDateAndTime(DT_LOCAL));
RulesVarReplace(commands, F("%TOPIC%"), SettingsText(SET_MQTT_TOPIC));

View File

@ -65,6 +65,31 @@ keywords if then else endif, or, and are better readable for beginners (others m
uint32_t EncodeLightId(uint8_t relay_id);
uint32_t DecodeLightId(uint32_t hue_id);
#ifdef ESP32
#include "FS.h"
#include "SPIFFS.h"
void SaveFile(char *name,const uint8_t *buf,uint32_t len) {
File file = SPIFFS.open(name, FILE_WRITE);
if (!file) return;
file.write(buf, len);
file.close();
}
#define FORMAT_SPIFFS_IF_FAILED true
void LoadFile(char *name,uint8_t *buf,uint32_t len) {
if(!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)){
return;
}
File file = SPIFFS.open(name);
if (!file) return;
file.read(buf, len);
file.close();
}
#endif
// offsets epoch readings by 1.1.2019 00:00:00 to fit into float with second resolution
#define EPOCH_OFFSET 1546300800
@ -3597,6 +3622,15 @@ void ScriptSaveSettings(void) {
}
#endif
#ifndef ESP32_SCRIPT_SIZE
#define ESP32_SCRIPT_SIZE 8192
#endif
#if defined(ESP32) && !defined(USE_24C256) && !defined(USE_SCRIPT_FATFS)
if (glob_script_mem.flags&1) {
SaveFile("/script.txt",(uint8_t*)glob_script_mem.script_ram,ESP32_SCRIPT_SIZE);
}
#endif
}
if (glob_script_mem.script_mem) {
@ -4720,7 +4754,13 @@ void ScriptWebShow(void) {
#ifdef USE_SENDMAIL
#ifdef ESP8266
void script_send_email_body(BearSSL::WiFiClientSecure_light *client) {
#else
void script_send_email_body(WiFiClient *client) {
#endif
uint8_t msect=Run_Scripter(">m",-2,0);
if (msect==99) {
char line[128];
@ -4814,6 +4854,7 @@ bool Xdrv10(uint8_t function)
switch (function) {
case FUNC_PRE_INIT:
//webcam_setup();
// set defaults to rules memory
glob_script_mem.script_ram=Settings.rules[0];
glob_script_mem.script_size=MAX_SCRIPT_SIZE;
@ -4883,6 +4924,21 @@ bool Xdrv10(uint8_t function)
}
#endif
#if defined(ESP32) && !defined(USE_24C256) && !defined(USE_SCRIPT_FATFS)
char *script;
script=(char*)calloc(ESP32_SCRIPT_SIZE+4,1);
if (!script) break;
LoadFile("/script.txt",(uint8_t*)script,ESP32_SCRIPT_SIZE);
glob_script_mem.script_ram=script;
glob_script_mem.script_size=ESP32_SCRIPT_SIZE;
script[ESP32_SCRIPT_SIZE-1]=0;
// use rules storage for permanent vars
glob_script_mem.script_pram=(uint8_t*)Settings.rules[0];
glob_script_mem.script_pram_size=MAX_SCRIPT_SIZE;
glob_script_mem.flags=1;
#endif
// assure permanent memory is 4 byte aligned
{ uint32_t ptr=(uint32_t)glob_script_mem.script_pram;
ptr&=0xfffffffc;

View File

@ -180,12 +180,12 @@ void HAssAnnounceRelayLight(void)
mqtt_data[0] = '\0'; // Clear retained message
// Clear "other" topic first in case the device has been reconfigured from light to switch or vice versa
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d"), ESP.getChipId(), (is_topic_light) ? "RL" : "LI", i);
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d"), ESP_getChipId(), (is_topic_light) ? "RL" : "LI", i);
snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/%s/%s/config"),
(is_topic_light) ? "switch" : "light", unique_id);
MqttPublish(stopic, true);
// Clear or Set topic
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d"), ESP.getChipId(), (is_topic_light) ? "LI" : "RL", i);
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d"), ESP_getChipId(), (is_topic_light) ? "LI" : "RL", i);
snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/%s/%s/config"),
(is_topic_light) ? "light" : "switch", unique_id);
@ -210,7 +210,7 @@ void HAssAnnounceRelayLight(void)
Response_P(HASS_DISCOVER_BASE, name, state_topic, availability_topic);
TryResponseAppend_P(HASS_DISCOVER_RELAY, command_topic, value_template, SettingsText(SET_STATE_TXT1), SettingsText(SET_STATE_TXT2));
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP.getChipId());
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId());
#ifdef USE_LIGHT
if (is_light
@ -270,7 +270,7 @@ void HAssAnnouncerTriggers(uint8_t device, uint8_t present, uint8_t key, uint8_t
mqtt_data[0] = '\0'; // Clear retained message
for (uint8_t i = 2; i <= 3; i++) {
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d_%s"), ESP.getChipId(), key ? "SW" : "BTN", device + 1, GetStateText(i));
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d_%s"), ESP_getChipId(), key ? "SW" : "BTN", device + 1, GetStateText(i));
snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/device_automation/%s/config"), unique_id);
if (Settings.flag.hass_discovery && present) { // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59)
@ -294,7 +294,7 @@ void HAssAnnouncerTriggers(uint8_t device, uint8_t present, uint8_t key, uint8_t
if (i == 3) { pload = hold; }
GetTextIndexed(param, sizeof(param), pload, kHAssTriggerType);
snprintf_P(subtype, sizeof(subtype), PSTR("%s_%d"), key ? "switch" : "button", device + 1);
Response_P(HASS_TRIGGER_TYPE, state_topic, GetStateText(i), param, subtype, ESP.getChipId());
Response_P(HASS_TRIGGER_TYPE, state_topic, GetStateText(i), param, subtype, ESP_getChipId());
} else { mqtt_data[0] = '\0'; } // Need to be cleaned again to avoid duplicate.
}
MqttPublish(stopic, true);
@ -310,7 +310,7 @@ void HAssAnnouncerBinSensors(uint8_t device, uint8_t present, uint8_t dual, uint
mqtt_data[0] = '\0'; // Clear retained message
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_SW_%d"), ESP.getChipId(), device + 1);
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_SW_%d"), ESP_getChipId(), device + 1);
snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/binary_sensor/%s/config"), unique_id);
@ -335,7 +335,7 @@ void HAssAnnouncerBinSensors(uint8_t device, uint8_t present, uint8_t dual, uint
} else {
TryResponseAppend_P(HASS_DISCOVER_BIN_PIR, PSTR(D_RSLT_STATE), SettingsText(SET_STATE_TXT2));
}
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP.getChipId());
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId());
TryResponseAppend_P(PSTR("}"));
}
}
@ -491,7 +491,7 @@ void HAssAnnounceSensor(const char *sensorname, const char *subsensortype, const
// Clear or Set topic
NoAlNumToUnderscore(subname, MultiSubName); //Replace all non alphaumeric characters to '_' to avoid topic name issues
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%s"), ESP.getChipId(), sensorname, subname);
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%s"), ESP_getChipId(), sensorname, subname);
snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/sensor/%s/config"), unique_id);
if (Settings.flag.hass_discovery)
@ -506,7 +506,7 @@ void HAssAnnounceSensor(const char *sensorname, const char *subsensortype, const
GetTopic_P(availability_topic, TELE, mqtt_topic, S_LWT);
Response_P(HASS_DISCOVER_BASE, name, state_topic, availability_topic);
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP.getChipId());
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId());
char jname[32];
@ -632,7 +632,7 @@ void HAssAnnounceStatusSensor(void)
mqtt_data[0] = '\0'; // Clear retained message
// Clear or Set topic
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_status"), ESP.getChipId());
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_status"), ESP_getChipId());
snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/sensor/%s/config"), unique_id);
if (Settings.flag.hass_discovery)
@ -648,7 +648,7 @@ void HAssAnnounceStatusSensor(void)
Response_P(HASS_DISCOVER_BASE, name, state_topic, availability_topic);
TryResponseAppend_P(HASS_DISCOVER_SENSOR_HASS_STATUS, state_topic);
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO, unique_id, ESP.getChipId(), SettingsText(SET_FRIENDLYNAME1),
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO, unique_id, ESP_getChipId(), SettingsText(SET_FRIENDLYNAME1),
ModuleName().c_str(), my_version, my_image);
TryResponseAppend_P(PSTR("}"));
}
@ -658,7 +658,7 @@ void HAssAnnounceStatusSensor(void)
void HAssPublishStatus(void)
{
Response_P(PSTR("{\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_BUILDDATETIME "\":\"%s\","
"\"" D_JSON_COREVERSION "\":\"" ARDUINO_ESP8266_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\","
"\"" D_JSON_COREVERSION "\":\"" ARDUINO_CORE_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\","
"\"" D_CMND_MODULE "\":\"%s\",\"" D_JSON_RESTARTREASON "\":\"%s\",\"" D_JSON_UPTIME "\":\"%s\","
"\"WiFi " D_JSON_LINK_COUNT "\":%d,\"WiFi " D_JSON_DOWNTIME "\":\"%s\",\"" D_JSON_MQTT_COUNT "\":%d,"
"\"" D_JSON_BOOTCOUNT "\":%d,\"" D_JSON_SAVECOUNT "\":%d,\"" D_CMND_IPADDRESS "\":\"%s\","

View File

@ -192,7 +192,7 @@ String GetHueUserId(void)
{
char userid[7];
snprintf_P(userid, sizeof(userid), PSTR("%03x"), ESP.getChipId());
snprintf_P(userid, sizeof(userid), PSTR("%03x"), ESP_getChipId());
return String(userid);
}
@ -786,7 +786,7 @@ void HueGroups(String *path)
String response = "{}";
uint8_t maxhue = (devices_present > MAX_HUE_DEVICES) ? MAX_HUE_DEVICES : devices_present;
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " HueGroups (%s)"), path->c_str());
if (path->endsWith("/0")) {
response = FPSTR(HUE_GROUP0_STATUS_JSON);
String lights = F("\"1\"");
@ -795,7 +795,7 @@ void HueGroups(String *path)
lights += EncodeLightId(i);
lights += "\"";
}
#ifdef USE_ZIGBEE
ZigbeeHueGroups(&response);
#endif // USE_ZIGBEE

View File

@ -42,7 +42,7 @@ String WemoSerialnumber(void)
{
char serial[16];
snprintf_P(serial, sizeof(serial), PSTR("201612K%08X"), ESP.getChipId());
snprintf_P(serial, sizeof(serial), PSTR("201612K%08X"), ESP_getChipId());
return String(serial);
}

View File

@ -400,18 +400,10 @@ void PWMDimmerHandleButton(void)
else
#endif // USE_PWM_DIMMER_REMOTE
uint8_value = Light.fixed_color_index;
if (is_down_button) {
if (uint8_value)
uint8_value--;
else
uint8_value = MAX_FIXED_COLOR;
}
else {
if (uint8_value < MAX_FIXED_COLOR)
uint8_value++;
else
uint8_value = 0;
}
if (is_down_button)
uint8_value--;
else
uint8_value++;
#ifdef USE_PWM_DIMMER_REMOTE
if (!active_device_is_local)
active_remote_pwm_dimmer->fixed_color_index = uint8_value;

View File

@ -22,7 +22,6 @@
#define XDRV_38 38
#include <ping.h>
#include <vector>
const char kPingCommands[] PROGMEM = "|" // no prefix
D_CMND_PING
@ -35,80 +34,77 @@ void (* const PingCommand[])(void) PROGMEM = {
// inspired by https://github.com/dancol90/ESP8266Ping
typedef struct Ping_t {
ping_option opt; // extend the ping_option structure with internal values
uint16_t total_count; // total count if packets sent
uint16_t timeout_count; // time-outs (no responses)
uint32_t min_time; // minimum time in ms for a successful response
uint32_t max_time; // maximum time in ms for a successful response
uint32_t sum_time; // cumulated time in ms for all successful responses (used to compute the average)
bool busy; // is ping on-going
bool done; // indicates the ping campaign is finished
} Ping_t;
std::vector<Ping_t*> pings = {};
ping_option ping_opt;
Ping_t ping;
extern "C" {
// callbacks for ping
// called after a ping response is received or time-out
void ICACHE_RAM_ATTR ping_recv_cb(Ping_t *ping, struct ping_resp *p_resp) {
void ICACHE_RAM_ATTR ping_recv_cb(ping_option *popt, struct ping_resp *p_resp) {
// If successful
if (p_resp->ping_err >= 0) {
uint32_t resp_time = p_resp->resp_time;
ping->sum_time += resp_time;
if (resp_time < ping->min_time) { ping->min_time = resp_time; }
if (resp_time > ping->max_time) { ping->max_time = resp_time; }
ping.sum_time += resp_time;
if (resp_time < ping.min_time) { ping.min_time = resp_time; }
if (resp_time > ping.max_time) { ping.max_time = resp_time; }
}
}
// called after the ping campaign is finished
void ICACHE_RAM_ATTR ping_sent_cb(Ping_t *ping, struct ping_resp *p_resp) {
void ICACHE_RAM_ATTR ping_sent_cb(ping_option *popt, struct ping_resp *p_resp) {
// copy counters to build the MQTT response
ping->total_count = p_resp->total_count;
ping->timeout_count = p_resp->timeout_count;
ping->done = true;
ping.total_count = p_resp->total_count;
ping.timeout_count = p_resp->timeout_count;
ping.done = true;
}
}
// Check if any ping requests is completed, and publish the results
void PingResponsePoll(void) {
for (auto it = pings.begin(); it != pings.end(); it++) {
Ping_t *ping = *it;
if (ping->done) {
uint32_t success = ping->total_count - ping->timeout_count;
uint32_t ip = ping->opt.ip;
if (ping.done) {
uint32_t success = ping.total_count - ping.timeout_count;
uint32_t ip = ping_opt.ip;
// Serial.printf(
// "DEBUG ping_sent_cb: ping reply\n"
// "\tsuccess_count = %d \n"
// "\ttimeout_count = %d \n"
// "\tmin_time = %d \n"
// "\tmax_time = %d \n"
// "\tavg_time = %d \n",
// success, ping->timeout_count,
// ping->min_time, ping->max_time,
// success ? ping->sum_time / success : 0
// );
// Serial.printf(
// "DEBUG ping_sent_cb: ping reply\n"
// "\tsuccess_count = %d \n"
// "\ttimeout_count = %d \n"
// "\tmin_time = %d \n"
// "\tmax_time = %d \n"
// "\tavg_time = %d \n",
// success, ping.timeout_count,
// ping.min_time, ping.max_time,
// success ? ping.sum_time / success : 0
// );
Response_P(PSTR("{\"" D_JSON_PING "\":{\"%d.%d.%d.%d\":{"
"\"Reachable\":%s"
",\"Success\":%d"
",\"Timeout\":%d"
",\"MinTime\":%d"
",\"MaxTime\":%d"
",\"AvgTime\":%d"
"}}}"),
ip & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, ip >> 24,
success ? "true" : "false",
success, ping->timeout_count,
ping->min_time, ping->max_time,
success ? ping->sum_time / success : 0
);
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_PING));
XdrvRulesProcess();
pings.erase(it--); // remove from list
delete ping; // free memory allocated
}
Response_P(PSTR("{\"" D_JSON_PING "\":{\"%d.%d.%d.%d\":{"
"\"Reachable\":%s"
",\"Success\":%d"
",\"Timeout\":%d"
",\"MinTime\":%d"
",\"MaxTime\":%d"
",\"AvgTime\":%d"
"}}}"),
ip & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, ip >> 24,
success ? "true" : "false",
success, ping.timeout_count,
ping.min_time, ping.max_time,
success ? ping.sum_time / success : 0
);
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_PING));
XdrvRulesProcess();
ping.done = false;
ping.busy = false;
}
}
@ -117,28 +113,32 @@ void CmndPing(void) {
IPAddress ip;
RemoveSpace(XdrvMailbox.data);
if (count > 60) { count = 60; }
if (count > 8) { count = 8; }
if (ping.busy) {
ResponseCmndChar_P(PSTR("Ping busy"));
return;
}
if (WiFi.hostByName(XdrvMailbox.data, ip)) {
Ping_t *ping = new Ping_t();
memset(ping, 0, sizeof(Ping_t ));
ping->min_time = UINT32_MAX;
memset(&ping_opt, 0, sizeof(ping_opt));
memset(&ping, 0, sizeof(ping));
ping.min_time = UINT32_MAX;
ping_option &opt = ping->opt;
opt.count = count;
opt.coarse_time = 1; // wait 1 second between messages
opt.ip = ip;
ping_opt.count = count;
ping_opt.coarse_time = 1; // wait 1 second between messages
ping_opt.ip = ip;
// callbacks
opt.recv_function = (ping_recv_function) ping_recv_cb; // at each response or time-out
opt.sent_function = (ping_sent_function) ping_sent_cb; // when all packets have been sent and reveived
ping_opt.recv_function = (ping_recv_function) ping_recv_cb; // at each response or time-out
ping_opt.sent_function = (ping_sent_function) ping_sent_cb; // when all packets have been sent and reveived
if (ping_start(&opt)) {
pings.push_back(ping);
ping.busy = true;
if (ping_start(&ping_opt)) {
ResponseCmndDone();
} else {
ResponseCmndChar_P(PSTR("Unable to send Ping"));
delete ping;
ping.busy = false;
}
} else {
ResponseCmndChar_P(PSTR("Unable to resolve IP address"));

View File

@ -56,6 +56,7 @@
#define APDS9960_CHIPID_1 0xAB
#define APDS9960_CHIPID_2 0x9C
#define APDS9960_CHIPID_3 0xA8
#define APDS9930_CHIPID_1 0x12 // we will check, if someone got an incorrect sensor
#define APDS9930_CHIPID_2 0x39 // there are case reports about "accidentially bought" 9930's
@ -1884,7 +1885,7 @@ void APDS9960_detect(void)
if (APDS9960type || I2cActive(APDS9960_I2C_ADDR)) { return; }
APDS9960type = I2cRead8(APDS9960_I2C_ADDR, APDS9960_ID);
if (APDS9960type == APDS9960_CHIPID_1 || APDS9960type == APDS9960_CHIPID_2) {
if (APDS9960type == APDS9960_CHIPID_1 || APDS9960type == APDS9960_CHIPID_2 || APDS9960type == APDS9960_CHIPID_3) {
if (APDS9960_init()) {
I2cSetActiveFound(APDS9960_I2C_ADDR, APDS9960stype);

View File

@ -18,6 +18,10 @@
*/
#ifdef USE_GPS
#if defined(ESP32) && defined(USE_FLOG)
#undef USE_FLOG
#warning FLOG deactivated on ESP32
#endif //ESP32
/*********************************************************************************************\
--------------------------------------------------------------------------------------------
Version Date Action Description
@ -115,6 +119,10 @@ rule3 on tele-FLOG#sec do DisplayText [f0c1l4]SAV:%value% endon on tele-FLOG#r
#include "NTPServer.h"
#include "NTPPacket.h"
#ifdef ESP32
#include <HardwareSerial.h>
#endif
/*********************************************************************************************\
* constants
\*********************************************************************************************/
@ -291,7 +299,11 @@ enum UBXMsgType {
#ifdef USE_FLOG
FLOG *Flog = nullptr;
#endif //USE_FLOG
#ifdef ESP8266
TasmotaSerial *UBXSerial;
#else
HardwareSerial *UBXSerial;
#endif
NtpServer timeServer(PortUdp);
@ -351,13 +363,21 @@ void UBXDetect(void)
{
UBX.mode.init = 0;
if ((pin[GPIO_GPS_RX] < 99) && (pin[GPIO_GPS_TX] < 99)) {
#ifdef ESP8266
UBXSerial = new TasmotaSerial(pin[GPIO_GPS_RX], pin[GPIO_GPS_TX], 1, 0, UBX_SERIAL_BUFFER_SIZE); // 64 byte buffer is NOT enough
if (UBXSerial->begin(9600)) {
#else
UBXSerial = new HardwareSerial(2);
UBXSerial->begin(9600,SERIAL_8N1,pin[GPIO_GPS_RX], pin[GPIO_GPS_TX]);
{
#endif
DEBUG_SENSOR_LOG(PSTR("UBX: started serial"));
#ifdef ESP8266
if (UBXSerial->hardwareSerial()) {
ClaimSerial();
DEBUG_SENSOR_LOG(PSTR("UBX: claim HW"));
}
#endif
}
}
else {