This commit is contained in:
Samt43 2025-12-28 18:23:00 +00:00 committed by GitHub
commit b15c47d5fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
58 changed files with 737 additions and 75 deletions

2
.clangd Normal file
View file

@ -0,0 +1,2 @@
CompileFlags:
Remove: [-f*, -m*]

2
.gitignore vendored
View file

@ -3,6 +3,8 @@ debug_custom.json
esp32.vsd esp32.vsd
esp32s3.svd esp32s3.svd
debug.cfg debug.cfg
build/
managed_components/
SomfyController.ino.XIAO_ESP32S3.bin SomfyController.ino.XIAO_ESP32S3.bin
SomfyController.ino.esp32c3.bin SomfyController.ino.esp32c3.bin

36
CMakeLists.txt Normal file
View file

@ -0,0 +1,36 @@
# For more information about build system see
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)
include(FetchContent)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
idf_build_set_property(MINIMAL_BUILD ON)
FetchContent_Declare(
c1101_driver
GIT_REPOSITORY https://github.com/Viproz/SmartRC-CC1101-Driver-Lib.git
GIT_TAG 3664897200d1d695fbc78f7ae5d731cb2acff8be
)
FetchContent_MakeAvailable(c1101_driver)
FetchContent_Declare(
pubsubclient
GIT_REPOSITORY https://github.com/knolleary/pubsubclient.git
GIT_TAG 2d228f2f862a95846c65a8518c79f48dfc8f188c
)
FetchContent_MakeAvailable(pubsubclient)
FetchContent_Declare(
arduinoWebSockets
GIT_REPOSITORY https://github.com/Links2004/arduinoWebSockets.git
GIT_TAG 8d0744eb5e916ec646d83bd1ffed5f643aab04d8
)
FetchContent_MakeAvailable(arduinoWebSockets)
project(main)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,8 @@
idf_component_register(SRCS "${c1101_driver_SOURCE_DIR}/ELECHOUSE_CC1101_SRC_DRV.cpp"
INCLUDE_DIRS "${c1101_driver_SOURCE_DIR}/"
REQUIRES "arduino-esp32" # Library requires Arduino
)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-misleading-indentation -Wno-maybe-uninitialized)

View file

