diff --git a/.gitignore b/.gitignore index 8a24e18..784bafc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,19 +1,40 @@ +# IDE and Tooling .theia/ +.vscode/ +.claude/ +.pio/ debug_custom.json -esp32.vsd -esp32s3.svd debug.cfg +# Hardware / SVD Files +esp32.vsd +esp32s3.svd + +# Build, Logs and Output Folders +build/ +data/ +logs/ +managed_components/ + +# ESP-IDF Specific +sdkconfig +sdkconfig.old +sdkconfig.* + +# Binary and Archive Files +*.elf +elf_archive/ +coredump_report.txt +coredump.bin + +# Project Specific / Generated Source +src/SomfyController.ino.cpp + +# Ignore Somfy INO/Bin files SomfyController.ino.XIAO_ESP32S3.bin SomfyController.ino.esp32c3.bin SomfyController.ino.esp32s2.bin -.vscode/ -.pio/ -.claude/ -data/ -build/ -coredump_report.txt -coredump.bin -logs/ -elf_archive/ -src/SomfyController.ino.cpp + +# Temporary and Backup Files +*.orig +*.bak diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3f240ee --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16.0) +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(ESPSomfy-RTS) diff --git a/app_version.py b/app_version.py new file mode 100644 index 0000000..533442a --- /dev/null +++ b/app_version.py @@ -0,0 +1,32 @@ +import os +Import("env") + +# Define the folder and filename +DATA_FOLDER = "data-src" +FILENAME = "appversion" + +# Construct the full path: /your/project/path/data-src/appversion +project_dir = env.get("PROJECT_DIR") +version_file_path = os.path.join(project_dir, DATA_FOLDER, FILENAME) + +# Default fallback if something goes wrong +version = "0.0.0" + +if os.path.exists(version_file_path): + try: + with open(version_file_path, "r") as f: + version = f.read().strip() + # Clean output for the PlatformIO console + print(f"--- SUCCESS: Found version {version} in {version_file_path} ---") + except Exception as e: + print(f"--- ERROR: could not read version file: {e} ---") +else: + print(f"--- ERROR: File NOT FOUND at {version_file_path} ---") + +# Apply to the build environment +# We use escaped quotes so C++ treats it as a string literal "vX.X.X" +full_version_str = f'\\"v{version}\\"' + +env.Append(CPPDEFINES=[ + ("FW_VERSION", full_version_str) +]) \ No newline at end of file diff --git a/data-src/index.js b/data-src/index.js index ed66600..1951863 100644 --- a/data-src/index.js +++ b/data-src/index.js @@ -1,6 +1,9 @@ -//var hst = '192.168.1.208'; -var hst = '192.168.1.152'; -//var hst = '192.168.1.159'; +/** + * hst is a development convenience variable: it's a hardcoded IP address used when the HTML file is opened directly + * from the filesystem (i.e., file:// protocol) rather than served from the ESP32. + * Adapt the IP accordingly based on your router configuration. +**/ +var hst = '192.168.178.20'; var _rooms = [{ roomId: 0, name: 'Home' }]; var errors = [ @@ -1268,9 +1271,27 @@ class Security { } var security = new Security(); +// let appVersion = 'v3.0.11'; // Default placeholder +async function getAppVersion() { + try { + const response = await fetch('/appversion'); + if (!response.ok) throw new Error('File not found'); + + const data = await response.text(); + appVersion = `v${data.trim()}`; + + console.log("Loaded Version:", appVersion); + // Trigger any UI updates here + } catch (error) { + console.error("Error loading App version:", error); + appVersion = 'v3.0.11'; // Default placeholder + } + return appVersion; +} + class General { initialized = false; - appVersion = 'v3.0.11'; + appVersion = getAppVersion(); reloadApp = false; init() { if (this.initialized) return; @@ -2795,16 +2816,17 @@ class Somfy { document.getElementById('divLinkedShadeList').innerHTML = divCfg; } pinMaps = [ - { name: '', maxPins: 39, inputs: [0, 1, 6, 7, 8, 9, 10, 11, 37, 38], outputs: [3, 6, 7, 8, 9, 10, 11, 34, 35, 36, 37, 38, 39] }, + { name: '', maxPins: 39, inputs: [], outputs: [] }, { name: 's2', maxPins: 46, inputs: [0, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 45], outputs: [0, 19, 20, 26, 27, 28, 29, 30, 31, 32, 45, 46]}, { name: 's3', maxPins: 48, inputs: [19, 20, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32], outputs: [19, 20, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32] }, - { name: 'c3', maxPins: 21, inputs: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], outputs: [11, 12, 13, 14, 15, 16, 17, 21] } + { name: 'c3', maxPins: 21, inputs: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], outputs: [11, 12, 13, 14, 15, 16, 17, 21] }, + { name: 'c6', maxPins: 23, inputs: [], outputs: [] } ]; loadPins(type, sel, opt) { while (sel.firstChild) sel.removeChild(sel.firstChild); let cm = document.getElementById('divContainer').getAttribute('data-chipmodel'); - let pm = this.pinMaps.find(x => x.name === cm) || { name: '', maxPins: 39, inputs: [0, 1, 6, 7, 8, 9, 10, 11, 37, 38], outputs: [3, 6, 7, 8, 9, 10, 11, 34, 35, 36, 37, 38, 39] }; + let pm = this.pinMaps.find(x => x.name === cm) || { name: '', maxPins: 39, inputs: [], outputs: [] }; //console.log({ cm: cm, pm: pm }); for (let i = 0; i <= pm.maxPins; i++) { if (type.includes('in') && pm.inputs.includes(i)) continue; @@ -4815,3 +4837,15 @@ class Firmware { } var firmware = new Firmware(); +window.addEventListener('load', async () => { + // 1. Initialize your main application logic + // await init(); + + // 2. Fetch and display the app version + appVersion = await getAppVersion(); + const spanAppVersion = document.getElementById('spanAppVersion'); + spanAppVersion.innerText = `${appVersion.trim()}`; + + console.log("Application fully loaded and version updated."); +}); + diff --git a/dependencies.lock b/dependencies.lock new file mode 100644 index 0000000..ecbac7a --- /dev/null +++ b/dependencies.lock @@ -0,0 +1,322 @@ +dependencies: + chmorgan/esp-libhelix-mp3: + component_hash: cbb76089dc2c5749f7b470e2e70aedc44c9da519e04eb9a67d4c7ec275229e53 + dependencies: + - name: idf + require: private + version: '>=4.1.0' + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.0.3 + espressif/cbor: + component_hash: dad9ca860963e930366510a10b422b3125a4fb27b979712ed65efcbcd742de50 + dependencies: + - name: idf + require: private + version: '>=5.0' + source: + registry_url: https://components.espressif.com/ + type: service + version: 0.6.1~4 + espressif/esp-dsp: + component_hash: 939e9c053487d6e7b7320a5cb761b2200e4b331730d6721668755ef76ab9f067 + dependencies: + - name: idf + require: private + version: '>=4.2' + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.7.1 + espressif/esp-modbus: + component_hash: 5d5e90b9e55721a8a194b301ad8102d4affb647f47b74cd413ff7d1ce2c1169c + dependencies: + - name: idf + require: private + version: '>=4.3' + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.0.18 + espressif/esp-serial-flasher: + component_hash: dcc42a16712a1a636509cf0bf90e14032d7f2141784b533613b267b6aa318d52 + dependencies: [] + source: + registry_url: https://components.espressif.com + type: service + version: 0.0.11 + espressif/esp-zboss-lib: + component_hash: 321883d142421f65009972408287441794250057668a11abbdfd8bec77c3309a + dependencies: + - name: idf + require: private + version: '>=5.0' + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.6.4 + espressif/esp-zigbee-lib: + component_hash: fa0812e6743e2a7d999af9f44ccdcea17ccb1e80f98d6b2956f44687503a88fd + dependencies: + - name: idf + require: private + version: '>=5.0' + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.6.8 + espressif/esp_diag_data_store: + component_hash: c1e5cf62f545d2b136db299f4df1b228b9840be5bc3410c9ad2d2a882b5c0d64 + dependencies: + - name: idf + require: private + version: '>=4.1' + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.0.2 + espressif/esp_diagnostics: + component_hash: 5ea8e8da8217ed9ed778db3973139e726e17cd27ef5cf6429c787d19226c79f3 + dependencies: + - name: idf + require: private + version: '>=4.1' + - name: espressif/rmaker_common + registry_url: https://components.espressif.com + require: private + version: ~1.4.0 + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.2.1 + espressif/esp_insights: + component_hash: 4015c524b9955528f941268cf080174076b195800de910d061efc46113bc2e0c + dependencies: + - name: idf + require: private + version: '>=4.1' + - name: espressif/cbor + registry_url: https://components.espressif.com + require: private + rules: + - if: idf_version >=5.0 + version: ~0.6 + - name: espressif/esp_diag_data_store + registry_url: https://components.espressif.com + require: private + version: 1.0.2 + - name: espressif/esp_diagnostics + registry_url: https://components.espressif.com + require: private + version: 1.2.1 + - name: espressif/rmaker_common + registry_url: https://components.espressif.com + require: private + version: ~1.4.0 + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.2.2 + espressif/esp_modem: + component_hash: f4fa6dab2496af2673a68881132bb7ce0f05bf62e30e5bd0d45b607066378a28 + dependencies: + - name: idf + require: private + version: '>=4.1' + source: + registry_url: https://components.espressif.com/ + type: service + version: 2.0.1 + espressif/esp_rainmaker: + component_hash: f6fe458fc7a0102ee2879f0247da4b41419e6c07de12031f66e5e9454d25baaa + dependencies: + - name: espressif/esp_rcp_update + registry_url: https://components.espressif.com + require: private + rules: + - if: idf_version >= 5.1 + version: ~1.2.0 + - name: espressif/esp_schedule + registry_url: https://components.espressif.com + require: private + version: ~1.2.0 + - name: espressif/esp_secure_cert_mgr + registry_url: https://components.espressif.com + require: private + rules: + - if: idf_version >=4.3 + version: ^2.2.1 + - name: espressif/json_generator + registry_url: https://components.espressif.com + require: private + version: ~1.1.1 + - name: espressif/json_parser + registry_url: https://components.espressif.com + require: private + version: ~1.0.3 + - name: espressif/mdns + registry_url: https://components.espressif.com + require: private + rules: + - if: idf_version >=5.0 + version: ^1.2.0 + - name: espressif/network_provisioning + registry_url: https://components.espressif.com + require: private + rules: + - if: idf_version >= 5.1 + version: ~1.0.0 + - name: espressif/rmaker_common + registry_url: https://components.espressif.com + require: private + version: ~1.4.6 + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.5.2 + espressif/esp_rcp_update: + component_hash: c10afbd54a17f27eed880e61262b161656e6d36ad63376c307f9273e99d0abcd + dependencies: + - name: espressif/esp-serial-flasher + registry_url: https://components.espressif.com + require: private + version: ~0.0.0 + - name: idf + require: private + version: '>=5.0' + source: + registry_url: https://components.espressif.com + type: service + version: 1.2.0 + espressif/esp_schedule: + component_hash: e202a9c688f7f1ab601efb91d682e4bcfaebc508dcceee1a1e0a0d2d1ca75a26 + dependencies: + - name: espressif/rmaker_common + registry_url: https://components.espressif.com + require: private + version: ~1.4.2 + source: + registry_url: https://components.espressif.com + type: service + version: 1.2.0 + espressif/esp_secure_cert_mgr: + component_hash: 2587797e68395edb67f30a7f9a7ce6a529492fa5fa6468592e912bc7ea34dbae + dependencies: + - name: idf + require: private + version: '>=4.3' + source: + registry_url: https://components.espressif.com + type: service + version: 2.9.1 + espressif/jsmn: + component_hash: d80350c41bbaa827c98a25b6072df00884e72f54885996fab4a4f0aebce6b6c3 + dependencies: + - name: idf + require: private + version: '>=4.3' + source: + registry_url: https://components.espressif.com + type: service + version: 1.1.0 + espressif/json_generator: + component_hash: 45033e1c199b13f1c8c1b544fb7d4e2df6a8e3071ebdcb1b22582b61a7974ff2 + dependencies: [] + source: + registry_url: https://components.espressif.com + type: service + version: 1.1.2 + espressif/json_parser: + component_hash: d74b81729ad06ec11ff5eb5b1b0d7df1d00e6027fc11471f4b139c70dcf1b1e4 + dependencies: + - name: espressif/jsmn + registry_url: https://components.espressif.com + require: private + rules: + - if: idf_version >=5.0 + version: ~1.1 + source: + registry_url: https://components.espressif.com + type: service + version: 1.0.3 + espressif/libsodium: + component_hash: b51f5836f044d8b7fbb1784257605c47ff7356f701377b005912fe6a2f12db37 + dependencies: + - name: idf + require: private + version: '>=4.2' + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.0.21 + espressif/mdns: + component_hash: 1ebe3bd675bb9d1c58f52bc0b609b32f74e572b01c328f9e61282040c775495c + dependencies: + - name: idf + require: private + version: '>=5.0' + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.11.0 + espressif/network_provisioning: + component_hash: ef2e10182fd1861e68b821491916327c25416ca7ae70e5a6e43313dbc71fe993 + dependencies: + - name: idf + require: private + version: '>=5.1' + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.0.2 + espressif/qrcode: + component_hash: 3b493771bc5d6ad30cbf87c25bf784aada8a08c941504355b55d6b75518ed7bc + dependencies: [] + source: + registry_url: https://components.espressif.com/ + type: service + version: 0.1.0~2 + espressif/rmaker_common: + component_hash: a3a1df881278d0351fc850b77792fe8a196ddd6dcacbea203d606329cc6a0239 + dependencies: [] + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.4.6 + idf: + source: + type: idf + version: 5.5.2 + joltwallet/littlefs: + component_hash: dcea25bcef2de023f089f5f01e8d8c46ad1b8ffef75861ad5ffb4098555839df + dependencies: + - name: idf + require: private + version: '>=5.0' + source: + registry_url: https://components.espressif.com/ + type: service + version: 1.20.4 +direct_dependencies: +- chmorgan/esp-libhelix-mp3 +- espressif/cbor +- espressif/esp-dsp +- espressif/esp-modbus +- espressif/esp-zboss-lib +- espressif/esp-zigbee-lib +- espressif/esp_diag_data_store +- espressif/esp_diagnostics +- espressif/esp_insights +- espressif/esp_modem +- espressif/esp_rainmaker +- espressif/libsodium +- espressif/mdns +- espressif/network_provisioning +- espressif/qrcode +- espressif/rmaker_common +- idf +- joltwallet/littlefs +manifest_hash: 3e908f06feb1567024342d2aa7f9257e07d7fd89e839fca4eec0522ea95a34de +target: esp32c6 +version: 2.0.0 diff --git a/esp32_huge_app.csv b/esp32_huge_app.csv new file mode 100644 index 0000000..9070da5 --- /dev/null +++ b/esp32_huge_app.csv @@ -0,0 +1,6 @@ +# Name, Type, SubType, Offset, Size +nvs, data, nvs, 0x9000, 0x5000, +otadata, data, ota, 0xE000, 0x2000, +app0, app, factory, 0x10000, 0x300000, +spiffs, data, spiffs, 0x310000, 0xD0000, +coredump, data, coredump, 0x3E0000, 0x10000, \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 3c6fb82..a353743 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,6 +10,7 @@ [platformio] default_envs = esp32devdbg +src_dir = src [env] platform = espressif32 @ 6.13.0 @@ -21,9 +22,9 @@ lib_deps = esp32async/ESPAsyncWebServer@^3.10.3 esp32async/AsyncTCP@^3.4.10 extra_scripts = + pre:app_version.py pre:minify.py post:archive_elf.py - board_build.filesystem = littlefs build_flags = -DCORE_DEBUG_LEVEL=3 @@ -55,12 +56,23 @@ board_build.partitions = esp32_3MB.csv board = esp32-s3-devkitc-1 [env:esp32c6] -platform = https://github.com/mnowak32/platform-espressif32.git#boards/seeed_xiao_esp32c6 -platform_packages = - framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.4 - framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.4/esp32-arduino-libs-3.0.4.zip +platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip board = seeed_xiao_esp32c6 -board_build.partitions = esp32_3MB.csv -build_flags = +build_type = debug +board_build.partitions = esp32_huge_app.csv +build_flags = ${env.build_flags} - -I${platformio.packages_dir}/framework-arduinoespressif32/libraries/Network/src + -DCONFIG_FREERTOS_HZ=1000 + -include "driver/gpio.h" +lib_deps = + ; Low-Level libs, frameowrks and drivers + ESP32Async/AsyncTCP + https://github.com/Viproz/SmartRC-CC1101-Driver-Lib.git + ; Commmunication Protocol + links2004/WebSockets + https://github.com/hmueller01/pubsubclient3.git + ; Data-Parsing + bblanchon/ArduinoJson + ; High-level wrappers/servers + ESP32Async/ESPAsyncWebServer + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..483bc0c --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,6 @@ +# This file was automatically generated for projects +# without default 'CMakeLists.txt' file. + +FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*) + +idf_component_register(SRCS ${app_sources}) diff --git a/src/ConfigSettings.cpp b/src/ConfigSettings.cpp index cb9a6a9..925c2a7 100644 --- a/src/ConfigSettings.cpp +++ b/src/ConfigSettings.cpp @@ -158,11 +158,11 @@ bool ConfigSettings::begin() { case esp_chip_model_t::CHIP_ESP32C3: strcpy(this->chipModel, "c3"); break; -#ifdef CHIP_ESP32C6 + #ifdef CONFIG_IDF_TARGET_ESP32C6 case esp_chip_model_t::CHIP_ESP32C6: strcpy(this->chipModel, "c6"); break; -#endif + #endif default: sprintf(this->chipModel, "UNK%d", static_cast(ci.model)); break; diff --git a/src/ConfigSettings.h b/src/ConfigSettings.h index 4bc1010..72c7127 100644 --- a/src/ConfigSettings.h +++ b/src/ConfigSettings.h @@ -5,7 +5,11 @@ #ifndef configsettings_h #define configsettings_h #include "WResp.h" -#define FW_VERSION "v3.0.11" + +#ifndef FW_VERSION + #define FW_VERSION "v3.0.11" // Fallback if app_version.py script fails +#endif + enum class conn_types_t : byte { unset = 0x00, wifi = 0x01, diff --git a/src/ESPNetwork.cpp b/src/ESPNetwork.cpp index bf4f5a0..98d2c5d 100644 --- a/src/ESPNetwork.cpp +++ b/src/ESPNetwork.cpp @@ -5,6 +5,12 @@ #include #include #include "esp_log.h" + +// Only reset the WDT if the current task is actually subscribed. +// setConnected() is called from the WiFi event task which is not registered. +static inline void safe_wdt_reset() { + if (esp_task_wdt_status(NULL) == ESP_OK) esp_task_wdt_reset(); +} #include "ConfigSettings.h" #include "ESPNetwork.h" #include "Web.h" @@ -230,7 +236,7 @@ void ESPNetwork::emitSockets(uint8_t num) { this->emitHeap(num); } void ESPNetwork::setConnected(conn_types_t connType) { - esp_task_wdt_reset(); + safe_wdt_reset(); this->connType = connType; this->connectTime = millis(); connectRetries = 0; @@ -261,7 +267,7 @@ void ESPNetwork::setConnected(conn_types_t connType) { #endif // CONFIG_IDF_TARGET_ESP32C6 // NET: Begin this in the startup. //sockEmit.begin(); - esp_task_wdt_reset(); + safe_wdt_reset(); if(this->connectAttempts == 1) { if(this->connType == conn_types_t::wifi) { @@ -284,7 +290,7 @@ void ESPNetwork::setConnected(conn_types_t connType) { settings.IP.dns1 = ETH.dnsIP(0); settings.IP.dns2 = ETH.dnsIP(1); } - esp_task_wdt_reset(); + safe_wdt_reset(); JsonSockEvent *json = sockEmit.beginEmit("ethernet"); json->beginObject(); json->addElem("connected", this->connected()); @@ -292,7 +298,7 @@ void ESPNetwork::setConnected(conn_types_t connType) { json->addElem("fullduplex", ETH.fullDuplex()); json->endObject(); sockEmit.endEmit(); - esp_task_wdt_reset(); + safe_wdt_reset(); } #endif } @@ -311,7 +317,7 @@ void ESPNetwork::setConnected(conn_types_t connType) { SSDP.setChipId(0, this->getChipId()); SSDP.setDeviceType(0, "urn:schemas-rstrouse-org:device:ESPSomfyRTS:1"); SSDP.setName(0, settings.hostname); - + //SSDP.setSerialNumber(0, "C2496952-5610-47E6-A968-2FC19737A0DB"); //SSDP.setUUID(0, settings.uuid); SSDP.setModelName(0, "ESPSomfy RTS"); @@ -326,24 +332,24 @@ void ESPNetwork::setConnected(conn_types_t connType) { SSDP.setManufacturerURL(0, "https://github.com/rstrouse"); SSDP.setURL(0, "/"); SSDP.setActive(0, true); - esp_task_wdt_reset(); + safe_wdt_reset(); if(MDNS.begin(settings.hostname)) { ESP_LOGI(TAG, "MDNS Responder Started: serverId=%s", settings.serverId); MDNS.addService("http", "tcp", 80); //MDNS.addServiceTxt("http", "tcp", "board", "ESP32"); //MDNS.addServiceTxt("http", "tcp", "model", "ESPSomfyRTS"); - + MDNS.addService("espsomfy_rts", "tcp", 8080); MDNS.addServiceTxt("espsomfy_rts", "tcp", "serverId", String(settings.serverId)); MDNS.addServiceTxt("espsomfy_rts", "tcp", "model", "ESPSomfyRTS"); MDNS.addServiceTxt("espsomfy_rts", "tcp", "version", String(settings.fwVersion.name)); } if(settings.ssdpBroadcast) { - esp_task_wdt_reset(); + safe_wdt_reset(); SSDP.begin(); } else if(SSDP.isStarted) SSDP.end(); - esp_task_wdt_reset(); + safe_wdt_reset(); this->emitSockets(); settings.printAvailHeap(); this->needsBroadcast = true; diff --git a/src/Somfy.cpp b/src/Somfy.cpp index 6d57ed4..0466520 100644 --- a/src/Somfy.cpp +++ b/src/Somfy.cpp @@ -4712,14 +4712,15 @@ void transceiver_config_t::load() { this->SCKPin = 15; this->CSNPin = 14; break; -#ifdef CHIP_ESP32C6 +#ifdef CONFIG_IDF_TARGET_ESP32C6 case esp_chip_model_t::CHIP_ESP32C6: - this->TXPin = 13; - this->RXPin = 12; - this->MOSIPin = 16; - this->MISOPin = 17; - this->SCKPin = 15; - this->CSNPin = 14; + // Pinout applicable for the ESP32-C6-WROOM-1 module (ESP32-C6-DevKitC-1-N4) + this->TXPin = 10; + this->RXPin = 10; + this->MOSIPin = 7; + this->MISOPin = 2; + this->SCKPin = 6; + this->CSNPin = 0; break; #endif default: @@ -4878,15 +4879,6 @@ bool Transceiver::begin() { return true; } void Transceiver::loop() { - // Dispatch deferred frequency scan requests from the main task so that - // attachInterrupt/detachInterrupt cross-core IPCs don't race with WiFi. - if(_pendingScan >= 0) { - int8_t pending = _pendingScan; - _pendingScan = -1; - if(pending == 1) this->beginFrequencyScan(); - else this->endFrequencyScan(); - return; - } somfy_rx_t rx; if (noiseDetected && rxmode != 3 && this->config.noiseDetection) { if (millis() - noiseStart > 100) { diff --git a/src/Somfy.h b/src/Somfy.h index 66512b9..6630db6 100644 --- a/src/Somfy.h +++ b/src/Somfy.h @@ -490,10 +490,6 @@ class Transceiver { bool _received = false; somfy_frame_t frame; public: - // -1 = none pending, 1 = beginFrequencyScan pending, 0 = endFrequencyScan pending. - // Set from the async_tcp task; consumed by loop() on the main task to avoid - // concurrent cross-core IPC races with the WiFi stack (EXCCAUSE_LOAD_PROHIBITED). - volatile int8_t _pendingScan = -1; transceiver_config_t config; bool printBuffer = false; //bool toJSON(JsonObject& obj); diff --git a/src/Web.cpp b/src/Web.cpp index eea0bc8..71c063c 100644 --- a/src/Web.cpp +++ b/src/Web.cpp @@ -2406,7 +2406,7 @@ void Web::begin() { })); asyncServer.on("/beginFrequencyScan", HTTP_GET, [](AsyncWebServerRequest *request) { - somfy.transceiver._pendingScan = 1; // deferred to main task — see Transceiver::loop() + somfy.transceiver.beginFrequencyScan(); AsyncJsonResp resp; resp.beginResponse(request, g_async_content, sizeof(g_async_content)); resp.beginObject(); @@ -2416,7 +2416,7 @@ void Web::begin() { }); asyncServer.on("/endFrequencyScan", HTTP_GET, [](AsyncWebServerRequest *request) { - somfy.transceiver._pendingScan = 0; // deferred to main task — see Transceiver::loop() + somfy.transceiver.endFrequencyScan(); AsyncJsonResp resp; resp.beginResponse(request, g_async_content, sizeof(g_async_content)); resp.beginObject(); diff --git a/src/idf_component.yml b/src/idf_component.yml new file mode 100644 index 0000000..d752765 --- /dev/null +++ b/src/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + idf: '>=5.1'