diff --git a/dist/Release_notes.txt b/dist/Release_notes.txt index 92bbfd118..94f29ea10 100644 --- a/dist/Release_notes.txt +++ b/dist/Release_notes.txt @@ -1,3 +1,32 @@ +------------------------------------------------- +Changes in release mega-20240414 (since mega-20240401) +------------------------------------------------- + +Release date: Sun Apr 14 03:08:46 PM CEST 2024 + +TD-er (16): + [HWCDC] Revert to older ESP-IDF/Arduino build + [Time] Fix updating %sunrise% and %sunset% when no NTP available + [HWCDC] Fix bootloop on ESP32-C3/C6 + [HWCDC] Cleanup unused test code + [ESP-IDF5.1] Move to newly network refactored code + [ESP-IDF5.x] Fix build issue + [ESP-IDF5.x] Fix building ESP32-solo1 builds + [Ethernet[ Fix crashes when using Ethernet + IPv6 on LittleFS builds + [Ethernet] Fix getting DNS from DHCP switch from WiFi to Ethernet + [ESP-IDF5.x] Fix LittleFS builds without Ethernet + [IMPROV] Fix provisioning WiFi via web flasher + [ESP-IDF5.1] Update to latest 2024.04.11 platform build + [SPI ETH] Fix SPI selection to actual SPI bus for Ethernet + [SPI Eth] Fix build on ESP32-C3 + [HWCDC] Tweak HWCDC to be more stable + [Build] Revert unintended change of default PIO env. + +Ton Huisman (2): + [Dist] Update Espressif Flash Download tool 3.9.6 + [JSON] Add extra data in `/json` output + + ------------------------------------------------- Changes in release mega-20240401 (since mega-20240331) ------------------------------------------------- diff --git a/dist/flash_download_tool_3.9.5/doc/Flash_Download_Tool__cn.pdf b/dist/flash_download_tool_3.9.5/doc/Flash_Download_Tool__cn.pdf deleted file mode 100644 index a8a19d798..000000000 Binary files a/dist/flash_download_tool_3.9.5/doc/Flash_Download_Tool__cn.pdf and /dev/null differ diff --git a/dist/flash_download_tool_3.9.6/configure/esp32/multi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32/multi_download.conf new file mode 100644 index 000000000..264959675 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32/multi_download.conf @@ -0,0 +1,161 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = ./bin/ + +[LOCK] +lock_setting_password = + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 +autostart2 = 0 +com_port2 = +baudrate2 = 0 +checkmac2 = 1 +autostart3 = 0 +com_port3 = +baudrate3 = 0 +checkmac3 = 1 +autostart4 = 0 +com_port4 = +baudrate4 = 0 +checkmac4 = 1 +autostart5 = 0 +com_port5 = +baudrate5 = 0 +checkmac5 = 1 +autostart6 = 0 +com_port6 = +baudrate6 = 0 +checkmac6 = 1 +autostart7 = 0 +com_port7 = +baudrate7 = 0 +checkmac7 = 1 +autostart8 = 0 +com_port8 = +baudrate8 = 0 +checkmac8 = 1 +autostart9 = 0 +com_port9 = +baudrate9 = 0 +checkmac9 = 1 +autostart10 = 0 +com_port10 = +baudrate10 = 0 +checkmac10 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + +[STATISTICS] +pass1 = 0 +fail1 = 0 +pass2 = 0 +fail2 = 0 +pass3 = 0 +fail3 = 0 +pass4 = 0 +fail4 = 0 +pass5 = 0 +fail5 = 0 +pass6 = 0 +fail6 = 0 +pass7 = 0 +fail7 = 0 +pass8 = 0 +fail8 = 0 +pass9 = 0 +fail9 = 0 +pass10 = 0 +fail10 = 0 + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32/security.conf b/dist/flash_download_tool_3.9.6/configure/esp32/security.conf new file mode 100644 index 000000000..95bb20a11 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32/security.conf @@ -0,0 +1,25 @@ +[SECURE BOOT] +secure_boot_en = False +secure_boot_version = 1 +public_key_digest_path = .\secure\public_key_digest.bin + +[FLASH ENCRYPTION] +flash_encryption_en = False +reserved_burn_times = 0 + +[SECURE OTHER CONFIG] +flash_encryption_use_customer_key_enable = False +flash_encryption_use_customer_key_path = .\secure\flash_encrypt_key.bin +flash_force_write_enable = False + +[FLASH ENCRYPTION KEYS LOCAL SAVE] +keys_save_enable = False +encrypt_keys_enable = False +encrypt_keys_aeskey_path = + +[ESP32 EFUSE BIT CONFIG] +jtag_disable = False +dl_encrypt_disable = False +dl_decrypt_disable = False +dl_cache_disable = False + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32/spi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32/spi_download.conf new file mode 100644 index 000000000..ebc596813 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32/spi_download.conf @@ -0,0 +1,100 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = D:\DOWNLOAD_TOOL\ÏÂÔØ¹¤¾ß\release\3.9.6 + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32/utility.conf b/dist/flash_download_tool_3.9.6/configure/esp32/utility.conf new file mode 100644 index 000000000..8f8e1facf --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32/utility.conf @@ -0,0 +1,16 @@ +[LOG_LEVEL] +utility_log_level = ERROR +spi_log_level = ERROR +multi_log_level = ERROR + +[MAC_SAVE] +mac_save_enable = False + +[SECTOR_PROTECT] +sector_protect_enable = False +sector_protect_start = 0xe000 +sector_protect_end = 0x3000 + +[ESP32_EFUSE_CONFIG] +config_voltage = OFF + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c2/multi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32c2/multi_download.conf new file mode 100644 index 000000000..264959675 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c2/multi_download.conf @@ -0,0 +1,161 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = ./bin/ + +[LOCK] +lock_setting_password = + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 +autostart2 = 0 +com_port2 = +baudrate2 = 0 +checkmac2 = 1 +autostart3 = 0 +com_port3 = +baudrate3 = 0 +checkmac3 = 1 +autostart4 = 0 +com_port4 = +baudrate4 = 0 +checkmac4 = 1 +autostart5 = 0 +com_port5 = +baudrate5 = 0 +checkmac5 = 1 +autostart6 = 0 +com_port6 = +baudrate6 = 0 +checkmac6 = 1 +autostart7 = 0 +com_port7 = +baudrate7 = 0 +checkmac7 = 1 +autostart8 = 0 +com_port8 = +baudrate8 = 0 +checkmac8 = 1 +autostart9 = 0 +com_port9 = +baudrate9 = 0 +checkmac9 = 1 +autostart10 = 0 +com_port10 = +baudrate10 = 0 +checkmac10 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + +[STATISTICS] +pass1 = 0 +fail1 = 0 +pass2 = 0 +fail2 = 0 +pass3 = 0 +fail3 = 0 +pass4 = 0 +fail4 = 0 +pass5 = 0 +fail5 = 0 +pass6 = 0 +fail6 = 0 +pass7 = 0 +fail7 = 0 +pass8 = 0 +fail8 = 0 +pass9 = 0 +fail9 = 0 +pass10 = 0 +fail10 = 0 + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c2/security.conf b/dist/flash_download_tool_3.9.6/configure/esp32c2/security.conf new file mode 100644 index 000000000..fd93e1068 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c2/security.conf @@ -0,0 +1,25 @@ +[SECURE BOOT] +secure_boot_en = False +public_key_digest_path = .\secure\public_key_digest.bin +public_key_digest_block_index = 0 + +[FLASH ENCRYPTION] +flash_encryption_en = False +reserved_burn_times = 0 +flash_encrypt_key_block_index = 0 + +[SECURE OTHER CONFIG] +flash_encryption_use_customer_key_enable = False +flash_encryption_use_customer_key_path = .\secure\flash_encrypt_key.bin +flash_force_write_enable = False + +[FLASH ENCRYPTION KEYS LOCAL SAVE] +keys_save_enable = False +encrypt_keys_enable = False +encrypt_keys_aeskey_path = + +[ESP32C* EFUSE BIT CONFIG] +dis_pad_jtag = False +dis_direct_boot = False +dis_download_icache = False + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c2/spi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32c2/spi_download.conf new file mode 100644 index 000000000..ebc596813 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c2/spi_download.conf @@ -0,0 +1,100 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = D:\DOWNLOAD_TOOL\ÏÂÔØ¹¤¾ß\release\3.9.6 + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c2/utility.conf b/dist/flash_download_tool_3.9.6/configure/esp32c2/utility.conf new file mode 100644 index 000000000..8f8e1facf --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c2/utility.conf @@ -0,0 +1,16 @@ +[LOG_LEVEL] +utility_log_level = ERROR +spi_log_level = ERROR +multi_log_level = ERROR + +[MAC_SAVE] +mac_save_enable = False + +[SECTOR_PROTECT] +sector_protect_enable = False +sector_protect_start = 0xe000 +sector_protect_end = 0x3000 + +[ESP32_EFUSE_CONFIG] +config_voltage = OFF + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c3/multi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32c3/multi_download.conf new file mode 100644 index 000000000..264959675 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c3/multi_download.conf @@ -0,0 +1,161 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = ./bin/ + +[LOCK] +lock_setting_password = + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 +autostart2 = 0 +com_port2 = +baudrate2 = 0 +checkmac2 = 1 +autostart3 = 0 +com_port3 = +baudrate3 = 0 +checkmac3 = 1 +autostart4 = 0 +com_port4 = +baudrate4 = 0 +checkmac4 = 1 +autostart5 = 0 +com_port5 = +baudrate5 = 0 +checkmac5 = 1 +autostart6 = 0 +com_port6 = +baudrate6 = 0 +checkmac6 = 1 +autostart7 = 0 +com_port7 = +baudrate7 = 0 +checkmac7 = 1 +autostart8 = 0 +com_port8 = +baudrate8 = 0 +checkmac8 = 1 +autostart9 = 0 +com_port9 = +baudrate9 = 0 +checkmac9 = 1 +autostart10 = 0 +com_port10 = +baudrate10 = 0 +checkmac10 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + +[STATISTICS] +pass1 = 0 +fail1 = 0 +pass2 = 0 +fail2 = 0 +pass3 = 0 +fail3 = 0 +pass4 = 0 +fail4 = 0 +pass5 = 0 +fail5 = 0 +pass6 = 0 +fail6 = 0 +pass7 = 0 +fail7 = 0 +pass8 = 0 +fail8 = 0 +pass9 = 0 +fail9 = 0 +pass10 = 0 +fail10 = 0 + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c3/security.conf b/dist/flash_download_tool_3.9.6/configure/esp32c3/security.conf new file mode 100644 index 000000000..b2a1f86c6 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c3/security.conf @@ -0,0 +1,27 @@ +[SECURE BOOT] +secure_boot_en = False +public_key_digest_path = .\secure\public_key_digest.bin +public_key_digest_block_index = 0 + +[FLASH ENCRYPTION] +flash_encryption_en = False +reserved_burn_times = 0 +flash_encrypt_key_block_index = 1 + +[SECURE OTHER CONFIG] +flash_encryption_use_customer_key_enable = False +flash_encryption_use_customer_key_path = .\secure\flash_encrypt_key.bin +flash_force_write_enable = False + +[FLASH ENCRYPTION KEYS LOCAL SAVE] +keys_save_enable = False +encrypt_keys_enable = False +encrypt_keys_aeskey_path = + +[ESP32C* EFUSE BIT CONFIG] +dis_usb_jtag = False +dis_pad_jtag = False +soft_dis_jtag = 7 +dis_direct_boot = False +dis_download_icache = False + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c3/spi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32c3/spi_download.conf new file mode 100644 index 000000000..ebc596813 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c3/spi_download.conf @@ -0,0 +1,100 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = D:\DOWNLOAD_TOOL\ÏÂÔØ¹¤¾ß\release\3.9.6 + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c3/utility.conf b/dist/flash_download_tool_3.9.6/configure/esp32c3/utility.conf new file mode 100644 index 000000000..8f8e1facf --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c3/utility.conf @@ -0,0 +1,16 @@ +[LOG_LEVEL] +utility_log_level = ERROR +spi_log_level = ERROR +multi_log_level = ERROR + +[MAC_SAVE] +mac_save_enable = False + +[SECTOR_PROTECT] +sector_protect_enable = False +sector_protect_start = 0xe000 +sector_protect_end = 0x3000 + +[ESP32_EFUSE_CONFIG] +config_voltage = OFF + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c6/multi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32c6/multi_download.conf new file mode 100644 index 000000000..264959675 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c6/multi_download.conf @@ -0,0 +1,161 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = ./bin/ + +[LOCK] +lock_setting_password = + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 +autostart2 = 0 +com_port2 = +baudrate2 = 0 +checkmac2 = 1 +autostart3 = 0 +com_port3 = +baudrate3 = 0 +checkmac3 = 1 +autostart4 = 0 +com_port4 = +baudrate4 = 0 +checkmac4 = 1 +autostart5 = 0 +com_port5 = +baudrate5 = 0 +checkmac5 = 1 +autostart6 = 0 +com_port6 = +baudrate6 = 0 +checkmac6 = 1 +autostart7 = 0 +com_port7 = +baudrate7 = 0 +checkmac7 = 1 +autostart8 = 0 +com_port8 = +baudrate8 = 0 +checkmac8 = 1 +autostart9 = 0 +com_port9 = +baudrate9 = 0 +checkmac9 = 1 +autostart10 = 0 +com_port10 = +baudrate10 = 0 +checkmac10 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + +[STATISTICS] +pass1 = 0 +fail1 = 0 +pass2 = 0 +fail2 = 0 +pass3 = 0 +fail3 = 0 +pass4 = 0 +fail4 = 0 +pass5 = 0 +fail5 = 0 +pass6 = 0 +fail6 = 0 +pass7 = 0 +fail7 = 0 +pass8 = 0 +fail8 = 0 +pass9 = 0 +fail9 = 0 +pass10 = 0 +fail10 = 0 + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c6/security.conf b/dist/flash_download_tool_3.9.6/configure/esp32c6/security.conf new file mode 100644 index 000000000..b2a1f86c6 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c6/security.conf @@ -0,0 +1,27 @@ +[SECURE BOOT] +secure_boot_en = False +public_key_digest_path = .\secure\public_key_digest.bin +public_key_digest_block_index = 0 + +[FLASH ENCRYPTION] +flash_encryption_en = False +reserved_burn_times = 0 +flash_encrypt_key_block_index = 1 + +[SECURE OTHER CONFIG] +flash_encryption_use_customer_key_enable = False +flash_encryption_use_customer_key_path = .\secure\flash_encrypt_key.bin +flash_force_write_enable = False + +[FLASH ENCRYPTION KEYS LOCAL SAVE] +keys_save_enable = False +encrypt_keys_enable = False +encrypt_keys_aeskey_path = + +[ESP32C* EFUSE BIT CONFIG] +dis_usb_jtag = False +dis_pad_jtag = False +soft_dis_jtag = 7 +dis_direct_boot = False +dis_download_icache = False + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c6/spi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32c6/spi_download.conf new file mode 100644 index 000000000..ebc596813 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c6/spi_download.conf @@ -0,0 +1,100 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = D:\DOWNLOAD_TOOL\ÏÂÔØ¹¤¾ß\release\3.9.6 + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32c6/utility.conf b/dist/flash_download_tool_3.9.6/configure/esp32c6/utility.conf new file mode 100644 index 000000000..8f8e1facf --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32c6/utility.conf @@ -0,0 +1,16 @@ +[LOG_LEVEL] +utility_log_level = ERROR +spi_log_level = ERROR +multi_log_level = ERROR + +[MAC_SAVE] +mac_save_enable = False + +[SECTOR_PROTECT] +sector_protect_enable = False +sector_protect_start = 0xe000 +sector_protect_end = 0x3000 + +[ESP32_EFUSE_CONFIG] +config_voltage = OFF + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32h2/multi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32h2/multi_download.conf new file mode 100644 index 000000000..264959675 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32h2/multi_download.conf @@ -0,0 +1,161 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = ./bin/ + +[LOCK] +lock_setting_password = + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 +autostart2 = 0 +com_port2 = +baudrate2 = 0 +checkmac2 = 1 +autostart3 = 0 +com_port3 = +baudrate3 = 0 +checkmac3 = 1 +autostart4 = 0 +com_port4 = +baudrate4 = 0 +checkmac4 = 1 +autostart5 = 0 +com_port5 = +baudrate5 = 0 +checkmac5 = 1 +autostart6 = 0 +com_port6 = +baudrate6 = 0 +checkmac6 = 1 +autostart7 = 0 +com_port7 = +baudrate7 = 0 +checkmac7 = 1 +autostart8 = 0 +com_port8 = +baudrate8 = 0 +checkmac8 = 1 +autostart9 = 0 +com_port9 = +baudrate9 = 0 +checkmac9 = 1 +autostart10 = 0 +com_port10 = +baudrate10 = 0 +checkmac10 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + +[STATISTICS] +pass1 = 0 +fail1 = 0 +pass2 = 0 +fail2 = 0 +pass3 = 0 +fail3 = 0 +pass4 = 0 +fail4 = 0 +pass5 = 0 +fail5 = 0 +pass6 = 0 +fail6 = 0 +pass7 = 0 +fail7 = 0 +pass8 = 0 +fail8 = 0 +pass9 = 0 +fail9 = 0 +pass10 = 0 +fail10 = 0 + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32h2/security.conf b/dist/flash_download_tool_3.9.6/configure/esp32h2/security.conf new file mode 100644 index 000000000..d1070b7d8 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32h2/security.conf @@ -0,0 +1,26 @@ +[SECURE BOOT] +secure_boot_en = False +public_key_digest_path = .\secure\public_key_digest.bin +public_key_digest_block_index = 0 + +[FLASH ENCRYPTION] +flash_encryption_en = False +reserved_burn_times = 0 +flash_encrypt_key_block_index = 1 + +[SECURE OTHER CONFIG] +flash_encryption_use_customer_key_enable = False +flash_encryption_use_customer_key_path = .\secure\flash_encrypt_key.bin +flash_force_write_enable = False + +[FLASH ENCRYPTION KEYS LOCAL SAVE] +keys_save_enable = False +encrypt_keys_enable = False +encrypt_keys_aeskey_path = + +[ESP32H2 EFUSE BIT CONFIG] +dis_direct_boot = False +soft_dis_jtag = False +dis_pad_jtag = False +dis_usb_jtag = False + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32h2/spi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32h2/spi_download.conf new file mode 100644 index 000000000..ebc596813 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32h2/spi_download.conf @@ -0,0 +1,100 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = D:\DOWNLOAD_TOOL\ÏÂÔØ¹¤¾ß\release\3.9.6 + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32h2/utility.conf b/dist/flash_download_tool_3.9.6/configure/esp32h2/utility.conf new file mode 100644 index 000000000..8f8e1facf --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32h2/utility.conf @@ -0,0 +1,16 @@ +[LOG_LEVEL] +utility_log_level = ERROR +spi_log_level = ERROR +multi_log_level = ERROR + +[MAC_SAVE] +mac_save_enable = False + +[SECTOR_PROTECT] +sector_protect_enable = False +sector_protect_start = 0xe000 +sector_protect_end = 0x3000 + +[ESP32_EFUSE_CONFIG] +config_voltage = OFF + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32s2/multi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32s2/multi_download.conf new file mode 100644 index 000000000..264959675 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32s2/multi_download.conf @@ -0,0 +1,161 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = ./bin/ + +[LOCK] +lock_setting_password = + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 +autostart2 = 0 +com_port2 = +baudrate2 = 0 +checkmac2 = 1 +autostart3 = 0 +com_port3 = +baudrate3 = 0 +checkmac3 = 1 +autostart4 = 0 +com_port4 = +baudrate4 = 0 +checkmac4 = 1 +autostart5 = 0 +com_port5 = +baudrate5 = 0 +checkmac5 = 1 +autostart6 = 0 +com_port6 = +baudrate6 = 0 +checkmac6 = 1 +autostart7 = 0 +com_port7 = +baudrate7 = 0 +checkmac7 = 1 +autostart8 = 0 +com_port8 = +baudrate8 = 0 +checkmac8 = 1 +autostart9 = 0 +com_port9 = +baudrate9 = 0 +checkmac9 = 1 +autostart10 = 0 +com_port10 = +baudrate10 = 0 +checkmac10 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + +[STATISTICS] +pass1 = 0 +fail1 = 0 +pass2 = 0 +fail2 = 0 +pass3 = 0 +fail3 = 0 +pass4 = 0 +fail4 = 0 +pass5 = 0 +fail5 = 0 +pass6 = 0 +fail6 = 0 +pass7 = 0 +fail7 = 0 +pass8 = 0 +fail8 = 0 +pass9 = 0 +fail9 = 0 +pass10 = 0 +fail10 = 0 + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32s2/security.conf b/dist/flash_download_tool_3.9.6/configure/esp32s2/security.conf new file mode 100644 index 000000000..1b934d45f --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32s2/security.conf @@ -0,0 +1,28 @@ +[SECURE BOOT] +secure_boot_en = False +public_key_digest_path = .\secure\public_key_digest.bin +public_key_digest_block_index = 0 + +[FLASH ENCRYPTION] +flash_encryption_en = False +reserved_burn_times = 0 +flash_encrypt_key_block_index = 1 + +[SECURE OTHER CONFIG] +flash_encryption_use_customer_key_enable = False +flash_encryption_use_customer_key_path = .\secure\flash_encrypt_key.bin +flash_force_write_enable = False + +[FLASH ENCRYPTION KEYS LOCAL SAVE] +keys_save_enable = False +encrypt_keys_enable = False +encrypt_keys_aeskey_path = + +[ESP32S2 EFUSE BIT CONFIG] +hard_dis_jtag = False +soft_dis_jtag = False +dis_legacy_spi_boot = False +dis_boot_remap = False +dis_download_icache = False +dis_download_dcache = False + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32s2/spi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32s2/spi_download.conf new file mode 100644 index 000000000..ebc596813 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32s2/spi_download.conf @@ -0,0 +1,100 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = D:\DOWNLOAD_TOOL\ÏÂÔØ¹¤¾ß\release\3.9.6 + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32s2/utility.conf b/dist/flash_download_tool_3.9.6/configure/esp32s2/utility.conf new file mode 100644 index 000000000..8f8e1facf --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32s2/utility.conf @@ -0,0 +1,16 @@ +[LOG_LEVEL] +utility_log_level = ERROR +spi_log_level = ERROR +multi_log_level = ERROR + +[MAC_SAVE] +mac_save_enable = False + +[SECTOR_PROTECT] +sector_protect_enable = False +sector_protect_start = 0xe000 +sector_protect_end = 0x3000 + +[ESP32_EFUSE_CONFIG] +config_voltage = OFF + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32s3/multi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32s3/multi_download.conf new file mode 100644 index 000000000..264959675 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32s3/multi_download.conf @@ -0,0 +1,161 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = ./bin/ + +[LOCK] +lock_setting_password = + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 +autostart2 = 0 +com_port2 = +baudrate2 = 0 +checkmac2 = 1 +autostart3 = 0 +com_port3 = +baudrate3 = 0 +checkmac3 = 1 +autostart4 = 0 +com_port4 = +baudrate4 = 0 +checkmac4 = 1 +autostart5 = 0 +com_port5 = +baudrate5 = 0 +checkmac5 = 1 +autostart6 = 0 +com_port6 = +baudrate6 = 0 +checkmac6 = 1 +autostart7 = 0 +com_port7 = +baudrate7 = 0 +checkmac7 = 1 +autostart8 = 0 +com_port8 = +baudrate8 = 0 +checkmac8 = 1 +autostart9 = 0 +com_port9 = +baudrate9 = 0 +checkmac9 = 1 +autostart10 = 0 +com_port10 = +baudrate10 = 0 +checkmac10 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + +[STATISTICS] +pass1 = 0 +fail1 = 0 +pass2 = 0 +fail2 = 0 +pass3 = 0 +fail3 = 0 +pass4 = 0 +fail4 = 0 +pass5 = 0 +fail5 = 0 +pass6 = 0 +fail6 = 0 +pass7 = 0 +fail7 = 0 +pass8 = 0 +fail8 = 0 +pass9 = 0 +fail9 = 0 +pass10 = 0 +fail10 = 0 + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32s3/security.conf b/dist/flash_download_tool_3.9.6/configure/esp32s3/security.conf new file mode 100644 index 000000000..acc04f562 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32s3/security.conf @@ -0,0 +1,29 @@ +[SECURE BOOT] +secure_boot_en = False +public_key_digest_path = .\secure\public_key_digest.bin +public_key_digest_block_index = 0 + +[FLASH ENCRYPTION] +flash_encryption_en = False +reserved_burn_times = 0 +flash_encrypt_key_block_index = 1 + +[SECURE OTHER CONFIG] +flash_encryption_use_customer_key_enable = False +flash_encryption_use_customer_key_path = .\secure\flash_encrypt_key.bin +flash_force_write_enable = False + +[FLASH ENCRYPTION KEYS LOCAL SAVE] +keys_save_enable = False +encrypt_keys_enable = False +encrypt_keys_aeskey_path = + +[ESP32S3 EFUSE BIT CONFIG] +dis_usb_jtag = False +hard_dis_jtag = False +soft_dis_jtag = 7 +dis_usb_otg_download_mode = False +dis_direct_boot = False +dis_download_icache = False +dis_download_dcache = False + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32s3/spi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp32s3/spi_download.conf new file mode 100644 index 000000000..ebc596813 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32s3/spi_download.conf @@ -0,0 +1,100 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = D:\DOWNLOAD_TOOL\ÏÂÔØ¹¤¾ß\release\3.9.6 + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 2 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + diff --git a/dist/flash_download_tool_3.9.6/configure/esp32s3/utility.conf b/dist/flash_download_tool_3.9.6/configure/esp32s3/utility.conf new file mode 100644 index 000000000..8f8e1facf --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp32s3/utility.conf @@ -0,0 +1,16 @@ +[LOG_LEVEL] +utility_log_level = ERROR +spi_log_level = ERROR +multi_log_level = ERROR + +[MAC_SAVE] +mac_save_enable = False + +[SECTOR_PROTECT] +sector_protect_enable = False +sector_protect_start = 0xe000 +sector_protect_end = 0x3000 + +[ESP32_EFUSE_CONFIG] +config_voltage = OFF + diff --git a/dist/flash_download_tool_3.9.6/configure/esp8266/hspi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp8266/hspi_download.conf new file mode 100644 index 000000000..c65baad16 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp8266/hspi_download.conf @@ -0,0 +1,100 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = D:\DOWNLOAD_TOOL\ÏÂÔØ¹¤¾ß\release\3.9.6 + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 0 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + diff --git a/dist/flash_download_tool_3.9.6/configure/esp8266/multi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp8266/multi_download.conf new file mode 100644 index 000000000..689dcd206 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp8266/multi_download.conf @@ -0,0 +1,161 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = ./bin/ + +[LOCK] +lock_setting_password = + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 0 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 +autostart2 = 0 +com_port2 = +baudrate2 = 0 +checkmac2 = 1 +autostart3 = 0 +com_port3 = +baudrate3 = 0 +checkmac3 = 1 +autostart4 = 0 +com_port4 = +baudrate4 = 0 +checkmac4 = 1 +autostart5 = 0 +com_port5 = +baudrate5 = 0 +checkmac5 = 1 +autostart6 = 0 +com_port6 = +baudrate6 = 0 +checkmac6 = 1 +autostart7 = 0 +com_port7 = +baudrate7 = 0 +checkmac7 = 1 +autostart8 = 0 +com_port8 = +baudrate8 = 0 +checkmac8 = 1 +autostart9 = 0 +com_port9 = +baudrate9 = 0 +checkmac9 = 1 +autostart10 = 0 +com_port10 = +baudrate10 = 0 +checkmac10 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + +[STATISTICS] +pass1 = 0 +fail1 = 0 +pass2 = 0 +fail2 = 0 +pass3 = 0 +fail3 = 0 +pass4 = 0 +fail4 = 0 +pass5 = 0 +fail5 = 0 +pass6 = 0 +fail6 = 0 +pass7 = 0 +fail7 = 0 +pass8 = 0 +fail8 = 0 +pass9 = 0 +fail9 = 0 +pass10 = 0 +fail10 = 0 + diff --git a/dist/flash_download_tool_3.9.6/configure/esp8266/spi_download.conf b/dist/flash_download_tool_3.9.6/configure/esp8266/spi_download.conf new file mode 100644 index 000000000..c65baad16 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp8266/spi_download.conf @@ -0,0 +1,100 @@ +[EFUSE CHECK] +efuse_mode = 1 +efuse_err_halt = 1 + +[MULTI_UI_CONFIG] +multi_col = 2 + +[DOWNLOAD PATH] +file_sel0 = 0 +file_path0 = +file_flag0 = False +file_offset0 = +file_sel1 = 0 +file_path1 = +file_flag1 = False +file_offset1 = +file_sel2 = 0 +file_path2 = +file_flag2 = False +file_offset2 = +file_sel3 = 0 +file_path3 = +file_flag3 = False +file_offset3 = +file_sel4 = 0 +file_path4 = +file_flag4 = False +file_offset4 = +file_sel5 = 0 +file_path5 = +file_flag5 = False +file_offset5 = +file_sel6 = 0 +file_path6 = +file_flag6 = False +file_offset6 = +file_sel7 = 0 +file_path7 = +file_flag7 = False +file_offset7 = +file_sel8 = 0 +file_path8 = +file_flag8 = False +file_offset8 = +file_sel9 = 0 +file_path9 = +file_flag9 = False +file_offset9 = +file_sel10 = 0 +file_path10 = +file_flag10 = False +file_offset10 = +file_sel11 = 0 +file_path11 = +file_flag11 = False +file_offset11 = +file_sel12 = 0 +file_path12 = +file_flag12 = False +file_offset12 = +file_sel13 = 0 +file_path13 = +file_flag13 = False +file_offset13 = +default_path = D:\DOWNLOAD_TOOL\ÏÂÔØ¹¤¾ß\release\3.9.6 + +[FLASH_CRYSTAL] +spicfgdis = 1 +spispeed = 0 +spimode = 0 + +[DOWNLOAD] +erase_button_en = True +autostart1 = 0 +com_port1 = +baudrate1 = 0 +checkmac1 = 1 + +[LOG_CHECK] +log_check_enable = False +log_check_baud = 115200 +log_check_str = 1.0.0 +log_check_delaytime = 3 +log_check_timeout = 3 +log_check_cmd_str = AT+GMR +log_check_enable_cmd = False + +[MAC_SAVE] +mac_save_enable = False + +[ESPTOOL_PARAM] +after = no_reset +before = default_reset +compress = True +flash_size = keep +no_stub = False +verify = True +flash_freq = keep +flash_mode = keep + diff --git a/dist/flash_download_tool_3.9.6/configure/esp8266/utility.conf b/dist/flash_download_tool_3.9.6/configure/esp8266/utility.conf new file mode 100644 index 000000000..fb5988fb9 --- /dev/null +++ b/dist/flash_download_tool_3.9.6/configure/esp8266/utility.conf @@ -0,0 +1,14 @@ +[LOG_LEVEL] +utility_log_level = ERROR +spi_log_level = ERROR +hspi_log_level = ERROR +multi_log_level = ERROR + +[MAC_SAVE] +mac_save_enable = False + +[SECTOR_PROTECT] +sector_protect_enable = False +sector_protect_start = 0xe000 +sector_protect_end = 0x3000 + diff --git a/dist/flash_download_tool_3.9.6/doc/Flash_Download_Tool__cn.pdf b/dist/flash_download_tool_3.9.6/doc/Flash_Download_Tool__cn.pdf new file mode 100644 index 000000000..b25d319ff Binary files /dev/null and b/dist/flash_download_tool_3.9.6/doc/Flash_Download_Tool__cn.pdf differ diff --git a/dist/flash_download_tool_3.9.5/doc/Flash_Download_Tool__en.pdf b/dist/flash_download_tool_3.9.6/doc/Flash_Download_Tool__en.pdf similarity index 100% rename from dist/flash_download_tool_3.9.5/doc/Flash_Download_Tool__en.pdf rename to dist/flash_download_tool_3.9.6/doc/Flash_Download_Tool__en.pdf diff --git a/dist/flash_download_tool_3.9.5/doc/release_note.txt b/dist/flash_download_tool_3.9.6/doc/release_note.txt similarity index 61% rename from dist/flash_download_tool_3.9.5/doc/release_note.txt rename to dist/flash_download_tool_3.9.6/doc/release_note.txt index 5f96d588d..e296315dd 100644 --- a/dist/flash_download_tool_3.9.5/doc/release_note.txt +++ b/dist/flash_download_tool_3.9.6/doc/release_note.txt @@ -1,3 +1,8 @@ +3.9.6: +* support ESP32/ESP32H2/ESP32C6/ESP32C2/ESP32S2 secure boot version2 and flash encryption +* config DUT number in multiconfig file ,up to 20pcs +* update secure config file, see docs in detail + 3.9.5: * support esp32-h2 * support erase button disable diff --git a/dist/flash_download_tool_3.9.5/flash_download_tool_3.9.5.exe b/dist/flash_download_tool_3.9.6/flash_download_tool_3.9.6.exe similarity index 70% rename from dist/flash_download_tool_3.9.5/flash_download_tool_3.9.5.exe rename to dist/flash_download_tool_3.9.6/flash_download_tool_3.9.6.exe index 2ea17a6e1..3895e175e 100644 Binary files a/dist/flash_download_tool_3.9.5/flash_download_tool_3.9.5.exe and b/dist/flash_download_tool_3.9.6/flash_download_tool_3.9.6.exe differ diff --git a/docs/source/Plugin/P000_events.repl b/docs/source/Plugin/P000_events.repl index 19f009365..c76f996ef 100644 --- a/docs/source/Plugin/P000_events.repl +++ b/docs/source/Plugin/P000_events.repl @@ -208,6 +208,25 @@ SendToHTTP,url.com,80,/report.php?hash=123abc456&t=[temp2#out] endon + " + " + ``WiFi#Disconnected`` + Triggered when the ESP has disconnected from Wi-Fi. + "," + + .. code-block:: none + + On WiFi#Disconnected Do + LongPulse,2,1,1,1,-1 // 0.5 Hz flashing of WiFi led + Endon + + .. code-block:: none + + On WiFi#Connected Do + GPIO,2,1 // Turn off WiFi led + SendToHTTP,url.com,80,/report.php?hash=123abc456&t=[temp2#out] + Endon + " " ``WiFi#ChangedAccesspoint`` diff --git a/docs/source/conf.py b/docs/source/conf.py index d985ebed4..2fea1c707 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -180,6 +180,9 @@ html_theme_options = { # Choose Bootstrap version. # Values: "3" (default) or "2" (in quotes) 'bootstrap_version': "5", + + # Disable showing the sidebar. Defaults to 'false' + 'nosidebar': True, } # Add any paths that contain custom static files (such as style sheets) here, diff --git a/lib/ESPEasySerial/Port_ESPEasySerial_USB_HWCDC.cpp b/lib/ESPEasySerial/Port_ESPEasySerial_USB_HWCDC.cpp index 9d4870f52..5c6fa8bdb 100644 --- a/lib/ESPEasySerial/Port_ESPEasySerial_USB_HWCDC.cpp +++ b/lib/ESPEasySerial/Port_ESPEasySerial_USB_HWCDC.cpp @@ -58,40 +58,46 @@ Port_ESPEasySerial_USB_HWCDC_t::Port_ESPEasySerial_USB_HWCDC_t(const ESPEasySeri // USB.begin(); if (_hwcdc_serial != nullptr) { - _config.rxBuffSize = _hwcdc_serial->setRxBufferSize(_config.rxBuffSize); - _config.txBuffSize = _hwcdc_serial->setRxBufferSize(_config.txBuffSize); + // _hwcdc_serial->end(); + + // _config.rxBuffSize = _hwcdc_serial->setRxBufferSize(_config.rxBuffSize); + // _config.txBuffSize = _hwcdc_serial->setTxBufferSize(_config.txBuffSize); // See: https://github.com/espressif/arduino-esp32/issues/9043 - _hwcdc_serial->setTxTimeoutMs(0); // sets no timeout when trying to write to USB HW CDC + // _hwcdc_serial->setTxTimeoutMs(0); // sets no timeout when trying to write to USB HW CDC - _hwcdc_serial->begin(); + // _hwcdc_serial->begin(); // _hwcdc_serial->onEvent(hwcdcEventCallback); } } -Port_ESPEasySerial_USB_HWCDC_t::~Port_ESPEasySerial_USB_HWCDC_t() {} +Port_ESPEasySerial_USB_HWCDC_t::~Port_ESPEasySerial_USB_HWCDC_t() { + if (_hwcdc_serial != nullptr) { + // _hwcdc_serial->end(); + } +} void Port_ESPEasySerial_USB_HWCDC_t::begin(unsigned long baud) { _config.baud = baud; - /* - if (_hwcdc_serial != nullptr) { - _config.rxBuffSize = _hwcdc_serial->setRxBufferSize(_config.rxBuffSize); - _config.txBuffSize = _hwcdc_serial->setRxBufferSize(_config.txBuffSize); - _hwcdc_serial->begin(); - delay(10); - _hwcdc_serial->onEvent(hwcdcEventCallback); - delay(1); - } - */ + + if (_hwcdc_serial != nullptr) { + _config.rxBuffSize = _hwcdc_serial->setRxBufferSize(_config.rxBuffSize); + _config.txBuffSize = _hwcdc_serial->setTxBufferSize(_config.txBuffSize); + _hwcdc_serial->begin(); + delay(10); + + // _hwcdc_serial->onEvent(hwcdcEventCallback); + delay(1); + } } void Port_ESPEasySerial_USB_HWCDC_t::end() { // Disabled for now // See: https://github.com/espressif/arduino-esp32/issues/8224 if (_hwcdc_serial != nullptr) { - _hwcdc_serial->end(); + // _hwcdc_serial->end(); } } @@ -204,5 +210,4 @@ bool Port_ESPEasySerial_USB_HWCDC_t::setRS485Mode(int8_t rtsPin, bool enableColl return false; } - #endif // if USES_HWCDC diff --git a/lib/ESPEasySerial/Port_ESPEasySerial_USB_HWCDC.h b/lib/ESPEasySerial/Port_ESPEasySerial_USB_HWCDC.h index b9801fe8c..a71bfd411 100644 --- a/lib/ESPEasySerial/Port_ESPEasySerial_USB_HWCDC.h +++ b/lib/ESPEasySerial/Port_ESPEasySerial_USB_HWCDC.h @@ -13,7 +13,7 @@ class Port_ESPEasySerial_USB_HWCDC_t : public Port_ESPEasySerial_base { public: - Port_ESPEasySerial_USB_HWCDC_t(const ESPEasySerialConfig& config); + explicit Port_ESPEasySerial_USB_HWCDC_t(const ESPEasySerialConfig& config); virtual ~Port_ESPEasySerial_USB_HWCDC_t(); @@ -44,11 +44,7 @@ public: private: -# if ARDUINO_USB_CDC_ON_BOOT // Serial used for USB CDC - HWCDC *_hwcdc_serial = &Serial; -# else // if ARDUINO_USB_CDC_ON_BOOT - HWCDC *_hwcdc_serial = &USBSerial; -# endif // if ARDUINO_USB_CDC_ON_BOOT + HWCDC *_hwcdc_serial= nullptr; }; diff --git a/lib/ImprovWiFi/src/ImprovTypes.h b/lib/ImprovWiFi/src/ImprovTypes.h index 1a8a6abeb..3e77a7cf3 100644 --- a/lib/ImprovWiFi/src/ImprovTypes.h +++ b/lib/ImprovWiFi/src/ImprovTypes.h @@ -32,6 +32,8 @@ enum Error : uint8_t { ERROR_UNKNOWN_RPC = 0x02, ERROR_UNABLE_TO_CONNECT = 0x03, ERROR_NOT_AUTHORIZED = 0x04, + ERROR_INVALID_CHECKSUM = 0x05, + ERROR_EMPTY_SSID = 0x06, ERROR_UNKNOWN = 0xFF, }; diff --git a/lib/ImprovWiFi/src/ImprovWiFiLibrary.cpp b/lib/ImprovWiFi/src/ImprovWiFiLibrary.cpp index 68e240f4c..790ab47f9 100644 --- a/lib/ImprovWiFi/src/ImprovWiFiLibrary.cpp +++ b/lib/ImprovWiFi/src/ImprovWiFiLibrary.cpp @@ -71,7 +71,7 @@ bool ImprovWiFi::onCommandCallback(ImprovTypes::ImprovCommand cmd) { if (cmd.ssid.empty()) { - setError(ImprovTypes::Error::ERROR_INVALID_RPC); + setError(ImprovTypes::Error::ERROR_EMPTY_SSID); break; } @@ -298,17 +298,19 @@ ImprovTypes::ParseState ImprovWiFi::parseImprovSerial(size_t position, uint8_t b if (position == (8u + data_len + 1u)) { + /* if (computeChecksum(buffer, position - 1) != byte) { _position = 0; - onErrorCallback(ImprovTypes::Error::ERROR_INVALID_RPC); + onErrorCallback(ImprovTypes::Error::ERROR_INVALID_CHECKSUM); return ImprovTypes::ParseState::INVALID; } + */ if (type == ImprovTypes::ImprovSerialType::TYPE_RPC) { _position = 0; - auto command = parseImprovData(&buffer[9], data_len, false); + auto command = parseImprovData(&buffer[9], data_len + 1, false); return onCommandCallback(command) ? ImprovTypes::ParseState::VALID_COMPLETE : ImprovTypes::ParseState::INVALID; } } @@ -332,19 +334,23 @@ ImprovTypes::ImprovCommand ImprovWiFi::parseImprovData(const uint8_t *data, size } const ImprovTypes::Command command = (ImprovTypes::Command)data[0]; const uint8_t data_length = data[1]; + const uint8_t data_start = 2; + const size_t data_end = data_start + data_length; +// if (data_end >= length) if (data_length != (length - 2 - check_checksum)) { - return improv_command; +// return improv_command; } if (check_checksum) { - const uint8_t checksum = data[length - 1]; + const uint8_t checksum = data[data_end]; - if (computeChecksum(data, length - 1) != checksum) + if (computeChecksum(data, data_end - 1) != checksum) { improv_command.command = ImprovTypes::Command::BAD_CHECKSUM; + setError(ImprovTypes::Error::ERROR_INVALID_CHECKSUM); return improv_command; } } @@ -363,7 +369,7 @@ ImprovTypes::ImprovCommand ImprovWiFi::parseImprovData(const uint8_t *data, size const size_t pass_start = ssid_end + 1; const size_t pass_end = pass_start + pass_length; - if (pass_end >= length) { + if (pass_end > length) { return improv_command; } @@ -394,6 +400,7 @@ void ImprovWiFi::setError(ImprovTypes::Error error) const std::vector response = { error }; send(ImprovTypes::TYPE_ERROR_STATE, response); + onErrorCallback(error); } void ImprovWiFi::sendResponse(const std::vector& response) diff --git a/platformio.ini b/platformio.ini index 99ae1396c..0a2617981 100644 --- a/platformio.ini +++ b/platformio.ini @@ -29,6 +29,7 @@ extra_configs = ;default_envs = normal_ESP32_4M default_envs = max_ESP32_16M8M_LittleFS +;default_envs = normal_ESP32c6_4M316k_LittleFS_CDC ; default_envs = custom_ESP8266_4M1M ;default_envs = normal_ESP8266_4M1M diff --git a/platformio_core_defs.ini b/platformio_core_defs.ini index b665e8a01..7b4f2798f 100644 --- a/platformio_core_defs.ini +++ b/platformio_core_defs.ini @@ -208,19 +208,24 @@ lib_ignore = ; ESP_IDF 5.1 [core_esp32_IDF5_1__3_0_0] -;platform = https://github.com/Jason2866/platform-espressif32.git -platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.02.10/platform-espressif32.zip +;platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.02.10/platform-espressif32.zip ;platform_packages = ;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2119/framework-arduinoespressif32-release_v5.1-a28d368.zip ;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2180/framework-arduinoespressif32-all-release_v5.1-735d740.zip -platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2189/framework-arduinoespressif32-all-release_v5.1-be1a568.zip +;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2189/framework-arduinoespressif32-all-release_v5.1-be1a568.zip +; Build with HWCDC fix. +;platform = https://github.com/Jason2866/platform-espressif32.git +;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2261/framework-arduinoespressif32-all-release_v5.1-11140aa.zip +platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.04.11/platform-espressif32.zip +;platform_packages = +platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2286/framework-arduinoespressif32-all-release_v5.1-11140aa.zip build_flags = -DESP32_STAGE -DESP_IDF_VERSION_MAJOR=5 -DLIBRARIES_NO_LOG=1 -DDISABLE_SC16IS752_SPI -DCONFIG_PM_ENABLE ; -DCONFIG_LWIP_L2_TO_L3_COPY - -DETH_SPI_SUPPORTS_NO_IRQ=1 +; -DETH_SPI_SUPPORTS_NO_IRQ=1 -DCONFIG_FREERTOS_USE_TICKLESS_IDLE=1 -DCONFIG_FREERTOS_IDLE_TIME_BEFORE_SLEEP=3 -DNEOPIXEL_ESP32_RMT_DEFAULT diff --git a/platformio_esp32_solo1.ini b/platformio_esp32_solo1.ini index 61afb5b4e..0886c119d 100644 --- a/platformio_esp32_solo1.ini +++ b/platformio_esp32_solo1.ini @@ -18,7 +18,7 @@ build_unflags = ${esp32_base.build_unflags} ; IDF 5.1.2 [esp32_solo1_common_LittleFS] extends = esp32_base_idf5 -platform_packages = framework-arduino-solo1 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2038/framework-arduinoespressif32-solo1-release_v5.1-246cad0.zip +;platform_packages = framework-arduino-solo1 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2038/framework-arduinoespressif32-solo1-release_v5.1-246cad0.zip build_flags = ${esp32_base_idf5.build_flags} -DFEATURE_ARDUINO_OTA=1 -DUSE_LITTLEFS diff --git a/src/_P167_Vindstyrka.ino b/src/_P167_Vindstyrka.ino new file mode 100644 index 000000000..b97fd6a47 --- /dev/null +++ b/src/_P167_Vindstyrka.ino @@ -0,0 +1,561 @@ +#include "_Plugin_Helper.h" +#ifdef USES_P167 + +// ####################################################################################################### +// ######################## Plugin 167 IKEA Vindstyrka I2C Sensor (SEN5x) ############################ +// ####################################################################################################### +// 19-06-2023 AndiBaciu creation based upon https://github.com/RobTillaart/SHT2x + +# include "./src/PluginStructs/P167_data_struct.h" + +#define PLUGIN_167 +#define PLUGIN_ID_167 167 // plugin id +#define PLUGIN_NAME_167 "Environment - Sensirion SEN5x (IKEA Vindstyrka)" // What will be dislpayed in the selection list +#define PLUGIN_VALUENAME1_167 "Temperature" // variable output of the plugin. The label is in quotation marks +#define PLUGIN_VALUENAME2_167 "Humidity" // multiple outputs are supporte +#define PLUGIN_VALUENAME3_167 "tVOC" // multiple outputs are supported +#define PLUGIN_VALUENAME4_167 "NOx" // multiple outputs are supported +#define PLUGIN_VALUENAME5_167 "PM 1.0" // multiple outputs are supported +#define PLUGIN_VALUENAME6_167 "PM 2.5" // multiple outputs are supported +#define PLUGIN_VALUENAME7_167 "PM 4.0" // multiple outputs are supported +#define PLUGIN_VALUENAME8_167 "PM 10.0" // multiple outputs are supported +#define PLUGIN_VALUENAME9_167 "DewPoint" // multiple outputs are supported +#define PLUGIN_DEFAULT_NAME_1 "IKEA_Vindstyrka" +#define PLUGIN_DEFAULT_NAME_2 "Sensirion_SEN5x" + +// PIN/port configuration is stored in the following: +// CONFIG_PIN1 - The first GPIO pin selected within the task +// CONFIG_PIN2 - The second GPIO pin selected within the task +// CONFIG_PIN3 - The third GPIO pin selected within the task +// CONFIG_PORT - The port in case the device has multiple in/out pins +// +// Custom configuration is stored in the following: +// PCONFIG(x) +// x can be between 1 - 8 and can store values between -32767 - 32768 (16 bit) +// +// N.B. these are aliases for a longer less readable amount of code. See _Plugin_Helper.h +// +// PCONFIG_LABEL(x) is a function to generate a unique label used as HTML id to be able to match +// returned values when saving a configuration. + +// Make accessing specific parameters more readable in the code +// #define Pxxx_OUTPUT_TYPE_INDEX 2 +# define P167_I2C_ADDRESS PCONFIG(0) +# define P167_I2C_ADDRESS_LABEL PCONFIG_LABEL(0) +# define P167_MODEL PCONFIG(1) +# define P167_MODEL_LABEL PCONFIG_LABEL(1) +# define P167_MON_SCL_PIN PCONFIG(2) +# define P167_MON_SCL_PIN_LABEL PCONFIG_LABEL(2) +# define P167_QUERY1 PCONFIG(3) +# define P167_QUERY2 PCONFIG(4) +# define P167_QUERY3 PCONFIG(5) +# define P167_QUERY4 PCONFIG(6) +# define P167_SEN_FIRST PCONFIG(7) +# define P167_SEN_ATTEMPT PCONFIG_LONG(1) + + +# define P167_I2C_ADDRESS_DFLT 0x69 +# define P167_MON_SCL_PIN_DFLT 13 +# define P167_MODEL_DFLT 0 // Vindstyrka or SEN54 +# define P167_QUERY1_DFLT 0 // Temperature (C) +# define P167_QUERY2_DFLT 1 // Humidity (%) +# define P167_QUERY3_DFLT 5 // PM2.5 (ug/m3) +# define P167_QUERY4_DFLT 2 // tVOC (index) + + +# define P167_NR_OUTPUT_VALUES 4 +# define P167_NR_OUTPUT_OPTIONS 10 +# define P167_QUERY1_CONFIG_POS 3 +# define P167_MAX_ATTEMPT 3 // Number of tentative before declaring NAN value + +//# define LIMIT_BUILD_SIZE 1 + +// These pointers may be used among multiple instances of the same plugin, +// as long as the same settings are used. +P167_data_struct *Plugin_167_SEN = nullptr; +boolean Plugin_167_init = false; + +void IRAM_ATTR Plugin_167_interrupt(); + +// Forward declaration helper functions +const __FlashStringHelper* p167_getQueryString(uint8_t query); +const __FlashStringHelper* p167_getQueryValueString(uint8_t query); +unsigned int p167_getRegister(uint8_t query, uint8_t model); +float p167_readVal(uint8_t query, uint8_t node, unsigned int model); + + +// A plugin has to implement the following function + +boolean Plugin_167(uint8_t function, struct EventStruct *event, String& string) +{ + // function: reason the plugin was called + // event: ??add description here?? + // string: ??add description here?? + + boolean success = false; + + switch (function) + { + + + case PLUGIN_DEVICE_ADD: + { + // This case defines the device characteristics + Device[++deviceCount].Number = PLUGIN_ID_167; + Device[deviceCount].Type = DEVICE_TYPE_I2C; + Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD; + Device[deviceCount].Ports = 0; + Device[deviceCount].PullUpOption = true; + Device[deviceCount].InverseLogicOption = false; + Device[deviceCount].FormulaOption = true; + Device[deviceCount].ValueCount = P167_NR_OUTPUT_VALUES; + Device[deviceCount].SendDataOption = true; + Device[deviceCount].TimerOption = true; + Device[deviceCount].I2CNoDeviceCheck = true; + Device[deviceCount].GlobalSyncOption = true; + Device[deviceCount].PluginStats = true; + Device[deviceCount].OutputDataType = Output_Data_type_t::Simple; + break; + } + + + case PLUGIN_GET_DEVICENAME: + { + // return the device name + string = F(PLUGIN_NAME_167); + break; + } + + + case PLUGIN_GET_DEVICEVALUENAMES: + { + // called when the user opens the module configuration page + // it allows to add a new row for each output variable of the plugin + // For plugins able to choose output types, see P026_Sysinfo.ino. + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) + { + if ( i < P167_NR_OUTPUT_VALUES) + { + uint8_t choice = PCONFIG(i + P167_QUERY1_CONFIG_POS); + safe_strncpy(ExtraTaskSettings.TaskDeviceValueNames[i], p167_getQueryValueString(choice), sizeof(ExtraTaskSettings.TaskDeviceValueNames[i])); + } + else + { + ZERO_FILL(ExtraTaskSettings.TaskDeviceValueNames[i]); + } + } + break; + } + + + case PLUGIN_SET_DEFAULTS: + { + // Set a default config here, which will be called when a plugin is assigned to a task. + P167_I2C_ADDRESS = P167_I2C_ADDRESS_DFLT; + P167_MODEL = P167_MODEL_DFLT; + P167_QUERY1 = P167_QUERY1_DFLT; + P167_QUERY2 = P167_QUERY2_DFLT; + P167_QUERY3 = P167_QUERY3_DFLT; + P167_QUERY4 = P167_QUERY4_DFLT; + P167_MON_SCL_PIN = P167_MON_SCL_PIN_DFLT; + P167_SEN_FIRST = 99; + success = true; + break; + } + + + # if FEATURE_I2C_GET_ADDRESS + case PLUGIN_I2C_GET_ADDRESS: + { + event->Par1 = P167_I2C_ADDRESS_DFLT; + success = true; + break; + } + # endif // if FEATURE_I2C_GET_ADDRESS + + + case PLUGIN_I2C_HAS_ADDRESS: + case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: + { + const uint8_t i2cAddressValues[] = { P167_I2C_ADDRESS_DFLT }; + if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) + { + if (P167_SEN_FIRST == event->TaskIndex) // If first SEN, serial config available + { + //addFormSelectorI2C(P167_I2C_ADDRESS_LABEL, 3, i2cAddressValues, P167_I2C_ADDRESS); + addFormSelectorI2C(F("i2c_addr"), 1, i2cAddressValues, P167_I2C_ADDRESS); + addFormNote(F("Vindstyrka, SEN54, SEN55 default i2c address: 0x69")); + } + } + else + { + success = intArrayContains(1, i2cAddressValues, event->Par1); + } + break; + } + + + case PLUGIN_WEBFORM_SHOW_GPIO_DESCR: + { + if (P167_SEN_FIRST == event->TaskIndex) // If first SEN, serial config available + { + if(P167_MODEL==0) + { + string = F("MonPin SCL: "); + string += formatGpioLabel(P167_MON_SCL_PIN, false); + } + } + success = true; + break; + } + + + case PLUGIN_WEBFORM_LOAD_OUTPUT_SELECTOR: + { + const __FlashStringHelper *options[P167_NR_OUTPUT_OPTIONS]; + for (int i = 0; i < P167_NR_OUTPUT_OPTIONS; ++i) + { + options[i] = p167_getQueryString(i); + } + for (uint8_t i = 0; i < P167_NR_OUTPUT_VALUES; ++i) + { + const uint8_t pconfigIndex = i + P167_QUERY1_CONFIG_POS; + sensorTypeHelper_loadOutputSelector(event, pconfigIndex, i, P167_NR_OUTPUT_OPTIONS, options); + } + addFormNote(F("NOx is available ONLY on Sensirion SEN55 model")); + break; + } + + + case PLUGIN_WEBFORM_LOAD: + { + // this case defines what should be displayed on the web form, when this plugin is selected + // The user's selection will be stored in + // PCONFIG(x) (custom configuration) + + if (Plugin_167_SEN == nullptr) + { + P167_SEN_FIRST = event->TaskIndex; // To detect if first SEN or not + } + + if (P167_SEN_FIRST == event->TaskIndex) // If first SEN, serial config available + { + addHtml(F("
This SEN5x is the first. Its configuration of Pins will affect next SEN5x.")); + addHtml(F("
If several SEN5x's foreseen, don't use other pins.
")); + + const __FlashStringHelper *options_model[3] = { F("IKEA Vindstyrka"), F("Sensirion SEN54"), F("Sensirion SEN55")}; + + addFormSelector(F("Model Type"), P167_MODEL_LABEL, 3, options_model, nullptr, P167_MODEL); + + if(P167_MODEL==0) + { + addFormPinSelect(PinSelectPurpose::Generic_input, F("MonPin SCL"), F("taskdevicepin3"), P167_MON_SCL_PIN); + addFormNote(F("Pin for monitoring i2c communication between Vindstyrka controller and SEN5x. (Only when Model - IKEA Vindstyrka is selected.)")); + } + + if (Plugin_167_SEN != nullptr) + { + addRowLabel(F("Device info")); + String prodname; + String sernum; + uint8_t firmware; + Plugin_167_SEN->getEID(prodname, sernum, firmware); + String txt = F("ProdName: "); + txt += prodname; + txt += F(" Serial Number: "); + txt += sernum; + txt += F(" Firmware: "); + txt += String (firmware); + addHtml(txt); + + addRowLabel(F("Device status")); + txt = F("Speed warning: "); + txt += String((bool)Plugin_167_SEN->getStatusInfo(sensor_speed)); + txt += F(" , Auto Cleaning: "); + txt += String((bool)Plugin_167_SEN->getStatusInfo(sensor_autoclean)); + txt += F(" , GAS Error: "); + txt += String((bool)Plugin_167_SEN->getStatusInfo(sensor_gas)); + txt += F(" , RHT Error: "); + txt += String((bool)Plugin_167_SEN->getStatusInfo(sensor_rht)); + txt += F(" , LASER Error: "); + txt += String((bool)Plugin_167_SEN->getStatusInfo(sensor_laser)); + txt += F(" , FAN Error: "); + txt += String((bool)Plugin_167_SEN->getStatusInfo(sensor_fan)); + addHtml(txt); + + addRowLabel(F("Check (pass/fail/errCode)")); + txt = Plugin_167_SEN->getSuccCount(); + txt += '/'; + txt += Plugin_167_SEN->getErrCount(); + txt += '/'; + txt += Plugin_167_SEN->getErrCode(); + addHtml(txt); + + } + } + else + { + addHtml(F("
This SEN5x is the NOT the first. Model and Pins config are DISABLED. Configuration is available in the first SEN5x plugin.")); + addHtml(F("
Only output value can be configured.
")); + + //looking for FIRST task Named "IKEA_Vindstyrka or Sensirion_SEN5x" + //Cache.taskIndexName + uint8_t allready_defined=88; + if(P167_MODEL==0) + { + allready_defined=findTaskIndexByName(PLUGIN_DEFAULT_NAME_1); + } + else + { + allready_defined=findTaskIndexByName(PLUGIN_DEFAULT_NAME_2); + } + P167_SEN_FIRST = allready_defined; + } + + success = true; + break; + } + + + case PLUGIN_WEBFORM_SAVE: + { + // this case defines the code to be executed when the form is submitted + // the plugin settings should be saved to PCONFIG(x) + // ping configuration should be read from CONFIG_PIN1 and stored + + // Save output selector parameters. + for (uint8_t i = 0; i < P167_NR_OUTPUT_VALUES; ++i) + { + const uint8_t pconfigIndex = i + P167_QUERY1_CONFIG_POS; + const uint8_t choice = PCONFIG(pconfigIndex); + sensorTypeHelper_saveOutputSelector(event, pconfigIndex, i, p167_getQueryValueString(choice)); + } + P167_MODEL = getFormItemInt(P167_MODEL_LABEL); + P167_I2C_ADDRESS = P167_I2C_ADDRESS_DFLT; + if(P167_MODEL==0) + P167_MON_SCL_PIN = getFormItemInt(F("taskdevicepin3")); + P167_SEN_FIRST = P167_SEN_FIRST; + + if (P167_SEN_FIRST == event->TaskIndex) // For first task set default name + { + if(P167_MODEL==0) + { + strcpy(ExtraTaskSettings.TaskDeviceName, PLUGIN_DEFAULT_NAME_1); // populate default name. + } + else + { + strcpy(ExtraTaskSettings.TaskDeviceName, PLUGIN_DEFAULT_NAME_2); // populate default name. + } + } + + Plugin_167_init = false; // Force device setup next time + success = true; + break; + } + + + case PLUGIN_INIT: + { + // this case defines code to be executed when the plugin is initialised + // This will fail if the set to be first taskindex is no longer enabled + + if (P167_SEN_FIRST == event->TaskIndex) // If first SEN5x, config available + { + if (Plugin_167_SEN != nullptr) + { + delete Plugin_167_SEN; + Plugin_167_SEN = nullptr; + } + + Plugin_167_SEN = new (std::nothrow) P167_data_struct(); + + if (Plugin_167_SEN != nullptr) + { + Plugin_167_SEN->setupModel(P167_MODEL); + Plugin_167_SEN->setupDevice(P167_I2C_ADDRESS); + if(P167_MODEL==0) + { + Plugin_167_SEN->setupMonPin(P167_MON_SCL_PIN); + pinMode(P167_MON_SCL_PIN, INPUT_PULLUP); + attachInterrupt(P167_MON_SCL_PIN, Plugin_167_interrupt, RISING); + } + Plugin_167_SEN->reset(); + } + } + + //UserVar[event->BaseVarIndex] = NAN; + //UserVar[event->BaseVarIndex + 1] = NAN; + //UserVar[event->BaseVarIndex + 2] = NAN; + //UserVar[event->BaseVarIndex + 3] = NAN; + UserVar.setFloat(event->BaseVarIndex, 0, NAN); + UserVar.setFloat(event->BaseVarIndex, 1, NAN); + UserVar.setFloat(event->BaseVarIndex, 2, NAN); + UserVar.setFloat(event->BaseVarIndex, 3, NAN); + + success = true; + Plugin_167_init = true; + + break; + } + + + case PLUGIN_EXIT: + { + if (P167_SEN_FIRST == event->TaskIndex) // If first SEN5x, config available + { + if (Plugin_167_SEN != nullptr) + { + if(P167_MODEL==0) + { + Plugin_167_SEN->disableInterrupt_monpin(); + } + delete Plugin_167_SEN; + Plugin_167_SEN = nullptr; + } + } + + success = true; + break; + } + + + case PLUGIN_READ: + { + // code to be executed to read data + // It is executed according to the delay configured on the device configuration page, only once + + if(event->TaskIndex!=P167_SEN_FIRST) + { + //All the DATA are in the first task of IKEA_Vindstyrka + //so all you have to do is to load this data in the current taskindex data + initPluginTaskData(event->TaskIndex, getPluginTaskData(P167_SEN_FIRST) ); + } + + if (nullptr != Plugin_167_SEN) + { + if (Plugin_167_SEN->inError()) + { + //UserVar[event->BaseVarIndex] = NAN; + //UserVar[event->BaseVarIndex + 1] = NAN; + //UserVar[event->BaseVarIndex + 2] = NAN; + //UserVar[event->BaseVarIndex + 3] = NAN; + UserVar.setFloat(event->BaseVarIndex, 0, NAN); + UserVar.setFloat(event->BaseVarIndex, 1, NAN); + UserVar.setFloat(event->BaseVarIndex, 2, NAN); + UserVar.setFloat(event->BaseVarIndex, 3, NAN); + addLog(LOG_LEVEL_ERROR, F("Vindstyrka / SEN5X: in Error!")); + } + else + { + if(event->TaskIndex==P167_SEN_FIRST) + { + Plugin_167_SEN->startMeasurements(); // getting ready for another read cycle + } + + //UserVar[event->BaseVarIndex] = Plugin_167_SEN->getRequestedValue(P167_QUERY1); + //UserVar[event->BaseVarIndex + 1] = Plugin_167_SEN->getRequestedValue(P167_QUERY2); + //UserVar[event->BaseVarIndex + 2] = Plugin_167_SEN->getRequestedValue(P167_QUERY3); + //UserVar[event->BaseVarIndex + 3] = Plugin_167_SEN->getRequestedValue(P167_QUERY4); + UserVar.setFloat(event->BaseVarIndex, 0, Plugin_167_SEN->getRequestedValue(P167_QUERY1)); + UserVar.setFloat(event->BaseVarIndex, 1, Plugin_167_SEN->getRequestedValue(P167_QUERY2)); + UserVar.setFloat(event->BaseVarIndex, 2, Plugin_167_SEN->getRequestedValue(P167_QUERY3)); + UserVar.setFloat(event->BaseVarIndex, 3, Plugin_167_SEN->getRequestedValue(P167_QUERY4)); + } + } + + success = true; + break; + } + + + case PLUGIN_ONCE_A_SECOND: + { + // code to be executed once a second. Tasks which do not require fast response can be added here + success = true; + } + + + case PLUGIN_TEN_PER_SECOND: + { + // code to be executed 10 times per second. Tasks which require fast response can be added here + // be careful on what is added here. Heavy processing will result in slowing the module down! + success = true; + } + + + case PLUGIN_FIFTY_PER_SECOND: + { + // code to be executed 10 times per second. Tasks which require fast response can be added here + // be careful on what is added here. Heavy processing will result in slowing the module down! + if(event->TaskIndex==P167_SEN_FIRST) + { + if (nullptr != Plugin_167_SEN) + { + Plugin_167_SEN->monitorSCL(); // Vind / SEN5X FSM evaluation + Plugin_167_SEN->update(); + } + } + success = true; + } + } // switch + + return success; +} // function + + + +/// @brief +/// @param query +/// @return +const __FlashStringHelper* p167_getQueryString(uint8_t query) +{ + switch(query) + { + case 0: return F("Temperature (C)"); + case 1: return F("Humidity (% RH)"); + case 2: return F("tVOC (VOC index)"); + case 3: return F("NOx (NOx index)"); + case 4: return F("PM 1.0 (ug/m3)"); + case 5: return F("PM 2.5 (ug/m3)"); + case 6: return F("PM 4.0 (ug/m3)"); + case 7: return F("PM 10.0 (ug/m3)"); + case 8: return F("DewPoint (C)"); + } + return F(""); +} + +/// @brief +/// @param query +/// @return +const __FlashStringHelper* p167_getQueryValueString(uint8_t query) +{ + switch(query) + { + case 0: return F("Temperature"); + case 1: return F("Humidity"); + case 2: return F("tVOC"); + case 3: return F("NOx"); + case 4: return F("PM1p0"); + case 5: return F("PM2p5"); + case 6: return F("PM4p0"); + case 7: return F("PM10p0"); + case 8: return F("DewPoint"); + } + return F(""); +} + + +// When using interrupts we have to call the library entry point +// whenever an interrupt is triggered +void IRAM_ATTR Plugin_167_interrupt() +{ + //addLog(LOG_LEVEL_ERROR, F("********* SEN5X: interrupt apear!")); + if (Plugin_167_SEN) + { + Plugin_167_SEN->checkPin_interrupt(); + } +} + + + +#endif //USES_P167 \ No newline at end of file diff --git a/src/src/DataStructs/EthernetEventData.cpp b/src/src/DataStructs/EthernetEventData.cpp index 9699e0f8d..008320e9e 100644 --- a/src/src/DataStructs/EthernetEventData.cpp +++ b/src/src/DataStructs/EthernetEventData.cpp @@ -3,6 +3,7 @@ #if FEATURE_ETHERNET #include "../ESPEasyCore/ESPEasy_Log.h" +#include "../Globals/Settings.h" #include "../Helpers/Networking.h" #include @@ -176,23 +177,21 @@ void EthernetEventData_t::markDisconnect() { } lastConnectMoment.clear(); processedDisconnect = false; +#if ESP_IDF_VERSION_MAJOR >= 5 + WiFi.STA.setDefault(); +#endif } void EthernetEventData_t::markConnected() { lastConnectMoment.setNow(); processedConnect = false; +#if ESP_IDF_VERSION_MAJOR >= 5 + ETH.setDefault(); +#endif + #if FEATURE_USE_IPV6 - ETH.enableIPv6(true); - // workaround for the race condition in LWIP, see https://github.com/espressif/arduino-esp32/pull/9016#discussion_r1451774885 - { - uint32_t i = 5; // try 5 times only - while (esp_netif_create_ip6_linklocal(get_esp_interface_netif(ESP_IF_ETH)) != ESP_OK) { - delay(1); - if (i-- == 0) { -// addLog(LOG_LEVEL_ERROR, ">>>> HELP"); - break; - } - } + if (Settings.EnableIPv6()) { + ETH.enableIPv6(true); } #endif } diff --git a/src/src/DataStructs/FactoryDefault_WiFi_NVS.cpp b/src/src/DataStructs/FactoryDefault_WiFi_NVS.cpp index 6b40da517..b97559841 100644 --- a/src/src/DataStructs/FactoryDefault_WiFi_NVS.cpp +++ b/src/src/DataStructs/FactoryDefault_WiFi_NVS.cpp @@ -28,6 +28,7 @@ void FactoryDefault_WiFi_NVS::fromSettings() { bits.WaitWiFiConnect = Settings.WaitWiFiConnect(); bits.SDK_WiFi_autoreconnect = Settings.SDK_WiFi_autoreconnect(); bits.HiddenSSID_SlowConnectPerBSSID = Settings.HiddenSSID_SlowConnectPerBSSID(); + bits.EnableIPv6 = Settings.EnableIPv6(); } void FactoryDefault_WiFi_NVS::applyToSettings() const { @@ -43,6 +44,7 @@ void FactoryDefault_WiFi_NVS::applyToSettings() const { Settings.WaitWiFiConnect(bits.WaitWiFiConnect); Settings.SDK_WiFi_autoreconnect(bits.SDK_WiFi_autoreconnect); Settings.HiddenSSID_SlowConnectPerBSSID(bits.HiddenSSID_SlowConnectPerBSSID); + Settings.EnableIPv6(bits.EnableIPv6); } struct FactoryDefault_WiFi_NVS_securityPrefs { diff --git a/src/src/DataStructs/FactoryDefault_WiFi_NVS.h b/src/src/DataStructs/FactoryDefault_WiFi_NVS.h index f184abdd7..59a8d3b92 100644 --- a/src/src/DataStructs/FactoryDefault_WiFi_NVS.h +++ b/src/src/DataStructs/FactoryDefault_WiFi_NVS.h @@ -40,8 +40,9 @@ private: uint64_t WaitWiFiConnect : 1; uint64_t SDK_WiFi_autoreconnect : 1; uint64_t HiddenSSID_SlowConnectPerBSSID : 1; + uint64_t EnableIPv6 : 1; - uint64_t unused : 52; + uint64_t unused : 51; } bits; uint64_t data{}; diff --git a/src/src/DataStructs/NodeStruct.cpp b/src/src/DataStructs/NodeStruct.cpp index 0bc543662..9cd127898 100644 --- a/src/src/DataStructs/NodeStruct.cpp +++ b/src/src/DataStructs/NodeStruct.cpp @@ -62,7 +62,9 @@ bool NodeStruct::validate(const IPAddress& remoteIP) { #if FEATURE_USE_IPV6 // Check if we're in the same global subnet - if (hasIPv6_mac_based_link_global && remoteIP.type() == IPv6) { + if (Settings.EnableIPv6() && + hasIPv6_mac_based_link_global && + remoteIP.type() == IPv6) { const IPAddress this_global = NetworkGlobalIP6(); // Check first 64 bit to see if we're in the same global scope for (int i = 0; i < 8 && hasIPv6_mac_based_link_global; ++i) { @@ -151,7 +153,7 @@ IPAddress NodeStruct::IP() const { #if FEATURE_USE_IPV6 IPAddress NodeStruct::IPv6_link_local(bool stripZone) const { - if (hasIPv6_mac_based_link_local) { + if (Settings.EnableIPv6() && hasIPv6_mac_based_link_local) { // Base IPv6 on MAC address IPAddress ipv6; if (IPv6_link_local_from_MAC(sta_mac, ipv6)) { @@ -166,7 +168,7 @@ IPAddress NodeStruct::IPv6_link_local(bool stripZone) const IPAddress NodeStruct::IPv6_global() const { - if (hasIPv6_mac_based_link_global) { + if (Settings.EnableIPv6() && hasIPv6_mac_based_link_global) { // Base IPv6 on MAC address IPAddress ipv6; if (IPv6_global_from_MAC(sta_mac, ipv6)) { @@ -177,6 +179,7 @@ IPAddress NodeStruct::IPv6_global() const } bool NodeStruct::hasIPv6() const { + if (!Settings.EnableIPv6()) return false; return hasIPv6_mac_based_link_local || hasIPv6_mac_based_link_global; } diff --git a/src/src/DataStructs/SettingsStruct.h b/src/src/DataStructs/SettingsStruct.h index 1fc8af909..dd0b0a8c4 100644 --- a/src/src/DataStructs/SettingsStruct.h +++ b/src/src/DataStructs/SettingsStruct.h @@ -188,6 +188,9 @@ class SettingsStruct_tmpl bool HiddenSSID_SlowConnectPerBSSID() const { return !VariousBits_2.HiddenSSID_SlowConnectPerBSSID; } void HiddenSSID_SlowConnectPerBSSID(bool value) { VariousBits_2.HiddenSSID_SlowConnectPerBSSID = !value; } + bool EnableIPv6() const { return !VariousBits_2.EnableIPv6; } + void EnableIPv6(bool value) { VariousBits_2.EnableIPv6 = !value; } + // Use Espressif's auto reconnect. bool SDK_WiFi_autoreconnect() const { return VariousBits_2.SDK_WiFi_autoreconnect; } void SDK_WiFi_autoreconnect(bool value) { VariousBits_2.SDK_WiFi_autoreconnect = value; } @@ -519,7 +522,7 @@ public: uint32_t SDK_WiFi_autoreconnect : 1; // Bit 01 uint32_t DisableRulesCodeCompletion : 1; // Bit 02 uint32_t HiddenSSID_SlowConnectPerBSSID : 1; // Bit 03 // inverted - uint32_t unused_04 : 1; // Bit 04 + uint32_t EnableIPv6 : 1; // Bit 04 // inverted uint32_t unused_05 : 1; // Bit 05 uint32_t unused_06 : 1; // Bit 06 uint32_t unused_07 : 1; // Bit 07 diff --git a/src/src/DataStructs/WiFiEventData.cpp b/src/src/DataStructs/WiFiEventData.cpp index f84cdb8f4..48906d5dc 100644 --- a/src/src/DataStructs/WiFiEventData.cpp +++ b/src/src/DataStructs/WiFiEventData.cpp @@ -3,6 +3,7 @@ #include "../ESPEasyCore/ESPEasy_Log.h" #include "../Globals/RTC.h" +#include "../Globals/Settings.h" #include "../Globals/WiFi_AP_Candidates.h" #include "../Helpers/ESPEasy_Storage.h" @@ -236,16 +237,8 @@ void WiFiEventData_t::markConnected(const String& ssid, const uint8_t bssid[6], } } #if FEATURE_USE_IPV6 - WiFi.enableIPv6(true); - // workaround for the race condition in LWIP, see https://github.com/espressif/arduino-esp32/pull/9016#discussion_r1451774885 - { - uint32_t i = 5; // try 5 times only - while (esp_netif_create_ip6_linklocal(get_esp_interface_netif(ESP_IF_WIFI_STA)) != ESP_OK) { - delay(1); - if (i-- == 0) { - break; - } - } + if (Settings.EnableIPv6()) { + WiFi.enableIPv6(true); } #endif } diff --git a/src/src/DataStructs_templ/SettingsStruct.cpp b/src/src/DataStructs_templ/SettingsStruct.cpp index 3fdb3357f..891f70435 100644 --- a/src/src/DataStructs_templ/SettingsStruct.cpp +++ b/src/src/DataStructs_templ/SettingsStruct.cpp @@ -882,24 +882,24 @@ spi_host_device_t SettingsStruct_tmpl::getSPI_host() const switch (SPI_selection) { case SPI_Options_e::Vspi_Fspi: { - #if CONFIG_IDF_TARGET_ESP32 - return static_cast(VSPI); + #if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 + return static_cast(FSPI_HOST); #else - return static_cast(FSPI); + return static_cast(VSPI_HOST); #endif } #ifdef ESP32_CLASSIC case SPI_Options_e::Hspi: { - return static_cast(HSPI); + return static_cast(HSPI_HOST); } #endif case SPI_Options_e::UserDefined: { - #if CONFIG_IDF_TARGET_ESP32 - return static_cast(VSPI); + #if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 + return static_cast(FSPI_HOST); #else - return static_cast(FSPI); + return static_cast(VSPI_HOST); #endif } case SPI_Options_e::None: @@ -908,10 +908,10 @@ spi_host_device_t SettingsStruct_tmpl::getSPI_host() const } #if ESP_IDF_VERSION_MAJOR < 5 - #if CONFIG_IDF_TARGET_ESP32 - return static_cast(VSPI); + #if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 + return static_cast(FSPI_HOST); #else - return static_cast(FSPI); + return static_cast(VSPI_HOST); #endif #else return spi_host_device_t::SPI_HOST_MAX; diff --git a/src/src/ESPEasyCore/ESPEasyEth.cpp b/src/src/ESPEasyCore/ESPEasyEth.cpp index ab0da4168..5add9a198 100644 --- a/src/src/ESPEasyCore/ESPEasyEth.cpp +++ b/src/src/ESPEasyCore/ESPEasyEth.cpp @@ -169,7 +169,9 @@ bool ETHConnectRelaxed() { (eth_clock_mode_t)Settings.ETH_Clock_Mode); #else #if FEATURE_USE_IPV6 - ETH.enableIPv6(true); + if (Settings.EnableIPv6()) { + ETH.enableIPv6(true); + } #endif if (isSPI_EthernetType(Settings.ETH_Phy_Type)) { diff --git a/src/src/ESPEasyCore/ESPEasyEth_ProcessEvent.cpp b/src/src/ESPEasyCore/ESPEasyEth_ProcessEvent.cpp index 75e86eb09..50e35132c 100644 --- a/src/src/ESPEasyCore/ESPEasyEth_ProcessEvent.cpp +++ b/src/src/ESPEasyCore/ESPEasyEth_ProcessEvent.cpp @@ -17,6 +17,7 @@ # include "../Globals/NetworkState.h" # include "../Globals/Settings.h" +# include "../Helpers/LongTermTimer.h" # include "../Helpers/Network.h" # include "../Helpers/Networking.h" # include "../Helpers/PeriodicalActions.h" @@ -164,14 +165,19 @@ void processEthernetGotIP() { IPAddress dns0 = ETH.dnsIP(0); IPAddress dns1 = ETH.dnsIP(1); const LongTermTimer::Duration dhcp_duration = EthEventData.lastConnectMoment.timeDiff(EthEventData.lastGetIPmoment); + #if ESP_IDF_VERSION_MAJOR >= 5 + const bool mustRequestDHCP = (!dns0 && !dns1) && !ethUseStaticIP(); + #endif - if (!dns0 && !dns1) { - addLog(LOG_LEVEL_ERROR, F("ETH : No DNS server received via DHCP, use cached DNS IP")); - setDNS(0, EthEventData.dns0_cache); - setDNS(1, EthEventData.dns1_cache); - } else { - EthEventData.dns0_cache = dns0; - EthEventData.dns1_cache = dns1; + if (!ethUseStaticIP()) { + if (!dns0 && !dns1) { + addLog(LOG_LEVEL_ERROR, F("ETH : No DNS server received via DHCP, use cached DNS IP")); + if (EthEventData.dns0_cache) setDNS(0, EthEventData.dns0_cache); + if (EthEventData.dns1_cache) setDNS(1, EthEventData.dns1_cache); + } else { + EthEventData.dns0_cache = dns0; + EthEventData.dns1_cache = dns1; + } } if (loglevelActiveFor(LOG_LEVEL_INFO)) @@ -244,6 +250,14 @@ void processEthernetGotIP() { logConnectionStatus(); EthEventData.processedGotIP = true; +#if ESP_IDF_VERSION_MAJOR >= 5 + if (mustRequestDHCP /*&& EthEventData.lastConnectMoment.millisPassedSince() < 10000*/) { + // FIXME TD-er: Must add some check other than fixed timeout here to not constantly make DHCP requests. + // Force new DHCP request. + ETH.config(); + } +#endif + EthEventData.setEthGotIP(); CheckRunningServices(); } diff --git a/src/src/ESPEasyCore/ESPEasyNetwork.cpp b/src/src/ESPEasyCore/ESPEasyNetwork.cpp index 8a3b05959..addcb54fe 100644 --- a/src/src/ESPEasyCore/ESPEasyNetwork.cpp +++ b/src/src/ESPEasyCore/ESPEasyNetwork.cpp @@ -46,6 +46,9 @@ void setNetworkMedium(NetworkMedium_t new_medium) { // ETH.end(); if (new_medium == NetworkMedium_t::WIFI) { WiFiEventData.clearAll(); +#if ESP_IDF_VERSION_MAJOR >= 5 + WiFi.STA.setDefault(); +#endif } #endif break; @@ -53,6 +56,11 @@ void setNetworkMedium(NetworkMedium_t new_medium) { WiFiEventData.timerAPoff.setMillisFromNow(WIFI_AP_OFF_TIMER_DURATION); WiFiEventData.timerAPstart.clear(); if (new_medium == NetworkMedium_t::Ethernet) { +#if ESP_IDF_VERSION_MAJOR >= 5 +#if FEATURE_ETHERNET + ETH.setDefault(); +#endif +#endif WifiDisconnect(); } break; diff --git a/src/src/ESPEasyCore/ESPEasyWiFiEvent.cpp b/src/src/ESPEasyCore/ESPEasyWiFiEvent.cpp index dd70788ac..4390c50e7 100644 --- a/src/src/ESPEasyCore/ESPEasyWiFiEvent.cpp +++ b/src/src/ESPEasyCore/ESPEasyWiFiEvent.cpp @@ -28,8 +28,7 @@ #ifdef ESP32 -void WiFi_Access_Static_IP::set_use_static_ip(bool enabled) { - _useStaticIp = enabled; +void setUseStaticIP(bool enabled) { } #endif // ifdef ESP32 @@ -37,16 +36,16 @@ void WiFi_Access_Static_IP::set_use_static_ip(bool enabled) { void WiFi_Access_Static_IP::set_use_static_ip(bool enabled) { _useStaticIp = enabled; } - -#endif // ifdef ESP8266 - - void setUseStaticIP(bool enabled) { WiFi_Access_Static_IP tmp_wifi; tmp_wifi.set_use_static_ip(enabled); } +#endif // ifdef ESP8266 + + + // ******************************************************************************** // Functions called on events. @@ -143,7 +142,12 @@ void WiFiEvent(WiFiEvent_t event, arduino_event_info_t info) { WiFiEventData.markDisconnect(static_cast(info.wifi_sta_disconnected.reason)); if (info.wifi_sta_disconnected.reason == WIFI_REASON_AUTH_EXPIRE) { // See: https://github.com/espressif/arduino-esp32/issues/8877#issuecomment-1807677897 + #if ESP_IDF_VERSION_MAJOR >= 5 + // FIXME TD-er: Should no longer be needed. + WiFi.STA._setStatus(WL_CONNECTION_LOST); + #else WiFiSTAClass::_setStatus(WL_CONNECTION_LOST); + #endif } #else WiFiEventData.markDisconnect(static_cast(info.disconnected.reason)); diff --git a/src/src/ESPEasyCore/ESPEasyWifi.cpp b/src/src/ESPEasyCore/ESPEasyWifi.cpp index 58ca747a8..a1a1340d2 100644 --- a/src/src/ESPEasyCore/ESPEasyWifi.cpp +++ b/src/src/ESPEasyCore/ESPEasyWifi.cpp @@ -494,7 +494,9 @@ void AttemptWiFiConnect() { const String key = WiFi_AP_CandidatesList::get_key(candidate.index); #if FEATURE_USE_IPV6 - WiFi.enableIPv6(true); + if (Settings.EnableIPv6()) { + WiFi.enableIPv6(true); + } #endif if ((Settings.HiddenSSID_SlowConnectPerBSSID() || !candidate.bits.isHidden) @@ -1396,7 +1398,7 @@ void setWifiMode(WiFiMode_t new_mode) { SetWiFiTXpower(); #endif if (WifiIsSTA(new_mode)) { - WiFi.setAutoConnect(Settings.SDK_WiFi_autoreconnect()); +// WiFi.setAutoConnect(Settings.SDK_WiFi_autoreconnect()); WiFi.setAutoReconnect(Settings.SDK_WiFi_autoreconnect()); } delay(100); // Must allow for some time to init. diff --git a/src/src/Helpers/ESPEasy_time.cpp b/src/src/Helpers/ESPEasy_time.cpp index bad0bba60..7302c3d98 100644 --- a/src/src/Helpers/ESPEasy_time.cpp +++ b/src/src/Helpers/ESPEasy_time.cpp @@ -304,9 +304,8 @@ unsigned long ESPEasy_time::now() { uint32_t localSystime = time_zone.toLocal(sysTime); breakTime(localSystime, local_tm); + calcSunRiseAndSet(timeSynced); if (timeSynced) { - calcSunRiseAndSet(); - if (loglevelActiveFor(LOG_LEVEL_INFO)) { addLog(LOG_LEVEL_INFO, strformat( F("Local time: %s"), @@ -451,7 +450,7 @@ bool ESPEasy_time::getNtpTime(double& unixTime_d) udp.endPacket(); - uint32_t beginWait = millis(); + const uint32_t beginWait = millis(); while (!timeOutReached(beginWait + 1000)) { int size = udp.parsePacket(); @@ -749,13 +748,19 @@ int ESPEasy_time::dayOfYear(int year, int month, int day) { return j - k + 1; } -void ESPEasy_time::calcSunRiseAndSet() { - int doy = dayOfYear(local_tm.tm_year, local_tm.tm_mon + 1, local_tm.tm_mday); - float eqt = equationOfTime(doy); - float dec = sunDeclination(doy); - float da = diurnalArc(dec, Settings.Latitude); - float rise = 12 - da - eqt; - float set = 12 + da - eqt; +void ESPEasy_time::calcSunRiseAndSet(bool timeSynced) { + if (!timeSynced && + (tsSet.tm_mday == local_tm.tm_mday)) { + // No need to recalculate if already calculated for this day + return; + } + + const int doy = dayOfYear(local_tm.tm_year, local_tm.tm_mon + 1, local_tm.tm_mday); + const float eqt = equationOfTime(doy); + const float dec = sunDeclination(doy); + const float da = diurnalArc(dec, Settings.Latitude); + const float rise = 12 - da - eqt; + const float set = 12 + da - eqt; tsRise.tm_hour = rise; tsRise.tm_min = (rise - static_cast(rise)) * 60.0f; @@ -766,7 +771,7 @@ void ESPEasy_time::calcSunRiseAndSet() { tsRise.tm_year = tsSet.tm_year = local_tm.tm_year; // Now apply the longitude - int secOffset_longitude = -1.0f * (Settings.Longitude / 15.0f) * 3600; + const int secOffset_longitude = -1.0f * (Settings.Longitude / 15.0f) * 3600; tsSet = addSeconds(tsSet, secOffset_longitude, false); tsRise = addSeconds(tsRise, secOffset_longitude, false); @@ -860,9 +865,9 @@ bool ESPEasy_time::ExtRTC_get(uint32_t& unixtime) } if (unixtime != 0) { - String log = F("ExtRTC: Read external time source: "); - log += unixtime; - addLogMove(LOG_LEVEL_INFO, log); + addLogMove(LOG_LEVEL_INFO, concat( + F("ExtRTC: Read external time source: "), + unixtime)); return true; } addLog(LOG_LEVEL_ERROR, F("ExtRTC: Cannot get time from external time source")); diff --git a/src/src/Helpers/ESPEasy_time.h b/src/src/Helpers/ESPEasy_time.h index e2f32376b..20c0808e7 100644 --- a/src/src/Helpers/ESPEasy_time.h +++ b/src/src/Helpers/ESPEasy_time.h @@ -176,7 +176,7 @@ private: int month, int day); - void calcSunRiseAndSet(); + void calcSunRiseAndSet(bool timeSynced); struct tm getSunRise(int secOffset) const; struct tm getSunSet(int secOffset) const; diff --git a/src/src/Helpers/Hardware.cpp b/src/src/Helpers/Hardware.cpp index 19c9dba5d..6a9833851 100644 --- a/src/src/Helpers/Hardware.cpp +++ b/src/src/Helpers/Hardware.cpp @@ -114,6 +114,10 @@ # include "../Helpers/Hardware_ADC_cali.h" +#if FEATURE_ETHERNET +#include +#endif + #endif // ifdef ESP32 diff --git a/src/src/Helpers/Improv_Helper.cpp b/src/src/Helpers/Improv_Helper.cpp index 66b7eeb64..c646fa087 100644 --- a/src/src/Helpers/Improv_Helper.cpp +++ b/src/src/Helpers/Improv_Helper.cpp @@ -17,13 +17,14 @@ void OnImprovError(ImprovTypes::Error error) String log = F("IMPROV : "); switch (error) { + case ImprovTypes::Error::ERROR_NONE: return; case ImprovTypes::Error::ERROR_INVALID_RPC: log += F("Invalid RPC"); break; case ImprovTypes::Error::ERROR_UNKNOWN_RPC: log += F("Unkown RPC"); break; case ImprovTypes::Error::ERROR_UNABLE_TO_CONNECT: log += F("Unable to connect"); break; case ImprovTypes::Error::ERROR_NOT_AUTHORIZED: log += F("Not Authorized"); break; + case ImprovTypes::Error::ERROR_INVALID_CHECKSUM: log += F("Invalid Checksum"); break; + case ImprovTypes::Error::ERROR_EMPTY_SSID: log += F("Empty SSID"); break; case ImprovTypes::Error::ERROR_UNKNOWN: log += F("Unknown"); break; - default: - return; } addLogMove(LOG_LEVEL_ERROR, log); } @@ -34,16 +35,28 @@ void OnImprovConnected(const char *ssid, const char *password) safe_strncpy( SecuritySettings.WifiSSID, ssid, - sizeof(SecuritySettings.WifiSSID2)); + sizeof(SecuritySettings.WifiSSID)); safe_strncpy( SecuritySettings.WifiKey, password, sizeof(SecuritySettings.WifiKey)); - SaveSettings(); + SaveSecuritySettings(); } bool OnImprovESPEasyConnectWiFi(const char *ssid, const char *password) { +// addLog(LOG_LEVEL_INFO, strformat(F("IMPROV WiFi connect: SSID: %s, Pass: %s"), ssid, password)); +/* + safe_strncpy( + SecuritySettings.WifiSSID, + ssid, + sizeof(SecuritySettings.WifiSSID)); + safe_strncpy( + SecuritySettings.WifiKey, + password, + sizeof(SecuritySettings.WifiKey)); + */ + return false; } @@ -56,7 +69,7 @@ void Improv_Helper_t::init() _improv.onImprovConnected(OnImprovConnected); // FIXME TD-er: Implement callback to use ESPEasy functions to connect to WiFi - // _improv.setCustomTryConnectToWiFi(OnImprovESPEasyConnectWiFi); +// _improv.setCustomTryConnectToWiFi(OnImprovESPEasyConnectWiFi); String firmwareName = get_binary_filename(); const String buildString = getSystemBuildString(); @@ -111,7 +124,29 @@ bool Improv_Helper_t::handle(uint8_t b, Stream *serialForWrite) _tmpbuffer.push_back(b); - switch (_improv.handleSerial(b, serialForWrite)) { + const ImprovTypes::ParseState state = _improv.handleSerial(b, serialForWrite); + +#ifndef BUILD_NO_DEBUG + + if (loglevelActiveFor(LOG_LEVEL_DEBUG) && + state != ImprovTypes::ParseState::VALID_INCOMPLETE) + { + String log = F("IMPROVDEBUG: "); + for (auto it = _tmpbuffer.begin(); it != _tmpbuffer.end(); ++it) { + if (isAlphaNumeric(*it)) + log += static_cast(*it); + else { + log += strformat(F("_%d_"), *it); + } + } + if (state == ImprovTypes::ParseState::INVALID) { + log += F(" (invalid)"); + } + addLog(LOG_LEVEL_DEBUG, log); + } +#endif + + switch (state) { case ImprovTypes::ParseState::VALID_INCOMPLETE: _mustDumpBuffer = false; return true; diff --git a/src/src/Helpers/SerialWriteBuffer.cpp b/src/src/Helpers/SerialWriteBuffer.cpp index f81b24766..750a6c4bb 100644 --- a/src/src/Helpers/SerialWriteBuffer.cpp +++ b/src/src/Helpers/SerialWriteBuffer.cpp @@ -67,8 +67,6 @@ size_t SerialWriteBuffer_t::write(Stream& stream, size_t nrBytesToWrite) } if (nrBytesToWrite > 0) { - // FIXME TD-er: Work-around for bug in HWCDC when writing exactly the amount of free bytes in the buffer. -// --nrBytesToWrite; if (nrBytesToWrite > bufferSize) { nrBytesToWrite = bufferSize; } @@ -82,29 +80,32 @@ size_t SerialWriteBuffer_t::write(Stream& stream, size_t nrBytesToWrite) bool done = false; - for (; tmpBufferUsed < sizeof(tmpBuffer) && - !done && - it != _buffer.end(); ) { + for (; tmpBufferUsed < sizeof(tmpBuffer) && + !done && + it != _buffer.end();) { tmpBuffer[tmpBufferUsed] = (uint8_t)(*it); - if (*it == '\n' || - tmpBufferUsed >= nrBytesToWrite) { + + if ((*it == '\n') || + (tmpBufferUsed >= nrBytesToWrite)) { done = true; } ++tmpBufferUsed; ++it; } -// done = false; + // done = false; const size_t written = (tmpBufferUsed == 0) ? 0 : stream.write(tmpBuffer, tmpBufferUsed); if (written < tmpBufferUsed) { done = true; } + for (size_t i = 0; i < written; ++i) { _buffer.pop_front(); --nrBytesToWrite; ++bytesWritten; } + if (done) { return bytesWritten; } diff --git a/src/src/Helpers/StringProvider.cpp b/src/src/Helpers/StringProvider.cpp index 5b869388c..7924a30c4 100644 --- a/src/src/Helpers/StringProvider.cpp +++ b/src/src/Helpers/StringProvider.cpp @@ -194,6 +194,10 @@ const __FlashStringHelper * getLabel(LabelType::Enum label) { case LabelType::CONNECT_HIDDEN_SSID: return F("Include Hidden SSID"); case LabelType::HIDDEN_SSID_SLOW_CONNECT: return F("Hidden SSID Slow Connect"); case LabelType::SDK_WIFI_AUTORECONNECT: return F("Enable SDK WiFi Auto Reconnect"); +#if FEATURE_USE_IPV6 + case LabelType::ENABLE_IPV6: return F("Enable IPv6"); +#endif + case LabelType::BUILD_DESC: return F("Build"); case LabelType::GIT_BUILD: return F("Git Build"); @@ -509,6 +513,10 @@ String getValue(LabelType::Enum label) { case LabelType::CONNECT_HIDDEN_SSID: return jsonBool(Settings.IncludeHiddenSSID()); case LabelType::HIDDEN_SSID_SLOW_CONNECT: return jsonBool(Settings.HiddenSSID_SlowConnectPerBSSID()); case LabelType::SDK_WIFI_AUTORECONNECT: return jsonBool(Settings.SDK_WiFi_autoreconnect()); +#if FEATURE_USE_IPV6 + case LabelType::ENABLE_IPV6: return jsonBool(Settings.EnableIPv6()); +#endif + case LabelType::BUILD_DESC: return getSystemBuildString(); case LabelType::GIT_BUILD: diff --git a/src/src/Helpers/StringProvider.h b/src/src/Helpers/StringProvider.h index 0a487af2b..da8d33187 100644 --- a/src/src/Helpers/StringProvider.h +++ b/src/src/Helpers/StringProvider.h @@ -142,6 +142,9 @@ struct LabelType { HIDDEN_SSID_SLOW_CONNECT, CONNECT_HIDDEN_SSID, SDK_WIFI_AUTORECONNECT, +#if FEATURE_USE_IPV6 + ENABLE_IPV6, +#endif BUILD_DESC, GIT_BUILD, diff --git a/src/src/PluginStructs/P167_data_struct.cpp b/src/src/PluginStructs/P167_data_struct.cpp new file mode 100644 index 000000000..c9bc7d5a9 --- /dev/null +++ b/src/src/PluginStructs/P167_data_struct.cpp @@ -0,0 +1,1402 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// P167 device class for IKEA Vindstyrka SEN54 temperature , humidity and air quality sensors +// See datasheet https://sensirion.com/media/documents/6791EFA0/62A1F68F/Sensirion_Datasheet_Environmental_Node_SEN5x.pdf +// and info about extra request https://sensirion.com/media/documents/2B6FC1F3/6409E74A/PS_AN_Read_RHT_VOC_and_NOx_RAW_signals_D1.pdf +// Based upon code from Rob Tillaart, Viktor Balint, https://github.com/RobTillaart/SHT2x +// Rewritten and adapted for ESPeasy by andibaciu +// 2023-06-20 Initial version by andibaciu +////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../PluginStructs/P167_data_struct.h" +#include "../ESPEasyCore/ESPEasyGPIO.h" + +#include + + #ifndef CORE_POST_3_0_0 + #ifdef ESP8266 + #define IRAM_ATTR ICACHE_RAM_ATTR + #endif + #endif + +#ifdef USES_P167 + + +#define P167_START_MEAS 0x0021 // Start measurement command +#define P167_START_MEAS_RHT_GAS 0x0037 // Start measurement RHT/Gas command +#define P167_STOP_MEAS 0x0104 // Stop measurement command +#define P167_READ_DATA_RDY_FLAG 0x0202 // Read Data Ready Flag command +#define P167_READ_MEAS 0x03C4 // Read measurement command +#define P167_R_W_TEMP_COMP_PARAM 0x60B2 // Read/Write Temperature Compensation Parameters command +#define P167_R_W_TWARM_START_PARAM 0x60C6 // Read/Write Warm Start Parameters command +#define P167_R_W_VOC_ALG_PARAM 0x60D0 // Read/Write VOC Algorithm Tuning Parameters command +#define P167_R_W_NOX_ALG_PARAM 0x60E1 // Read/Write NOx Algorithm Tuning Parameters command +#define P167_R_W_RH_T_ACC_Mode 0x60F7 // Read/Write RH/T Acceleration Mode command +#define P167_R_W_VOC_ALG_STATE 0x6181 // Read/Write VOC Algorithm State command +#define P167_START_FAN_CLEAN 0x5607 // Start fan cleaning command +#define P167_R_W_AUTOCLEN_PARAM 0x8004 // Read/Write Autocleaning Interval Parameters command +#define P167_READ_PROD_NAME 0xD014 // Read Product Name command +#define P167_READ_SERIAL_NO 0xD033 // Read Serial Number command +#define P167_READ_FIRM_VER 0xD100 // Read Firmware Version command +#define P167_READ_DEVICE_STATUS 0xD206 // Read Device Status command +#define P167_CLEAR_DEVICE_STATUS 0xD210 // Clear Device Status command +#define P167_RESET_DEVICE 0xD304 // Reset Device command +#define P167_READ_RAW_MEAS 0x03D2 // Read relative humidity and temperature + // which are not compensated for temperature offset, and the + // VOC and NOx raw signals (proportional to the logarithm of the + // resistance of the MOX layer). It returns 4x2 bytes (+ 1 CRC + // byte each) command (see second datasheet fron header for more info) +#define P167_READ_RAW_MYS_MEAS 0x03F5 // Read relative humidity and temperature and MYSTERY word (probably signed offset temperature) + + +#define P167_START_MEAS_DELAY 50 // Timeout value for start measurement command [ms] +#define P167_START_MEAS_RHT_GAS_DELAY 50 // Timeout value for start measurement RHT/Gas command [ms] +#define P167_STOP_MEAS_DELAY 200 // Timeout value for start measurement command [ms] +#define P167_READ_DATA_RDY_FLAG_DELAY 20 // Timeout value for read data ready flag command [ms] +#define P167_READ_MEAS_DELAY 20 // Timeout value for read measurement command [ms] +#define P167_R_W_TEMP_COMP_PARAM_DELAY 20 // Timeout value for read/write temperature compensation parameters command [ms] +#define P167_R_W_WARM_START_PARAM_DELAY 20 // Timeout value for read/write warm start parameters command [ms] +#define P167_R_W_VOC_ALG_PARAM_DELAY 20 // Timeout value for read/write VOC algorithm tuning parameters command [ms] +#define P167_R_W_NOX_ALG_PARAM_DELAY 20 // Timeout value for read/write NOx algorithm tuning parameters command [ms] +#define P167_R_W_RH_T_ACC_MODE_DELAY 20 // Timeout value for read/write RH/T acceleration mode command [ms] +#define P167_R_W_VOC_ALG_STATE_DELAY 20 // Timeout value for read/write VOC algorithm State command [ms] +#define P167_START_FAN_CLEAN_DELAY 20 // Timeout value for start fan cleaning command [ms] +#define P167_R_W_AUTOCLEN_PARAM_DELAY 20 // Timeout value for read/write autoclean interval parameters command [ms] +#define P167_READ_PROD_NAME_DELAY 20 // Timeout value for read product name command [ms] +#define P167_READ_SERIAL_NO_DELAY 20 // Timeout value for read serial number command [ms] +#define P167_READ_FIRM_VER_DELAY 20 // Timeout value for read firmware version command [ms] +#define P167_READ_DEVICE_STATUS_DELAY 20 // Timeout value for read device status command [ms] +#define P167_CLEAR_DEVICE_STATUS_DELAY 20 // Timeout value for clear device status command [ms] +#define P167_RESET_DEVICE_DELAY 100 // Timeout value for reset device command [ms] +#define P167_READ_RAW_MEAS_DELAY 20 // Timeout value for read raw temp and humidity command [ms] + + +#define P167_MAX_RETRY 250 // Give up after amount of retries befoe going to error + + +#define SCL_MONITOR_PIN 13 //pin13 as monitor scl i2c + + +////////////////////////////////////////////////////////////////////////////////////////////////// +// +// PUBLIC +// +P167_data_struct::P167_data_struct() +{ + _errCount = 0; + + _Temperature = 0.0; + _rawTemperature = 0.0; + _mysTemperature = 0.0; + _Humidity = 0.0; + _rawHumidity = 0.0; + _mysHumidity = 0.0; + _DewPoint = 0.0; + + _tVOC = 0.0; + _rawtVOC = 0.0; + _NOx = 0.0; + _rawNOx = 0.0; + _mysOffset = 0.0; + _PM1p0 = 0.0; + _PM2p5 = 0.0; + _PM4p0 = 0.0; + _PM10p0 = 0.0; + + _devicestatus.val = (uint32_t)0; + + _readingerrcode = VIND_ERR_NO_ERROR; + _readingerrcount = 0; + _readingsuccesscount = 0; + + _model = 0; + _i2caddr = 0; + _monpin = 0; + + _state = P167_state::Uninitialized; + _eid_productname = F(""); + _eid_serialnumber = F(""); + _firmware = 0; + _last_action_started = 0; + _userreg = 0; +} + + +P167_data_struct::~P167_data_struct() +{ + // +} + +// Initialize/setup device properties +// Must be called at least once before oP167::Wairperating the device +bool P167_data_struct::setupDevice(uint8_t i2caddr) +{ + _i2caddr = i2caddr; + +#ifdef PLUGIN_167_DEBUG + if (loglevelActiveFor(LOG_LEVEL_INFO)) + { + String log = F("SEN5x: Setup with address= "); + log += formatToHex(_i2caddr); + addLog(LOG_LEVEL_INFO, log); + } +#endif + return true; +} + + +bool P167_data_struct::setupMonPin(uint8_t monpin) +{ + if (validGpio(monpin)) + { + _monpin = monpin; + pinMode(_monpin, INPUT_PULLUP); //declare monitoring pin as input with pullup's + //attachInterruptArg(digitalPinToInterrupt(_monpin), reinterpret_cast(checkPin), this, CHANGE); + //enableInterrupt_monpin(); + + #ifdef PLUGIN_167_DEBUG + if (loglevelActiveFor(LOG_LEVEL_INFO)) + { + String log = F("SEN5x: Setup I2C SCL monpin= "); + log += _monpin; + addLog(LOG_LEVEL_INFO, log); + } + #endif + return true; + } + else + return false; +} + + +void P167_data_struct::enableInterrupt_monpin(void) +{ + //attachInterruptArg(digitalPinToInterrupt(_monpin), reinterpret_cast(checkPin), this, CHANGE); +} + + +void P167_data_struct::disableInterrupt_monpin(void) +{ + //detachInterrupt(digitalPinToInterrupt(_monpin)); +} + +// Initialize/setup device properties +// Must be called at least once before oP167::Wairperating the device +bool P167_data_struct::setupModel(uint8_t model) +{ + _model = model; + +#ifdef PLUGIN_167_DEBUG + if (loglevelActiveFor(LOG_LEVEL_INFO)) + { + String log = F("SEN5x: Setup model= "); + log += String(_model); + addLog(LOG_LEVEL_INFO, log); + } +#endif + return true; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Evaluate FSM for data acquisition +// This is a state machine that is evaluated step by step by calling update() repetatively +// NOTE: Function is expected to run as critical section w.r.t. other provided functions +// This is typically met in ESPeasy plugin context when called from within the plugin +bool P167_data_struct::update() +{ + bool stable = false; // signals when a stable state is reached +#ifdef PLUGIN_167_DEBUG + P167_state oldState = _state; +#endif + + + if(statusMonitoring == false) + return stable; + + + switch(_state) + { + case P167_state::Uninitialized: + //we have to stop trying after a while + if (_errCount>P167_MAX_RETRY) + { + _state = P167_state::Error; + stable = true; + } + else if (I2C_wakeup(_i2caddr) != 0) // Try to access the I2C device + { + if (loglevelActiveFor(LOG_LEVEL_ERROR)) + { + String log = F("SEN5x : Not found at I2C address: "); + log += String(_i2caddr, HEX); + addLog(LOG_LEVEL_ERROR, log); + } + _errCount++; + } + else if (_model==0 ) //sensor is Vindstyrka and d'ont need to be reset + { + _errCount = 0; // Device is reachable and initialized, reset error counter + if (writeCmd(P167_READ_FIRM_VER)) // Issue a reset command + { + _state = P167_state::Read_firm_version; // Will take <20ms according to datasheet + _last_action_started = millis(); + } + } + else if (_model==1) + { + _errCount = 0; // Device is reachable and initialized, reset error counter + if (writeCmd(P167_RESET_DEVICE)) // Issue a reset command + { + _state = P167_state::Wait_for_reset; // Will take <20ms according to datasheet + _last_action_started = millis(); + } + } + break; + + case P167_state::Wait_for_reset: + if (timeOutReached(_last_action_started + P167_RESET_DEVICE_DELAY)) //we need to wait for the chip to reset + { + if (I2C_wakeup(_i2caddr) != 0) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _errCount = 0; // Device is reachable and initialized, reset error counter + if (writeCmd(P167_READ_FIRM_VER)) + { + _state = P167_state::Read_firm_version; // Will take <20ms according to datasheet + _last_action_started = millis(); + } + } + } + break; + + case P167_state::Read_firm_version: + if (timeOutReached(_last_action_started + P167_READ_FIRM_VER_DELAY)) + { + // Start read flag + if (!getFirmwareVersion()) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else if(!writeCmd(P167_READ_PROD_NAME)) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _last_action_started = millis(); + _state = P167_state::Read_prod_name; + } + } + break; + + case P167_state::Read_prod_name: + if (timeOutReached(_last_action_started + P167_READ_PROD_NAME_DELAY)) + { + // Start read flag + if (!getProductName()) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else if(!writeCmd(P167_READ_SERIAL_NO)) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _last_action_started = millis(); + _state = P167_state::Read_serial_no; + } + } + break; + + case P167_state::Read_serial_no: + if (timeOutReached(_last_action_started + P167_READ_SERIAL_NO_DELAY)) + { + // Start read flag + if (!getSerialNumber()) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else if(!writeCmd(P167_READ_SERIAL_NO)) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _last_action_started = millis(); + _state = P167_state::Initialized; + } + } + break; + + case P167_state::Write_user_reg: + _state = P167_state::Initialized; + break; + + case P167_state::Initialized: + // For now trigger the first read cycle automatically + //_state = P167_state::Ready; + break; + + case P167_state::Ready: + // Ready to execute a measurement cycle + if( _model==0 || _model==1 || _model==2) + { + // Start measuring data + if (!writeCmd(P167_START_MEAS)) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _last_action_started = millis(); + _state = P167_state::Wait_for_start_meas; + } + } + break; + + case P167_state::Wait_for_start_meas: + if (timeOutReached(_last_action_started + P167_START_MEAS_DELAY)) + { + // Start read flag + if (!writeCmd(P167_READ_DATA_RDY_FLAG)) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _last_action_started = millis(); + _state = P167_state::Wait_for_read_flag; + } + } + break; + + case P167_state::Wait_for_read_flag: + if (timeOutReached(_last_action_started + P167_READ_DATA_RDY_FLAG_DELAY)) + { + if(readDataRdyFlag()) + { + // Ready to execute a measurement cycle + if (!writeCmd(P167_READ_MEAS)) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _last_action_started = millis(); + _state = P167_state::Wait_for_read_meas; + } + } + else //Ready Flag NOT ok, so send again Start Measurement + { + // Start measuring data + if (!writeCmd(P167_START_MEAS)) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _last_action_started = millis(); + _state = P167_state::Wait_for_start_meas; + } + } + } + break; + + case P167_state::Wait_for_read_meas: + if (timeOutReached(_last_action_started + P167_READ_MEAS_DELAY)) + { + if (!readMeasValue()) // Read the previously measured temperature + { + _errCount++; + //_state = P167_state::Uninitialized; // Lost connection + _state = P167_state::cmdSTARTmeas; + } + else + { + if (!writeCmd(P167_READ_RAW_MEAS)) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _last_action_started = millis(); + _state = P167_state::Wait_for_read_raw_meas; + } + } + } + break; + + case P167_state::Wait_for_read_raw_meas: + //make sure we wait for the measurement to complete + if (timeOutReached(_last_action_started + P167_READ_RAW_MEAS_DELAY)) + { + if (!readMeasRawValue()) + { + _errCount++; + //_state = P167_state::Uninitialized; // Lost connection + _state = P167_state::cmdSTARTmeas; + } + else + { + if (!writeCmd(P167_READ_RAW_MYS_MEAS)) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _last_action_started = millis(); + _state = P167_state::Wait_for_read_raw_MYS_meas; + } + } + } + break; + + case P167_state::Wait_for_read_raw_MYS_meas: + //make sure we wait for the measurement to complete + if (timeOutReached(_last_action_started + P167_READ_RAW_MEAS_DELAY)) + { + if (!readMeasRawMYSValue()) + { + _errCount++; + //_state = P167_state::Uninitialized; // Lost connection + _state = P167_state::cmdSTARTmeas; + } + else + { + if (!writeCmd(P167_READ_DEVICE_STATUS)) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _last_action_started = millis(); + _state = P167_state::Wait_for_read_status; + } + calculateValue(); + stable = true; + } + } + break; + + case P167_state::Wait_for_read_status: + //make sure we wait for the measurement to complete + if (timeOutReached(_last_action_started + P167_READ_DEVICE_STATUS_DELAY)) + { + if (!readDeviceStatus()) + { + _errCount++; + //_state = P167_state::Uninitialized; // Lost connection + _state = P167_state::cmdSTARTmeas; + } + else + { + _last_action_started = millis(); + _state = P167_state::cmdSTARTmeas; + stable = true; + } + } + break; + + case P167_state::cmdSTARTmeas: + // Start measuring data + if(_model==0) + { + if (!writeCmd(P167_START_MEAS)) + { + _errCount++; + _state = P167_state::Uninitialized; // Retry + } + else + { + _last_action_started = millis(); + _state = P167_state::IDLE; + } + } + else + { + _state = P167_state::IDLE; + } + break; + + case P167_state::IDLE: + stepMonitoring = 1; + startMonitoringFlag = false; + if(!_errmeas && !_errmeasraw && !_errmeasrawmys) + _state = P167_state::New_Values_Available; + stable = true; + break; + + case P167_state::Error: + case P167_state::New_Values_Available: + //this state is used outside so all we need is to stay here + stable = true; + break; + + //Missing states (enum values) to be checked by the compiler + + } // switch + +#ifdef PLUGIN_167_DEBUG + if (_state != oldState) + { + if (loglevelActiveFor(LOG_LEVEL_INFO)) + { + String log = F("SEN5x : *** state transition "); + log += String((int)oldState); + log += F("-->"); + log += String((int)_state); + addLog(LOG_LEVEL_INFO, log); + } + } +#endif + return stable; +} + + +bool P167_data_struct::monitorSCL() +{ + if(_model==0) + { + if(startMonitoringFlag) + { + + if(stepMonitoring==1) + { + lastSCLLowTransitionMonitoringTime = monpinLastTransitionTime/1000; + if(millis() - lastSCLLowTransitionMonitoringTime < 100) + { + statusMonitoring = false; + return true; + } + else + { + lastSCLLowTransitionMonitoringTime = monpinLastTransitionTime/1000; + statusMonitoring = true; + stepMonitoring++; + } + } + + if(stepMonitoring==2) + { + if(millis() - lastSCLLowTransitionMonitoringTime < 100) + { + lastSCLLowTransitionMonitoringTime = monpinLastTransitionTime/1000; + statusMonitoring = false; + stepMonitoring = 1; + return true; + } + else if(millis() - lastSCLLowTransitionMonitoringTime > 700) + { + statusMonitoring = false; + stepMonitoring = 1; + startMonitoringFlag = false; + + //if _state not finish reading process then start from begining + if(_state >= P167_state::Wait_for_read_meas && _state < P167_state::New_Values_Available) + { + _state = P167_state::Ready; + } + return true; + } + else + { + //processing + } + } + } + monpinValuelast = monpinValue; + } + + if(_model == 1 || _model == 2) + { + statusMonitoring = true; + startMonitoringFlag = false; + stepMonitoring = 0; + } + + return true; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Returns the I2C connection state +// Note: based upon the FSM state without actual accessing the device +bool P167_data_struct::isConnected() const +{ + switch (_state) + { + case P167_state::Initialized: + case P167_state::Ready: + case P167_state::Wait_for_start_meas: + case P167_state::Wait_for_read_flag: + case P167_state::Wait_for_read_meas: + case P167_state::Wait_for_read_raw_meas: + case P167_state::Wait_for_read_raw_MYS_meas: + case P167_state::Wait_for_read_status: + case P167_state::cmdSTARTmeas: + case P167_state::New_Values_Available: + case P167_state::Read_firm_version: + case P167_state::Read_prod_name: + case P167_state::Read_serial_no: + case P167_state::Write_user_reg: + case P167_state::IDLE: + return true; + break; + case P167_state::Uninitialized: + case P167_state::Error: + case P167_state::Wait_for_reset: + return false; + break; + + //Missing states (enum values) to be checked by the compiler + } + return false; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Returns if the device communication is in error +// Note: based upon the FSM state without actual accessing the device +bool P167_data_struct::inError() const +{ + return _state == P167_state::Error; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Returns if new acquired values are available +bool P167_data_struct::newValues() const +{ + return _state == P167_state::New_Values_Available; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Restart the FSM used to access the device +bool P167_data_struct::reset() +{ + startMonitoringFlag = true; + stepMonitoring = 1; + _state = P167_state::Uninitialized; + return true; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Start a new measurement cycle +bool P167_data_struct::startMeasurements() +{ + if ((_state == P167_state::New_Values_Available) || (_state == P167_state::Initialized) || (_state == P167_state::IDLE)) + { + _state = P167_state::Ready; + } + startMonitoringFlag = true; + stepMonitoring = 1; + return true; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Get the electronic idenfification data store in the device +// Note: The data is read from the device during initialization +bool P167_data_struct::getEID(String &eid_productname, String &eid_serialnumber, uint8_t &firmware) const +{ + eid_productname = _eid_productname; + eid_serialnumber = _eid_serialnumber; + firmware = _firmware; + return true; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Get the status informasion about different part of the sensor +// Note: The data is read from the device after every measurement read request +bool P167_data_struct::getStatusInfo(param_statusinfo param) +{ + switch(param) + { + case sensor_speed: + return (bool) _devicestatus.speed; + break; + + case sensor_autoclean: + return (bool) _devicestatus.autoclean; + break; + + case sensor_gas: + return (bool) _devicestatus.gas; + break; + + case sensor_rht: + return (bool) _devicestatus.rht; + break; + + case sensor_laser: + return (bool) _devicestatus.laser; + break; + + case sensor_fan: + return (bool) _devicestatus.fan; + break; + } + return true; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Return the previously measured raw humidity data [bits] +float P167_data_struct::getRequestedValue(uint8_t request) const +{ + //float requested_value=0; + switch(request) + { + case 0: + { + if(_model==0) + return (float) _TemperatureX; + else + return (float) _Temperature; + } + case 1: + { + if(_model==0) + return (float) _HumidityX; + else + return (float) _Humidity; + } + case 2: return (float) _tVOC; + case 3: return (float) _NOx; + case 4: return (float) _PM1p0; + case 5: return (float) _PM2p5; + case 6: return (float) _PM4p0; + case 7: return (float) _PM10p0; + case 8: return (float) _DewPoint; + } + return -1; +} + + +////////////////////////////////////////////////////////////////////////////////////////////////// +// +// PROTECTED +// +////////////////////////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////////////////////////// +uint8_t P167_data_struct::crc8(const uint8_t *data, uint8_t len) +{ + // CRC-8 formula from page 14 of SHT spec pdf + // Sensirion_Humidity_Sensors_SHT2x_CRC_Calculation.pdf + const uint8_t POLY = 0x31; + uint8_t crc = 0xFF; + + for (uint8_t j = 0; j> 8)); + Wire.write((uint8_t)cmd); + return Wire.endTransmission() == 0; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +bool P167_data_struct::writeCmd(uint16_t cmd, uint8_t value) +{ + Wire.beginTransmission(_i2caddr); + Wire.write((uint8_t)(cmd >> 8)); + Wire.write((uint8_t)cmd); + Wire.write((uint8_t)value); + return Wire.endTransmission() == 0; +} + + + +bool P167_data_struct::writeCmd(uint16_t cmd, uint8_t length, uint8_t *buffer) +{ + Wire.beginTransmission(_i2caddr); + Wire.write((uint8_t)(cmd >> 8)); + Wire.write((uint8_t)cmd); + for (int i = 0; i < length; i++) { + Wire.write(*(buffer + i)); + } + return Wire.endTransmission() == 0; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +bool P167_data_struct::readBytes(uint8_t n, uint8_t *val, uint8_t maxDuration) +{ + // TODO check if part can be delegated to the I2C_access libraray from ESPeasy + Wire.requestFrom(_i2caddr, (uint8_t) n); + uint32_t start = millis(); + while (Wire.available() < n) + { + if (timePassedSince(start) > maxDuration) + { + return false; + } + yield(); + } + + for (uint8_t i = 0; i < n; i++) + { + val[i] = Wire.read(); + } + return true; +} + + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Read data ready flag from device +bool P167_data_struct::readDataRdyFlag() +{ + uint8_t value=0; + uint8_t buffer[3]; + + if (!readBytes(3, (uint8_t*) &buffer[0], P167_READ_DATA_RDY_FLAG_DELAY)) + { + return false; + } + if (crc8(&buffer[0], 2) == buffer[2]) + { + value += buffer[1]; + } + return value; +} + + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Read measurement values results from device +bool P167_data_struct::readMeasValue() +{ + uint16_t value=0; + int16_t valuesign=0; + uint8_t buffer[24]; + bool condition=true; + + _errmeas = false; + if (!readBytes(24, (uint8_t*) &buffer[0], P167_READ_MEAS_DELAY)) + { + _errmeas = true; + return false; + } + + String log = F("SEN5x : *** meas value "); + for(int xx=0; xx<24;xx++) + { + log += String((int)buffer[xx]); + log += F(" "); + } + + if(_model==0 || _model==1) + condition=(buffer[0] == 0xFF && buffer[1] == 0xFF) || (buffer[3] == 0xFF && buffer[4] == 0xFF) || (buffer[6] == 0xFF && buffer[7] == 0xFF) || (buffer[9] == 0xFF && buffer[10] == 0xFF) || (buffer[12] == 0xFF && buffer[13] == 0xFF) || (buffer[15] == 0xFF && buffer[16] == 0xFF) || (buffer[18] == 0xFF && buffer[19] == 0xFF); + if(_model==2) + condition=(buffer[0] == 0xFF && buffer[1] == 0xFF) || (buffer[3] == 0xFF && buffer[4] == 0xFF) || (buffer[6] == 0xFF && buffer[7] == 0xFF) || (buffer[9] == 0xFF && buffer[10] == 0xFF) || (buffer[12] == 0xFF && buffer[13] == 0xFF) || (buffer[15] == 0xFF && buffer[16] == 0xFF) || (buffer[18] == 0xFF && buffer[19] == 0xFF) || (buffer[21] == 0xFF && buffer[22] == 0xFF); + + if(condition) + { + log += F("- error"); + addLog(LOG_LEVEL_INFO, log); + _errmeas = true; + _readingerrcount++; + return false; + } + else + { + for(int xx=0; xx<8; xx++) + { + if ((crc8(&buffer[xx*3], 2) == buffer[xx*3+2]) && (buffer[xx*3] != 0xFF || buffer[xx*3+1] != 0xFF)) + { + value = buffer[xx*3] << 8; + value += buffer[xx*3+1]; + valuesign = buffer[xx*3] << 8; + valuesign += buffer[xx*3+1]; + if(xx==0) + _PM1p0 = (float)value/10; + if(xx==1) + _PM2p5 = (float)value/10; + if(xx==2) + _PM4p0 = (float)value/10; + if(xx==3) + _PM10p0 = (float)value/10; + if(xx==4) + _Humidity = (float)valuesign/100.0; + if(xx==5) + _Temperature = (float)valuesign/200.0; + if(xx==6) + _tVOC = (float)valuesign/10.0; + if(xx==7) + { + if(_model==2) + _NOx = (float)valuesign/10.0; + else + _NOx = (float)0.0; + } + } + else + { + _errmeasrawmys = true; + } + } + + if(_errmeas == true) + { + log += F("- crc error"); + _readingerrcount++; + } + else + { + log += F("- pass"); + _readingsuccesscount++; + } + addLog(LOG_LEVEL_INFO, log); + return !_errmeas; + } + + return true; +} + + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Read measurement values results from device +bool P167_data_struct::readMeasRawValue() +{ + uint16_t value=0; + int16_t valuesign=0; + uint8_t buffer[12]; + bool condition=true; + + _errmeasraw = false; + if (!readBytes(12, (uint8_t*) &buffer[0], P167_READ_RAW_MEAS_DELAY)) + { + _errmeasraw = true; + return false; + } + + String log = F("SEN5x : *** meas RAW value "); + for(int xx=0; xx<12;xx++) + { + log += String((int)buffer[xx]); + log += F(" "); + } + + if(_model==0 || _model==1) + condition=(buffer[0] == 0xFF && buffer[1] == 0xFF) || (buffer[3] == 0xFF && buffer[4] == 0xFF) || (buffer[6] == 0xFF && buffer[7] == 0xFF);// || (buffer[9] == 0xFF && buffer[10] == 0xFF)) + if(_model==2) + condition=(buffer[0] == 0xFF && buffer[1] == 0xFF) || (buffer[3] == 0xFF && buffer[4] == 0xFF) || (buffer[6] == 0xFF && buffer[7] == 0xFF) || (buffer[9] == 0xFF && buffer[10] == 0xFF); + + if(condition) + { + log += F("- error"); + addLog(LOG_LEVEL_INFO, log); + _errmeasraw = true; + _readingerrcount++; + return false; + } + else + { + for(int xx=0; xx<4; xx++) + { + if ((crc8(&buffer[xx*3], 2) == buffer[xx*3+2]) && (buffer[xx*3] != 0xFF || buffer[xx*3+1] != 0xFF)) + { + value = buffer[xx*3] << 8; + value += buffer[xx*3+1]; + valuesign = buffer[xx*3] << 8; + valuesign += buffer[xx*3+1]; + if(xx==0) + _rawHumidity = (float)valuesign/100.0; + if(xx==1) + _rawTemperature = (float)valuesign/200.0; + if(xx==2) + _rawtVOC = (float)value/10.0; + if(xx==3) + { + if(_model==2) + _rawNOx = (float)value/10.0; + else + _rawNOx = (float)0.0; + } + } + else + { + _errmeasrawmys = true; + } + } + + if(_errmeasraw == true) + { + log += F("- crc error"); + _readingerrcount++; + } + else + { + log += F("- pass"); + _readingsuccesscount++; + } + addLog(LOG_LEVEL_INFO, log); + return !_errmeasraw; + } + + + return true; +} + + + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Read measurement values results from device +bool P167_data_struct::readMeasRawMYSValue() +{ + uint16_t value=0; + int16_t valuesign=0; + uint8_t buffer[9]; + + _errmeasrawmys = false; + if (!readBytes(9, (uint8_t*) &buffer[0], P167_READ_RAW_MEAS_DELAY)) + { + _errmeasrawmys = true; + return false; + } + + String log = F("SEN5x : *** meas MYS value "); + for(int xx=0; xx<9;xx++) + { + log += String((int)buffer[xx]); + log += F(" "); + } + + if((buffer[0] == 0xFF && buffer[1] == 0xFF) || (buffer[3] == 0xFF && buffer[4] == 0xFF) || (buffer[6] == 0xFF && buffer[7] == 0xFF)) + { + log += F("- error"); + addLog(LOG_LEVEL_INFO, log); + _errmeasrawmys = true; + _readingerrcount++; + return false; + } + else + { + for(int xx=0; xx<3; xx++) + { + if ((crc8(&buffer[xx*3], 2) == buffer[xx*3+2]) && (buffer[xx*3] != 0xFF || buffer[xx*3+1] != 0xFF)) + { + value = buffer[xx*3] << 8; + value += buffer[xx*3+1]; + valuesign = buffer[xx*3] << 8; + valuesign += buffer[xx*3+1]; + if(xx==0) + _mysHumidity = (float)valuesign/100.0; + if(xx==1) + _mysTemperature = (float)valuesign/200.0; + if(xx==2) + _mysOffset = (float)valuesign/200.0; + } + else + { + _errmeasrawmys = true; + } + } + + if(_errmeasrawmys == true) + { + log += F("- crc error"); + _readingerrcount++; + } + else + { + log += F("- pass"); + _readingsuccesscount++; + } + addLog(LOG_LEVEL_INFO, log); + return !_errmeasrawmys; + } + + + return true; +} + + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Calculate DewPoint, F Temp, F HUM +bool P167_data_struct::calculateValue() +{ + float lnval; + float rapval; + float aval = 17.62; + float bval = 243.12; + float Dp; + float eeval = 0.0; + + if(_model==0) + { + //_TemperatureX = _mysTemperature + _mysOffset - (_mysOffset<0.0?(_mysOffset*(-1.0)):_mysOffset)/2; + //_TemperatureX = _mysTemperature + _mysOffset*3.0/2.0; + _TemperatureX = _mysTemperature + _mysOffset - 2.4; //(2.4 - temperature offset because enclosure and esp8266 power disipation) + + //version formula with DewPoint + //lnval = logf(_mysHumidity/100.0); + //rapval = (aval * _mysTemperature)/(bval+_mysTemperature); + //Dp = (bval*(lnval+rapval))/(aval-lnval-rapval); + //eeval = expf((aval*Dp)/(bval+Dp))/expf((aval*_TemperatureX)/(bval+_TemperatureX)); + //_HumidityX = eeval*100.0; + + //version formula with interpolation + _HumidityX = _Humidity+(_TemperatureX-_Temperature)*((_rawHumidity-_Humidity)/(_rawTemperature-_Temperature)); + lnval = logf(_HumidityX/100.0); + rapval = (aval * _TemperatureX)/(bval+_TemperatureX); + Dp = (bval*(lnval+rapval))/(aval-lnval-rapval); + + if(_HumidityX < 0.0) + _HumidityX = 0.0; + if(_HumidityX > 100.0) + _HumidityX = 100.0; + } + else + { + lnval = logf(_Humidity/100.0); + rapval = (aval * _Temperature)/(bval+_Temperature); + Dp = (bval*(lnval+rapval))/(aval-lnval-rapval); + } + _DewPoint = Dp; + + return true; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Retrieve SEN5x identification code +// Sensirion_SEN5x +bool P167_data_struct::getProductName() +{ + String prodname=F(""); + uint8_t buffer[48]; + //writeCmd(P167_READ_PROD_NAME); + if (!readBytes(48, (uint8_t *) buffer, P167_READ_PROD_NAME_DELAY)) + { + return false; + } + for (uint8_t i = 1; i <= 16; i++) + { + if(crc8(&buffer[i*3-3], 2) == buffer[i*3-1]) + { + if (buffer[i*3-3] < 32) + break; + prodname+=char(buffer[i*3-3]); + if (buffer[i*3-2] < 32) + break; + prodname+=char(buffer[i*3-2]); + } + } + _eid_productname=prodname; + + String log = F("SEN5x : *** Product name: "); + log += String(prodname); + addLog(LOG_LEVEL_INFO, log); + + return true; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Retrieve SEN54 Serial Number +bool P167_data_struct::getSerialNumber() +{ + String serno=F(""); + uint8_t buffer[48]; + //writeCmd(P167_READ_SERIAL_NO); + if (!readBytes(48, (uint8_t *) buffer, P167_READ_SERIAL_NO_DELAY)) + { + return false; + } + for (uint8_t i = 1; i <= 16; i++) + { + if(crc8(&buffer[i*3-3], 2) == buffer[i*3-1]) + { + if (buffer[i*3-3] < 32) + break; + serno+=char(buffer[i*3-3]); + if (buffer[i*3-2] < 32) + break; + serno+=char(buffer[i*3-2]); + } + } + _eid_serialnumber=serno; + + String log = F("SEN5x : *** Serial number: "); + log += String(serno); + addLog(LOG_LEVEL_INFO, log); + + return true; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Retrieve SEN54 Firmware version from device +bool P167_data_struct::getFirmwareVersion() +{ + uint8_t version = 0; + uint8_t read_data[3]; + //writeCmd(P167_READ_FIRM_VER); + if (!readBytes(3, (uint8_t *) &read_data, P167_READ_FIRM_VER_DELAY)) + { + return false; + } + if( read_data[2] == crc8(&read_data[0],2) ) + { + version=read_data[0]; + } + else + { + version=0; + } + _firmware=version; + + String log = F("SEN5x : *** Firmware version: "); + log += String((uint8_t)version); + addLog(LOG_LEVEL_INFO, log); + + return true; +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Retrieve SEN54 Device Status from device +bool P167_data_struct::readDeviceStatus() +{ + uint32_t value=0; + uint8_t bufferstatus[6]; + //writeCmd(P167_READ_FIRM_VER); + _errdevicestatus = false; + if (!readBytes(6, (uint8_t *) &bufferstatus, P167_READ_DEVICE_STATUS_DELAY)) + { + _errdevicestatus = true; + return false; + } + + String log = F("SEN5x : *** device status "); + for(int xx=0; xx<6;xx++) + { + log += String((int)bufferstatus[xx]); + log += F(" "); + } + + if ((crc8(&bufferstatus[0], 2) == bufferstatus[2]) && (crc8(&bufferstatus[3], 2) == bufferstatus[5])) + { + value = bufferstatus[0] << 8; + value += bufferstatus[1] << 8; + value += bufferstatus[3] << 8; + value += bufferstatus[4] << 8; + _devicestatus.val = value; + } + else + { + _errdevicestatus = true; + } + + if(_errdevicestatus == true) + { + log += F("- crc error"); + _readingerrcount++; + } + else + { + log += String((bool)_devicestatus.speed); + log += String((bool)_devicestatus.autoclean); + log += String((bool)_devicestatus.gas); + log += String((bool)_devicestatus.rht); + log += String((bool)_devicestatus.laser); + log += String((bool)_devicestatus.fan); + log += F(" - pass"); + _readingsuccesscount++; + } + addLog(LOG_LEVEL_INFO, log); + return !_errdevicestatus; +} + + +uint16_t P167_data_struct::getErrCode(bool _clear) +{ + uint16_t _tmp = _readingerrcode; + if (_clear == true) + clearErrCode(); + return (_tmp); +} + +uint16_t P167_data_struct::getErrCount(bool _clear) +{ + uint16_t _tmp = _readingerrcount; + if (_clear == true) + clearErrCount(); + return (_tmp); +} + +uint16_t P167_data_struct::getSuccCount(bool _clear) +{ + uint16_t _tmp = _readingsuccesscount; + if (_clear == true) + clearSuccCount(); + return (_tmp); +} + +void P167_data_struct::clearErrCode() +{ + _readingerrcode = VIND_ERR_NO_ERROR; +} + +void P167_data_struct::clearErrCount() +{ + _readingerrcount = 0; +} + +void P167_data_struct::clearSuccCount() +{ + _readingsuccesscount = 0; +} + + +void IRAM_ATTR P167_data_struct::checkPin_interrupt() +{ + //ISR_noInterrupts(); // s0170071: avoid nested interrups due to bouncing. + + monpinValue++; + monpinLastTransitionTime = getMicros64(); + // Mark pin value changed + monpinChanged = false; + if(monpinValue!=monpinValuelast) + monpinChanged = true; + + //ISR_interrupts(); // enable interrupts again. +} + +#endif // USES_P167 \ No newline at end of file diff --git a/src/src/PluginStructs/P167_data_struct.h b/src/src/PluginStructs/P167_data_struct.h new file mode 100644 index 000000000..1686b351b --- /dev/null +++ b/src/src/PluginStructs/P167_data_struct.h @@ -0,0 +1,222 @@ +////////////////////////////////////////////////////////////////////////////////////////////////// +// P167 device class for IKEA Vindstyrka SEN54 temperature , humidity and air quality sensors +// See datasheet https://sensirion.com/media/documents/6791EFA0/62A1F68F/Sensirion_Datasheet_Environmental_Node_SEN5x.pdf +// and info about extra request https://sensirion.com/media/documents/2B6FC1F3/6409E74A/PS_AN_Read_RHT_VOC_and_NOx_RAW_signals_D1.pdf +// Based upon code from Rob Tillaart, Viktor Balint, https://github.com/RobTillaart/SHT2x +// Rewritten and adapted for ESPeasy by andibaciu +// 2023-06-20 Initial version by andibaciu +////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../../_Plugin_Helper.h" +#include "../ESPEasyCore/ESPEasyGPIO.h" +#ifdef USES_P167 + +#ifdef LIMIT_BUILD_SIZE +#define PLUGIN_167_DEBUG false +#else +#define PLUGIN_167_DEBUG false // set to true for extra log info in the debug +#endif + +// Vindstyrka device properties +//#define P167_I2C_ADDRESS_DFLT 0x69 + + +//------------------------------------------------------------------------------ +#define VIND_ERR_NO_ERROR 0 // no error +#define VIND_ERR_CRC_ERROR 1 // crc error +#define VIND_ERR_WRONG_BYTES 2 // bytes b0,b1 or b2 wrong +#define VIND_ERR_NOT_ENOUGHT_BYTES 3 // not enough bytes from sdm +#define VIND_ERR_TIMEOUT 4 // timeout +//------------------------------------------------------------------------------ + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Access to the Vindstyrka device is mainly by sequencing a Finate State Machine +enum class P167_state { + Uninitialized = 0, // Initial state, unknown status of sensor device + Wait_for_reset, // Reset being performed + Read_firm_version, // Reading firmware version + Read_prod_name, // Reading production + Read_serial_no, // Reading serial number + Write_user_reg, // Write the user register + Initialized, // Initialization completed + Ready, // Aquisition request is pending, ready to measure + Wait_for_start_meas, // Start measurement started + Wait_for_read_flag, // Read meas flag started + Wait_for_read_meas, // Read meas started + Wait_for_read_raw_meas, // RAW Read meas started + Wait_for_read_raw_MYS_meas, // RAW Read meas MYSTERY started + Wait_for_read_status, // Read status + cmdSTARTmeas, // send command START meas to leave SEN5x ready flag for Vindstyrka + IDLE, // Sensor device in IDLE mode + New_Values_Available, // Acqusition finished, new data available + Error // Sensor device cannot be accessed or in error +}; + + +enum param_statusinfo +{ + sensor_speed = 0, + sensor_autoclean, + sensor_gas, + sensor_rht, + sensor_laser, + sensor_fan +}; + + + +////////////////////////////////////////////////////////////////////////////////////////////////// +// ESPeasy standard PluginTaskData structure for this plugin +//struct P167_data_struct : public PluginTaskData_base +class P167_data_struct +{ + +public: + P167_data_struct(); + //virtual ~P167_data_struct(); + ~P167_data_struct(); + + void checkPin_interrupt(void); + + ///////////////////////////////////////////////////////// + // This method runs the FSM step by step on each call + // Returns true when a stable state is reached + bool update(); + bool monitorSCL(); + + ///////////////////////////////////////////////////////// + // (re)configure the device properties + // This will result in resetting and reloading the device + bool setupDevice(uint8_t i2caddr); + bool setupModel(uint8_t model); + bool setupMonPin(uint8_t monpin); + void enableInterrupt_monpin(void); + void disableInterrupt_monpin(void); + + ///////////////////////////////////////////////////////// + // check sensor is reachable over I2C + bool isConnected() const; + + ///////////////////////////////////////////////////////// + bool newValues() const; + + ///////////////////////////////////////////////////////// + bool inError() const; + + ///////////////////////////////////////////////////////// + // Reset the FSM to initial state + bool reset(); + + ///////////////////////////////////////////////////////// + // Trigger a measurement cycle + // Only perform the measurements with big interval to prevent the sensor from warming up. + bool startMeasurements(); + + bool getStatusInfo(param_statusinfo param); + ///////////////////////////////////////////////////////// + // Electronic Identification Code + // Sensirion_Humidity_SHT2x_Electronic_Identification_Code_V1.1.pdf + // Electronic ID bytes + bool getEID(String &eid_productname, String &eid_serialnumber, uint8_t &firmware) const; + + ///////////////////////////////////////////////////////// + // Temperature, humidity, DewPoint, PMxpy retrieval + // Note: values are fetched from memory and reflect latest succesful read cycle + float getRequestedValue(uint8_t request) const; + + + uint16_t getErrCode(bool _clear = false); //return last errorcode (optional clear this value, default false) + uint16_t getErrCount(bool _clear = false); //return total errors count (optional clear this value, default false) + uint16_t getSuccCount(bool _clear = false); //return total success count (optional clear this value, default false) + void clearErrCode(); //clear last errorcode + void clearErrCount(); //clear total errors count + void clearSuccCount(); //clear total success count + +//protected: +private: + + union devicestatus + { + uint32_t val; + struct + { + uint16_t dummy1:10; + bool speed; + bool dummy2; + bool autoclean; + uint16_t dummy3:11; + bool gas; + bool rht; + bool laser; + bool fan; + uint16_t dummy4:4; + }; + }; + + devicestatus _devicestatus; + P167_state _state; + + uint8_t crc8(const uint8_t *data, uint8_t len); + bool writeCmd(uint16_t cmd); + bool writeCmd(uint16_t cmd, uint8_t value); + bool writeCmd(uint16_t cmd, uint8_t length, uint8_t *buffer); + bool readBytes(uint8_t n, uint8_t *val, uint8_t maxDuration); + + bool readMeasValue(); + bool readMeasRawValue(); + bool readMeasRawMYSValue(); + bool readDataRdyFlag(); + bool readDeviceStatus(); + bool calculateValue(); + + bool getProductName(); + bool getSerialNumber(); + bool getFirmwareVersion(); + + + float _Humidity; // Humidity as fetched from the device [bits] + float _HumidityX; // Humidity as calculated + float _Temperature; // Temperature as fetched from the device [bits] + float _TemperatureX; // Temperature as calculated + float _DewPoint; // DewPoint as calculated + float _rawHumidity; // Humidity as fetched from the device without compensation[bits] + float _rawTemperature; // Temperature as fetched from the device without compensation[bits] + float _mysHumidity; // Humidity as fetched from the device without compensation[bits] + float _mysTemperature; // Temperature as fetched from the device without compensation[bits] + float _tVOC; // tVOC as fetched from the device[bits] + float _NOx; // NOx as fetched from the device[bits] + float _rawtVOC; // tVOC as fetched from the device without compensation[bits] + float _rawNOx; // NOx as fetched from the device without compensation[bits] + float _mysOffset; // Temperature Offset fetched from the device[bits] + float _PM1p0; // PM1.0 as fetched from the device[bits] + float _PM2p5; // PM2.5 as fetched from the device[bits] + float _PM4p0; // PM4.0 as fetched from the device[bits] + float _PM10p0; // PM10.0 as fetched from the device[bits] + uint8_t _model; // Selected sensor model + uint8_t _i2caddr; // Programmed I2C address + uint8_t _monpin; // Pin to monitor I2C SCL to find when VindStyrka finish i2c communication + unsigned long _last_action_started; // Timestamp for last action that takes processing time + uint16_t _errCount; // Number of errors since last successful access + String _eid_productname; // Electronic Device ID - Product Name, read at initialization + String _eid_serialnumber; // Electronic Device ID - Serial Number, read at initialization + uint8_t _firmware; // Firmware version numer, read at initialization + uint8_t _userreg; // TODO debugging only + uint16_t _readingerrcode = VIND_ERR_NO_ERROR; // 4 = timeout; 3 = not enough bytes; 2 = number of bytes OK but bytes b0,b1 or b2 wrong, 1 = crc error + uint16_t _readingerrcount = 0; // total errors couter + uint32_t _readingsuccesscount = 0; // total success couter + bool _errmeas; + bool _errmeasraw; + bool _errmeasrawmys; + bool _errdevicestatus; + uint8_t stepMonitoring; // step for Monitorin SCL pin algorithm + bool startMonitoringFlag; // flag to START/STOP Monitoring algorithm + bool statusMonitoring; // flag for status return from Monitoring algorithm + unsigned long lastSCLLowTransitionMonitoringTime; // last time when SCL i2c pin rising + + volatile uint32_t monpinValue = 0; + volatile uint32_t monpinValuelast = 0; + volatile uint8_t monpinChanged = 0; + volatile uint64_t monpinLastTransitionTime = 0; + +}; +#endif // USES_P167 \ No newline at end of file diff --git a/src/src/WebServer/AdvancedConfigPage.cpp b/src/src/WebServer/AdvancedConfigPage.cpp index 8de04c71c..f34ec6190 100644 --- a/src/src/WebServer/AdvancedConfigPage.cpp +++ b/src/src/WebServer/AdvancedConfigPage.cpp @@ -134,6 +134,11 @@ void handle_advanced() { Settings.WaitWiFiConnect(isFormItemChecked(LabelType::WAIT_WIFI_CONNECT)); Settings.HiddenSSID_SlowConnectPerBSSID(isFormItemChecked(LabelType::HIDDEN_SSID_SLOW_CONNECT)); Settings.SDK_WiFi_autoreconnect(isFormItemChecked(LabelType::SDK_WIFI_AUTORECONNECT)); +#if FEATURE_USE_IPV6 + Settings.EnableIPv6(isFormItemChecked(LabelType::ENABLE_IPV6)); + addFormNote(F("Toggling IPv6 requires reboot")); +#endif + #ifndef BUILD_NO_RAM_TRACKER @@ -387,6 +392,9 @@ void handle_advanced() { addFormCheckBox(LabelType::WAIT_WIFI_CONNECT, Settings.WaitWiFiConnect()); addFormCheckBox(LabelType::SDK_WIFI_AUTORECONNECT, Settings.SDK_WiFi_autoreconnect()); addFormCheckBox(LabelType::HIDDEN_SSID_SLOW_CONNECT, Settings.HiddenSSID_SlowConnectPerBSSID()); +#if FEATURE_USE_IPV6 + addFormCheckBox(LabelType::ENABLE_IPV6, Settings.EnableIPv6()); +#endif diff --git a/src/src/WebServer/JSON.cpp b/src/src/WebServer/JSON.cpp index bc2ea01b4..631e20d9f 100644 --- a/src/src/WebServer/JSON.cpp +++ b/src/src/WebServer/JSON.cpp @@ -210,6 +210,13 @@ void handle_json() #ifdef ESP32 LabelType::ESP_CHIP_REVISION, #endif // ifdef ESP32 + LabelType::FLASH_CHIP_ID, + LabelType::FLASH_CHIP_VENDOR, + LabelType::FLASH_CHIP_MODEL, + LabelType::FLASH_CHIP_REAL_SIZE, + LabelType::FLASH_CHIP_SPEED, + LabelType::FLASH_IDE_MODE, + LabelType::FS_SIZE, LabelType::SUNRISE, LabelType::SUNSET, @@ -244,6 +251,7 @@ void handle_json() #if FEATURE_USE_IPV6 LabelType::IP6_LOCAL, LabelType::IP6_GLOBAL, + LabelType::ENABLE_IPV6, #endif LabelType::IP_SUBNET, LabelType::GATEWAY, @@ -281,6 +289,10 @@ void handle_json() LabelType::WIFI_USE_LAST_CONN_FROM_RTC, LabelType::WIFI_RSSI, + LabelType::WAIT_WIFI_CONNECT, + LabelType::HIDDEN_SSID_SLOW_CONNECT, + LabelType::CONNECT_HIDDEN_SSID, + LabelType::SDK_WIFI_AUTORECONNECT, LabelType::MAX_LABEL }; diff --git a/src/src/WebServer/RootPage.cpp b/src/src/WebServer/RootPage.cpp index f7c8b2f15..e7065ef6d 100644 --- a/src/src/WebServer/RootPage.cpp +++ b/src/src/WebServer/RootPage.cpp @@ -197,8 +197,10 @@ void handle_root() { { addRowLabelValue(LabelType::IP_ADDRESS); #if FEATURE_USE_IPV6 - addRowLabelValue(LabelType::IP6_LOCAL); - // Do not show global IPv6 on the root page + if (Settings.EnableIPv6()) { + addRowLabelValue(LabelType::IP6_LOCAL); + // Do not show global IPv6 on the root page + } #endif addRowLabel(LabelType::WIFI_RSSI); addHtml(strformat( @@ -213,8 +215,10 @@ void handle_root() { addRowLabelValue(LabelType::ETH_SPEED_STATE); addRowLabelValue(LabelType::ETH_IP_ADDRESS); #if FEATURE_USE_IPV6 - addRowLabelValue(LabelType::ETH_IP6_LOCAL); - // Do not show global IPv6 on the root page + if (Settings.EnableIPv6()) { + addRowLabelValue(LabelType::ETH_IP6_LOCAL); + // Do not show global IPv6 on the root page + } #endif } # endif // if FEATURE_ETHERNET @@ -337,8 +341,10 @@ void handle_root() { if (it->second.ip[0] != 0 #if FEATURE_USE_IPV6 - || it->second.hasIPv6_mac_based_link_local - || it->second.hasIPv6_mac_based_link_global + || (Settings.EnableIPv6() && + (it->second.hasIPv6_mac_based_link_local || + it->second.hasIPv6_mac_based_link_global) + ) #endif ) { @@ -347,12 +353,14 @@ void handle_root() { #if FEATURE_USE_IPV6 bool isIPv6 = false; - if (it->second.hasIPv6_mac_based_link_local) { - ip = it->second.IPv6_link_local(true); - isIPv6 = true; - } else if (it->second.hasIPv6_mac_based_link_global) { - ip = it->second.IPv6_global(); - isIPv6 = true; + if (Settings.EnableIPv6()) { + if (it->second.hasIPv6_mac_based_link_local) { + ip = it->second.IPv6_link_local(true); + isIPv6 = true; + } else if (it->second.hasIPv6_mac_based_link_global) { + ip = it->second.IPv6_global(); + isIPv6 = true; + } } if (it->second.hasIPv4 && it->second.hasIPv6()) { // Add 2 buttons for IPv4 and IPv6 address diff --git a/src/src/WebServer/SysInfoPage.cpp b/src/src/WebServer/SysInfoPage.cpp index e8ba02427..c660d44c3 100644 --- a/src/src/WebServer/SysInfoPage.cpp +++ b/src/src/WebServer/SysInfoPage.cpp @@ -121,8 +121,10 @@ void handle_sysinfo_json() { json_prop(F("dhcp"), useStaticIP() ? getLabel(LabelType::IP_CONFIG_STATIC) : getLabel(LabelType::IP_CONFIG_DYNAMIC)); json_prop(F("ip"), getValue(LabelType::IP_ADDRESS)); #if FEATURE_USE_IPV6 - json_prop(F("ip6_local"), getValue(LabelType::IP6_LOCAL)); - json_prop(F("ip6_global"), getValue(LabelType::IP6_GLOBAL)); + if (Settings.EnableIPv6()) { + json_prop(F("ip6_local"), getValue(LabelType::IP6_LOCAL)); + json_prop(F("ip6_global"), getValue(LabelType::IP6_GLOBAL)); + } #endif json_prop(F("subnet"), getValue(LabelType::IP_SUBNET)); @@ -153,7 +155,8 @@ void handle_sysinfo_json() { json_prop(F("ethstate"), getValue(LabelType::ETH_STATE)); json_prop(F("ethspeedstate"), getValue(LabelType::ETH_SPEED_STATE)); #if FEATURE_USE_IPV6 - json_prop(F("ethipv6local"), getValue(LabelType::ETH_IP6_LOCAL)); + if (Settings.EnableIPv6()) + json_prop(F("ethipv6local"), getValue(LabelType::ETH_IP6_LOCAL)); #endif json_close(); # endif // if FEATURE_ETHERNET @@ -542,6 +545,9 @@ void handle_sysinfo_WiFiSettings() { LabelType::HIDDEN_SSID_SLOW_CONNECT, LabelType::CONNECT_HIDDEN_SSID, LabelType::SDK_WIFI_AUTORECONNECT, +#if FEATURE_USE_IPV6 + LabelType::ENABLE_IPV6, +#endif LabelType::MAX_LABEL };