@ -0,0 +1,7 @@
file(GLOB_RECURSE SRCS_CPP ${arduinowebsockets_SOURCE_DIR}/src/*.cpp)
idf_component_register(SRCS ${SRCS_CPP}
INCLUDE_DIRS "${arduinowebsockets_SOURCE_DIR}/src/"
REQUIRES "arduino-esp32" # Library requires Arduino
)

View file

@ -0,0 +1,7 @@
idf_component_register(SRCS "${pubsubclient_SOURCE_DIR}/src/PubSubClient.cpp"
INCLUDE_DIRS "${pubsubclient_SOURCE_DIR}/src/."
REQUIRES "arduino-esp32" # Library requires Arduino
)

View file

@ -1,14 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Example OpenOCD configuration file for ESP32-S3 connected via builtin USB-JTAG adapter.
#
# For example, OpenOCD can be started for ESP32-S3 debugging on
#
# openocd -f board/esp32s3-builtin.cfg
#
# Source the JTAG interface configuration file
source [find interface/esp_usb_jtag.cfg]
# Source the ESP32-S3 configuration file
source [find target/esp32s3.cfg]

450
dependencies.lock Normal file
View file

@ -0,0 +1,450 @@
dependencies:
bblanchon/arduinojson:
component_hash: b1c2f0b0bc26969af19809cee80b220fb882481d59cc75f8e79ebceecdc69f06
dependencies: []
source:
registry_url: https://components.espressif.com/
type: service
version: 7.4.2
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/arduino-esp32:
component_hash: dcff5d6fbbe18c30bfe76cd200dc2b1254c98a7116a6835b600ae9076ff8761c
dependencies:
- name: chmorgan/esp-libhelix-mp3
registry_url: https://components.espressif.com
require: private
version: 1.0.3
- name: espressif/cbor
registry_url: https://components.espressif.com
require: private
rules:
- if: target not in [esp32c2, esp32p4]
version: 0.6.1~4
- name: espressif/esp-dsp
registry_url: https://components.espressif.com
require: private
rules:
- if: target not in [esp32c2, esp32c61]
version: ^1.3.4
- name: espressif/esp-modbus
registry_url: https://components.espressif.com
require: private
version: ^1.0.15
- name: espressif/esp-sr
registry_url: https://components.espressif.com
require: private
rules:
- if: target in [esp32s3, esp32p4]
version: ^2.1.5
- name: espressif/esp-zboss-lib
registry_url: https://components.espressif.com
require: private
rules:
- if: target not in [esp32c2, esp32c61, esp32p4]
version: ==1.6.4
- name: espressif/esp-zigbee-lib
registry_url: https://components.espressif.com
require: private
rules:
- if: target not in [esp32c2, esp32c61, esp32p4]
version: ==1.6.8
- name: espressif/esp_diag_data_store
registry_url: https://components.espressif.com
require: private
rules:
- if: target not in [esp32c2, esp32p4]
version: 1.0.2
- name: espressif/esp_diagnostics
registry_url: https://components.espressif.com
require: private
rules:
- if: target not in [esp32c2, esp32p4]
version: 1.2.1
- name: espressif/esp_hosted
registry_url: https://components.espressif.com
require: private
rules:
- if: target == esp32p4
version: ^2.8.0
- name: espressif/esp_insights
registry_url: https://components.espressif.com
require: private
rules:
- if: target not in [esp32c2, esp32p4]
version: 1.2.2
- name: espressif/esp_modem
registry_url: https://components.espressif.com
require: private
version: ^2.0.0
- name: espressif/esp_rainmaker
registry_url: https://components.espressif.com
require: private
rules:
- if: target not in [esp32c2, esp32p4]
version: 1.5.2
- name: espressif/esp_wifi_remote
registry_url: https://components.espressif.com
require: private
rules:
- if: target == esp32p4
version: ^1.2.2
- name: espressif/lan867x
registry_url: https://components.espressif.com
require: private
rules:
- if: target in [esp32, esp32p4]
version: ^2.0.0
- name: espressif/libsodium
registry_url: https://components.espressif.com
require: private
version: ^1.0.20~1
- name: espressif/mdns
registry_url: https://components.espressif.com
require: private
version: ^1.2.3
- name: espressif/network_provisioning
registry_url: https://components.espressif.com
require: private
rules:
- if: target != esp32c2
version: 1.0.2
- name: espressif/qrcode
registry_url: https://components.espressif.com
require: private
rules:
- if: target not in [esp32c2, esp32p4]
version: 0.1.0~2
- name: espressif/rmaker_common
registry_url: https://components.espressif.com
require: private
rules:
- if: target not in [esp32c2, esp32p4]
version: 1.4.6
- name: idf
require: private
version: '>=5.3,<5.6'
- name: joltwallet/littlefs
registry_url: https://components.espressif.com
require: private
version: ^1.10.2
source:
pre_release: true
registry_url: https://components.espressif.com/
type: service
targets:
- esp32
- esp32c2
- esp32c3
- esp32c5
- esp32c6
- esp32c61
- esp32h2
- esp32p4
- esp32s2
- esp32s3
version: 3.3.5
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: 42dce32d46ac93dc11f60d368e29a830e9661c7345d794b8a45c343479cae636
dependencies:
- name: idf
require: private
version: '>=4.2'
source:
registry_url: https://components.espressif.com
type: service
version: 1.7.0
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: 07b6ca85dc0c1edbcd76f650005c74067001db138db6bfa106bf05567adca4af
dependencies:
- name: idf
require: private
version: '>=4.1'
source:
registry_url: https://components.espressif.com
type: service
version: 2.0.0
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: e8ce8d5ac0ef4ef5df12fdb266190413c4170ad39b394435f0e3115a4fddc6a6
dependencies:
- name: idf
require: private
version: '>=4.3'
source:
registry_url: https://components.espressif.com
type: service
version: 2.7.2
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: 25b968723c584a2742ca36cebe5a7ef049c6767e059f7b1e1eec69946019025d
dependencies:
- name: idf
require: private
version: '>=4.2'
source:
registry_url: https://components.espressif.com
type: service
version: 1.0.20~2
espressif/mdns:
component_hash: 29e47564b1a7ee778135e17fbbf2a2773f71c97ebabfe626c8eda7c958a7ad16
dependencies:
- name: idf
require: private
version: '>=5.0'
source:
registry_url: https://components.espressif.com
type: service
version: 1.9.1
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.1
joltwallet/littlefs:
component_hash: 1808d73e99168f6f3c26dd31799a248484762b3a320ec4962dec11a145f4277f
dependencies:
- name: idf
require: private
version: '>=5.0'
source:
registry_url: https://components.espressif.com/
type: service
version: 1.20.3
direct_dependencies:
- bblanchon/arduinojson
- espressif/arduino-esp32
- joltwallet/littlefs
manifest_hash: 6fa77c8a26e1a013b95a0c62cfcc8f62714a07c7915334212c645ab446ee7b85
target: esp32c5
version: 2.0.0

11
main/CMakeLists.txt Normal file
View file

@ -0,0 +1,11 @@
file(GLOB_RECURSE SRCS_CPP *.cpp)
idf_component_register(SRCS ${SRCS_CPP}
INCLUDE_DIRS "." REQUIRES esp_common arduinoWebSockets pubsubclient SmartRC-CC1101-Driver-Lib)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-format -Wno-misleading-indentation -Wno-error=address)
# Note: you must have a partition named the first argument (here it's "littlefs")
# in your partition table csv file.
littlefs_create_partition_image(spiffs data FLASH_IN_PROJECT)

View file

@ -663,7 +663,7 @@ bool ShadeConfigFile::readNetRecord(restore_options_t &opts) {
settings.Ethernet.boardType = this->readUInt8(1); settings.Ethernet.boardType = this->readUInt8(1);
settings.Ethernet.phyType = static_cast<eth_phy_type_t>(this->readUInt8(0)); settings.Ethernet.phyType = static_cast<eth_phy_type_t>(this->readUInt8(0));
settings.Ethernet.CLKMode = static_cast<eth_clock_mode_t>(this->readUInt8(0)); settings.Ethernet.CLKMode = static_cast<eth_clock_mode_t>(this->readUInt8(0));
settings.Ethernet.phyAddress = this->readInt8(1); settings.Ethernet.phyAddress = static_cast<eth_phy_type_t>(this->readInt8(1));
settings.Ethernet.PWRPin = this->readInt8(1); settings.Ethernet.PWRPin = this->readInt8(1);
settings.Ethernet.MDCPin = this->readInt8(16); settings.Ethernet.MDCPin = this->readInt8(16);
settings.Ethernet.MDIOPin = this->readInt8(23); settings.Ethernet.MDIOPin = this->readInt8(23);

View file

@ -732,7 +732,7 @@ bool EthernetSettings::save() {
bool EthernetSettings::load() { bool EthernetSettings::load() {
pref.begin("ETH"); pref.begin("ETH");
this->boardType = pref.getChar("boardType", this->boardType); this->boardType = pref.getChar("boardType", this->boardType);
this->phyType = static_cast<eth_phy_type_t>(pref.getChar("phyType", ETH_PHY_LAN8720)); this->phyType = static_cast<eth_phy_type_t>(pref.getChar("phyType", 0));
this->CLKMode = static_cast<eth_clock_mode_t>(pref.getChar("CLKMode", ETH_CLOCK_GPIO0_IN)); this->CLKMode = static_cast<eth_clock_mode_t>(pref.getChar("CLKMode", ETH_CLOCK_GPIO0_IN));
this->phyAddress = pref.getChar("phyAddress", this->phyAddress); this->phyAddress = pref.getChar("phyAddress", this->phyAddress);
this->PWRPin = pref.getChar("PWRPin", this->PWRPin); this->PWRPin = pref.getChar("PWRPin", this->PWRPin);

View file

@ -4,6 +4,16 @@
#define configsettings_h #define configsettings_h
#include "WResp.h" #include "WResp.h"
#define FW_VERSION "v2.4.7" #define FW_VERSION "v2.4.7"
#if !CONFIG_ETH_USE_ESP32_EMAC
typedef enum {
ETH_CLOCK_GPIO0_IN,
ETH_CLOCK_GPIO0_OUT,
ETH_CLOCK_GPIO16_OUT,
ETH_CLOCK_GPIO17_OUT
} eth_clock_mode_t;
#endif
enum class conn_types_t : byte { enum class conn_types_t : byte {
unset = 0x00, unset = 0x00,
wifi = 0x01, wifi = 0x01,
@ -92,12 +102,12 @@ class EthernetSettings: BaseSettings {
public: public:
EthernetSettings(); EthernetSettings();
uint8_t boardType = 0; // These board types are enumerated in the ui and used to set the chip settings. uint8_t boardType = 0; // These board types are enumerated in the ui and used to set the chip settings.
eth_phy_type_t phyType = ETH_PHY_LAN8720; eth_phy_type_t phyType = ETH_PHY_MAX;
eth_clock_mode_t CLKMode = ETH_CLOCK_GPIO0_IN; eth_clock_mode_t CLKMode = ETH_CLOCK_GPIO0_IN;
int8_t phyAddress = ETH_PHY_ADDR; int8_t phyAddress = 0;
int8_t PWRPin = ETH_PHY_POWER; int8_t PWRPin = 0;
int8_t MDCPin = ETH_PHY_MDC; int8_t MDCPin = 0;
int8_t MDIOPin = ETH_PHY_MDIO; int8_t MDIOPin = 0;
bool begin(); bool begin();
bool fromJSON(JsonObject &obj); bool fromJSON(JsonObject &obj);

View file

@ -10,7 +10,9 @@
#include "Somfy.h" #include "Somfy.h"
#include "Web.h" #include "Web.h"
#include "WResp.h" #include "WResp.h"
#include "Network.h" #include "Network_internal.h"
#include "esp_chip_info.h"
@ -20,7 +22,7 @@ extern SocketEmitter sockEmit;
extern SomfyShadeController somfy; extern SomfyShadeController somfy;
extern rebootDelay_t rebootDelay; extern rebootDelay_t rebootDelay;
extern Web webServer; extern Web webServer;
extern Network net; extern Network_internal net;
@ -97,7 +99,7 @@ int16_t GitRepo::getReleases(uint8_t num) {
uint8_t ndx = 0; uint8_t ndx = 0;
uint8_t count = min((uint8_t)GIT_MAX_RELEASES, num); uint8_t count = min((uint8_t)GIT_MAX_RELEASES, num);
char url[128]; char url[128];
memset(this->releases, 0x00, sizeof(GitRelease) * GIT_MAX_RELEASES); //memset(this->releases, 0x00, sizeof(GitRelease) * GIT_MAX_RELEASES);
sprintf(url, "https://api.github.com/repos/rstrouse/espsomfy-rts/releases?per_page=%d&page=1", count); sprintf(url, "https://api.github.com/repos/rstrouse/espsomfy-rts/releases?per_page=%d&page=1", count);
GitRelease *main = &this->releases[GIT_MAX_RELEASES]; GitRelease *main = &this->releases[GIT_MAX_RELEASES];
main->releaseDate = Timestamp::now(); main->releaseDate = Timestamp::now();

View file

@ -5,7 +5,7 @@
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "MQTT.h" #include "MQTT.h"
#include "Somfy.h" #include "Somfy.h"
#include "Network.h" #include "Network_internal.h"
#include "Utils.h" #include "Utils.h"
WiFiClient tcpClient; WiFiClient tcpClient;
@ -16,7 +16,7 @@ static char g_content[MQTT_MAX_RESPONSE];
extern ConfigSettings settings; extern ConfigSettings settings;
extern SomfyShadeController somfy; extern SomfyShadeController somfy;
extern Network net; extern Network_internal net;
extern rebootDelay_t rebootDelay; extern rebootDelay_t rebootDelay;

View file

View file

@ -3,7 +3,7 @@
#include <ESPmDNS.h> #include <ESPmDNS.h>
#include <esp_task_wdt.h> #include <esp_task_wdt.h>
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "Network.h" #include "Network_internal.h"
#include "Web.h" #include "Web.h"
#include "Sockets.h" #include "Sockets.h"
#include "Utils.h" #include "Utils.h"
@ -15,7 +15,7 @@ extern Web webServer;
extern SocketEmitter sockEmit; extern SocketEmitter sockEmit;
extern MQTTClass mqtt; extern MQTTClass mqtt;
extern rebootDelay_t rebootDelay; extern rebootDelay_t rebootDelay;
extern Network net; extern Network_internal net;
extern SomfyShadeController somfy; extern SomfyShadeController somfy;
static unsigned long _lastHeapEmit = 0; static unsigned long _lastHeapEmit = 0;
@ -24,13 +24,13 @@ static bool _apScanning = false;
static uint32_t _lastMaxHeap = 0; static uint32_t _lastMaxHeap = 0;
static uint32_t _lastHeap = 0; static uint32_t _lastHeap = 0;
int connectRetries = 0; int connectRetries = 0;
void Network::end() { void Network_internal::end() {
SSDP.end(); SSDP.end();
mqtt.end(); mqtt.end();
sockEmit.end(); sockEmit.end();
delay(100); delay(100);
} }
bool Network::setup() { bool Network_internal::setup() {
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN); WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL); WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
WiFi.persistent(false); WiFi.persistent(false);
@ -48,7 +48,7 @@ bool Network::setup() {
sockEmit.begin(); sockEmit.begin();
return true; return true;
} }
conn_types_t Network::preferredConnType() { conn_types_t Network_internal::preferredConnType() {
switch(settings.connType) { switch(settings.connType) {
case conn_types_t::wifi: case conn_types_t::wifi:
return settings.WIFI.ssid[0] != '\0' ? conn_types_t::wifi : conn_types_t::ap; return settings.WIFI.ssid[0] != '\0' ? conn_types_t::wifi : conn_types_t::ap;
@ -63,7 +63,7 @@ conn_types_t Network::preferredConnType() {
return settings.connType; return settings.connType;
} }
} }
void Network::loop() { void Network_internal::loop() {
// ORDER OF OPERATIONS: // ORDER OF OPERATIONS:
// ---------------------------------------------- // ----------------------------------------------
// 1. If we are in the middle of a connection process we need to simply bail after the connect method. The // 1. If we are in the middle of a connection process we need to simply bail after the connect method. The
@ -154,7 +154,7 @@ void Network::loop() {
} }
else if(!settings.ssdpBroadcast && SSDP.isStarted) SSDP.end(); else if(!settings.ssdpBroadcast && SSDP.isStarted) SSDP.end();
} }
bool Network::changeAP(const uint8_t *bssid, const int32_t channel) { bool Network_internal::changeAP(const uint8_t *bssid, const int32_t channel) {
esp_task_wdt_reset(); // Make sure we do not reboot here. esp_task_wdt_reset(); // Make sure we do not reboot here.
if(SSDP.isStarted) SSDP.end(); if(SSDP.isStarted) SSDP.end();
mqtt.disconnect(); mqtt.disconnect();
@ -167,7 +167,7 @@ bool Network::changeAP(const uint8_t *bssid, const int32_t channel) {
this->connectStart = millis(); this->connectStart = millis();
return false; return false;
} }
void Network::emitSockets() { void Network_internal::emitSockets() {
this->emitHeap(); this->emitHeap();
if(this->needsBroadcast || if(this->needsBroadcast ||
(this->connType == conn_types_t::wifi && (abs(abs(WiFi.RSSI()) - abs(this->lastRSSI)) > 1 || WiFi.channel() != this->lastChannel))) { (this->connType == conn_types_t::wifi && (abs(abs(WiFi.RSSI()) - abs(this->lastRSSI)) > 1 || WiFi.channel() != this->lastChannel))) {
@ -176,12 +176,12 @@ void Network::emitSockets() {
this->needsBroadcast = false; this->needsBroadcast = false;
} }
} }
void Network::emitSockets(uint8_t num) { void Network_internal::emitSockets(uint8_t num) {
if(this->connType == conn_types_t::ethernet) { if(this->connType == conn_types_t::ethernet) {
JsonSockEvent *json = sockEmit.beginEmit("ethernet"); JsonSockEvent *json = sockEmit.beginEmit("ethernet");
json->beginObject(); json->beginObject();
json->addElem("connected", this->connected()); json->addElem("connected", this->connected());
json->addElem("speed", ETH.linkSpeed()); json->addElem("speed", (int32_t)ETH.linkSpeed());
json->addElem("fullduplex", ETH.fullDuplex()); json->addElem("fullduplex", ETH.fullDuplex());
json->endObject(); json->endObject();
sockEmit.endEmit(num); sockEmit.endEmit(num);
@ -220,7 +220,7 @@ void Network::emitSockets(uint8_t num) {
} }
this->emitHeap(num); this->emitHeap(num);
} }
void Network::setConnected(conn_types_t connType) { void Network_internal::setConnected(conn_types_t connType) {
esp_task_wdt_reset(); esp_task_wdt_reset();
this->connType = connType; this->connType = connType;
this->connectTime = millis(); this->connectTime = millis();
@ -288,7 +288,7 @@ void Network::setConnected(conn_types_t connType) {
JsonSockEvent *json = sockEmit.beginEmit("ethernet"); JsonSockEvent *json = sockEmit.beginEmit("ethernet");
json->beginObject(); json->beginObject();
json->addElem("connected", this->connected()); json->addElem("connected", this->connected());
json->addElem("speed", ETH.linkSpeed()); json->addElem("speed", (int32_t)ETH.linkSpeed());
json->addElem("fullduplex", ETH.fullDuplex()); json->addElem("fullduplex", ETH.fullDuplex());
json->endObject(); json->endObject();
sockEmit.endEmit(); sockEmit.endEmit();
@ -365,7 +365,7 @@ void Network::setConnected(conn_types_t connType) {
settings.printAvailHeap(); settings.printAvailHeap();
this->needsBroadcast = true; this->needsBroadcast = true;
} }
bool Network::connectWired() { bool Network_internal::connectWired() {
if(ETH.linkUp()) { if(ETH.linkUp()) {
// If the ethernet link is re-established then we need to shut down wifi. // If the ethernet link is re-established then we need to shut down wifi.
if(WiFi.status() == WL_CONNECTED) { if(WiFi.status() == WL_CONNECTED) {
@ -400,7 +400,9 @@ bool Network::connectWired() {
ETH.setHostname("ESPSomfy-RTS"); ETH.setHostname("ESPSomfy-RTS");
Serial.print("Set hostname to:"); Serial.print("Set hostname to:");
Serial.println(ETH.getHostname()); Serial.println(ETH.getHostname());
if(!ETH.begin(settings.Ethernet.phyAddress, settings.Ethernet.PWRPin, settings.Ethernet.MDCPin, settings.Ethernet.MDIOPin, settings.Ethernet.phyType, settings.Ethernet.CLKMode)) {
#if CONFIG_ETH_USE_ESP32_EMAC
if(!ETH.begin(settings.Ethernet.phyType, settings.Ethernet.phyAddress, settings.Ethernet.MDCPin, settings.Ethernet.MDIOPin, settings.Ethernet.PWRPin, settings.Ethernet.CLKMode)) {
Serial.println("Ethernet Begin failed"); Serial.println("Ethernet Begin failed");
this->ethStarted = false; this->ethStarted = false;
if(settings.connType == conn_types_t::ethernetpref) { if(settings.connType == conn_types_t::ethernetpref) {
@ -419,11 +421,12 @@ bool Network::connectWired() {
else else
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE); ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
} }
#endif
} }
this->connectStart = millis(); this->connectStart = millis();
return true; return true;
} }
void Network::updateHostname() { void Network_internal::updateHostname() {
if(settings.hostname[0] != '\0' && this->connected()) { if(settings.hostname[0] != '\0' && this->connected()) {
if(this->connType == conn_types_t::ethernet && if(this->connType == conn_types_t::ethernet &&
strcmp(settings.hostname, ETH.getHostname()) != 0) { strcmp(settings.hostname, ETH.getHostname()) != 0) {
@ -440,7 +443,7 @@ void Network::updateHostname() {
} }
} }
} }
bool Network::connectWiFi(const uint8_t *bssid, const int32_t channel) { bool Network_internal::connectWiFi(const uint8_t *bssid, const int32_t channel) {
if(this->softAPOpened && WiFi.softAPgetStationNum() > 0) { if(this->softAPOpened && WiFi.softAPgetStationNum() > 0) {
// There is a client connected to the soft AP. We do not want to close out the connection. While both the // There is a client connected to the soft AP. We do not want to close out the connection. While both the
// Soft AP and a wifi connection can coexist on ESP32 the performance is abysmal. // Soft AP and a wifi connection can coexist on ESP32 the performance is abysmal.
@ -513,7 +516,7 @@ bool Network::connectWiFi(const uint8_t *bssid, const int32_t channel) {
this->connectStart = millis(); this->connectStart = millis();
return true; return true;
} }
bool Network::connect(conn_types_t ctype) { bool Network_internal::connect(conn_types_t ctype) {
esp_task_wdt_reset(); esp_task_wdt_reset();
if(this->connecting()) return true; if(this->connecting()) return true;
if(this->disconnectTime == 0) this->disconnectTime = millis(); if(this->disconnectTime == 0) this->disconnectTime = millis();
@ -538,7 +541,7 @@ bool Network::connect(conn_types_t ctype) {
return true; return true;
} }
uint32_t Network::getChipId() { uint32_t Network_internal::getChipId() {
uint32_t chipId = 0; uint32_t chipId = 0;
uint64_t mac = ESP.getEfuseMac(); uint64_t mac = ESP.getEfuseMac();
for(int i=0; i<17; i=i+8) { for(int i=0; i<17; i=i+8) {
@ -546,7 +549,7 @@ uint32_t Network::getChipId() {
} }
return chipId; return chipId;
} }
bool Network::getStrongestAP(const char *ssid, uint8_t *bssid, int32_t *channel) { bool Network_internal::getStrongestAP(const char *ssid, uint8_t *bssid, int32_t *channel) {
// The new AP must be at least 10dbm greater. // The new AP must be at least 10dbm greater.
int32_t strength = this->connected() ? WiFi.RSSI() + 10 : -127; int32_t strength = this->connected() ? WiFi.RSSI() + 10 : -127;
int32_t chan = -1; int32_t chan = -1;
@ -567,7 +570,7 @@ bool Network::getStrongestAP(const char *ssid, uint8_t *bssid, int32_t *channel)
WiFi.scanDelete(); WiFi.scanDelete();
return chan > 0; return chan > 0;
} }
bool Network::openSoftAP() { bool Network_internal::openSoftAP() {
if(this->softAPOpened || this->openingSoftAP) return true; if(this->softAPOpened || this->openingSoftAP) return true;
if(this->connected()) WiFi.disconnect(false); if(this->connected()) WiFi.disconnect(false);
this->openingSoftAP = true; this->openingSoftAP = true;
@ -578,7 +581,7 @@ bool Network::openSoftAP() {
delay(200); delay(200);
return true; return true;
} }
bool Network::connected() { bool Network_internal::connected() {
if(this->connecting()) return false; if(this->connecting()) return false;
else if(this->connType == conn_types_t::unset) return false; else if(this->connType == conn_types_t::unset) return false;
else if(this->connType == conn_types_t::wifi) return WiFi.status() == WL_CONNECTED; else if(this->connType == conn_types_t::wifi) return WiFi.status() == WL_CONNECTED;
@ -586,12 +589,12 @@ bool Network::connected() {
else return this->connType != conn_types_t::unset; else return this->connType != conn_types_t::unset;
return false; return false;
} }
bool Network::connecting() { bool Network_internal::connecting() {
if(this->_connecting && millis() > this->connectStart + CONNECT_TIMEOUT) this->_connecting = false; if(this->_connecting && millis() > this->connectStart + CONNECT_TIMEOUT) this->_connecting = false;
return this->_connecting; return this->_connecting;
} }
void Network::clearConnecting() { this->_connecting = false; } void Network_internal::clearConnecting() { this->_connecting = false; }
void Network::networkEvent(WiFiEvent_t event) { void Network_internal::networkEvent(WiFiEvent_t event) {
switch(event) { switch(event) {
case ARDUINO_EVENT_WIFI_READY: Serial.println("(evt) WiFi interface ready"); break; case ARDUINO_EVENT_WIFI_READY: Serial.println("(evt) WiFi interface ready"); break;
case ARDUINO_EVENT_WIFI_SCAN_DONE: case ARDUINO_EVENT_WIFI_SCAN_DONE:
@ -670,7 +673,7 @@ void Network::networkEvent(WiFiEvent_t event) {
break; break;
} }
} }
void Network::emitHeap(uint8_t num) { void Network_internal::emitHeap(uint8_t num) {
bool bEmit = false; bool bEmit = false;
bool bTimeEmit = millis() - _lastHeapEmit > 15000; bool bTimeEmit = millis() - _lastHeapEmit > 15000;
bool bRoomEmit = false; bool bRoomEmit = false;

View file

@ -1,13 +1,13 @@
#include <Arduino.h> #include <Arduino.h>
#ifndef Network_h #ifndef Network_internal_h
#define Network_h #define Network_internal_h
//enum class conn_types_t : byte; //enum class conn_types_t : byte;
#define CONNECT_TIMEOUT 20000 #define CONNECT_TIMEOUT 20000
#define SSID_SCAN_INTERVAL 60000 #define SSID_SCAN_INTERVAL 60000
class Network { class Network_internal {
protected: protected:
unsigned long lastEmit = 0; unsigned long lastEmit = 0;
unsigned long lastMDNS = 0; unsigned long lastMDNS = 0;

84
main/README.md Normal file
View file

@ -0,0 +1,84 @@
# ESPSomfy-RTS <image src="https://user-images.githubusercontent.com/47839015/218898940-3541b360-5c49-4e38-a918-392cd0408b76.png" align="right" style="width:177px;display:inline-block;float:right"></image>
A controller for Somfy RTS blinds and shades that supports up to 32 individual shades and 16 groups over 433MHz RTx protocols. If you have IO Home Control motors this project is not for you but you can use the IO Remote protocol to connect the ESPSomfy RTS device to a disected remote. Look in the [Wiki](https://github.com/rstrouse/ESPSomfy-RTS/wiki/Controlling-Motors-with-GPIO) for options and verify whether the solution is workable for you.
Most of the 433MHz protocols are supported to include RTS, RTW, RTV/L and 433.92MHz radio transceivers. You can even mix and match these on the same device as long as the base frequency is tuned within the same range. For instance, you cannot have 433.92MHz and 433.42MHz motors on the same device.
If you have bare motors you can control these with a connected relay module using a simple configuration. So if you have a bunch of motors that don't have any radio module then I have you covered there as well. When you are done you can use any of the supported remotes for RTS, RTW, or RTV protocols on the 433MHz range.
## Why does this exist?
Most of my home is automated and one of the more annoying aspects was that there were three very expensive patio roller shades that still didn't have any type of automation attached to them. Since they were on the patio I had to run around on the patio looking for the Telis torpedo remote any time I wanted to move the outside shades. I have a rather large patio and the shades do a really good job at keeping the hot late afternoon sun from baking the house. These little remotes are sneaky and they tend to hide in plain sight and often move just out of reach when you are relaxing so that you have to extract your butt from your chair. Imagine just barking out commands at them and having them just work.
So I went searching for libraries that could automate my shades and relieve me from damning the torpedo. I didn't just want to move them I wanted to interact with them and manage their position. And because that Telis torpedo has been with me for so long I still wanted to be able to use that sneaky bugger as well.
The research led me to several projects that looked like they would do what I want. Most of them however, could send commands using a CC1101 radio attached to an ESP32 but I really wanted to be able to capture information from any external remotes as well. In the end I did not find what I wanted so this repository was born. ESPSomfy RTS is capable of not only controlling the shades but it can also manage the current position even when an old school remote is used to move the shades.
This software uses a couple of readily available hardware components. These include an ESP32 module and a CC1101 Transceiver module. The CC1101 is connected via SPI to the ESP32 and controlled using SmartRC-CC1101-Driver library. All in at the start of 2023 the total cost for me was about $12us for the final components.
# ESPSomfy RTS Device Updates
If you are here looking for how to install the latest software on your device. The wiki for instructions on how to do this is located here. [Updating ESPSomfy RTS](https://github.com/rstrouse/ESPSomfy-RTS/wiki/Updating-ESPSomfy-RTS)
# Functionality
After you get this up and running you will have the ability to interact with your shades using the built-in web interface, socket interface, and MQTT. There is also a full [Home Assistant integration](https://github.com/rstrouse/ESPSomfy-RTS-HA) that can be installed through HACS that can control your shades remotely and provide automations.
![image](https://user-images.githubusercontent.com/47839015/224559426-c81422c0-cdfe-45f9-a9c2-0c727619cdf9.png)
![image](https://github.com/rstrouse/ESPSomfy-RTS/assets/47839015/2a605e54-4487-49ba-9a7a-07e153db1c02)
* Identify each device by motor type (Awning, Shade, Shutter, Blind, or Drapery)
* Control movement using up, down, and my buttons
* Set and remove my button favorite
* Interactive positioning
* Tilt blinds
* Set blind tilt by percentage
* Control Awning Sun/Wind Sensors
## Moving a Shade
You can move the shade to the full up position by clicking the up button. To stop the shade during travel, press the my button and the shade will stop. To move the shade to the full down position press the down button. At any point during the movement you can press the my button to stop the shade.
If you would like to move the shade to a favorite position. Press the my button while the shade is at rest and the shade will move to the position set for the my button. These are displayed under the shade name so you do not have to guess what the current favorite is set to.
To move a shade to a target percentage of closed, click or tap on the shade icon. An interface will open that will allow you to select the position using a slider control. Move the slider to the desired position. When you release the slider the shade will begin to open or close to reach the desired position. You can change this position even when the shade is moving.
![image](https://user-images.githubusercontent.com/47839015/224559596-aa98d015-ee74-41f1-a852-3018f861e354.png)
## Setting a Favorite
To set your favorite my position you can either use the ESPSomfy RTS interface or your Somfy remote. ESPSomfy RTS listens for the long press of the my button so if you use the remote it will pick up this favorite. However, if you previously had a favorite set before installing ESPSomfy RTS you should reset it using ESPSomfy RTS. Somfy uses the same command to set and unset its favorites.
To set or unset a favorite long press the my button. After a few seconds a screen like below will appear. ESPSomfy RTS allows you to set a favorite by position, so you can drag the slider to 37% and press the `SET MY POSITION` button. After pressing the button the shade will move to that position and jog briefly indicating that the favorite has been saved.
![image](https://user-images.githubusercontent.com/47839015/224559730-859d3f9c-177c-46c3-9fb4-1a7df2cac505.png)
To unset a favorite perform the long press on the my button to open the favorites interface. Then move the slider to the current my position and the button will turn red and the text will change to `CLEAR MY POSITION`. Once you press the button the shade will jog indicating that the favorite has been cleared.
![image](https://user-images.githubusercontent.com/47839015/224559837-ad28b843-49ab-468c-8b8c-1ad470775750.png)
# Getting Started
To get started you must create a radio device. The wiki contains full instructions on how to get this up and running. You don't need a soldering iron to make this project work. Dupont connections between the radio and the ESP32 will suffice. However, I have also included some instructions on how to make an inconspicuous radio enclosure for a few bucks. Here is the [Simple Hardware Guide](https://github.com/rstrouse/ESPSomfy-RTS/wiki/Simple-ESPSomfy-RTS-device)
Next you need to get the initial firmware installed onto the ESP32. Once the firmware built and installed for your ESP32. The firmware installation process is a matter of uploading the onboard file to your ESP32. You will find the firmware guide in the wiki [Firmware Guide](https://github.com/rstrouse/ESPSomfy-RTS/wiki/Installing-the-Firmware)
Once you have your hardware built, the only thing left to do is connect the ESP32 to your network and begin pariing your shades. The software guide in the wiki will walk you through pairing your shades, linking remotes, and configuring your shades. The wiki also includes a comprehensive software guide that you can use to configure your shades. The good news is that this process is pretty easy to follow and you can be up and running very quickly.
[Configuring ESPSomfy-RTS](https://github.com/rstrouse/ESPSomfy-RTS/wiki/Configuring-the-Software)
## Integrations
While the interface that comes with the ESPSomfy RTS is a huge improvement, the whole idea of this project is to make the shades controllable from everywhere that I want to control them. So for that I created a couple of interfaces that you can use to bolt on your own automation. These options are for those people that have a propeller on their hat. They do things make red nodes (using Node-Red) or have their own web interface.
You can find the documentation for the interfaces in the [Integrations](https://github.com/rstrouse/ESPSomfy-RTS/wiki/Integrations) wiki. Plenty of stuff there for you folks that make red nodes and stuff.
## Sources for this Project
I spent some time reading about a myriad of topics but in the end the primary source for this project comes from https://pushstack.wordpress.com/somfy-rts-protocol/. The work done on pushstack regarding the protocol timing made this feasible without burning a bunch of time measuring pulses.
Configuration of the Transceiver is done with the ELECHOUSE_CC1101 library which you will need to include in your project should you want to compile the code. The one used for compiling this module can be found here. https://github.com/LSatan/SmartRC-CC1101-Driver-Lib

View file

@ -4,6 +4,7 @@
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "SSDP.h" #include "SSDP.h"
esp_netif_t *get_esp_interface_netif(esp_interface_t interface);
#define SSDP_PORT 1900 #define SSDP_PORT 1900
#define SSDP_METHOD_SIZE 10 #define SSDP_METHOD_SIZE 10
@ -381,15 +382,18 @@ void SSDPClass::_parsePacket(ssdp_packet_t *pkt, AsyncUDPPacket &p) {
IPAddress SSDPClass::localIP() IPAddress SSDPClass::localIP()
{ {
// Make sure we don't get a null IPAddress. // Make sure we don't get a null IPAddress.
tcpip_adapter_ip_info_t ip; esp_netif_ip_info_t ip;
if (WiFi.getMode() == WIFI_STA) { if (WiFi.getMode() == WIFI_STA) {
if (tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip)) { esp_netif_t* netif_sta = get_esp_interface_netif(ESP_IF_WIFI_STA);
if (esp_netif_get_ip_info(netif_sta, &ip)) {
return IPAddress(); return IPAddress();
} }
} else if (WiFi.getMode() == WIFI_OFF) { } else if (WiFi.getMode() == WIFI_OFF) {
if (tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)) { esp_netif_t* netif_eth = get_esp_interface_netif(ESP_IF_ETH);
if (esp_netif_get_ip_info(netif_eth, &ip)) {
return IPAddress(); return IPAddress();
} }
} }
return IPAddress(ip.ip.addr); return IPAddress(ip.ip.addr);
} }
@ -742,9 +746,11 @@ void SSDPClass::loop() {
void SSDPClass::schema(Print &client) { void SSDPClass::schema(Print &client) {
IPAddress ip = this->localIP(); IPAddress ip = this->localIP();
uint8_t devCount = 0; uint8_t devCount = 0;
for(uint8_t i = 0; i < this->m_cdeviceTypes; i++) { for(uint8_t i = 0; i < this->m_cdeviceTypes; i++) {
if(this->deviceTypes[i].deviceType && strlen(this->deviceTypes[i].deviceType) > 0) devCount++; if(strlen(this->deviceTypes[i].deviceType) > 0) devCount++;
} }
char schema_template[strlen_P(_ssdp_schema_template)+1]; char schema_template[strlen_P(_ssdp_schema_template)+1];
char device_template[strlen_P(_ssdp_device_schema_template)+1]; char device_template[strlen_P(_ssdp_device_schema_template)+1];
strcpy_P(schema_template, _ssdp_schema_template); strcpy_P(schema_template, _ssdp_schema_template);

View file

View file

@ -5,11 +5,11 @@
#include "Sockets.h" #include "Sockets.h"
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "Somfy.h" #include "Somfy.h"
#include "Network.h" #include "Network_internal.h"
#include "GitOTA.h" #include "GitOTA.h"
extern ConfigSettings settings; extern ConfigSettings settings;
extern Network net; extern Network_internal net;
extern SomfyShadeController somfy; extern SomfyShadeController somfy;
extern SocketEmitter sockEmit; extern SocketEmitter sockEmit;
extern GitUpdater git; extern GitUpdater git;

View file

@ -3,6 +3,7 @@
#include <SPI.h> #include <SPI.h>
#include <WebServer.h> #include <WebServer.h>
#include <esp_task_wdt.h> #include <esp_task_wdt.h>
#include <esp_chip_info.h>
#include "Utils.h" #include "Utils.h"
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "Somfy.h" #include "Somfy.h"
@ -4911,11 +4912,11 @@ void transceiver_config_t::load() {
break; break;
default: default:
this->TXPin = 13; this->TXPin = 13;
this->RXPin = 12; this->RXPin = 5;
this->MOSIPin = 23; this->MOSIPin = 2;
this->MISOPin = 19; this->MISOPin = 7;
this->SCKPin = 18; this->SCKPin = 6;
this->CSNPin = 5; this->CSNPin = 10;
break; break;
} }
pref.begin("CC1101"); pref.begin("CC1101");

View file

@ -13,7 +13,7 @@
#include "Web.h" #include "Web.h"
#include "MQTT.h" #include "MQTT.h"
#include "GitOTA.h" #include "GitOTA.h"
#include "Network.h" #include "Network_internal.h"
extern ConfigSettings settings; extern ConfigSettings settings;
extern SSDPClass SSDP; extern SSDPClass SSDP;
@ -22,7 +22,7 @@ extern SomfyShadeController somfy;
extern Web webServer; extern Web webServer;
extern MQTTClass mqtt; extern MQTTClass mqtt;
extern GitUpdater git; extern GitUpdater git;
extern Network net; extern Network_internal net;
//#define WEB_MAX_RESPONSE 34768 //#define WEB_MAX_RESPONSE 34768
#define WEB_MAX_RESPONSE 4096 #define WEB_MAX_RESPONSE 4096

View file

View file

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before After
Before After

View file

@ -1954,7 +1954,7 @@ class Somfy {
this.loadPins('input', document.getElementById('selTransRXPin')); this.loadPins('input', document.getElementById('selTransRXPin'));
//this.loadSomfy(); //this.loadSomfy();
ui.toElement(document.getElementById('divTransceiverSettings'), { ui.toElement(document.getElementById('divTransceiverSettings'), {
transceiver: { config: { proto: 0, SCKPin: 18, CSNPin: 5, MOSIPin: 23, MISOPin: 19, TXPin: 12, RXPin: 13, frequency: 433.42, rxBandwidth: 97.96, type: 56, deviation: 11.43, txPower: 10, enabled: false } } transceiver: { config: { proto: 0, SCKPin: 6, CSNPin: 10, MOSIPin: 7, MISOPin: 2, TXPin: 5, RXPin: 13, frequency: 433.42, rxBandwidth: 97.96, type: 56, deviation: 11.43, txPower: 10, enabled: false } }
}); });
this.loadPins('out', document.getElementById('selShadeGPIOUp')); this.loadPins('out', document.getElementById('selShadeGPIOUp'));
this.loadPins('out', document.getElementById('selShadeGPIODown')); this.loadPins('out', document.getElementById('selShadeGPIODown'));
@ -2795,7 +2795,7 @@ class Somfy {
document.getElementById('divLinkedShadeList').innerHTML = divCfg; document.getElementById('divLinkedShadeList').innerHTML = divCfg;
} }
pinMaps = [ 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: '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: '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] }
@ -2804,7 +2804,7 @@ class Somfy {
loadPins(type, sel, opt) { loadPins(type, sel, opt) {
while (sel.firstChild) sel.removeChild(sel.firstChild); while (sel.firstChild) sel.removeChild(sel.firstChild);
let cm = document.getElementById('divContainer').getAttribute('data-chipmodel'); 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 }); //console.log({ cm: cm, pm: pm });
for (let i = 0; i <= pm.maxPins; i++) { for (let i = 0; i <= pm.maxPins; i++) {
if (type.includes('in') && pm.inputs.includes(i)) continue; if (type.includes('in') && pm.inputs.includes(i)) continue;

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Before After
Before After

6
main/idf_component.yml Normal file
View file

@ -0,0 +1,6 @@
dependencies:
espressif/arduino-esp32:
pre_release: true
version: '*'
bblanchon/arduinojson: ^7.4.2
joltwallet/littlefs: ^1.20.3

View file

@ -2,7 +2,7 @@
#include <LittleFS.h> #include <LittleFS.h>
#include <esp_task_wdt.h> #include <esp_task_wdt.h>
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "Network.h" #include "Network_internal.h"
#include "Web.h" #include "Web.h"
#include "Sockets.h" #include "Sockets.h"
#include "Utils.h" #include "Utils.h"
@ -13,13 +13,20 @@
ConfigSettings settings; ConfigSettings settings;
Web webServer; Web webServer;
SocketEmitter sockEmit; SocketEmitter sockEmit;
Network net; Network_internal net;
rebootDelay_t rebootDelay; rebootDelay_t rebootDelay;
SomfyShadeController somfy; SomfyShadeController somfy;
MQTTClass mqtt; MQTTClass mqtt;
GitUpdater git; GitUpdater git;
uint32_t oldheap = 0; uint32_t oldheap = 0;
esp_task_wdt_config_t twdt_config = {
.timeout_ms = 7000,
.idle_core_mask = (1 << CONFIG_FREERTOS_NUMBER_OF_CORES) - 1, // Bitmask of all cores
.trigger_panic = true,
};
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
Serial.println(); Serial.println();
@ -37,7 +44,8 @@ void setup() {
net.setup(); net.setup();
somfy.begin(); somfy.begin();
//git.checkForUpdate(); //git.checkForUpdate();
esp_task_wdt_init(7, true); //enable panic so ESP32 restarts esp_task_wdt_config_t l_config;
esp_task_wdt_init(&twdt_config); //enable panic so ESP32 restarts
esp_task_wdt_add(NULL); //add current thread to WDT watch esp_task_wdt_add(NULL); //add current thread to WDT watch
} }

6
partitions.csv Normal file
View file

@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 2M,
spiffs, data, spiffs, , 0xF0000,
1 # Name, Type, SubType, Offset, Size, Flags
2 # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
3 nvs, data, nvs, 0x9000, 0x6000,
4 phy_init, data, phy, 0xf000, 0x1000,
5 factory, app, factory, 0x10000, 2M,
6 spiffs, data, spiffs, , 0xF0000,

27
sdkconfig.defaults Normal file
View file

@ -0,0 +1,27 @@
#
# Arduino ESP32
#
CONFIG_AUTOSTART_ARDUINO=y
# end of Arduino ESP32
#
# FREERTOS
#
CONFIG_FREERTOS_HZ=1000
# end of FREERTOS
# end of Component config
#
# DIAGNOSTICS
#
CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_MBEDTLS_PSK_MODES=y
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK=y
CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK=y