[SYS] Update arduino core to 3.1.1 + refactor ino to cpp (#2177)

* Update arduino core to 3.1.1

* Fix Blufi build

* Update arduinojson, fix build errors with idf

* Fix narrowing

* fix RF builds

* WIP-Convert ino files to cpp

* Fix pilight build

* Fix Somfy actuator build.

* Update esp32dev-rf partition

* Fix Weatherstation build

* Fix GFSunInverter build

* Fix esp32dev-ir build

* Fix ble-aws build

* Fix eth builds

* Fix m5Stack missing pins_arduino.h

* Fix build errors for M5 stack/tough, others are upstream issues.

* Fix RTL 433 build - remaining errors are from radolib

* Fix nodemcu build

* fix 2g builds

* Fix serial build

* Fix actuator on off builds

* Fix SSD1306 build - remaining errors are from radiolib

* Fix multiple definition of OTAserver_cert

* Fix nodemcu rf2 build

* Fix ADC builds

* Fix sensor builds

* Fix LORA builds

* Fix multi-receiver builds - remaining errors are in radiolib

* Fix fastled builds

* Fix theegns board builds

* Fix broker builds

* Update fastled - old version failed all-test build

* Fix RN8209 builds

* Fix max temp actuator builds

* Fix PWM builds

* Fix C37 sensor builds

* Fix HTU21 builds

* Fix INA266 builds

* Fix undefined variables in mqtt discovery

* Fix webui build

* Fix fastled invalid pin error

* Fix wifi manual setup builds

* Fix onewire/all-test build - bin too big error remaining

* Fix theengs plug build

* Fix rfbridge builds

* Fix blufi builds

* Fix undefined functions in serial

* Fix preprocessor definition checks

* Set IDF log level to erre

* Add delay in loop to prevent watchdog timeout

* Use xTaskCreateUniveral to support single core processors

* Remove old HTTPUpdate files - upsteam fixed.

* Cleanup and move common declarations to header file

* Use custom partiton table to fix builds where bin is too large

* Update M5StickC - fixs esp32-m5stick-c-ble build

* Revert to Arduino core 2.x for builds with incompatible libs

* Remove "Z" from file names and rename omg_common to TheengsCommon

* Fix gateway name when using MAC with new Arduino core

* Update IDF config to reduce loop task stack use

* Update esp-nimble-cpp version, corrects BLE uppercase ID's

* Update wifi manager to fix watchdog timeout error
This commit is contained in:
Ryan Powell authored and GitHub committed 2025-05-06 19:35:50 -05:00
1 parent 6e77efb11b
commit 585df9a420
83 files changed
+1042 -1060

No files matched your search

+1
View File
@@ -16,3 +16,4 @@ sdkconfig.*
!sdkconfig.defaults !sdkconfig.defaults
__pycache__ __pycache__
*.pem *.pem
managed_components
+28 -20
View File
@@ -188,7 +188,7 @@ custom_hardware = Theengs Plug
platform = ${com.esp32_platform} platform = ${com.esp32_platform}
board = esp32dev board = esp32dev
extra_scripts = ${com-esp32.extra_scripts} extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv board_build.partitions = partitions/no_coredump.csv
lib_deps = lib_deps =
${com-esp32.lib_deps} ${com-esp32.lib_deps}
${libraries.ble} ${libraries.ble}
@@ -270,6 +270,7 @@ build_flags =
[env:esp32dev-rf] [env:esp32dev-rf]
platform = ${com.esp32_platform} platform = ${com.esp32_platform}
board = esp32dev board = esp32dev
board_build.partitions = min_spiffs.csv
lib_deps = lib_deps =
${com-esp32.lib_deps} ${com-esp32.lib_deps}
${libraries.rc-switch} ${libraries.rc-switch}
@@ -311,6 +312,7 @@ custom_description = Gateway using ESPilight library only, need CC1101
[env:esp32dev-somfy-cc1101] [env:esp32dev-somfy-cc1101]
platform = ${com.esp32_platform} platform = ${com.esp32_platform}
board = esp32dev board = esp32dev
board_build.partitions = min_spiffs.csv
lib_deps = lib_deps =
${com-esp32.lib_deps} ${com-esp32.lib_deps}
${libraries.somfy_remote} ${libraries.somfy_remote}
@@ -342,6 +344,7 @@ custom_description = Gateway using Somfy Remote and ESPilight library, need CC11
[env:esp32dev-weatherstation] [env:esp32dev-weatherstation]
platform = ${com.esp32_platform} platform = ${com.esp32_platform}
board = esp32dev board = esp32dev
board_build.partitions = min_spiffs.csv
lib_deps = lib_deps =
${com-esp32.lib_deps} ${com-esp32.lib_deps}
${libraries.rfWeatherStation} ${libraries.rfWeatherStation}
@@ -354,6 +357,7 @@ custom_description = Gateway to retrieve weather station data Ventus W174/W132 (
[env:esp32dev-gf-sun-inverter] [env:esp32dev-gf-sun-inverter]
platform = ${com.esp32_platform} platform = ${com.esp32_platform}
board = esp32dev board = esp32dev
board_build.partitions = min_spiffs.csv
lib_deps = lib_deps =
${com-esp32.lib_deps} ${com-esp32.lib_deps}
${libraries.emodbus} ${libraries.emodbus}
@@ -598,10 +602,10 @@ custom_description = BLE gateway using wifi
custom_hardware = OLIMEX ESP32 Gateway custom_hardware = OLIMEX ESP32 Gateway
[env:esp32-m5stick-ble] [env:esp32-m5stick-ble]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = m5stack-core-esp32 board = m5stack-core-esp32
extra_scripts = ${com-esp32.extra_scripts} extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv board_build.partitions = partitions/no_coredump.csv
lib_deps = lib_deps =
${com-esp32.lib_deps} ${com-esp32.lib_deps}
${libraries.ble} ${libraries.ble}
@@ -622,7 +626,7 @@ custom_description = Expandable module with BLE gateway, display, and little IR
custom_hardware = M5Stick Grey custom_hardware = M5Stick Grey
[env:esp32-m5stack-ble] [env:esp32-m5stack-ble]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = m5stack-core-esp32 board = m5stack-core-esp32
extra_scripts = ${com-esp32.extra_scripts} extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
@@ -647,7 +651,7 @@ custom_description = Expandable module with BLE gateway and display
custom_hardware = M5Stack Core custom_hardware = M5Stack Core
[env:esp32-m5tough-ble] [env:esp32-m5tough-ble]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = m5stack-core-esp32 board = m5stack-core-esp32
extra_scripts = ${com-esp32.extra_scripts} extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
@@ -666,7 +670,7 @@ custom_description = Expandable module with BLE gateway and display, suitable fo
custom_hardware = M5Tough rugged custom_hardware = M5Tough rugged
[env:esp32-m5stick-c-ble] [env:esp32-m5stick-c-ble]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = m5stick-c board = m5stick-c
extra_scripts = ${com-esp32.extra_scripts} extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
@@ -697,10 +701,10 @@ custom_description = Expandable module with BLE gateway, display, and little IR
custom_hardware = M5Stick C custom_hardware = M5Stick C
[env:esp32-m5stick-cp-ble] [env:esp32-m5stick-cp-ble]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = pico32 board = pico32
extra_scripts = ${com-esp32.extra_scripts} extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv board_build.partitions = partitions/no_coredump.csv
lib_deps = lib_deps =
${com-esp32.lib_deps} ${com-esp32.lib_deps}
${libraries.ble} ${libraries.ble}
@@ -731,7 +735,7 @@ custom_hardware = M5Stick CP
platform = ${com.esp32_platform} platform = ${com.esp32_platform}
board = pico32 board = pico32
extra_scripts = ${com-esp32.extra_scripts} extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv board_build.partitions = partitions/no_coredump.csv
lib_deps = lib_deps =
${com-esp32.lib_deps} ${com-esp32.lib_deps}
${libraries.ble} ${libraries.ble}
@@ -762,7 +766,7 @@ custom_hardware = M5 ATOM Matrix
platform = ${com.esp32_platform} platform = ${com.esp32_platform}
board = pico32 board = pico32
extra_scripts = ${com-esp32.extra_scripts} extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv board_build.partitions = partitions/no_coredump.csv
lib_deps = lib_deps =
${com-esp32.lib_deps} ${com-esp32.lib_deps}
${libraries.ble} ${libraries.ble}
@@ -785,7 +789,7 @@ custom_description = Compact enclosure ESP32 with BLE gateway
custom_hardware = M5 ATOM Lite custom_hardware = M5 ATOM Lite
[env:esp32doitv1-aithinker-r01-sx1278] [env:esp32doitv1-aithinker-r01-sx1278]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = esp32doit-devkit-v1 board = esp32doit-devkit-v1
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
lib_deps = lib_deps =
@@ -864,7 +868,7 @@ upload_flags =
--port=8266 --port=8266
[env:esp32dev-rtl_433] [env:esp32dev-rtl_433]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = esp32dev board = esp32dev
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
lib_deps = lib_deps =
@@ -904,7 +908,7 @@ build_flags =
custom_description = Gateway using RTL_433_ESP library, need CC1101 custom_description = Gateway using RTL_433_ESP library, need CC1101
[env:heltec-rtl_433] [env:heltec-rtl_433]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = heltec_wifi_lora_32_V2 board = heltec_wifi_lora_32_V2
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h ; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
@@ -933,7 +937,7 @@ custom_description = Gateway using RTL_433_ESP and RadioLib
custom_hardware = ESP32 HELTEC LORA32 V2 custom_hardware = ESP32 HELTEC LORA32 V2
[env:heltec-rtl_433-fsk] [env:heltec-rtl_433-fsk]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = heltec_wifi_lora_32_V2 board = heltec_wifi_lora_32_V2
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h ; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
@@ -991,7 +995,7 @@ custom_description = Heltec BLE gateway with adaptive scanning activated, automa
custom_hardware = ESP32 HELTEC LORA32 V2 custom_hardware = ESP32 HELTEC LORA32 V2
[env:lilygo-rtl_433] [env:lilygo-rtl_433]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = ttgo-lora32-v21 board = ttgo-lora32-v21
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h ; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
@@ -1020,7 +1024,7 @@ custom_description = For ESP32, Gateway using RTL_433_ESP and RadioLib
custom_hardware = ESP32 LILYGO LoRa32 V2.1 custom_hardware = ESP32 LILYGO LoRa32 V2.1
[env:lilygo-rtl_433-fsk] [env:lilygo-rtl_433-fsk]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = ttgo-lora32-v21 board = ttgo-lora32-v21
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h ; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
@@ -1078,7 +1082,7 @@ custom_description = LilyGo BLE gateway with adaptive scanning activated, automa
custom_hardware = ESP32 LILYGO LoRa32 V2.1 custom_hardware = ESP32 LILYGO LoRa32 V2.1
[env:esp32dev-multi_receiver] [env:esp32dev-multi_receiver]
platform = ${com.esp32_platform} platform = espressif32@6.1.0
board = esp32dev board = esp32dev
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
lib_deps = lib_deps =
@@ -1896,11 +1900,16 @@ framework = arduino, espidf
board = esp32dev board = esp32dev
extra_scripts = ${com-esp32.extra_scripts} extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = partitions/min_spiffs.csv board_build.partitions = partitions/min_spiffs.csv
board_build.embed_txtfiles =
managed_components/espressif__esp_insights/server_certs/https_server.crt
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
lib_deps = lib_deps =
${com-esp32.lib_deps} ${com-esp32.lib_deps}
${libraries.decoder} ${libraries.decoder}
h2zero/esp-nimble-cpp@2.0.1 h2zero/esp-nimble-cpp@2.1.1
h2zero/NimBLEOta@0.1.0 h2zero/NimBLEOta@0.2.0
build_flags = build_flags =
${com-esp32.build_flags} ${com-esp32.build_flags}
'-DZgatewayBT="BT"' '-DZgatewayBT="BT"'
@@ -1909,5 +1918,4 @@ build_flags =
'-DGateway_Name="OMG_ESP32_BLE"' '-DGateway_Name="OMG_ESP32_BLE"'
'-DUSE_BLUFI=1' '-DUSE_BLUFI=1'
'-DenableMultiGTWSync=false' '-DenableMultiGTWSync=false'
'-DCONFIG_NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT=31'
custom_description = Regular BLE gateway based on esp-idf with adaptive scanning activated, automatically adapts the scan parameters depending on your devices custom_description = Regular BLE gateway based on esp-idf with adaptive scanning activated, automatically adapts the scan parameters depending on your devices
+100
View File
@@ -0,0 +1,100 @@
#pragma once
#include "User_config.h"
#define ARDUINOJSON_USE_LONG_LONG 1
#define ARDUINOJSON_ENABLE_STD_STRING 1
#include <ArduinoJson.h>
#include <ArduinoLog.h>
#if defined(ESP32)
# include <Preferences.h>
extern Preferences preferences;
#endif
// Flags definition for white list, black list, discovery management
#define device_flags_init 0 << 0
#define device_flags_isDisc 1 << 0
#define device_flags_isWhiteL 1 << 1
#define device_flags_isBlackL 1 << 2
#define device_flags_connect 1 << 3
#define isWhite(device) device->isWhtL
#define isBlack(device) device->isBlkL
#define isDiscovered(device) device->isDisc
enum GatewayState {
WAITING_ONBOARDING,
ONBOARDING,
OFFLINE,
NTWK_CONNECTED,
BROKER_CONNECTED,
PROCESSING,
NTWK_DISCONNECTED,
BROKER_DISCONNECTED,
LOCAL_OTA_IN_PROGRESS,
REMOTE_OTA_IN_PROGRESS,
SLEEPING,
ERROR
};
enum PowerMode {
DEACTIVATED = -1,
ALWAYS_ON,
INTERVAL,
ACTION
};
struct SYSConfig_s {
bool mqtt; // if true the gateway will publish the received data on the MQTT broker
bool serial; // if true the gateway will publish the received data on the SERIAL
bool blufi; // if true the gateway will be accesible with blufi
bool offline;
bool discovery; // HA discovery convention
#ifdef LED_ADDRESSABLE
int rgbbrightness; // brightness of the RGB LED
#endif
enum PowerMode powerMode;
};
extern GatewayState gatewayState;
extern SYSConfig_s SYSConfig;
extern bool ready_to_sleep;
extern char mqtt_topic[];
extern char gateway_name[];
extern unsigned long lastDiscovery; // Time of the last discovery to trigger automaticaly to off after DiscoveryAutoOffTimer
extern bool enqueueJsonObject(const StaticJsonDocument<JSON_MSG_BUFFER>& jsonDoc, int timeout);
extern bool enqueueJsonObject(const StaticJsonDocument<JSON_MSG_BUFFER>& jsonDoc);
extern void buildTopicFromId(JsonObject& Jsondata, const char* origin);
extern bool pubMQTT(const char* topic, const char* payload);
extern bool pubMQTT(const char* topic, const char* payload, bool retainFlag);
extern bool pubMQTT(String topic, const char* payload);
extern bool pubMQTT(const char* topic, unsigned long payload);
extern bool pubMQTT(const char* topic, unsigned long long payload);
extern bool pubMQTT(const char* topic, String payload);
extern bool pubMQTT(String topic, String payload);
extern bool pubMQTT(String topic, int payload);
extern bool pubMQTT(String topic, unsigned long long payload);
extern bool pubMQTT(String topic, float payload);
extern bool pubMQTT(const char* topic, float payload);
extern bool pubMQTT(const char* topic, int payload);
extern bool pubMQTT(const char* topic, unsigned int payload);
extern bool pubMQTT(const char* topic, long payload);
extern bool pubMQTT(const char* topic, double payload);
extern bool pubMQTT(String topic, unsigned long payload);
extern unsigned long uptime();
extern bool cmpToMainTopic(const char*, const char*);
extern bool pub(const char*, const char*, bool);
extern bool pub(const char*, const char*);
template <typename T>
void Config_update(JsonObject& data, const char* key, T& var) {
if (data.containsKey(key)) {
if (var != data[key].as<T>()) {
var = data[key].as<T>();
Log.notice(F("Config %s changed to: %T" CR), key, data[key].as<T>());
} else {
Log.notice(F("Config %s unchanged, currently: %T" CR), key, data[key].as<T>());
}
}
}
+17 -55
View File
@@ -226,7 +226,8 @@
#if AWS_IOT #if AWS_IOT
// Enable the use of ALPN for AWS IoT Core with the port 443 // Enable the use of ALPN for AWS IoT Core with the port 443
const char* alpnProtocols[] = {"x-amzn-mqtt-ca", NULL}; # define ALPN_PROTOCOLS \
{ "x-amzn-mqtt-ca", NULL }
#endif #endif
//# define MQTT_HTTPS_FW_UPDATE //uncomment to enable updating via MQTT message. //# define MQTT_HTTPS_FW_UPDATE //uncomment to enable updating via MQTT message.
@@ -251,7 +252,7 @@ const char* alpnProtocols[] = {"x-amzn-mqtt-ca", NULL};
# define RELEASE_LINK_DEV "https://ota.openmqttgateway.com/binaries/dev/" # define RELEASE_LINK_DEV "https://ota.openmqttgateway.com/binaries/dev/"
# define RELEASE_LINK "https://ota.openmqttgateway.com/binaries/" # define RELEASE_LINK "https://ota.openmqttgateway.com/binaries/"
#else #else
const char* OTAserver_cert = ""; static const char* OTAserver_cert = "";
#endif #endif
#ifndef MQTT_SECURE_SIGNED_CLIENT #ifndef MQTT_SECURE_SIGNED_CLIENT
@@ -289,12 +290,15 @@ struct ss_cnt_parameters {
bool validConnection; bool validConnection;
}; };
# define CNT_PARAMS_ARR \
{ \
{ss_server_cert, ss_client_cert, ss_client_key, OTAserver_cert, MQTT_SERVER, MQTT_PORT, MQTT_USER, MQTT_PASS, MQTT_SECURE_DEFAULT, MQTT_CERT_VALIDATE_DEFAULT, false}, \
{"", "", "", "", MQTT_SERVER, MQTT_PORT, MQTT_USER, MQTT_PASS, MQTT_SECURE_DEFAULT, MQTT_CERT_VALIDATE_DEFAULT, false}, \
{ "", "", "", "", MQTT_SERVER, MQTT_PORT, MQTT_USER, MQTT_PASS, MQTT_SECURE_DEFAULT, MQTT_CERT_VALIDATE_DEFAULT, false } \
}
# define cnt_parameters_array_size 3 # define cnt_parameters_array_size 3
ss_cnt_parameters cnt_parameters_array[cnt_parameters_array_size] = { extern ss_cnt_parameters cnt_parameters_array[];
{ss_server_cert, ss_client_cert, ss_client_key, OTAserver_cert, MQTT_SERVER, MQTT_PORT, MQTT_USER, MQTT_PASS, MQTT_SECURE_DEFAULT, MQTT_CERT_VALIDATE_DEFAULT, false},
{"", "", "", "", MQTT_SERVER, MQTT_PORT, MQTT_USER, MQTT_PASS, MQTT_SECURE_DEFAULT, MQTT_CERT_VALIDATE_DEFAULT, false},
{"", "", "", "", MQTT_SERVER, MQTT_PORT, MQTT_USER, MQTT_PASS, MQTT_SECURE_DEFAULT, MQTT_CERT_VALIDATE_DEFAULT, false}};
#endif #endif
#define MIN_CERT_LENGTH 200 // Minimum length of a certificate to be considered valid #define MIN_CERT_LENGTH 200 // Minimum length of a certificate to be considered valid
@@ -527,7 +531,7 @@ ss_cnt_parameters cnt_parameters_array[cnt_parameters_array_size] = {
#ifdef ESP8266 #ifdef ESP8266
//# define TRIGGER_GPIO 14 // pin D5 as full reset button (long press >10s) //# define TRIGGER_GPIO 14 // pin D5 as full reset button (long press >10s)
#elif ESP32 #elif defined(ESP32)
//# define TRIGGER_GPIO 0 // boot button as full reset button (long press >10s) //# define TRIGGER_GPIO 0 // boot button as full reset button (long press >10s)
//# define NO_INT_TEMP_READING true //Define if we don't want internal temperature reading for the ESP32 //# define NO_INT_TEMP_READING true //Define if we don't want internal temperature reading for the ESP32
#endif #endif
@@ -621,60 +625,14 @@ ss_cnt_parameters cnt_parameters_array[cnt_parameters_array_size] = {
#define displayPrint(...) // only print if not in low power mode #define displayPrint(...) // only print if not in low power mode
#define lpDisplayPrint(...) // print in low power mode #define lpDisplayPrint(...) // print in low power mode
/*----------- SHARED WITH OMG MODULES --------------*/
char mqtt_topic[parameters_size + 1] = Base_Topic;
char gateway_name[parameters_size + 1] = Gateway_Name;
void connectMQTT();
unsigned long uptime();
bool cmpToMainTopic(const char*, const char*);
bool pub(const char*, const char*, bool);
bool pub(const char*, const char*);
#if defined(ESP32)
# include <Preferences.h>
Preferences preferences;
#endif
unsigned long lastDiscovery = 0; // Time of the last discovery to trigger automaticaly to off after DiscoveryAutoOffTimer
#ifndef DEFAULT_DISCOVERY
# define DEFAULT_DISCOVERY true
#endif
#include <vector>
// Flags definition for white list, black list, discovery management
#define device_flags_init 0 << 0
#define device_flags_isDisc 1 << 0
#define device_flags_isWhiteL 1 << 1
#define device_flags_isBlackL 1 << 2
#define device_flags_connect 1 << 3
#define isWhite(device) device->isWhtL
#define isBlack(device) device->isBlkL
#define isDiscovered(device) device->isDisc
enum PowerMode { DEACTIVATED = -1,
ALWAYS_ON,
INTERVAL,
ACTION };
/*--------------------Minimum freeHeap--------------------*/ /*--------------------Minimum freeHeap--------------------*/
// Below this parameter we trigger a restart, this avoid stuck boards like seen in https://github.com/1technophile/OpenMQTTGateway/issues/1693 // Below this parameter we trigger a restart, this avoid stuck boards like seen in https://github.com/1technophile/OpenMQTTGateway/issues/1693
#define MinimumMemory 40000 #define MinimumMemory 40000
/*----------------CONFIGURABLE PARAMETERS-----------------*/ /*----------------CONFIGURABLE PARAMETERS-----------------*/
struct SYSConfig_s { #ifndef DEFAULT_DISCOVERY
bool mqtt; // if true the gateway will publish the received data on the MQTT broker # define DEFAULT_DISCOVERY true
bool serial; // if true the gateway will publish the received data on the SERIAL
bool blufi; // if true the gateway will be accesible with blufi
bool offline;
bool discovery; // HA discovery convention
#ifdef LED_ADDRESSABLE
int rgbbrightness; // brightness of the RGB LED
#endif #endif
enum PowerMode powerMode;
};
#ifndef DEFAULT_MQTT #ifndef DEFAULT_MQTT
# define DEFAULT_MQTT true # define DEFAULT_MQTT true
@@ -697,4 +655,8 @@ void storeSignalValue(uint64_t);
#define convertTemp_CtoF(c) ((c * 1.8) + 32) #define convertTemp_CtoF(c) ((c * 1.8) + 32)
#define convertTemp_FtoC(f) ((f - 32) * 5 / 9) #define convertTemp_FtoC(f) ((f - 32) * 5 / 9)
#ifndef QueueSize
# define QueueSize 18
#endif
#endif #endif
@@ -26,6 +26,8 @@
# include <FastLED.h> # include <FastLED.h>
# include "config_FASTLED.h"
enum LEDState { enum LEDState {
OFF, OFF,
FIRE, FIRE,
@@ -41,10 +43,12 @@ const long blinkInterval = 300;
const long fireUpdate = 10; const long fireUpdate = 10;
CRGBPalette16 gPal; CRGBPalette16 gPal;
void Fire2012WithPalette();
void setupFASTLED() { void setupFASTLED() {
Log.notice(F("FASTLED_DATA_GPIO: %d" CR), FASTLED_DATA_GPIO); Log.notice(F("FASTLED_DATA_GPIO: %d" CR), FASTLED_DATA_GPIO);
Log.notice(F("FASTLED_NUM_LEDS: %d" CR), FASTLED_NUM_LEDS); Log.notice(F("FASTLED_NUM_LEDS: %d" CR), FASTLED_NUM_LEDS);
Log.trace(F("ZactuatorFASTLED setup done " CR)); Log.trace(F("actuatorFASTLED setup done " CR));
FastLED.addLeds<FASTLED_TYPE, FASTLED_DATA_GPIO>(leds, FASTLED_NUM_LEDS); FastLED.addLeds<FASTLED_TYPE, FASTLED_DATA_GPIO>(leds, FASTLED_NUM_LEDS);
} }
@@ -30,7 +30,15 @@
#ifdef ZactuatorONOFF #ifdef ZactuatorONOFF
# include "LEDManager.h"
# include "TheengsCommon.h"
# include "config_ONOFF.h"
extern LEDManager ledManager;
extern void ActuatorTrigger();
# ifdef ESP32 # ifdef ESP32
// Global struct to store live ONOFF configuration data // Global struct to store live ONOFF configuration data
ONOFFConfig_s ONOFFConfig; ONOFFConfig_s ONOFFConfig;
@@ -94,9 +102,9 @@ void ONOFFConfig_load() {
} }
} }
# else # else
void ONOFFConfig_init(){}; void ONOFFConfig_init() {};
void ONOFFConfig_fromJson(JsonObject& ONOFFdata){}; void ONOFFConfig_fromJson(JsonObject& ONOFFdata) {};
void ONOFFConfig_load(){}; void ONOFFConfig_load() {};
# endif # endif
void updatePowerIndicator() { void updatePowerIndicator() {
@@ -109,6 +117,33 @@ void updatePowerIndicator() {
# endif # endif
} }
//Check regularly temperature of the ESP32 board and switch OFF the relay if temperature is more than MAX_TEMP_ACTUATOR
# ifdef MAX_TEMP_ACTUATOR
extern float intTemperatureRead();
void overLimitTemp(void* pvParameters) {
# if defined(ESP32) && !defined(NO_INT_TEMP_READING)
for (;;) {
static float previousInternalTempc = 0;
float internalTempc = intTemperatureRead();
Log.trace(F("Internal temperature of the ESP32 %F" CR), internalTempc);
// We switch OFF the actuator if the temperature of the ESP32 is more than MAX_TEMP_ACTUATOR two consecutive times, so as to avoid false single readings to trigger the relay OFF.
if (internalTempc > MAX_TEMP_ACTUATOR && previousInternalTempc > MAX_TEMP_ACTUATOR) {
if (digitalRead(ACTUATOR_ONOFF_GPIO) == ACTUATOR_ON) { // This could be with the previous condition, but it is better to trigger the digitalRead only if the previous condition is met to avoid the digitalRead
Log.error(F("[ActuatorONOFF] OverTemperature detected ( %F > %F ) switching OFF Actuator" CR), internalTempc, MAX_TEMP_ACTUATOR);
ActuatorTrigger();
# ifdef LED_ACTUATOR_ONOFF
ledManager.setMode(LED_ACTUATOR_ONOFF, 0, LEDManager::Mode::STATIC, LED_ERROR_COLOR, -1);
# endif
}
}
previousInternalTempc = internalTempc;
vTaskDelay(TimeBetweenReadingIntTemp);
}
# endif
}
# endif
void setupONOFF() { void setupONOFF() {
# ifdef MAX_TEMP_ACTUATOR # ifdef MAX_TEMP_ACTUATOR
xTaskCreate(overLimitTemp, "overLimitTemp", 4000, NULL, 10, NULL); xTaskCreate(overLimitTemp, "overLimitTemp", 4000, NULL, 10, NULL);
@@ -130,7 +165,7 @@ void setupONOFF() {
} }
# endif # endif
updatePowerIndicator(); updatePowerIndicator();
Log.trace(F("ZactuatorONOFF setup done" CR)); Log.trace(F("actuatorONOFF setup done" CR));
} }
# if jsonReceiving # if jsonReceiving
@@ -239,31 +274,6 @@ void XtoONOFF(const char* topicOri, const char* datacallback) {
} }
# endif # endif
//Check regularly temperature of the ESP32 board and switch OFF the relay if temperature is more than MAX_TEMP_ACTUATOR
# ifdef MAX_TEMP_ACTUATOR
void overLimitTemp(void* pvParameters) {
# if defined(ESP32) && !defined(NO_INT_TEMP_READING)
for (;;) {
static float previousInternalTempc = 0;
float internalTempc = intTemperatureRead();
Log.trace(F("Internal temperature of the ESP32 %F" CR), internalTempc);
// We switch OFF the actuator if the temperature of the ESP32 is more than MAX_TEMP_ACTUATOR two consecutive times, so as to avoid false single readings to trigger the relay OFF.
if (internalTempc > MAX_TEMP_ACTUATOR && previousInternalTempc > MAX_TEMP_ACTUATOR) {
if (digitalRead(ACTUATOR_ONOFF_GPIO) == ACTUATOR_ON) { // This could be with the previous condition, but it is better to trigger the digitalRead only if the previous condition is met to avoid the digitalRead
Log.error(F("[ActuatorONOFF] OverTemperature detected ( %F > %F ) switching OFF Actuator" CR), internalTempc, MAX_TEMP_ACTUATOR);
ActuatorTrigger();
# ifdef LED_ACTUATOR_ONOFF
ledManager.setMode(LED_ACTUATOR_ONOFF, 0, LEDManager::Mode::STATIC, LED_ERROR_COLOR, -1);
# endif
}
}
previousInternalTempc = internalTempc;
vTaskDelay(TimeBetweenReadingIntTemp);
}
# endif
}
# endif
// Check regularly current the relay and switch it OFF if the current is more than MAX_CURRENT_ACTUATOR // Check regularly current the relay and switch it OFF if the current is more than MAX_CURRENT_ACTUATOR
# ifdef MAX_CURRENT_ACTUATOR # ifdef MAX_CURRENT_ACTUATOR
void overLimitCurrent(float RN8209current) { void overLimitCurrent(float RN8209current) {
@@ -68,7 +68,7 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZactuatorPWM #ifdef ZactuatorPWM
# include "TheengsCommon.h"
# include "config_PWM.h" # include "config_PWM.h"
static long previousUpdateTime = 0; // milliseconds static long previousUpdateTime = 0; // milliseconds
@@ -128,15 +128,14 @@ void setupPWM() {
// Configure the pin for PWM output. // Configure the pin for PWM output.
// I think this is the fastest frequency that allows for a 16-bit // I think this is the fastest frequency that allows for a 16-bit
// duty cycle on an ESP32 // duty cycle on an ESP32
ledcSetup(i, 625.0, kNumDutyCycleBits); ledcAttachChannel(channelPins[i], 625.0, kNumDutyCycleBits, i);
ledcAttachPin(channelPins[i], i);
# endif # endif
calibrationMinLinear[i] = 0.f; calibrationMinLinear[i] = 0.f;
calibrationMaxLinear[i] = 1.f; calibrationMaxLinear[i] = 1.f;
calibrationGamma[i] = PWM_DEFAULT_GAMMA; calibrationGamma[i] = PWM_DEFAULT_GAMMA;
} }
Log.trace(F("ZactuatorPWM setup done " CR)); Log.trace(F("actuatorPWM setup done " CR));
} }
// This applies a power curve to the input to try to make the inputs // This applies a power curve to the input to try to make the inputs
@@ -24,15 +24,21 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZactuatorSomfy #ifdef ZactuatorSomfy
# include <EEPROM.h> # include <EEPROM.h>
# include <EEPROMRollingCodeStorage.h> # include <EEPROMRollingCodeStorage.h>
# include <SomfyRemote.h> # include <SomfyRemote.h>
# include "config_RF.h"
# include "config_Somfy.h"
# ifdef ZradioCC1101 # ifdef ZradioCC1101
# include <ELECHOUSE_CC1101_SRC_DRV.h> # include <ELECHOUSE_CC1101_SRC_DRV.h>
# endif # endif
void disableCurrentReceiver();
void enableActiveReceiver();
void initCC1101();
void setupSomfy();
void setupSomfy() { void setupSomfy() {
pinMode(RF_EMITTER_GPIO, OUTPUT); pinMode(RF_EMITTER_GPIO, OUTPUT);
digitalWrite(RF_EMITTER_GPIO, LOW); digitalWrite(RF_EMITTER_GPIO, LOW);
@@ -45,7 +51,7 @@ void setupSomfy() {
EEPROM.begin(max(4, SOMFY_REMOTE_NUM * 2)); EEPROM.begin(max(4, SOMFY_REMOTE_NUM * 2));
# endif # endif
Log.trace(F("ZactuatorSomfy setup done " CR)); Log.trace(F("actuatorSomfy setup done " CR));
} }
# if jsonReceiving # if jsonReceiving
@@ -61,7 +67,7 @@ void XtoSomfy(const char* topicOri, JsonObject& jsonData) {
const int remoteIndex = jsonData["remote"]; const int remoteIndex = jsonData["remote"];
if (remoteIndex >= SOMFY_REMOTE_NUM) { if (remoteIndex >= SOMFY_REMOTE_NUM) {
Log.warning(F("ZactuatorSomfy remote does not exist" CR)); Log.warning(F("actuatorSomfy remote does not exist" CR));
return; return;
} }
const String commandData = jsonData["command"]; const String commandData = jsonData["command"];
+15 -3
View File
@@ -26,15 +26,23 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#if defined(ESP32) && defined(USE_BLUFI) #if defined(ESP32) && defined(USE_BLUFI)
# include <PicoMQTT.h>
# include <WiFiManager.h>
# include "NimBLEDevice.h" # include "NimBLEDevice.h"
# include "NimBLEOta.h" # include "NimBLEOta.h"
# include "TheengsCommon.h"
# include "User_config.h"
# include "esp_blufi_api.h" # include "esp_blufi_api.h"
# include "esp_mac.h"
# include "esp_timer.h" # include "esp_timer.h"
extern "C" { extern "C" {
# include "esp_blufi.h" # include "esp_blufi.h"
} }
extern void receivingDATA(const char* topicOri, const char* datacallback);
static esp_timer_handle_t connection_timer = nullptr; static esp_timer_handle_t connection_timer = nullptr;
static NimBLEOta* pNimBLEOta; static NimBLEOta* pNimBLEOta;
static NimBLECharacteristic* pCommandCharacteristic; static NimBLECharacteristic* pCommandCharacteristic;
@@ -62,6 +70,10 @@ static uint8_t gl_sta_passwd[64];
static int gl_sta_ssid_len; static int gl_sta_ssid_len;
static bool gl_sta_is_connecting = false; static bool gl_sta_is_connecting = false;
static esp_blufi_extra_info_t gl_sta_conn_info; static esp_blufi_extra_info_t gl_sta_conn_info;
extern bool ethConnected;
extern bool mqttSetupPending;
extern std::unique_ptr<PicoMQTT::Client> mqtt;
extern WiFiManager wifiManager;
static void example_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_param_t* param); static void example_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_param_t* param);
void wifi_event_handler(arduino_event_id_t event); void wifi_event_handler(arduino_event_id_t event);
@@ -93,7 +105,7 @@ void receivingCommandTask(void* pvParameters) {
Log.error(F("deserialize config failed: %s, buffer capacity: %u" CR), error.c_str(), json.capacity()); Log.error(F("deserialize config failed: %s, buffer capacity: %u" CR), error.c_str(), json.capacity());
} else { } else {
if (jsonBlufi.containsKey("target") && jsonBlufi["target"].is<char*>()) { if (jsonBlufi.containsKey("target") && jsonBlufi["target"].is<char*>()) {
char topic[(parameters_size)*2 + jsonBlufi["target"].size() + 1]; char topic[(parameters_size) * 2 + jsonBlufi["target"].size() + 1];
snprintf(topic, sizeof(topic), "%s%s%s", mqtt_topic, gateway_name, jsonBlufi["target"].as<const char*>()); snprintf(topic, sizeof(topic), "%s%s%s", mqtt_topic, gateway_name, jsonBlufi["target"].as<const char*>());
jsonBlufi.remove("target"); jsonBlufi.remove("target");
char jsonStr[JSON_MSG_BUFFER_MAX]; char jsonStr[JSON_MSG_BUFFER_MAX];
@@ -105,7 +117,7 @@ void receivingCommandTask(void* pvParameters) {
json["cnt_index"] = CNT_DEFAULT_INDEX; json["cnt_index"] = CNT_DEFAULT_INDEX;
json["save_cnt"] = true; json["save_cnt"] = true;
} }
char topic[(parameters_size)*2 + strlen(subjectMQTTtoSYSset) + 1]; char topic[(parameters_size) * 2 + strlen(subjectMQTTtoSYSset) + 1];
snprintf(topic, sizeof(topic), "%s%s%s", mqtt_topic, gateway_name, subjectMQTTtoSYSset); snprintf(topic, sizeof(topic), "%s%s%s", mqtt_topic, gateway_name, subjectMQTTtoSYSset);
char jsonStr[JSON_MSG_BUFFER_MAX]; char jsonStr[JSON_MSG_BUFFER_MAX];
serializeJson(jsonBlufi, jsonStr); serializeJson(jsonBlufi, jsonStr);
@@ -320,7 +332,7 @@ void wifi_event_handler(arduino_event_id_t event) {
gl_sta_is_connecting = false; gl_sta_is_connecting = false;
esp_blufi_extra_info_t info = {}; esp_blufi_extra_info_t info = {};
const String current_ssid = WiFi.SSID(); const String current_ssid = WiFi.SSID();
gl_sta_ssid_len = std::min(current_ssid.length(), sizeof(gl_sta_ssid) - 1); gl_sta_ssid_len = std::min<uint32_t>(current_ssid.length(), sizeof(gl_sta_ssid) - 1);
std::copy_n(current_ssid.c_str(), gl_sta_ssid_len, gl_sta_ssid); std::copy_n(current_ssid.c_str(), gl_sta_ssid_len, gl_sta_ssid);
gl_sta_ssid[gl_sta_ssid_len] = '\0'; gl_sta_ssid[gl_sta_ssid_len] = '\0';
uint8_t* bssid = WiFi.BSSID(); uint8_t* bssid = WiFi.BSSID();
+35 -4
View File
@@ -6,8 +6,11 @@
#if defined(ESP32) && defined(USE_BLUFI) #if defined(ESP32) && defined(USE_BLUFI)
# include <ArduinoLog.h>
# include "esp_blufi_api.h" # include "esp_blufi_api.h"
# include "esp_crc.h" # include "esp_crc.h"
# include "esp_random.h"
# include "mbedtls/aes.h" # include "mbedtls/aes.h"
# include "mbedtls/dhm.h" # include "mbedtls/dhm.h"
# include "mbedtls/md5.h" # include "mbedtls/md5.h"
@@ -48,6 +51,12 @@ static int myrand(void* rng_state, unsigned char* output, size_t len) {
extern "C" void btc_blufi_report_error(esp_blufi_error_state_t state); extern "C" void btc_blufi_report_error(esp_blufi_error_state_t state);
void blufi_dh_negotiate_data_handler(uint8_t* data, int len, uint8_t** output_data, int* output_len, bool* need_free) { void blufi_dh_negotiate_data_handler(uint8_t* data, int len, uint8_t** output_data, int* output_len, bool* need_free) {
if (data == NULL || len < 3) {
Log.error(F("BLUFI Invalid data format" CR));
btc_blufi_report_error(ESP_BLUFI_DATA_FORMAT_ERROR);
return;
}
int ret; int ret;
uint8_t type = data[0]; uint8_t type = data[0];
@@ -66,6 +75,7 @@ void blufi_dh_negotiate_data_handler(uint8_t* data, int len, uint8_t** output_da
} }
blufi_sec->dh_param = (uint8_t*)malloc(blufi_sec->dh_param_len); blufi_sec->dh_param = (uint8_t*)malloc(blufi_sec->dh_param_len);
if (blufi_sec->dh_param == NULL) { if (blufi_sec->dh_param == NULL) {
blufi_sec->dh_param_len = 0; /* Reset length to avoid using unallocated memory */
btc_blufi_report_error(ESP_BLUFI_DH_MALLOC_ERROR); btc_blufi_report_error(ESP_BLUFI_DH_MALLOC_ERROR);
Log.error(F("%s, malloc failed\n" CR), __func__); Log.error(F("%s, malloc failed\n" CR), __func__);
return; return;
@@ -77,6 +87,13 @@ void blufi_dh_negotiate_data_handler(uint8_t* data, int len, uint8_t** output_da
btc_blufi_report_error(ESP_BLUFI_DH_PARAM_ERROR); btc_blufi_report_error(ESP_BLUFI_DH_PARAM_ERROR);
return; return;
} }
if (len < (blufi_sec->dh_param_len + 1)) {
Log.error(F("%s, invalid dh param len" CR), __func__);
btc_blufi_report_error(ESP_BLUFI_DH_PARAM_ERROR);
return;
}
uint8_t* param = blufi_sec->dh_param; uint8_t* param = blufi_sec->dh_param;
memcpy(blufi_sec->dh_param, &data[1], blufi_sec->dh_param_len); memcpy(blufi_sec->dh_param, &data[1], blufi_sec->dh_param_len);
ret = mbedtls_dhm_read_params(&blufi_sec->dhm, &param, &param[blufi_sec->dh_param_len]); ret = mbedtls_dhm_read_params(&blufi_sec->dhm, &param, &param[blufi_sec->dh_param_len]);
@@ -88,7 +105,15 @@ void blufi_dh_negotiate_data_handler(uint8_t* data, int len, uint8_t** output_da
free(blufi_sec->dh_param); free(blufi_sec->dh_param);
blufi_sec->dh_param = NULL; blufi_sec->dh_param = NULL;
ret = mbedtls_dhm_make_public(&blufi_sec->dhm, (int)mbedtls_mpi_size(&blufi_sec->dhm.P), blufi_sec->self_public_key, blufi_sec->dhm.len, myrand, NULL); const int dhm_len = mbedtls_dhm_get_len(&blufi_sec->dhm);
if (dhm_len > DH_SELF_PUB_KEY_LEN) {
Log.error(F("%s dhm len not support %d" CR), __func__, dhm_len);
btc_blufi_report_error(ESP_BLUFI_DH_PARAM_ERROR);
return;
}
ret = mbedtls_dhm_make_public(&blufi_sec->dhm, dhm_len, blufi_sec->self_public_key, DH_SELF_PUB_KEY_LEN, myrand, NULL);
if (ret) { if (ret) {
Log.error(F("%s make public failed %d" CR), __func__, ret); Log.error(F("%s make public failed %d" CR), __func__, ret);
btc_blufi_report_error(ESP_BLUFI_MAKE_PUBLIC_ERROR); btc_blufi_report_error(ESP_BLUFI_MAKE_PUBLIC_ERROR);
@@ -106,13 +131,19 @@ void blufi_dh_negotiate_data_handler(uint8_t* data, int len, uint8_t** output_da
return; return;
} }
mbedtls_md5(blufi_sec->share_key, blufi_sec->share_len, blufi_sec->psk); ret = mbedtls_md5(blufi_sec->share_key, blufi_sec->share_len, blufi_sec->psk);
mbedtls_aes_setkey_enc(&blufi_sec->aes, blufi_sec->psk, 128); if (ret) {
Log.error(F("%s mbedtls_md5 failed %d" CR), __func__, ret);
btc_blufi_report_error(ESP_BLUFI_CALC_MD5_ERROR);
return;
}
mbedtls_aes_setkey_enc(&blufi_sec->aes, blufi_sec->psk, PSK_LEN * 8);
/* alloc output data */ /* alloc output data */
*output_data = &blufi_sec->self_public_key[0]; *output_data = &blufi_sec->self_public_key[0];
*output_len = blufi_sec->dhm.len; *output_len = dhm_len;
*need_free = false; *need_free = false;
} break; } break;
+9
View File
@@ -29,6 +29,8 @@
#include "User_config.h" #include "User_config.h"
#if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK) || defined(ZboardM5TOUGH) #if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK) || defined(ZboardM5TOUGH)
# include "TheengsCommon.h"
# include "config_M5.h"
# ifdef ZboardM5STICKC # ifdef ZboardM5STICKC
# include <M5StickC.h> # include <M5StickC.h>
# endif # endif
@@ -41,6 +43,13 @@
# ifdef ZboardM5TOUGH # ifdef ZboardM5TOUGH
# include <M5Tough.h> # include <M5Tough.h>
# endif # endif
void wakeScreen(int brightness);
void displayIntro(int i, int X, int Y);
void drawLogo(int logoSize, int circle1X, int circle1Y, bool circle1, bool circle2, bool circle3, bool circle4, bool circle5, bool circle6);
void sleepScreen();
void setBrightness(int brightness);
void logToLCD(bool display) { void logToLCD(bool display) {
display ? Log.begin(LOG_LEVEL_LCD, &M5.Lcd) : Log.begin(LOG_LEVEL, &Serial); // Log on LCD following LOG_LEVEL_LCD display ? Log.begin(LOG_LEVEL_LCD, &M5.Lcd) : Log.begin(LOG_LEVEL, &Serial); // Log on LCD following LOG_LEVEL_LCD
} }
@@ -1,6 +1,17 @@
#if SELF_TEST #if SELF_TEST
# include <Arduino.h>
# include <ETH.h>
# include <LEDManager.h>
# include <WiFi.h>
# include <esp_chip_info.h>
# include <esp_system.h> # include <esp_system.h>
# include "TheengsCommon.h"
# include "User_config.h"
extern LEDManager ledManager;
extern void ESPRestart(byte reason);
String getChipModel() { String getChipModel() {
esp_chip_info_t chip_info; esp_chip_info_t chip_info;
esp_chip_info(&chip_info); esp_chip_info(&chip_info);
+4 -1
View File
@@ -1,4 +1,7 @@
const char* ss_client_cert PROGMEM = R"EOF(" #pragma once
#include <Arduino.h>
static const char* ss_client_cert PROGMEM = R"EOF("
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
... ...
-----END CERTIFICATE----- -----END CERTIFICATE-----
+4 -1
View File
@@ -1,4 +1,7 @@
const char* ss_client_key PROGMEM = R"EOF(" #pragma once
#include <Arduino.h>
static const char* ss_client_key PROGMEM = R"EOF("
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
... ...
-----END RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----
+4 -1
View File
@@ -1,6 +1,9 @@
// The certificate must be in PEM ascii format. // The certificate must be in PEM ascii format.
// The default certificate is for ota.openmqttgateway.com // The default certificate is for ota.openmqttgateway.com
const char* OTAserver_cert PROGMEM = R"EOF(" #pragma once
#include <Arduino.h>
static const char* OTAserver_cert PROGMEM = R"EOF("
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF
ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6 ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6
+4 -1
View File
@@ -1,4 +1,7 @@
const char* ss_server_cert PROGMEM = R"EOF(" #pragma once
#include <Arduino.h>
static const char* ss_server_cert PROGMEM = R"EOF("
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
... ...
-----END CERTIFICATE----- -----END CERTIFICATE-----
+11
View File
@@ -29,6 +29,17 @@
# ifdef ZradioCC1101 # ifdef ZradioCC1101
# include <ELECHOUSE_CC1101_SRC_DRV.h> # include <ELECHOUSE_CC1101_SRC_DRV.h>
# endif # endif
# include "TheengsCommon.h"
# include "config_RF.h"
# ifdef ZgatewayRTL_433
# include <rtl_433_ESP.h>
extern rtl_433_ESP rtl_433;
# endif
RFConfig_s RFConfig;
void RFConfig_init();
void RFConfig_load();
void initCC1101() { void initCC1101() {
# ifdef ZradioCC1101 //receiving with CC1101 # ifdef ZradioCC1101 //receiving with CC1101
+2
View File
@@ -26,6 +26,8 @@
#ifndef config_2G_h #ifndef config_2G_h
#define config_2G_h #define config_2G_h
#include "TheengsCommon.h"
extern void setup2G(); extern void setup2G();
extern bool _2GtoX(); extern bool _2GtoX();
extern void Xto2G(const char* topicOri, const char* datacallback); extern void Xto2G(const char* topicOri, const char* datacallback);
+2 -3
View File
@@ -47,8 +47,7 @@ extern void MeasureLightIntensity();
/*----------------------------USER PARAMETERS-----------------------------*/ /*----------------------------USER PARAMETERS-----------------------------*/
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/ /*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define subjectBH1750toMQTT "/BH1750toMQTT" #define subjectBH1750toMQTT "/BH1750toMQTT"
//Time used to wait for an interval before resending measured values
unsigned long timebh1750 = 0; #define BH1750_I2C_ADDR 0x23; // Light Sensor I2C Address
int BH1750_i2c_addr = 0x23; // Light Sensor I2C Address
#endif #endif
+1 -3
View File
@@ -53,9 +53,7 @@ extern void MeasureTempHumAndPressure();
# define BMETOPIC "/CLIMAtoMQTT/bme" # define BMETOPIC "/CLIMAtoMQTT/bme"
#endif #endif
//Time used to wait for an interval before resending measured values #define BME280_I2C_ADDR 0x76
unsigned long timebme280 = 0;
int BME280_i2c_addr = 0x76; // Bosch BME280 I2C Address
// Only supported for ESP // Only supported for ESP
#ifndef BME280_PIN_SDA #ifndef BME280_PIN_SDA
+3 -2
View File
@@ -26,6 +26,8 @@
#ifndef config_BT_h #ifndef config_BT_h
#define config_BT_h #define config_BT_h
#include "TheengsCommon.h"
extern void setupBT(); extern void setupBT();
extern void XtoBT(const char* topicOri, JsonObject& RFdata); extern void XtoBT(const char* topicOri, JsonObject& RFdata);
extern void launchBTDiscovery(bool overrideDiscovery); extern void launchBTDiscovery(bool overrideDiscovery);
@@ -34,7 +36,6 @@ extern String stateBTMeasures(bool);
#ifdef ESP32 #ifdef ESP32
# include "NimBLEDevice.h" # include "NimBLEDevice.h"
#endif #endif
/*-----------BT TOPICS & COMPILATION PARAMETERS-----------*/ /*-----------BT TOPICS & COMPILATION PARAMETERS-----------*/
@@ -135,7 +136,7 @@ extern String stateBTMeasures(bool);
# define BLE_CNCT_TIMEOUT 3000 # define BLE_CNCT_TIMEOUT 3000
#endif #endif
unsigned long scanCount = 0; extern unsigned long scanCount;
#ifndef pubBLEAdvData #ifndef pubBLEAdvData
# define pubBLEAdvData false // define true if you want to publish all advertisement data # define pubBLEAdvData false // define true if you want to publish all advertisement data
+3 -1
View File
@@ -24,6 +24,8 @@
#ifndef config_FASTLED_h #ifndef config_FASTLED_h
#define config_FASTLED_h #define config_FASTLED_h
#include "TheengsCommon.h"
extern void setupFASTLED(); extern void setupFASTLED();
extern void FASTLEDLoop(); extern void FASTLEDLoop();
extern void XtoFASTLED(const char*, const char*); extern void XtoFASTLED(const char*, const char*);
@@ -82,7 +84,7 @@ extern void XtoFASTLED(const char*, JsonObject&);
# define FASTLED_ESP8266_D1_GPIO_ORDER # define FASTLED_ESP8266_D1_GPIO_ORDER
# define FASTLED_DATA_GPIO D2 // only D2 works by me # define FASTLED_DATA_GPIO D2 // only D2 works by me
//#define FASTLED_CLOCK_GPIO 13 //#define FASTLED_CLOCK_GPIO 13
#elif ESP32 #elif defined(ESP32)
# ifndef FASTLED_DATA_GPIO # ifndef FASTLED_DATA_GPIO
# define FASTLED_DATA_GPIO 16 # define FASTLED_DATA_GPIO 16
# endif # endif
-4
View File
@@ -27,10 +27,6 @@
#ifndef config_GFSunInverter_h #ifndef config_GFSunInverter_h
#define config_GFSunInverter_h #define config_GFSunInverter_h
#include <Arduino.h>
#include <ArduinoJson.h>
#include <GfSun2000.h>
extern void setupGFSunInverter(); extern void setupGFSunInverter();
extern void ZgatewayGFSunInverterMQTT(); extern void ZgatewayGFSunInverterMQTT();
+4 -2
View File
@@ -26,6 +26,8 @@
#ifndef config_IR_h #ifndef config_IR_h
#define config_IR_h #define config_IR_h
#include "TheengsCommon.h"
extern void setupIR(); extern void setupIR();
extern void IRtoX(); extern void IRtoX();
extern void XtoIR(const char* topicOri, const char* datacallback); extern void XtoIR(const char* topicOri, const char* datacallback);
@@ -182,7 +184,7 @@ extern void XtoIR(const char* topicOri, JsonObject& RFdata);
#ifndef IR_RECEIVER_GPIO #ifndef IR_RECEIVER_GPIO
# ifdef ESP8266 # ifdef ESP8266
# define IR_RECEIVER_GPIO 2 //D4 /replace by 4 with sonoff rf bridge # define IR_RECEIVER_GPIO 2 //D4 /replace by 4 with sonoff rf bridge
# elif ESP32 # elif defined(ESP32)
# define IR_RECEIVER_GPIO 26 # define IR_RECEIVER_GPIO 26
# endif # endif
#endif #endif
@@ -190,7 +192,7 @@ extern void XtoIR(const char* topicOri, JsonObject& RFdata);
#ifndef IR_EMITTER_GPIO #ifndef IR_EMITTER_GPIO
# ifdef ESP8266 # ifdef ESP8266
# define IR_EMITTER_GPIO 16 //D0/ replace by 0 (D3) if you use IR LOLIN controller shield /replace by 5 with sonoff rf bridge # define IR_EMITTER_GPIO 16 //D0/ replace by 0 (D3) if you use IR LOLIN controller shield /replace by 5 with sonoff rf bridge
# elif ESP32 # elif defined(ESP32)
# define IR_EMITTER_GPIO 14 # define IR_EMITTER_GPIO 14
# endif # endif
#endif #endif
+2
View File
@@ -26,6 +26,8 @@
#ifndef config_LORA_h #ifndef config_LORA_h
#define config_LORA_h #define config_LORA_h
#include "TheengsCommon.h"
extern void setupLORA(); extern void setupLORA();
extern void LORAtoX(); extern void LORAtoX();
extern void XtoLORA(const char* topicOri, const char* datacallback); extern void XtoLORA(const char* topicOri, const char* datacallback);
-3
View File
@@ -62,7 +62,4 @@ extern void MQ2toX();
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/ /*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define subjectMQ2toMQTT "/GAStoMQTT/mq2" #define subjectMQ2toMQTT "/GAStoMQTT/mq2"
//Time used to wait for an interval before resending measured values
unsigned long timemq2 = 0;
#endif #endif
+3 -1
View File
@@ -26,6 +26,8 @@
#ifndef config_ONOFF_h #ifndef config_ONOFF_h
#define config_ONOFF_h #define config_ONOFF_h
#include "TheengsCommon.h"
extern void setupONOFF(); extern void setupONOFF();
extern void XtoONOFF(const char* topicOri, const char* datacallback); extern void XtoONOFF(const char* topicOri, const char* datacallback);
extern void XtoONOFF(const char* topicOri, JsonObject& RFdata); extern void XtoONOFF(const char* topicOri, JsonObject& RFdata);
@@ -70,7 +72,7 @@ extern void stateONOFFMeasures();
#ifndef ACTUATOR_ONOFF_GPIO #ifndef ACTUATOR_ONOFF_GPIO
# ifdef ESP8266 # ifdef ESP8266
# define ACTUATOR_ONOFF_GPIO 15 //12 for sonoff basic relay # define ACTUATOR_ONOFF_GPIO 15 //12 for sonoff basic relay
# elif ESP32 # elif defined(ESP32)
# define ACTUATOR_ONOFF_GPIO 15 # define ACTUATOR_ONOFF_GPIO 15
# else # else
# define ACTUATOR_ONOFF_GPIO 13 # define ACTUATOR_ONOFF_GPIO 13
+5
View File
@@ -22,7 +22,10 @@
*/ */
/*-------------------PWM topics & parameters----------------------*/ /*-------------------PWM topics & parameters----------------------*/
#ifndef config_PWM_h
#define config_PWM_h
#include "TheengsCommon.h"
// PWM MQTT Subjects // PWM MQTT Subjects
extern void setupPWM(); extern void setupPWM();
@@ -55,3 +58,5 @@ extern void XtoPWM(const char*, JsonObject&);
#ifndef PWM_DEFAULT_GAMMA #ifndef PWM_DEFAULT_GAMMA
# define PWM_DEFAULT_GAMMA 2.2f # define PWM_DEFAULT_GAMMA 2.2f
#endif #endif
#endif // config_PWM_h
+16 -9
View File
@@ -26,8 +26,7 @@
#ifndef config_RF_h #ifndef config_RF_h
#define config_RF_h #define config_RF_h
#include <Arduino.h> #include "TheengsCommon.h"
#include <ArduinoJson.h>
#ifdef ZgatewayRF #ifdef ZgatewayRF
extern void setupRF(); extern void setupRF();
@@ -47,14 +46,10 @@ extern void enableRF2Receive();
#ifdef ZgatewayPilight #ifdef ZgatewayPilight
extern void setupPilight(); extern void setupPilight();
extern void PilighttoX(); extern void PilighttoX();
extern void XtoPilight(const char* topicOri, const char* datacallback);
extern void XtoPilight(const char* topicOri, JsonObject& RFdata);
extern void disablePilightReceive(); extern void disablePilightReceive();
extern void enablePilightReceive(); extern void enablePilightReceive();
#endif #endif
#ifdef ZgatewayRTL_433 #ifdef ZgatewayRTL_433
# include <rtl_433_ESP.h>
rtl_433_ESP rtl_433;
extern void RTL_433Loop(); extern void RTL_433Loop();
extern void setupRTL_433(); extern void setupRTL_433();
@@ -217,7 +212,19 @@ struct RFConfig_s {
#define ACTIVE_RTL 3 #define ACTIVE_RTL 3
#define ACTIVE_RF2 4 #define ACTIVE_RF2 4
RFConfig_s RFConfig; #ifdef ZgatewayRF
# define ACTIVE_RECEIVER ACTIVE_RF
#elif defined(ZgatewayRF2)
# define ACTIVE_RECEIVER ACTIVE_RF2
#elif defined(ZgatewayPilight)
# define ACTIVE_RECEIVER ACTIVE_PILIGHT
#elif defined(ZgatewayRTL_433)
# define ACTIVE_RECEIVER ACTIVE_RTL
#else
# define ACTIVE_RECEIVER ACTIVE_NONE
#endif
extern RFConfig_s RFConfig;
/*-------------------CC1101 DefaultTXPower----------------------*/ /*-------------------CC1101 DefaultTXPower----------------------*/
//Adjust the default TX-Power for sending radio if ZradioCC1101 is used. //Adjust the default TX-Power for sending radio if ZradioCC1101 is used.
@@ -230,7 +237,7 @@ RFConfig_s RFConfig;
#ifndef RF_RECEIVER_GPIO #ifndef RF_RECEIVER_GPIO
# ifdef ESP8266 # ifdef ESP8266
# define RF_RECEIVER_GPIO 0 // D3 on nodemcu // put 4 with rf bridge direct mod # define RF_RECEIVER_GPIO 0 // D3 on nodemcu // put 4 with rf bridge direct mod
# elif ESP32 # elif defined(ESP32)
# define RF_RECEIVER_GPIO 27 // D27 on DOIT ESP32 # define RF_RECEIVER_GPIO 27 // D27 on DOIT ESP32
# endif # endif
#endif #endif
@@ -238,7 +245,7 @@ RFConfig_s RFConfig;
#ifndef RF_EMITTER_GPIO #ifndef RF_EMITTER_GPIO
# ifdef ESP8266 # ifdef ESP8266
# define RF_EMITTER_GPIO 3 // RX on nodemcu if it doesn't work with 3, try with 4 (D2) // put 5 with rf bridge direct mod # define RF_EMITTER_GPIO 3 // RX on nodemcu if it doesn't work with 3, try with 4 (D2) // put 5 with rf bridge direct mod
# elif ESP32 # elif defined(ESP32)
# define RF_EMITTER_GPIO 12 // D12 on DOIT ESP32 # define RF_EMITTER_GPIO 12 // D12 on DOIT ESP32
# else # else
//IMPORTANT NOTE: On arduino UNO connect IR emitter pin to D9 , comment #define IR_USE_TIMER2 and uncomment #define IR_USE_TIMER1 on library <library>IRremote/boarddefs.h so as to free pin D3 for RF RECEIVER PIN //IMPORTANT NOTE: On arduino UNO connect IR emitter pin to D9 , comment #define IR_USE_TIMER2 and uncomment #define IR_USE_TIMER1 on library <library>IRremote/boarddefs.h so as to free pin D3 for RF RECEIVER PIN
+8 -6
View File
@@ -26,6 +26,8 @@
#ifndef config_RFM69_h #ifndef config_RFM69_h
#define config_RFM69_h #define config_RFM69_h
#include "TheengsCommon.h"
extern void setupRFM69(); extern void setupRFM69();
extern bool RFM69toX(); extern bool RFM69toX();
extern void XtoRFM69(const char* topicOri, const char* datacallback); extern void XtoRFM69(const char* topicOri, const char* datacallback);
@@ -43,12 +45,12 @@ extern void XtoRFM69(const char* topicOri, JsonObject& RFdata);
#define defaultRFM69ReceiverId 99 #define defaultRFM69ReceiverId 99
// Default values // Default values
const char PROGMEM ENCRYPTKEY[] = "sampleEncryptKey"; #define RFM69_ENCRYPTKEY "sampleEncryptKey";
const char PROGMEM MDNS_NAME[] = "rfm69gw1"; #define RFM69_MDNS_NAME "rfm69gw1";
const char PROGMEM MQTT_BROKER[] = "raspi2"; #define RFM69_MQTT_BROKER "raspi2";
const char PROGMEM RFM69AP_NAME[] = "RFM69-AP"; #define RFM69_RFM69AP_NAME "RFM69-AP";
#define NETWORKID 200 //the same on all nodes that talk to each other #define RFM69_NETWORKID 200 //the same on all nodes that talk to each other
#define NODEID 10 #define RFM69_NODEID 10
//Match frequency to the hardware version of the radio //Match frequency to the hardware version of the radio
#define FREQUENCY RF69_433MHZ #define FREQUENCY RF69_433MHZ
+3 -1
View File
@@ -26,6 +26,8 @@
#ifndef config_SERIAL_h #ifndef config_SERIAL_h
#define config_SERIAL_h #define config_SERIAL_h
#include "TheengsCommon.h"
extern void setupSERIAL(); extern void setupSERIAL();
extern void SERIALtoX(); extern void SERIALtoX();
extern bool XtoSERIAL(const char* topicOri, JsonObject& SERIALdata); extern bool XtoSERIAL(const char* topicOri, JsonObject& SERIALdata);
@@ -131,7 +133,7 @@ extern bool XtoSERIAL(const char* topicOri, JsonObject& SERIALdata);
// define transmit pin (for software serial and/or ESP32) // define transmit pin (for software serial and/or ESP32)
# if defined(ESP8266) && !defined(SERIAL_UART) # if defined(ESP8266) && !defined(SERIAL_UART)
# define SERIAL_TX_GPIO 2 //D4 # define SERIAL_TX_GPIO 2 //D4
# elif ESP32 # elif defined(ESP32)
# define SERIAL_TX_GPIO 14 # define SERIAL_TX_GPIO 14
# endif # endif
#endif #endif
+2
View File
@@ -27,6 +27,8 @@
#ifndef config_SRFB_h #ifndef config_SRFB_h
#define config_SRFB_h #define config_SRFB_h
#include "TheengsCommon.h"
extern void setupSRFB(); extern void setupSRFB();
extern bool SRFBtoX(); extern bool SRFBtoX();
extern void XtoSRFB(const char* topicOri, const char* datacallback); extern void XtoSRFB(const char* topicOri, const char* datacallback);
+1 -54
View File
@@ -34,11 +34,7 @@
#ifndef config_SSD1306_h #ifndef config_SSD1306_h
#define config_SSD1306_h #define config_SSD1306_h
#include <Arduino.h> #include "TheengsCommon.h"
#include <ArduinoJson.h>
#include <Wire.h>
#include "SSD1306Wire.h"
#include "config_WebUI.h" #include "config_WebUI.h"
/*-------------------DEFINE LOG LEVEL----------------------*/ /*-------------------DEFINE LOG LEVEL----------------------*/
@@ -140,53 +136,4 @@ void ssd1306Print(char*);
/*-------------------End of Global Variables----------------------*/ /*-------------------End of Global Variables----------------------*/
// This pattern was borrowed from HardwareSerial and modified to support the ssd1306 display
class OledSerial : public Stream {
public:
OledSerial(int);
void begin();
void drawLogo(int xshift, int yshift);
boolean displayPage(webUIQueueMessage*);
SSD1306Wire* display;
int available(void); // Dummy functions
int peek(void); // Dummy functions
int read(void); // Dummy functions
void flush(void); // Dummy functions
void fillScreen(OLEDDISPLAY_COLOR); // fillScreen display and set color
// This is a bit of lazy programmer simplification for the semaphore and core detecting code. Not sure if it is truly space efficient.
inline size_t write(uint8_t x) {
return write(&x, 1);
}
size_t write(const uint8_t* buffer, size_t size);
inline size_t write(const char* buffer, size_t size) {
return write((uint8_t*)buffer, size);
}
inline size_t write(const char* s) {
return write((uint8_t*)s, strlen(s));
}
inline size_t write(unsigned long n) {
return write((uint8_t)n);
}
inline size_t write(long n) {
return write((uint8_t)n);
}
inline size_t write(unsigned int n) {
return write((uint8_t)n);
}
inline size_t write(int n) {
return write((uint8_t)n);
}
protected:
};
extern OledSerial Oled;
#endif #endif
+1 -2
View File
@@ -24,8 +24,7 @@
#ifndef config_Somfy_h #ifndef config_Somfy_h
#define config_Somfy_h #define config_Somfy_h
#include <Arduino.h> #include "TheengsCommon.h"
#include <ArduinoJson.h>
extern void setupSomfy(); extern void setupSomfy();
extern void XtoSomfy(const char* topicOri, JsonObject& RFdata); extern void XtoSomfy(const char* topicOri, JsonObject& RFdata);
-3
View File
@@ -49,7 +49,4 @@ extern void MeasureLightIntensityTEMT6000();
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/ /*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define subjectTEMT6000toMQTT "/LIGHTtoMQTT" #define subjectTEMT6000toMQTT "/LIGHTtoMQTT"
//Time used to wait for an interval before resending measured values
unsigned long timetemt6000 = 0;
#endif #endif
-4
View File
@@ -48,8 +48,4 @@ extern void MeasureLightIntensityTSL2561();
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/ /*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
#define subjectTSL12561toMQTT "/LIGHTtoMQTT" #define subjectTSL12561toMQTT "/LIGHTtoMQTT"
//Time used to wait for an interval before resending measured values
unsigned long timetsl2561 = 0;
//int TSL2561_i2c_addr = 0x37; // Light Sensor I2C Address (Set in Adafruit library)
#endif #endif
+1 -4
View File
@@ -26,9 +26,6 @@
#ifndef config_WeatherStation_h #ifndef config_WeatherStation_h
#define config_WeatherStation_h #define config_WeatherStation_h
#include <Arduino.h>
#include <ArduinoJson.h>
extern void setupWeatherStation(); extern void setupWeatherStation();
extern void ZgatewayWeatherStationtoX(); extern void ZgatewayWeatherStationtoX();
/*----------------------------USER PARAMETERS-----------------------------*/ /*----------------------------USER PARAMETERS-----------------------------*/
@@ -39,7 +36,7 @@ extern void ZgatewayWeatherStationtoX();
#ifndef RF_WS_RECEIVER_GPIO #ifndef RF_WS_RECEIVER_GPIO
# ifdef ESP8266 # ifdef ESP8266
# define RF_WS_RECEIVER_GPIO 0 // D3 on nodemcu // put 4 with rf bridge direct mod # define RF_WS_RECEIVER_GPIO 0 // D3 on nodemcu // put 4 with rf bridge direct mod
# elif ESP32 # elif defined(ESP32)
# define RF_WS_RECEIVER_GPIO 27 // D27 on DOIT ESP32 # define RF_WS_RECEIVER_GPIO 27 // D27 on DOIT ESP32
# endif # endif
#endif #endif
+7 -4
View File
@@ -26,9 +26,10 @@
#ifndef config_WebUI_h #ifndef config_WebUI_h
#define config_WebUI_h #define config_WebUI_h
#include <ArduinoJson.h>
#include <Wire.h> #include <Wire.h>
#include "TheengsCommon.h"
#define WEBUI_TEXT_WIDTH 128 #define WEBUI_TEXT_WIDTH 128
/*------------------- Optional Compiler Directives ----------------------*/ /*------------------- Optional Compiler Directives ----------------------*/
@@ -65,6 +66,8 @@
# define WEBUI_LOGIN "admin" # define WEBUI_LOGIN "admin"
#endif #endif
extern char ota_pass[];
/*------------------- End of Compiler Directives ----------------------*/ /*------------------- End of Compiler Directives ----------------------*/
#define WEBUI_SECURE \ #define WEBUI_SECURE \
@@ -92,7 +95,7 @@ struct webUIQueueMessage {
char line2[WEBUI_TEXT_WIDTH]; char line2[WEBUI_TEXT_WIDTH];
char line3[WEBUI_TEXT_WIDTH]; char line3[WEBUI_TEXT_WIDTH];
char line4[WEBUI_TEXT_WIDTH]; char line4[WEBUI_TEXT_WIDTH];
} webUIQueueMessage_t; };
/*------------------- Global Functions and Variables ----------------------*/ /*------------------- Global Functions and Variables ----------------------*/
@@ -106,8 +109,8 @@ void XtoWebUI(const char*, JsonObject&);
String stateWebUIStatus(); String stateWebUIStatus();
webUIQueueMessage* currentWebUIMessage; extern webUIQueueMessage* currentWebUIMessage;
bool newSSD1306Message = false; // Flag to indicate new message to display extern bool newSSD1306Message; // Flag to indicate new message to display
/*------------------- End of Global Functions ----------------------*/ /*------------------- End of Global Functions ----------------------*/
+1 -81
View File
@@ -111,7 +111,7 @@ void announceGatewayTrigger(const char* topic,
#ifndef discovery_Prefix #ifndef discovery_Prefix
# define discovery_Prefix "homeassistant" # define discovery_Prefix "homeassistant"
#endif #endif
char discovery_prefix[parameters_size + 1] = discovery_Prefix; extern char discovery_prefix[];
// discovery_republish_on_reconnect false to publish discovery topics over MQTT only with first connect // discovery_republish_on_reconnect false to publish discovery topics over MQTT only with first connect
// discovery_republish_on_reconnect true to always republish discovery topics over MQTT when connection is re-established // discovery_republish_on_reconnect true to always republish discovery topics over MQTT when connection is re-established
@@ -176,86 +176,6 @@ char discovery_prefix[parameters_size + 1] = discovery_Prefix;
#define stateClassTotal "total" #define stateClassTotal "total"
#define stateClassTotalIncreasing "total_increasing" #define stateClassTotalIncreasing "total_increasing"
// From https://github.com/home-assistant/core/blob/d7ac4bd65379e11461c7ce0893d3533d8d8b8cbf/homeassistant/const.py#L225
// List of classes available in Home Assistant
const char* availableHASSClasses[] = {"battery_charging",
"battery",
"carbon_dioxide",
"carbon_monoxide",
"current",
"data_size",
"distance",
"door",
"duration",
"energy",
"enum",
"gas",
"humidity",
"illuminance",
"irradiance",
"lock",
"motion",
"moving",
"pm1",
"pm10",
"pm25",
"power_factor",
"power",
"precipitation_intensity",
"precipitation",
"pressure",
"problem",
"restart",
"signal_strength",
"sound_pressure",
"temperature",
"timestamp",
"voltage",
"water",
"weight",
"wind_speed",
"window"};
// From https://github.com/home-assistant/core/blob/d7ac4bd65379e11461c7ce0893d3533d8d8b8cbf/homeassistant/const.py#L379
// List of units available in Home Assistant
const char* availableHASSUnits[] = {"W",
"kW",
"V",
"kWh",
"A",
"W",
"°C",
"°F",
"ms",
"s",
"min",
"hPa",
"L",
"kg",
"lb",
"µS/cm",
"ppm",
"μg/m³",
"m³",
"mg/m³",
"m/s²",
"mV",
"lx",
"Ω",
"%",
"bar",
"bpm",
"dB",
"dBm",
"B",
"UV index",
"m/s",
"km/h",
"°",
"mm",
"mm/h",
"cm"};
// Define the command used to update through OTA depending if we want to update from dev nightly or latest release // Define the command used to update through OTA depending if we want to update from dev nightly or latest release
#if DEVELOPMENTOTA #if DEVELOPMENTOTA
# define LATEST_OR_DEV "{\"version\":\"dev\"}" # define LATEST_OR_DEV "{\"version\":\"dev\"}"
@@ -31,17 +31,61 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "User_config.h"
#if defined(ZdisplaySSD1306) #if defined(ZdisplaySSD1306)
# include "SSD1306Wire.h"
# include <ArduinoJson.h> # include "TheengsCommon.h"
# include "ArduinoLog.h"
# include "User_config.h"
# include "config_SSD1306.h" # include "config_SSD1306.h"
# ifdef DISPLAY_BLANKING # ifdef DISPLAY_BLANKING
# include "driver/touch_sensor.h" # include "driver/touch_sensor.h"
# endif # endif
// This pattern was borrowed from HardwareSerial and modified to support the ssd1306 display
class OledSerial : public Stream {
public:
OledSerial(int);
void begin();
void drawLogo(int xshift, int yshift);
boolean displayPage(webUIQueueMessage*);
SSD1306Wire* display;
int available(void); // Dummy functions
int peek(void); // Dummy functions
int read(void); // Dummy functions
void flush(void); // Dummy functions
void fillScreen(OLEDDISPLAY_COLOR); // fillScreen display and set color
// This is a bit of lazy programmer simplification for the semaphore and core detecting code. Not sure if it is truly space efficient.
inline size_t write(uint8_t x) {
return write(&x, 1);
}
size_t write(const uint8_t* buffer, size_t size);
inline size_t write(const char* buffer, size_t size) {
return write((uint8_t*)buffer, size);
}
inline size_t write(const char* s) {
return write((uint8_t*)s, strlen(s));
}
inline size_t write(unsigned long n) {
return write((uint8_t)n);
}
inline size_t write(long n) {
return write((uint8_t)n);
}
inline size_t write(unsigned int n) {
return write((uint8_t)n);
}
inline size_t write(int n) {
return write((uint8_t)n);
}
} Oled(0); // Oled object
SemaphoreHandle_t semaphoreOLEDOperation; SemaphoreHandle_t semaphoreOLEDOperation;
boolean logToOLEDDisplay = LOG_TO_OLED; boolean logToOLEDDisplay = LOG_TO_OLED;
@@ -50,7 +94,11 @@ boolean displayFlip = DISPLAY_FLIP;
boolean displayState = DISPLAY_STATE; boolean displayState = DISPLAY_STATE;
boolean idlelogo = DISPLAY_IDLE_LOGO; boolean idlelogo = DISPLAY_IDLE_LOGO;
uint8_t displayBrightness = DISPLAY_BRIGHTNESS; uint8_t displayBrightness = DISPLAY_BRIGHTNESS;
bool newSSD1306Message = false; // Flag to indicate new message to display
void SSD1306Config_init();
bool SSD1306Config_load();
void SSD1306Config_save();
/* /*
Toogle log display Toogle log display
*/ */
@@ -66,12 +114,12 @@ void setupSSD1306() {
SSD1306Config_init(); SSD1306Config_init();
SSD1306Config_load(); SSD1306Config_load();
Log.trace(F("Setup SSD1306 Display" CR)); Log.trace(F("Setup SSD1306 Display" CR));
Log.trace(F("ZdisplaySSD1306 command topic: %s" CR), subjectMQTTtoSSD1306set); Log.trace(F("displaySSD1306 command topic: %s" CR), subjectMQTTtoSSD1306set);
Log.trace(F("ZdisplaySSD1306 log-oled: %T" CR), logToOLEDDisplay); Log.trace(F("displaySSD1306 log-oled: %T" CR), logToOLEDDisplay);
Log.trace(F("ZdisplaySSD1306 json-oled: %T" CR), jsonDisplay); Log.trace(F("displaySSD1306 json-oled: %T" CR), jsonDisplay);
Log.trace(F("ZdisplaySSD1306 DISPLAY_PAGE_INTERVAL: %d" CR), DISPLAY_PAGE_INTERVAL); Log.trace(F("displaySSD1306 DISPLAY_PAGE_INTERVAL: %d" CR), DISPLAY_PAGE_INTERVAL);
Log.trace(F("ZdisplaySSD1306 DISPLAY_IDLE_LOGO: %T" CR), idlelogo); Log.trace(F("displaySSD1306 DISPLAY_IDLE_LOGO: %T" CR), idlelogo);
Log.trace(F("ZdisplaySSD1306 DISPLAY_FLIP: %T" CR), displayFlip); Log.trace(F("displaySSD1306 DISPLAY_FLIP: %T" CR), displayFlip);
Oled.begin(); Oled.begin();
Log.notice(F("Setup SSD1306 Display end" CR)); Log.notice(F("Setup SSD1306 Display end" CR));
@@ -316,7 +364,6 @@ void ssd1306Print(char* line1) {
// This pattern was borrowed from HardwareSerial and modified to support the ssd1306 display // This pattern was borrowed from HardwareSerial and modified to support the ssd1306 display
OledSerial Oled(0); // Not sure about this, came from Hardwareserial
OledSerial::OledSerial(int x) { OledSerial::OledSerial(int x) {
# if defined(WIFI_Kit_32) || defined(WIFI_LoRa_32) || defined(WIFI_LoRa_32_V2) # if defined(WIFI_Kit_32) || defined(WIFI_LoRa_32) || defined(WIFI_LoRa_32_V2)
pinMode(RST_OLED, OUTPUT); // https://github.com/espressif/arduino-esp32/issues/4278 pinMode(RST_OLED, OUTPUT); // https://github.com/espressif/arduino-esp32/issues/4278
+7 -2
View File
@@ -30,7 +30,12 @@
#ifdef Zgateway2G #ifdef Zgateway2G
# include <A6lib.h> // library for controling A6 or A7 module # include <A6lib.h> // library for controling A6 or A7 module
# include <ArduinoJson.h>
# include "TheengsCommon.h"
# include "config_2G.h"
void signalStrengthAnalysis();
void setupGSM(bool deleteSMS);
// Instantiate the library with TxPin, RxPin. // Instantiate the library with TxPin, RxPin.
A6lib A6l(_2G_TX_GPIO, _2G_RX_GPIO); //D6 to A6 RX, D7 to A6 TX A6lib A6l(_2G_TX_GPIO, _2G_RX_GPIO); //D6 to A6 RX, D7 to A6 TX
@@ -43,7 +48,7 @@ void setup2G() {
Log.notice(F("_2G_TX_GPIO: %d " CR), _2G_TX_GPIO); Log.notice(F("_2G_TX_GPIO: %d " CR), _2G_TX_GPIO);
Log.notice(F("_2G_RX_GPIO: %d " CR), _2G_RX_GPIO); Log.notice(F("_2G_RX_GPIO: %d " CR), _2G_RX_GPIO);
setupGSM(false); setupGSM(false);
Log.trace(F("Zgateway2G setup done " CR)); Log.trace(F("gateway2G setup done " CR));
} }
void setupGSM(bool deleteSMS) { void setupGSM(bool deleteSMS) {
@@ -1,12 +1,13 @@
#ifdef ESP32 #ifdef ESP32
# include "User_config.h" # include "User_config.h"
# ifdef ZgatewayBT # ifdef ZgatewayBT
# include "ArduinoJson.h" # include "gatewayBLEConnect.h"
# include "ArduinoLog.h" # include "mbedtls/aes.h"
# include "ZgatewayBLEConnect.h"
# define convertTemp_CtoF(c) ((c * 1.8) + 32) # define convertTemp_CtoF(c) ((c * 1.8) + 32)
extern std::vector<BLEdevice*> devices; extern std::vector<BLEdevice*> devices;
extern bool BTProcessLock;
NimBLERemoteCharacteristic* zBLEConnect::getCharacteristic(const NimBLEUUID& service, NimBLERemoteCharacteristic* zBLEConnect::getCharacteristic(const NimBLEUUID& service,
const NimBLEUUID& characteristic) { const NimBLEUUID& characteristic) {
@@ -2,8 +2,8 @@
#define zBLEConnect_h #define zBLEConnect_h
#ifdef ESP32 #ifdef ESP32
# include "ArduinoJson.h"
# include "NimBLEDevice.h" # include "NimBLEDevice.h"
# include "TheengsCommon.h"
# include "config_BT.h" # include "config_BT.h"
class zBLEConnect { class zBLEConnect {
+28 -14
View File
@@ -29,11 +29,12 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
#include "User_config.h" #include "User_config.h"
#ifdef ZgatewayBT #ifdef ZgatewayBT
# include "TheengsCommon.h"
SemaphoreHandle_t semaphoreCreateOrUpdateDevice; SemaphoreHandle_t semaphoreCreateOrUpdateDevice;
SemaphoreHandle_t semaphoreBLEOperation; SemaphoreHandle_t semaphoreBLEOperation;
QueueHandle_t BLEQueue; QueueHandle_t BLEQueue;
// Headers used for deep sleep functions unsigned long scanCount = 0;
# include <NimBLEAdvertisedDevice.h> # include <NimBLEAdvertisedDevice.h>
# include <NimBLEDevice.h> # include <NimBLEDevice.h>
# include <NimBLEScan.h> # include <NimBLEScan.h>
@@ -43,7 +44,9 @@ QueueHandle_t BLEQueue;
# include <atomic> # include <atomic>
# include "ZgatewayBLEConnect.h" # include "TheengsCommon.h"
# include "config_mqttDiscovery.h"
# include "gatewayBLEConnect.h"
# include "soc/timer_group_reg.h" # include "soc/timer_group_reg.h"
# include "soc/timer_group_struct.h" # include "soc/timer_group_struct.h"
@@ -71,15 +74,26 @@ vector<BLEAction> BLEactions;
vector<BLEdevice*> devices; vector<BLEdevice*> devices;
int newDevices = 0; int newDevices = 0;
static BLEdevice NO_BT_DEVICE_FOUND = {{0}, static BLEdevice NO_BT_DEVICE_FOUND = {
0, {0},
false, 0,
false, false,
false, false,
false, false,
UNKWNON_MODEL}; false,
(int)UNKWNON_MODEL,
0,
};
static bool oneWhite = false; static bool oneWhite = false;
extern bool BTProcessLock;
extern int queueLength;
void setupBTTasksAndBLE();
bool checkIfIsTracker(char ch);
void hass_presence(JsonObject& HomePresence);
void BTforceScan();
void BTConfig_init() { void BTConfig_init() {
BTConfig.bleConnect = AttemptBLEConnect; BTConfig.bleConnect = AttemptBLEConnect;
BTConfig.BLEinterval = TimeBtwRead; BTConfig.BLEinterval = TimeBtwRead;
@@ -846,7 +860,7 @@ void setupBTTasksAndBLE() {
BLEDevice::setScanDuplicateCacheSize(BLEScanDuplicateCacheSize); BLEDevice::setScanDuplicateCacheSize(BLEScanDuplicateCacheSize);
# endif # endif
BLEDevice::init(""); BLEDevice::init("");
xTaskCreatePinnedToCore( xTaskCreateUniversal(
procBLETask, /* Function to implement the task */ procBLETask, /* Function to implement the task */
"procBLETask", /* Name of the task */ "procBLETask", /* Name of the task */
# if defined(USE_ESP_IDF) || defined(USE_BLUFI) # if defined(USE_ESP_IDF) || defined(USE_BLUFI)
@@ -860,7 +874,7 @@ void setupBTTasksAndBLE() {
1); /* Core where the task should run */ 1); /* Core where the task should run */
// we setup a task with priority one to avoid conflict with other gateways // we setup a task with priority one to avoid conflict with other gateways
xTaskCreatePinnedToCore( xTaskCreateUniversal(
coreTask, /* Function to implement the task */ coreTask, /* Function to implement the task */
"coreTask", /* Name of the task */ "coreTask", /* Name of the task */
5120, /* Stack size in bytes */ 5120, /* Stack size in bytes */
@@ -897,9 +911,9 @@ void setupBT() {
BLEQueue = xQueueCreate(QueueSize, sizeof(NimBLEAdvertisedDevice*)); BLEQueue = xQueueCreate(QueueSize, sizeof(NimBLEAdvertisedDevice*));
if (BTConfig.enabled) { if (BTConfig.enabled) {
setupBTTasksAndBLE(); setupBTTasksAndBLE();
Log.notice(F("ZgatewayBT multicore ESP32 setup done" CR)); Log.notice(F("gatewayBT multicore ESP32 setup done" CR));
} else { } else {
Log.notice(F("ZgatewayBT multicore ESP32 setup disabled" CR)); Log.notice(F("gatewayBT multicore ESP32 setup disabled" CR));
} }
} }
@@ -1399,7 +1413,7 @@ void immediateBTAction(void* pvParameters) {
void startBTActionTask() { void startBTActionTask() {
TaskHandle_t th; TaskHandle_t th;
xTaskCreatePinnedToCore( xTaskCreateUniversal(
immediateBTAction, /* Function to implement the task */ immediateBTAction, /* Function to implement the task */
"imActTask", /* Name of the task */ "imActTask", /* Name of the task */
8000, /* Stack size in bytes */ 8000, /* Stack size in bytes */
@@ -27,6 +27,11 @@
#ifdef ZgatewayGFSunInverter #ifdef ZgatewayGFSunInverter
# include <GfSun2000.h>
# include "TheengsCommon.h"
# include "config_GFSunInverter.h"
GfSun2000 GF = GfSun2000(); GfSun2000 GF = GfSun2000();
void GFSunInverterDataHandler(GfSun2000Data data) { void GFSunInverterDataHandler(GfSun2000Data data) {
@@ -79,7 +84,7 @@ void setupGFSunInverter() {
GF.setup(Serial2); GF.setup(Serial2);
GF.setDataHandler(GFSunInverterDataHandler); GF.setDataHandler(GFSunInverterDataHandler);
GF.setErrorHandler(GFSunInverterErrorHandler); GF.setErrorHandler(GFSunInverterErrorHandler);
Log.trace(F("ZgatewayGFSunInverter setup done " CR)); Log.trace(F("gatewayGFSunInverter setup done " CR));
} }
void ZgatewayGFSunInverterMQTT() { void ZgatewayGFSunInverterMQTT() {
+5 -3
View File
@@ -28,11 +28,13 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZgatewayIR #ifdef ZgatewayIR
# include <IRrecv.h> // Needed if you want to receive IR commands. # include <IRrecv.h> // Needed if you want to receive IR commands.
# include <IRremoteESP8266.h> # include <IRremoteESP8266.h>
# include <IRsend.h> // Needed if you want to send IR commands. # include <IRsend.h> // Needed if you want to send IR commands.
# include <IRutils.h> # include <IRutils.h>
# include "TheengsCommon.h"
# include "config_IR.h"
# ifdef DumpMode // in dump mode we increase the size of the buffer to catch big codes # ifdef DumpMode // in dump mode we increase the size of the buffer to catch big codes
IRrecv irrecv(IR_RECEIVER_GPIO, 1024, 15U, true); IRrecv irrecv(IR_RECEIVER_GPIO, 1024, 15U, true);
# else # else
@@ -99,7 +101,7 @@ void setupIR() {
Log.notice(F("IR_EMITTER_GPIO: %d " CR), IR_EMITTER_GPIO); Log.notice(F("IR_EMITTER_GPIO: %d " CR), IR_EMITTER_GPIO);
Log.notice(F("IR_RECEIVER_GPIO: %d " CR), IR_RECEIVER_GPIO); Log.notice(F("IR_RECEIVER_GPIO: %d " CR), IR_RECEIVER_GPIO);
Log.trace(F("ZgatewayIR setup done " CR)); Log.trace(F("gatewayIR setup done " CR));
} }
void IRtoX() { void IRtoX() {
@@ -1084,7 +1086,7 @@ bool sendIdentifiedProtocol(const char* protocol_name, uint64_t data, const char
} }
# endif # endif
# ifdef IR_ZEPEAL # ifdef IR_ZEPEAL
if (strcmp(protocol_name, "ZEPEAL") == 0) { if (strcmp(protocol_name, "EPEAL") == 0) {
Log.notice(F("Sending IR signal with %s" CR), protocol_name); Log.notice(F("Sending IR signal with %s" CR), protocol_name);
if (valueRPT == repeatIRwNumber) if (valueRPT == repeatIRwNumber)
valueRPT = std::max(valueRPT, kZepealMinRepeat); valueRPT = std::max(valueRPT, kZepealMinRepeat);
+21 -5
View File
@@ -28,18 +28,35 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZgatewayLORA #ifdef ZgatewayLORA
# include <LoRa.h> # include <LoRa.h>
# include <SPI.h> # include <SPI.h>
# include <TheengsUtils.h>
# include <Wire.h> # include <Wire.h>
# include "TheengsCommon.h"
# include "config_LORA.h"
# include "config_mqttDiscovery.h"
# define WIPHONE_MESSAGE_MAGIC 0x6c6d # define WIPHONE_MESSAGE_MAGIC 0x6c6d
# define WIPHONE_MESSAGE_MIN_LEN sizeof(wiphone_message) - WIPHONE_MAX_MESSAGE_LEN # define WIPHONE_MESSAGE_MIN_LEN sizeof(wiphone_message) - WIPHONE_MAX_MESSAGE_LEN
# define WIPHONE_MAX_MESSAGE_LEN 230 # define WIPHONE_MAX_MESSAGE_LEN 230
LORAConfig_s LORAConfig; LORAConfig_s LORAConfig;
void LORAConfig_fromJson(JsonObject& LORAdata);
String stateLORAMeasures();
# ifdef ZmqttDiscovery # ifdef ZmqttDiscovery
# include "config_mqttDiscovery.h"
extern void createDiscovery(const char* sensor_type,
const char* st_topic, const char* s_name, const char* unique_id,
const char* availability_topic, const char* device_class, const char* value_template,
const char* payload_on, const char* payload_off, const char* unit_of_meas,
int off_delay,
const char* payload_available, const char* payload_not_available, bool gateway_entity, const char* cmd_topic,
const char* device_name, const char* device_manufacturer, const char* device_model, const char* device_id, bool retainCmd,
const char* state_class, const char* state_off, const char* state_on, const char* enum_options, const char* command_template);
SemaphoreHandle_t semaphorecreateOrUpdateDeviceLORA; SemaphoreHandle_t semaphorecreateOrUpdateDeviceLORA;
std::vector<LORAdevice*> LORAdevices; std::vector<LORAdevice*> LORAdevices;
int newLORADevices = 0; int newLORADevices = 0;
@@ -389,9 +406,8 @@ void setupLORA() {
LoRa.setPins(LORA_SS, LORA_RST, LORA_DI0); LoRa.setPins(LORA_SS, LORA_RST, LORA_DI0);
if (!LoRa.begin(LORAConfig.frequency)) { if (!LoRa.begin(LORAConfig.frequency)) {
Log.error(F("ZgatewayLORA setup failed!" CR)); Log.error(F("gatewayLORA setup failed!" CR));
while (1) while (1);
;
} }
LoRa.receive(); LoRa.receive();
Log.notice(F("LORA_SCK: %d" CR), LORA_SCK); Log.notice(F("LORA_SCK: %d" CR), LORA_SCK);
@@ -400,7 +416,7 @@ void setupLORA() {
Log.notice(F("LORA_SS: %d" CR), LORA_SS); Log.notice(F("LORA_SS: %d" CR), LORA_SS);
Log.notice(F("LORA_RST: %d" CR), LORA_RST); Log.notice(F("LORA_RST: %d" CR), LORA_RST);
Log.notice(F("LORA_DI0: %d" CR), LORA_DI0); Log.notice(F("LORA_DI0: %d" CR), LORA_DI0);
Log.trace(F("ZgatewayLORA setup done" CR)); Log.trace(F("gatewayLORA setup done" CR));
} }
void LORAtoX() { void LORAtoX() {
@@ -28,6 +28,15 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZgatewayPilight #ifdef ZgatewayPilight
# include "TheengsCommon.h"
# if defined(ESP32)
# include <SPIFFS.h>
# else
# include <FS.h>
# endif
# include "config_RF.h"
# ifdef ZradioCC1101 # ifdef ZradioCC1101
# include <ELECHOUSE_CC1101_SRC_DRV.h> # include <ELECHOUSE_CC1101_SRC_DRV.h>
@@ -41,6 +50,10 @@ ESPiLight rf(RF_EMITTER_GPIO); // use -1 to disable transmitter
bool pilightRawEnabled = 0; bool pilightRawEnabled = 0;
# endif # endif
void disableCurrentReceiver();
void initCC1101();
void enableActiveReceiver();
void pilightCallback(const String& protocol, const String& message, int status, void pilightCallback(const String& protocol, const String& message, int status,
size_t repeats, const String& deviceID) { size_t repeats, const String& deviceID) {
if (status == VALID) { if (status == VALID) {
@@ -297,7 +310,7 @@ extern void enablePilightReceive() {
Log.notice(F("Switching to Pilight Receiver: %F" CR), RFConfig.frequency); Log.notice(F("Switching to Pilight Receiver: %F" CR), RFConfig.frequency);
Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO); Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO);
Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO); Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO);
Log.trace(F("ZgatewayPilight command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoPilight); Log.trace(F("gatewayPilight command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoPilight);
initCC1101(); initCC1101();
@@ -311,6 +324,6 @@ extern void enablePilightReceive() {
pinMode(RF_EMITTER_GPIO, OUTPUT); // Set this here, because if this is the RX pin it was reset to INPUT by Serial.end(); pinMode(RF_EMITTER_GPIO, OUTPUT); // Set this here, because if this is the RX pin it was reset to INPUT by Serial.end();
rf.enableReceiver(); rf.enableReceiver();
loadPilightConfig(); loadPilightConfig();
Log.trace(F("ZgatewayPilight setup done " CR)); Log.trace(F("gatewayPilight setup done " CR));
}; };
#endif #endif
+6 -3
View File
@@ -28,15 +28,18 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZgatewayRF #ifdef ZgatewayRF
# include <ArduinoJson.h> # include "TheengsCommon.h"
# include <ArduinoLog.h> # include "config_RF.h"
# ifdef ZradioCC1101 # ifdef ZradioCC1101
# include <ELECHOUSE_CC1101_SRC_DRV.h> # include <ELECHOUSE_CC1101_SRC_DRV.h>
extern void initCC1101();
# endif # endif
# include <RCSwitch.h> // library for controling Radio frequency switch # include <RCSwitch.h> // library for controling Radio frequency switch
void disableCurrentReceiver();
void enableActiveReceiver();
RCSwitch mySwitch = RCSwitch(); RCSwitch mySwitch = RCSwitch();
/** /**
+13 -2
View File
@@ -36,6 +36,9 @@ sudo mosquitto_pub -t home/commands/MQTTtoRF2/CODE_8233372/UNIT_0/PERIOD_272 -m/
#include "User_config.h" #include "User_config.h"
#ifdef ZgatewayRF2 #ifdef ZgatewayRF2
# include "TheengsCommon.h"
# include "TheengsUtils.h"
# include "config_RF.h"
# ifdef ZradioCC1101 # ifdef ZradioCC1101
# include <ELECHOUSE_CC1101_SRC_DRV.h> # include <ELECHOUSE_CC1101_SRC_DRV.h>
@@ -44,6 +47,9 @@ sudo mosquitto_pub -t home/commands/MQTTtoRF2/CODE_8233372/UNIT_0/PERIOD_272 -m/
# include <NewRemoteReceiver.h> # include <NewRemoteReceiver.h>
# include <NewRemoteTransmitter.h> # include <NewRemoteTransmitter.h>
void disableCurrentReceiver();
void enableActiveReceiver();
struct RF2rxd { struct RF2rxd {
unsigned int period; unsigned int period;
unsigned long address; unsigned long address;
@@ -55,7 +61,12 @@ struct RF2rxd {
RF2rxd rf2rd; RF2rxd rf2rd;
extern void initCC1101();
# ifdef ZmqttDiscovery # ifdef ZmqttDiscovery
# include "config_mqttDiscovery.h"
extern String getUniqueId(String name, String sufix);
//Register for autodiscover in Home Assistant //Register for autodiscover in Home Assistant
void RF2toMQTTdiscovery(JsonObject& data) { void RF2toMQTTdiscovery(JsonObject& data) {
Log.trace(F("switchRF2Discovery" CR)); Log.trace(F("switchRF2Discovery" CR));
@@ -310,10 +321,10 @@ void enableRF2Receive() {
Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO); Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO);
Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO); Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO);
Log.trace(F("ZgatewayRF2 command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoRF2); Log.trace(F("gatewayRF2 command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoRF2);
pinMode(RF_EMITTER_GPIO, OUTPUT); pinMode(RF_EMITTER_GPIO, OUTPUT);
digitalWrite(RF_EMITTER_GPIO, LOW); digitalWrite(RF_EMITTER_GPIO, LOW);
Log.trace(F("ZgatewayRF2 setup done " CR)); Log.trace(F("gatewayRF2 setup done " CR));
} }
#endif #endif
@@ -31,15 +31,21 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZgatewayRFM69 #ifdef ZgatewayRFM69
# include <EEPROM.h> # include <EEPROM.h>
# include <RFM69.h> //https://www.github.com/lowpowerlab/rfm69 # include <RFM69.h> //https://www.github.com/lowpowerlab/rfm69
char RadioConfig[128]; # include "TheengsCommon.h"
# include "config_RFM69.h"
// vvvvvvvvv Global Configuration vvvvvvvvvvv static char RadioConfig[128];
static const char* PROGMEM ENCRYPTKEY = RFM69_ENCRYPTKEY;
static const char* PROGMEM MDNS_NAME = RFM69_MDNS_NAME;
static const char* PROGMEM MQTT_BROKER = RFM69_MQTT_BROKER;
static const char* PROGMEM RFM69AP_NAME = RFM69_RFM69AP_NAME
struct _GLOBAL_CONFIG { // vvvvvvvvv Global Configuration vvvvvvvvvvv
struct _GLOBAL_CONFIG {
uint32_t checksum; uint32_t checksum;
char rfmapname[32]; char rfmapname[32];
char encryptkey[16 + 1]; char encryptkey[16 + 1];
@@ -75,8 +81,8 @@ void eeprom_setup() {
memset(pGC, 0, sizeof(*pGC)); memset(pGC, 0, sizeof(*pGC));
strcpy_P(pGC->encryptkey, ENCRYPTKEY); strcpy_P(pGC->encryptkey, ENCRYPTKEY);
strcpy_P(pGC->rfmapname, RFM69AP_NAME); strcpy_P(pGC->rfmapname, RFM69AP_NAME);
pGC->networkid = NETWORKID; pGC->networkid = RFM69_NETWORKID;
pGC->nodeid = NODEID; pGC->nodeid = RFM69_NODEID;
pGC->powerlevel = ((IS_RFM69HCW) ? 0x80 : 0x00) | POWER_LEVEL; pGC->powerlevel = ((IS_RFM69HCW) ? 0x80 : 0x00) | POWER_LEVEL;
pGC->rfmfrequency = FREQUENCY; pGC->rfmfrequency = FREQUENCY;
pGC->checksum = gc_checksum(); pGC->checksum = gc_checksum();
@@ -97,7 +103,7 @@ void setupRFM69(void) {
// Initialize radio // Initialize radio
if (!radio.initialize(pGC->rfmfrequency, pGC->nodeid, pGC->networkid)) { if (!radio.initialize(pGC->rfmfrequency, pGC->nodeid, pGC->networkid)) {
Log.error(F("ZgatewayRFM69 initialization failed" CR)); Log.error(F("gatewayRFM69 initialization failed" CR));
} }
if (GC_IS_RFM69HCW) { if (GC_IS_RFM69HCW) {
@@ -125,7 +131,7 @@ void setupRFM69(void) {
freq = -1; freq = -1;
break; break;
} }
Log.notice(F("ZgatewayRFM69 Listening and transmitting at: %d" CR), freq); Log.notice(F("gatewayRFM69 Listening and transmitting at: %d" CR), freq);
size_t len = snprintf_P(RadioConfig, sizeof(RadioConfig), JSONtemplate, size_t len = snprintf_P(RadioConfig, sizeof(RadioConfig), JSONtemplate,
freq, GC_IS_RFM69HCW, pGC->networkid, GC_POWER_LEVEL); freq, GC_IS_RFM69HCW, pGC->networkid, GC_POWER_LEVEL);
@@ -26,19 +26,22 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifdef ZgatewayRTL_433
# include <ArduinoJson.h> #include "User_config.h"
# include <config_RF.h>
#ifdef ZgatewayRTL_433
# include <rtl_433_ESP.h> # include <rtl_433_ESP.h>
# include "ArduinoLog.h" # include "TheengsCommon.h"
# include "User_config.h" # include "config_RF.h"
# ifdef ZmqttDiscovery # ifdef ZmqttDiscovery
# include "config_mqttDiscovery.h" # include "config_mqttDiscovery.h"
# endif # endif
char messageBuffer[JSON_MSG_BUFFER]; # include <vector>
static char messageBuffer[JSON_MSG_BUFFER];
rtl_433_ESP rtl_433;
# ifdef ZmqttDiscovery # ifdef ZmqttDiscovery
SemaphoreHandle_t semaphorecreateOrUpdateDeviceRTL_433; SemaphoreHandle_t semaphorecreateOrUpdateDeviceRTL_433;
@@ -314,8 +317,8 @@ void setupRTL_433() {
semaphorecreateOrUpdateDeviceRTL_433 = xSemaphoreCreateBinary(); semaphorecreateOrUpdateDeviceRTL_433 = xSemaphoreCreateBinary();
xSemaphoreGive(semaphorecreateOrUpdateDeviceRTL_433); xSemaphoreGive(semaphorecreateOrUpdateDeviceRTL_433);
# endif # endif
Log.trace(F("ZgatewayRTL_433 command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoRFset); Log.trace(F("gatewayRTL_433 command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoRFset);
Log.notice(F("ZgatewayRTL_433 setup done " CR)); Log.notice(F("gatewayRTL_433 setup done " CR));
} }
void RTL_433Loop() { void RTL_433Loop() {
@@ -28,6 +28,8 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZgatewaySERIAL #ifdef ZgatewaySERIAL
# include "TheengsCommon.h"
# include "config_SERIAL.h"
# ifndef SERIAL_UART // software serial mode # ifndef SERIAL_UART // software serial mode
# include <SoftwareSerial.h> # include <SoftwareSerial.h>
@@ -48,6 +50,8 @@ const TickType_t semaphoreTimeout = pdMS_TO_TICKS(1000); // 1 second timeout
# define SEMAPHORE_SERIAL_GIVE # define SEMAPHORE_SERIAL_GIVE
# endif # endif
extern void receivingDATA(const char* topicOri, const char* datacallback);
// use pointer to stream class for serial communication to make code // use pointer to stream class for serial communication to make code
// compatible with both softwareSerial as hardwareSerial. // compatible with both softwareSerial as hardwareSerial.
Stream* SERIALStream = NULL; Stream* SERIALStream = NULL;
@@ -64,6 +68,10 @@ const unsigned long maxHeartbeatInterval = 60000; // Maximum interval of 1 minut
unsigned long heartbeatInterval = 5000; // 5 seconds unsigned long heartbeatInterval = 5000; // 5 seconds
bool isOverflow = false; bool isOverflow = false;
static void sendHeartbeat();
static void sendHeartbeatAck();
static void handleHeartbeat();
void setupSERIAL() { void setupSERIAL() {
//Initalize serial port //Initalize serial port
# ifdef SERIAL_UART // Hardware serial # ifdef SERIAL_UART // Hardware serial
@@ -130,7 +138,7 @@ void setupSERIAL() {
SERIALStream->read(); SERIALStream->read();
Log.notice(F("SERIALBaud: %d" CR), SERIALBaud); Log.notice(F("SERIALBaud: %d" CR), SERIALBaud);
Log.trace(F("ZgatewaySERIAL setup done" CR)); Log.trace(F("gatewaySERIAL setup done" CR));
} }
# if SERIALtoMQTTmode == 0 // Convert received data to single MQTT topic # if SERIALtoMQTTmode == 0 // Convert received data to single MQTT topic
@@ -31,12 +31,19 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZgatewaySRFB #ifdef ZgatewaySRFB
# include <TheengsUtils.h>
# include "TheengsCommon.h"
# include "config_SRFB.h"
unsigned char _uartbuf[RF_MESSAGE_SIZE + 3] = {0}; unsigned char _uartbuf[RF_MESSAGE_SIZE + 3] = {0};
unsigned char _uartpos = 0; unsigned char _uartpos = 0;
void _rfbDecode();
void _rfbAck();
void setupSRFB() { void setupSRFB() {
Log.trace(F("ZgatewaySRFB setup done " CR)); Log.trace(F("gatewaySRFB setup done " CR));
Log.trace(F("Serial Baud: %l" CR), SERIAL_BAUD); Log.trace(F("Serial Baud: %l" CR), SERIAL_BAUD);
} }
@@ -27,10 +27,14 @@
#ifdef ZgatewayWeatherStation #ifdef ZgatewayWeatherStation
# include <WeatherStationDataRx.h> # include <WeatherStationDataRx.h>
# include "TheengsCommon.h"
# include "config_WeatherStation.h"
WeatherStationDataRx wsdr(RF_WS_RECEIVER_GPIO, true); WeatherStationDataRx wsdr(RF_WS_RECEIVER_GPIO, true);
void PairedDeviceAdded(byte newID) { void PairedDeviceAdded(byte newID) {
Serial.printf("ZgatewayWeatherStation: New device paired %d\r\n", newID); Serial.printf("gatewayWeatherStation: New device paired %d\r\n", newID);
StaticJsonDocument<JSON_MSG_BUFFER> RFdataBuffer; StaticJsonDocument<JSON_MSG_BUFFER> RFdataBuffer;
JsonObject RFdata = RFdataBuffer.to<JsonObject>(); JsonObject RFdata = RFdataBuffer.to<JsonObject>();
RFdata["sensor"] = newID; RFdata["sensor"] = newID;
@@ -44,7 +48,7 @@ void setupWeatherStation() {
Log.notice(F("RF_WS_RECEIVER_GPIO %d" CR), RF_WS_RECEIVER_GPIO); Log.notice(F("RF_WS_RECEIVER_GPIO %d" CR), RF_WS_RECEIVER_GPIO);
wsdr.begin(); wsdr.begin();
wsdr.pair(NULL, PairedDeviceAdded); wsdr.pair(NULL, PairedDeviceAdded);
Log.trace(F("ZgatewayWeatherStation setup done " CR)); Log.trace(F("gatewayWeatherStation setup done " CR));
} }
void sendWindSpeedData(byte id, float wind_speed, byte battery_status) { void sendWindSpeedData(byte id, float wind_speed, byte battery_status) {
+87 -80
View File
@@ -25,22 +25,16 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "User_config.h"
enum GatewayState { #include <PicoMQTT.h>
WAITING_ONBOARDING,
ONBOARDING, #include <memory>
OFFLINE, #include <queue>
NTWK_CONNECTED,
BROKER_CONNECTED, #include "LEDManager.h"
PROCESSING, #include "TheengsCommon.h"
NTWK_DISCONNECTED, #include "TheengsUtils.h"
BROKER_DISCONNECTED,
LOCAL_OTA_IN_PROGRESS,
REMOTE_OTA_IN_PROGRESS,
SLEEPING,
ERROR
};
GatewayState gatewayState = GatewayState::WAITING_ONBOARDING; GatewayState gatewayState = GatewayState::WAITING_ONBOARDING;
// Macros and structure to enable the duplicates removing on the following gateways // Macros and structure to enable the duplicates removing on the following gateways
@@ -56,6 +50,12 @@ ReceivedSignal receivedSignal[] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0
# define struct_size (sizeof(receivedSignal) / sizeof(ReceivedSignal)) # define struct_size (sizeof(receivedSignal) / sizeof(ReceivedSignal))
#endif #endif
int queueLength = -1; // We want to give one cycle of the loop before starting modules that are big msgs producers (example BT), to avoid queue overloading
unsigned long queueLengthSum = 0;
unsigned long blockedMessages = 0;
unsigned long receivedMessages = 0;
int maxQueueLength = 0;
//Time used to wait for an interval before measures //Time used to wait for an interval before measures
unsigned long timer_sys_measures = 0; unsigned long timer_sys_measures = 0;
@@ -65,34 +65,12 @@ unsigned long timer_sys_checks = 0;
// First Start of offline mode modules // First Start of offline mode modules
bool firstStart = true; bool firstStart = true;
#define ARDUINOJSON_USE_LONG_LONG 1
#define ARDUINOJSON_ENABLE_STD_STRING 1
#include <queue>
int queueLength = -1; // We want to give one cycle of the loop before starting modules that are big msgs producers (example BT), to avoid queue overloading
unsigned long queueLengthSum = 0;
unsigned long blockedMessages = 0;
unsigned long receivedMessages = 0;
int maxQueueLength = 0;
#ifndef QueueSize
# define QueueSize 18
#endif
/** /**
* Deep-sleep for the ESP8266 & ESP32 we need some form of indicator that we have posted the measurements and am ready to deep sleep. * Deep-sleep for the ESP8266 & ESP32 we need some form of indicator that we have posted the measurements and am ready to deep sleep.
* Set this to true in the sensor code after publishing the measurement. * Set this to true in the sensor code after publishing the measurement.
*/ */
bool ready_to_sleep = false; bool ready_to_sleep = false;
#include <ArduinoJson.h>
#include <ArduinoLog.h>
#include <PicoMQTT.h>
#include <memory>
#include "LEDManager.h"
#include "TheengsUtils.h"
LEDManager ledManager; LEDManager ledManager;
struct JsonBundle { struct JsonBundle {
@@ -112,12 +90,16 @@ SemaphoreHandle_t xMqttMutex;
StaticJsonDocument<JSON_MSG_BUFFER> modulesBuffer; StaticJsonDocument<JSON_MSG_BUFFER> modulesBuffer;
JsonArray modules = modulesBuffer.to<JsonArray>(); JsonArray modules = modulesBuffer.to<JsonArray>();
bool ethConnected = false; bool ethConnected = false;
char mqtt_topic[parameters_size + 1] = Base_Topic;
char gateway_name[parameters_size + 1] = Gateway_Name;
unsigned long lastDiscovery = 0;
#if !MQTT_BROKER_MODE
ss_cnt_parameters cnt_parameters_array[cnt_parameters_array_size] = CNT_PARAMS_ARR;
#endif
#ifndef ZgatewayGFSunInverter #if defined(ESP32)
// Arduino IDE compiles, it automatically creates all the header declarations for all the functions you have in your *.ino file. # include <Preferences.h>
// Unfortunately it ignores #if directives. Preferences preferences;
// This is a simple workaround for this problem.
struct GfSun2000Data {};
#endif #endif
// Modules config inclusion // Modules config inclusion
@@ -235,9 +217,53 @@ struct GfSun2000Data {};
#if defined(ZgatewaySERIAL) #if defined(ZgatewaySERIAL)
# include "config_SERIAL.h" # include "config_SERIAL.h"
#endif #endif
#if defined(USE_BLUFI) && defined(ESP32)
extern bool isBlufiConnected();
extern bool isStaConnecting();
extern bool startBlufi();
extern bool stopBlufi();
#endif
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
bool pub(JsonObject& data);
bool pubMQTT(const char* topic, const char* payload);
bool pubMQTT(const char* topic, const char* payload, bool retainFlag);
bool pubMQTT(String topic, const char* payload);
bool pubMQTT(const char* topic, unsigned long payload);
bool pubMQTT(const char* topic, unsigned long long payload);
bool pubMQTT(const char* topic, String payload);
bool pubMQTT(String topic, String payload);
bool pubMQTT(String topic, int payload);
bool pubMQTT(String topic, unsigned long long payload);
bool pubMQTT(String topic, float payload);
bool pubMQTT(const char* topic, float payload);
bool pubMQTT(const char* topic, int payload);
bool pubMQTT(const char* topic, unsigned int payload);
bool pubMQTT(const char* topic, long payload);
bool pubMQTT(const char* topic, double payload);
bool pubMQTT(String topic, unsigned long payload);
void checkButton();
void ESPRestart(byte reason);
void eraseConfig();
void readCntParameters(int index);
void saveConfig();
void receivingDATA(const char* topicOri, const char* datacallback);
void updateAndHandleLEDsTask(void* pvParameters);
void updateAndHandleLEDsTask();
bool loadConfigFromFlash();
void setupWiFiManager();
void setOTA();
void setupCommonRF();
void sleep();
bool checkForUpdates();
String stateMeasures();
String stateRFMeasures();
int getMin();
void XtoRFset(const char* topicOri, JsonObject& RFdata);
void MQTTHttpsFWUpdate(const char* topicOri, JsonObject& HttpsFwUpdateData);
void setup_ethernet_esp32();
void setupTLS(int index = CNT_DEFAULT_INDEX); void setupTLS(int index = CNT_DEFAULT_INDEX);
void XtoSYS(const char* topicOri, JsonObject& SYSdata);
char ota_pass[parameters_size] = gw_password; char ota_pass[parameters_size] = gw_password;
#ifdef USE_MAC_AS_GATEWAY_NAME #ifdef USE_MAC_AS_GATEWAY_NAME
@@ -256,7 +282,7 @@ SYSConfig_s SYSConfig;
bool failSafeMode = false; bool failSafeMode = false;
bool ProcessLock = true; // Process lock when we want to use a critical function like OTA for example bool ProcessLock = true; // Process lock when we want to use a critical function like OTA for example
static bool mqttSetupPending = true; bool mqttSetupPending = true;
static int cnt_index = CNT_DEFAULT_INDEX; static int cnt_index = CNT_DEFAULT_INDEX;
#ifdef ESP32 #ifdef ESP32
@@ -367,20 +393,6 @@ std::unique_ptr< ::Client> eClient;
std::unique_ptr<PicoMQTT::Client> mqtt; std::unique_ptr<PicoMQTT::Client> mqtt;
#endif #endif
template <typename T> // Declared here to avoid pre-compilation issue (missing "template" in auto declaration by pio)
void Config_update(JsonObject& data, const char* key, T& var);
template <typename T>
void Config_update(JsonObject& data, const char* key, T& var) {
if (data.containsKey(key)) {
if (var != data[key].as<T>()) {
var = data[key].as<T>();
Log.notice(F("Config %s changed to: %T" CR), key, data[key].as<T>());
} else {
Log.notice(F("Config %s unchanged, currently: %T" CR), key, data[key].as<T>());
}
}
}
/* /*
* Dispatch json messages towards the communication layer * Dispatch json messages towards the communication layer
* *
@@ -419,7 +431,7 @@ bool jsonDispatch(JsonObject& data) {
} }
// Add a document to the queue // Add a document to the queue
boolean enqueueJsonObject(const StaticJsonDocument<JSON_MSG_BUFFER>& jsonDoc, int timeout) { bool enqueueJsonObject(const StaticJsonDocument<JSON_MSG_BUFFER>& jsonDoc, int timeout) {
receivedMessages++; receivedMessages++;
if (jsonDoc.size() == 0) { if (jsonDoc.size() == 0) {
Log.error(F("Empty JSON, skipping" CR)); Log.error(F("Empty JSON, skipping" CR));
@@ -1351,7 +1363,7 @@ void setup() {
Serial.end(); Serial.end();
Serial.begin(SERIAL_BAUD, SERIAL_8N1, SERIAL_TX_ONLY); // enable on ESP8266 to free some pin Serial.begin(SERIAL_BAUD, SERIAL_8N1, SERIAL_TX_ONLY); // enable on ESP8266 to free some pin
# endif # endif
#elif ESP32 #elif defined(ESP32)
xTaskCreate(updateAndHandleLEDsTask, "updateAndHandleLEDsTask", 2500, NULL, 1, NULL); xTaskCreate(updateAndHandleLEDsTask, "updateAndHandleLEDsTask", 2500, NULL, 1, NULL);
xQueueMutex = xSemaphoreCreateMutex(); xQueueMutex = xSemaphoreCreateMutex();
xMqttMutex = xSemaphoreCreateMutex(); xMqttMutex = xSemaphoreCreateMutex();
@@ -1405,8 +1417,10 @@ void setup() {
#endif #endif
#if defined(ESPWifiManualSetup) #if defined(ESPWifiManualSetup)
extern void setupWiFiFromBuild();
setupWiFiFromBuild(); setupWiFiFromBuild();
#else #else
WiFi.mode(WIFI_STA);
if (loadConfigFromFlash()) { // Config present if (loadConfigFromFlash()) { // Config present
Log.notice(F("Config loaded from flash" CR)); Log.notice(F("Config loaded from flash" CR));
# ifdef ESP32_ETHERNET # ifdef ESP32_ETHERNET
@@ -1421,6 +1435,7 @@ void setup() {
# if SELF_TEST # if SELF_TEST
// Check serial input to trigger a Self Test sequence if required // Check serial input to trigger a Self Test sequence if required
extern void checkSerial();
checkSerial(); checkSerial();
# endif # endif
@@ -1503,21 +1518,12 @@ void setup() {
#endif #endif
#ifdef ZgatewayRF #ifdef ZgatewayRF
modules.add(ZgatewayRF); modules.add(ZgatewayRF);
# define ACTIVE_RECEIVER ACTIVE_RF
#endif #endif
#ifdef ZgatewayRF2 #ifdef ZgatewayRF2
modules.add(ZgatewayRF2); modules.add(ZgatewayRF2);
# ifdef ACTIVE_RECEIVER
# undef ACTIVE_RECEIVER
# endif
# define ACTIVE_RECEIVER ACTIVE_RF2
#endif #endif
#ifdef ZgatewayPilight #ifdef ZgatewayPilight
modules.add(ZgatewayPilight); modules.add(ZgatewayPilight);
# ifdef ACTIVE_RECEIVER
# undef ACTIVE_RECEIVER
# endif
# define ACTIVE_RECEIVER ACTIVE_PILIGHT
#endif #endif
#ifdef ZgatewayWeatherStation #ifdef ZgatewayWeatherStation
setupWeatherStation(); setupWeatherStation();
@@ -1568,10 +1574,6 @@ void setup() {
modules.add(ZactuatorPWM); modules.add(ZactuatorPWM);
#endif #endif
#ifdef ZactuatorSomfy #ifdef ZactuatorSomfy
# ifdef ACTIVE_RECEIVER
# undef ACTIVE_RECEIVER
# endif
# define ACTIVE_RECEIVER ACTIVE_NONE
setupSomfy(); setupSomfy();
modules.add(ZactuatorSomfy); modules.add(ZactuatorSomfy);
#endif #endif
@@ -1599,10 +1601,6 @@ void setup() {
setupSHTC3(); setupSHTC3();
#endif #endif
#ifdef ZgatewayRTL_433 #ifdef ZgatewayRTL_433
# ifdef ACTIVE_RECEIVER
# undef ACTIVE_RECEIVER
# endif
# define ACTIVE_RECEIVER ACTIVE_RTL
setupRTL_433(); setupRTL_433();
modules.add(ZgatewayRTL_433); modules.add(ZgatewayRTL_433);
#endif #endif
@@ -1722,6 +1720,7 @@ void setupTLS(int index) {
# if AWS_IOT # if AWS_IOT
if (strcmp(cnt_parameters_array[index].mqtt_port, "443") == 0) { if (strcmp(cnt_parameters_array[index].mqtt_port, "443") == 0) {
Log.notice(F("Using ALPN" CR)); Log.notice(F("Using ALPN" CR));
static const char* alpnProtocols[] = ALPN_PROTOCOLS;
sClient->setAlpnProtocols(alpnProtocols); sClient->setAlpnProtocols(alpnProtocols);
} }
# endif # endif
@@ -1889,6 +1888,7 @@ void blockingWaitForReset() {
Log.notice(F("Button Held" CR)); Log.notice(F("Button Held" CR));
// Switching off the relay during reset or failsafe operations // Switching off the relay during reset or failsafe operations
# ifdef ZactuatorONOFF # ifdef ZactuatorONOFF
extern void ActuatorTrigger();
uint8_t level = digitalRead(ACTUATOR_ONOFF_GPIO); uint8_t level = digitalRead(ACTUATOR_ONOFF_GPIO);
if (level == ACTUATOR_ON) { if (level == ACTUATOR_ON) {
ActuatorTrigger(); ActuatorTrigger();
@@ -2192,7 +2192,6 @@ bool loadConfigFromFlash() {
void setupWiFiManager() { void setupWiFiManager() {
delay(10); delay(10);
WiFi.mode(WIFI_STA);
# ifdef USE_MAC_AS_GATEWAY_NAME # ifdef USE_MAC_AS_GATEWAY_NAME
String s = WiFi.macAddress(); String s = WiFi.macAddress();
@@ -2497,6 +2496,7 @@ void loop() {
} }
if (firstStart) { if (firstStart) {
#ifdef ZgatewaySERIAL #ifdef ZgatewaySERIAL
extern bool isSerialReady();
if (SYSConfig.serial && isSerialReady()) { if (SYSConfig.serial && isSerialReady()) {
# ifdef ZgatewayBT # ifdef ZgatewayBT
BTProcessLock = !BTConfig.enabled; BTProcessLock = !BTConfig.enabled;
@@ -2569,6 +2569,7 @@ void loop() {
stateSSD1306Display(); stateSSD1306Display();
#endif #endif
#ifdef ZgatewayLORA #ifdef ZgatewayLORA
extern String stateLORAMeasures();
stateLORAMeasures(); stateLORAMeasures();
#endif #endif
#if defined(ZgatewayRTL_433) || defined(ZgatewayPilight) || defined(ZgatewayRF) || defined(ZgatewayRF2) || defined(ZactuatorSomfy) #if defined(ZgatewayRTL_433) || defined(ZgatewayPilight) || defined(ZgatewayRF) || defined(ZgatewayRF2) || defined(ZactuatorSomfy)
@@ -2604,6 +2605,7 @@ void loop() {
MeasureLightIntensity(); //Addon to measure Light Intensity with a BH1750 MeasureLightIntensity(); //Addon to measure Light Intensity with a BH1750
#endif #endif
#ifdef ZsensorMQ2 #ifdef ZsensorMQ2
extern void MeasureGasMQ2();
MeasureGasMQ2(); MeasureGasMQ2();
#endif #endif
#ifdef ZsensorTEMT6000 #ifdef ZsensorTEMT6000
@@ -2704,6 +2706,7 @@ void loop() {
if (ready_to_sleep) { if (ready_to_sleep) {
sleep(); sleep();
} }
delay(1);
} }
/** /**
@@ -2979,6 +2982,7 @@ void receivingDATA(const char* topicOri, const char* datacallback) {
//Log.notice(F("[ MQTT->OMG ]: %s" CR), buffer.c_str()); //Log.notice(F("[ MQTT->OMG ]: %s" CR), buffer.c_str());
#ifdef ZgatewayPilight // ZgatewayPilight is only defined with json publishing due to its numerous parameters #ifdef ZgatewayPilight // ZgatewayPilight is only defined with json publishing due to its numerous parameters
extern void XtoPilight(const char* topicOri, JsonObject& RFdata);
XtoPilight(strTopicOri.c_str(), jsondata); XtoPilight(strTopicOri.c_str(), jsondata);
#endif #endif
#if defined(ZgatewayRTL_433) || defined(ZgatewayPilight) || defined(ZgatewayRF) || defined(ZgatewayRF2) || defined(ZactuatorSomfy) #if defined(ZgatewayRTL_433) || defined(ZgatewayPilight) || defined(ZgatewayRF) || defined(ZgatewayRF2) || defined(ZactuatorSomfy)
@@ -3016,6 +3020,7 @@ void receivingDATA(const char* topicOri, const char* datacallback) {
XtoPWM(strTopicOri.c_str(), jsondata); XtoPWM(strTopicOri.c_str(), jsondata);
# endif # endif
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK) || defined(ZboardM5TOUGH) # if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK) || defined(ZboardM5TOUGH)
void XtoM5(const char* topicOri, JsonObject& M5data);
XtoM5(strTopicOri.c_str(), jsondata); XtoM5(strTopicOri.c_str(), jsondata);
# endif # endif
# if defined(ZdisplaySSD1306) # if defined(ZdisplaySSD1306)
@@ -3076,8 +3081,7 @@ void receivingDATA(const char* topicOri, const char* datacallback) {
String latestVersion; String latestVersion;
# ifdef ESP32 # ifdef ESP32
# include <HTTPClient.h> # include <HTTPClient.h>
# include <HTTPUpdate.h>
# include "zzHTTPUpdate.h"
# if CHECK_OTA_UPDATE # if CHECK_OTA_UPDATE
/** /**
@@ -3358,6 +3362,7 @@ void XtoSYS(const char* topicOri, JsonObject& SYSdata) { // json object decoding
SYSConfig.rgbbrightness = TheengsUtils::round2(SYSdata["rgbb"]); SYSConfig.rgbbrightness = TheengsUtils::round2(SYSdata["rgbb"]);
ledManager.setBrightness(SYSConfig.rgbbrightness); ledManager.setBrightness(SYSConfig.rgbbrightness);
# ifdef ZactuatorONOFF # ifdef ZactuatorONOFF
extern void updatePowerIndicator();
updatePowerIndicator(); updatePowerIndicator();
# endif # endif
Log.notice(F("RGB brightness: %d" CR), SYSConfig.rgbbrightness); Log.notice(F("RGB brightness: %d" CR), SYSConfig.rgbbrightness);
@@ -3577,8 +3582,10 @@ void XtoSYS(const char* topicOri, JsonObject& SYSdata) { // json object decoding
lastDiscovery = millis(); lastDiscovery = millis();
SYSConfig.discovery = SYSdata["disc"]; SYSConfig.discovery = SYSdata["disc"];
publishState = true; publishState = true;
if (SYSConfig.discovery) if (SYSConfig.discovery) {
extern void pubMqttDiscovery();
pubMqttDiscovery(); pubMqttDiscovery();
}
} else { } else {
Log.warning(F("Discovery command not a boolean" CR)); Log.warning(F("Discovery command not a boolean" CR));
} }
@@ -24,14 +24,107 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <ArduinoJson.h>
#include <ArduinoLog.h>
#include "User_config.h" #include "User_config.h"
#ifdef ZmqttDiscovery #ifdef ZmqttDiscovery
# include "TheengsCommon.h"
# ifdef ESP8266
# include <ESP8266WiFi.h>
# elif defined(ESP32)
# include <WiFi.h>
# include "esp_mac.h"
# endif
# ifdef ESP32_ETHERNET
# include <ETH.h>
# endif
# include "config_mqttDiscovery.h" # include "config_mqttDiscovery.h"
extern bool ethConnected;
extern JsonArray modules;
char discovery_prefix[parameters_size + 1] = discovery_Prefix;
// From https://github.com/home-assistant/core/blob/d7ac4bd65379e11461c7ce0893d3533d8d8b8cbf/homeassistant/const.py#L225
// List of classes available in Home Assistant
const char* availableHASSClasses[] = {"battery_charging",
"battery",
"carbon_dioxide",
"carbon_monoxide",
"current",
"data_size",
"distance",
"door",
"duration",
"energy",
"enum",
"gas",
"humidity",
"illuminance",
"irradiance",
"lock",
"motion",
"moving",
"pm1",
"pm10",
"pm25",
"power_factor",
"power",
"precipitation_intensity",
"precipitation",
"pressure",
"problem",
"restart",
"signal_strength",
"sound_pressure",
"temperature",
"timestamp",
"voltage",
"water",
"weight",
"wind_speed",
"window"};
// From https://github.com/home-assistant/core/blob/d7ac4bd65379e11461c7ce0893d3533d8d8b8cbf/homeassistant/const.py#L379
// List of units available in Home Assistant
const char* availableHASSUnits[] = {"W",
"kW",
"V",
"kWh",
"A",
"W",
"°C",
"°F",
"ms",
"s",
"min",
"hPa",
"L",
"kg",
"lb",
"µS/cm",
"ppm",
"μg/m³",
"m³",
"mg/m³",
"m/s²",
"mV",
"lx",
"Ω",
"%",
"bar",
"bpm",
"dB",
"dBm",
"B",
"UV index",
"m/s",
"km/h",
"°",
"mm",
"mm/h",
"cm"};
String getMacAddress() { String getMacAddress() {
uint8_t baseMac[6]; uint8_t baseMac[6];
char baseMacChr[13] = {0}; char baseMacChr[13] = {0};
@@ -53,6 +146,7 @@ String getUniqueId(String name, String sufix) {
} }
# if defined(ZgatewayBT) || defined(SecondaryModule) # if defined(ZgatewayBT) || defined(SecondaryModule)
# include "config_BT.h"
/** /**
* Create a discover messages form a list of attribute * Create a discover messages form a list of attribute
* *
@@ -644,6 +738,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZdisplaySSD1306 # ifdef ZdisplaySSD1306
# include "config_SSD1306.h"
createDiscovery("switch", //set Type createDiscovery("switch", //set Type
subjectSSD1306toMQTT, "SSD1306: Control", (char*)getUniqueId("onstate", "").c_str(), //set state_topic,name,uniqueId subjectSSD1306toMQTT, "SSD1306: Control", (char*)getUniqueId("onstate", "").c_str(), //set state_topic,name,uniqueId
will_Topic, "", "{{ value_json.onstate }}", //set availability_topic,device_class,value_template, will_Topic, "", "{{ value_json.onstate }}", //set availability_topic,device_class,value_template,
@@ -795,6 +890,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorBME280 # ifdef ZsensorBME280
# include "config_BME280.h"
# define BMEparametersCount 5 # define BMEparametersCount 5
Log.trace(F("bme280Discovery" CR)); Log.trace(F("bme280Discovery" CR));
char* BMEsensor[BMEparametersCount][8] = { char* BMEsensor[BMEparametersCount][8] = {
@@ -819,6 +915,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorHTU21 # ifdef ZsensorHTU21
# include "config_HTU21.h"
# define HTUparametersCount 2 # define HTUparametersCount 2
Log.trace(F("htu21Discovery" CR)); Log.trace(F("htu21Discovery" CR));
char* HTUsensor[HTUparametersCount][8] = { char* HTUsensor[HTUparametersCount][8] = {
@@ -856,6 +953,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorAHTx0 # ifdef ZsensorAHTx0
# include "config_AHTx0.h"
# define AHTparametersCount 2 # define AHTparametersCount 2
Log.trace(F("AHTx0Discovery" CR)); Log.trace(F("AHTx0Discovery" CR));
char* AHTsensor[AHTparametersCount][8] = { char* AHTsensor[AHTparametersCount][8] = {
@@ -877,6 +975,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorDHT # ifdef ZsensorDHT
# include "config_DHT.h"
# define DHTparametersCount 2 # define DHTparametersCount 2
Log.trace(F("DHTDiscovery" CR)); Log.trace(F("DHTDiscovery" CR));
char* DHTsensor[DHTparametersCount][8] = { char* DHTsensor[DHTparametersCount][8] = {
@@ -899,6 +998,8 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorADC # ifdef ZsensorADC
# include "config_ADC.h"
Log.trace(F("ADCDiscovery" CR)); Log.trace(F("ADCDiscovery" CR));
char* ADCsensor[8] = {"sensor", "adc", "", "", jsonAdc, "", "", ""}; char* ADCsensor[8] = {"sensor", "adc", "", "", jsonAdc, "", "", ""};
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement //component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
@@ -915,6 +1016,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorBH1750 # ifdef ZsensorBH1750
# include "config_BH1750.h"
# define BH1750parametersCount 3 # define BH1750parametersCount 3
Log.trace(F("BH1750Discovery" CR)); Log.trace(F("BH1750Discovery" CR));
char* BH1750sensor[BH1750parametersCount][8] = { char* BH1750sensor[BH1750parametersCount][8] = {
@@ -938,6 +1040,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorMQ2 # ifdef ZsensorMQ2
# include "config_MQ2.h"
# define MQ2parametersCount 2 # define MQ2parametersCount 2
Log.trace(F("MQ2Discovery" CR)); Log.trace(F("MQ2Discovery" CR));
char* MQ2sensor[MQ2parametersCount][8] = { char* MQ2sensor[MQ2parametersCount][8] = {
@@ -959,6 +1062,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorTEMT6000 # ifdef ZsensorTEMT6000
# include "config_TEMT6000.h"
# define TEMT6000parametersCount 3 # define TEMT6000parametersCount 3
Log.trace(F("TEMT6000Discovery" CR)); Log.trace(F("TEMT6000Discovery" CR));
char* TEMT6000sensor[TEMT6000parametersCount][8] = { char* TEMT6000sensor[TEMT6000parametersCount][8] = {
@@ -982,6 +1086,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorTSL2561 # ifdef ZsensorTSL2561
# include "config_TSL2561.h"
# define TSL2561parametersCount 3 # define TSL2561parametersCount 3
Log.trace(F("TSL2561Discovery" CR)); Log.trace(F("TSL2561Discovery" CR));
char* TSL2561sensor[TSL2561parametersCount][8] = { char* TSL2561sensor[TSL2561parametersCount][8] = {
@@ -1005,6 +1110,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorHCSR501 # ifdef ZsensorHCSR501
# include "config_HCSR501.h"
Log.trace(F("HCSR501Discovery" CR)); Log.trace(F("HCSR501Discovery" CR));
char* HCSR501sensor[8] = {"binary_sensor", "hcsr501", "", "motion", jsonPresence, "true", "false", ""}; char* HCSR501sensor[8] = {"binary_sensor", "hcsr501", "", "motion", jsonPresence, "true", "false", ""};
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement //component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
@@ -1021,6 +1127,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorGPIOInput # ifdef ZsensorGPIOInput
# include "config_GPIOInput.h"
Log.trace(F("GPIOInputDiscovery" CR)); Log.trace(F("GPIOInputDiscovery" CR));
char* GPIOInputsensor[8] = {"binary_sensor", "GPIOInput", "", "", jsonGpio, INPUT_GPIO_ON_VALUE, INPUT_GPIO_OFF_VALUE, ""}; char* GPIOInputsensor[8] = {"binary_sensor", "GPIOInput", "", "", jsonGpio, INPUT_GPIO_ON_VALUE, INPUT_GPIO_OFF_VALUE, ""};
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement //component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
@@ -1037,6 +1144,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorINA226 # ifdef ZsensorINA226
# include "config_INA226.h"
# define INA226parametersCount 3 # define INA226parametersCount 3
Log.trace(F("INA226Discovery" CR)); Log.trace(F("INA226Discovery" CR));
char* INA226sensor[INA226parametersCount][8] = { char* INA226sensor[INA226parametersCount][8] = {
@@ -1060,11 +1168,13 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorDS1820 # ifdef ZsensorDS1820
extern void pubOneWire_HADiscovery();
// Publish any DS1820 sensors found on the OneWire bus // Publish any DS1820 sensors found on the OneWire bus
pubOneWire_HADiscovery(); pubOneWire_HADiscovery();
# endif # endif
# ifdef ZactuatorONOFF # ifdef ZactuatorONOFF
# include "config_ONOFF.h"
Log.trace(F("actuatorONOFFDiscovery" CR)); Log.trace(F("actuatorONOFFDiscovery" CR));
char* actuatorONOFF[8] = {"switch", "actuatorONOFF", "", "", "{{ value_json.cmd }}", "{\"cmd\":1}", "{\"cmd\":0}", ""}; char* actuatorONOFF[8] = {"switch", "actuatorONOFF", "", "", "{{ value_json.cmd }}", "{\"cmd\":1}", "{\"cmd\":0}", ""};
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement //component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
@@ -1082,6 +1192,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZsensorRN8209 # ifdef ZsensorRN8209
# include "config_RN8209.h"
# define RN8209parametersCount 4 # define RN8209parametersCount 4
Log.trace(F("RN8209Discovery" CR)); Log.trace(F("RN8209Discovery" CR));
char* RN8209sensor[RN8209parametersCount][8] = { char* RN8209sensor[RN8209parametersCount][8] = {
@@ -1130,6 +1241,8 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZgatewayRF2 # ifdef ZgatewayRF2
# include "config_RF.h"
// Sensor to display RF received value // Sensor to display RF received value
Log.trace(F("gatewayRF2Discovery" CR)); Log.trace(F("gatewayRF2Discovery" CR));
char* gatewayRF2[8] = {"sensor", "gatewayRF2", "", "", jsonAddress, "", "", ""}; char* gatewayRF2[8] = {"sensor", "gatewayRF2", "", "", jsonAddress, "", "", ""};
@@ -1152,6 +1265,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZgatewayRFM69 # ifdef ZgatewayRFM69
# include "config_RFM69.h"
// Sensor to display RF received value // Sensor to display RF received value
Log.trace(F("gatewayRFM69Discovery" CR)); Log.trace(F("gatewayRFM69Discovery" CR));
char* gatewayRFM69[8] = {"sensor", "gatewayRFM69", "", "", jsonVal, "", "", ""}; char* gatewayRFM69[8] = {"sensor", "gatewayRFM69", "", "", jsonVal, "", "", ""};
@@ -1169,6 +1283,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZgatewayLORA # ifdef ZgatewayLORA
# include "config_LORA.h"
// Sensor to display RF received value // Sensor to display RF received value
Log.trace(F("gatewayLORADiscovery" CR)); Log.trace(F("gatewayLORADiscovery" CR));
char* gatewayLORA[8] = {"sensor", "gatewayLORA", "", "", jsonMsg, "", "", ""}; char* gatewayLORA[8] = {"sensor", "gatewayLORA", "", "", jsonMsg, "", "", ""};
@@ -1219,6 +1334,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZgatewaySRFB # ifdef ZgatewaySRFB
# include "config_SRFB.h"
// Sensor to display RF received value // Sensor to display RF received value
Log.trace(F("gatewaySRFBDiscovery" CR)); Log.trace(F("gatewaySRFBDiscovery" CR));
char* gatewaySRFB[8] = {"sensor", "gatewaySRFB", "", "", jsonVal, "", "", ""}; char* gatewaySRFB[8] = {"sensor", "gatewaySRFB", "", "", jsonVal, "", "", ""};
@@ -1236,6 +1352,8 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZgatewayPilight # ifdef ZgatewayPilight
# include "config_RF.h"
// Sensor to display RF received value // Sensor to display RF received value
Log.trace(F("gatewayPilightDiscovery" CR)); Log.trace(F("gatewayPilightDiscovery" CR));
char* gatewayPilight[8] = {"sensor", "gatewayPilight", "", "", jsonMsg, "", "", ""}; char* gatewayPilight[8] = {"sensor", "gatewayPilight", "", "", jsonMsg, "", "", ""};
@@ -1258,6 +1376,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef ZgatewayIR # ifdef ZgatewayIR
# include "config_IR.h"
// Sensor to display IR received value // Sensor to display IR received value
Log.trace(F("gatewayIRDiscovery" CR)); Log.trace(F("gatewayIRDiscovery" CR));
char* gatewayIR[8] = {"sensor", "gatewayIR", "", "", jsonVal, "", "", ""}; char* gatewayIR[8] = {"sensor", "gatewayIR", "", "", jsonVal, "", "", ""};
@@ -1275,6 +1394,7 @@ void pubMqttDiscovery() {
# endif # endif
# ifdef Zgateway2G # ifdef Zgateway2G
# include "config_2G.h"
// Sensor to display 2G received value // Sensor to display 2G received value
Log.trace(F("gateway2GDiscovery" CR)); Log.trace(F("gateway2GDiscovery" CR));
char* gateway2G[8] = {"sensor", "gateway2G", "", "", jsonMsg, "", "", ""}; char* gateway2G[8] = {"sensor", "gateway2G", "", "", jsonMsg, "", "", ""};
@@ -29,6 +29,8 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZsensorADC #ifdef ZsensorADC
# include "TheengsCommon.h"
# include "config_ADC.h"
# if defined(ESP8266) # if defined(ESP8266)
ADC_MODE(ADC_TOUT); ADC_MODE(ADC_TOUT);
@@ -41,6 +41,7 @@
# include <stdint.h> # include <stdint.h>
# include "Adafruit_AHTX0.h" # include "Adafruit_AHTX0.h"
# include "TheengsCommon.h"
# include "Wire.h" // Library for communication with I2C / TWI devices # include "Wire.h" // Library for communication with I2C / TWI devices
# include "config_AHTx0.h" # include "config_AHTx0.h"
@@ -39,9 +39,15 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZsensorBH1750 #ifdef ZsensorBH1750
# include "TheengsCommon.h"
# include "Wire.h" // Library for communication with I2C / TWI devices # include "Wire.h" // Library for communication with I2C / TWI devices
# include "config_BH1750.h"
# include "math.h" // Library for trig and exponential functions # include "math.h" // Library for trig and exponential functions
//Time used to wait for an interval before resending measured values
static unsigned long timebh1750 = 0;
static int BH1750_i2c_addr = BH1750_I2C_ADDR;
void setupZsensorBH1750() { void setupZsensorBH1750() {
Log.notice(F("Setup BH1750 on adress: %H" CR), BH1750_i2c_addr); Log.notice(F("Setup BH1750 on adress: %H" CR), BH1750_i2c_addr);
Wire.begin(); Wire.begin();
@@ -43,10 +43,14 @@
# include <stdint.h> # include <stdint.h>
# include "SparkFunBME280.h" # include "SparkFunBME280.h"
# include "TheengsCommon.h"
# include "Wire.h" // Library for communication with I2C / TWI devices # include "Wire.h" // Library for communication with I2C / TWI devices
# include "config_BME280.h"
//Global sensor object //Time used to wait for an interval before resending measured values
BME280 mySensor; static unsigned long timebme280 = 0;
static int BME280_i2c_addr = BME280_I2C_ADDR; // Default I2C address for BME280 is 0x76, for BMP280 is 0x77
static BME280 mySensor;
void setupZsensorBME280() { void setupZsensorBME280() {
// Allow custom pins on ESP Platforms // Allow custom pins on ESP Platforms
@@ -24,6 +24,8 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZsensorC37_YL83_HMRD #ifdef ZsensorC37_YL83_HMRD
# include "TheengsCommon.h"
# include "config_C37_YL83_HMRD.h"
//Time used to wait for an interval before resending temp and hum //Time used to wait for an interval before resending temp and hum
unsigned long timeC37YL83HMRD = 0; unsigned long timeC37YL83HMRD = 0;
@@ -33,6 +33,9 @@
# include <DHT.h> # include <DHT.h>
# include <DHT_U.h> # include <DHT_U.h>
# include "TheengsCommon.h"
# include "config_DHT.h"
DHT dht(DHT_RECEIVER_GPIO, DHT_SENSOR_TYPE); DHT dht(DHT_RECEIVER_GPIO, DHT_SENSOR_TYPE);
//Time used to wait for an interval before resending temp and hum //Time used to wait for an interval before resending temp and hum
@@ -29,6 +29,9 @@
# include <DallasTemperature.h> # include <DallasTemperature.h>
# include <OneWire.h> # include <OneWire.h>
# include "TheengsCommon.h"
# include "config_DS1820.h"
OneWire owbus(DS1820_OWBUS_GPIO); OneWire owbus(DS1820_OWBUS_GPIO);
DallasTemperature ds1820(&owbus); DallasTemperature ds1820(&owbus);
DeviceAddress ds1820_address, ds1820_devices[OW_MAX_SENSORS]; DeviceAddress ds1820_address, ds1820_devices[OW_MAX_SENSORS];
@@ -38,6 +41,15 @@ static uint8_t ds1820_resolution[OW_MAX_SENSORS];
static String ds1820_type[OW_MAX_SENSORS]; static String ds1820_type[OW_MAX_SENSORS];
static String ds1820_addr[OW_MAX_SENSORS]; static String ds1820_addr[OW_MAX_SENSORS];
extern void createDiscovery(const char* sensor_type,
const char* st_topic, const char* s_name, const char* unique_id,
const char* availability_topic, const char* device_class, const char* value_template,
const char* payload_on, const char* payload_off, const char* unit_of_meas,
int off_delay,
const char* payload_available, const char* payload_not_available, bool gateway_entity, const char* cmd_topic,
const char* device_name, const char* device_manufacturer, const char* device_model, const char* device_id, bool retainCmd,
const char* state_class, const char* state_off, const char* state_on, const char* enum_options, const char* command_template);
void setupZsensorDS1820() { void setupZsensorDS1820() {
Log.trace(F("DS1820: configured pin: %d for 1-wire bus" CR), DS1820_OWBUS_GPIO); Log.trace(F("DS1820: configured pin: %d for 1-wire bus" CR), DS1820_OWBUS_GPIO);
ds1820.begin(); ds1820.begin();
@@ -100,6 +112,8 @@ void setupZsensorDS1820() {
void pubOneWire_HADiscovery() { void pubOneWire_HADiscovery() {
// If zmqttDiscovery is enabled, create a sensor topic for each DS18b20 sensor found on the bus, using addr as uniqueID // If zmqttDiscovery is enabled, create a sensor topic for each DS18b20 sensor found on the bus, using addr as uniqueID
# ifdef ZmqttDiscovery # ifdef ZmqttDiscovery
# include "config_mqttDiscovery.h"
// If zmqtt discovery is enabled, create a sensor topic for each DS18b20 sensor found on the bus, using addr as uniqueID // If zmqtt discovery is enabled, create a sensor topic for each DS18b20 sensor found on the bus, using addr as uniqueID
if (SYSConfig.discovery) { if (SYSConfig.discovery) {
for (int index = 0; index < ds1820_count; index++) { for (int index = 0; index < ds1820_count; index++) {
@@ -29,6 +29,12 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZsensorGPIOInput #ifdef ZsensorGPIOInput
# include "TheengsCommon.h"
# include "config_GPIOInput.h"
extern void ActuatorTrigger();
extern void eraseConfig();
# if defined(TRIGGER_GPIO) && INPUT_GPIO == TRIGGER_GPIO # if defined(TRIGGER_GPIO) && INPUT_GPIO == TRIGGER_GPIO
unsigned long resetTime = 0; unsigned long resetTime = 0;
# endif # endif
@@ -26,6 +26,8 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZsensorGPIOKeyCode #ifdef ZsensorGPIOKeyCode
# include "TheengsCommon.h"
# include "config_GPIOKeyCode.h"
int InputStateGPIOKeyCode = 0x0f; // Set to 3 so that it reads on startup int InputStateGPIOKeyCode = 0x0f; // Set to 3 so that it reads on startup
int lastInputStateGPIOKeyCode = 0x0f; int lastInputStateGPIOKeyCode = 0x0f;
@@ -30,6 +30,8 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZsensorHCSR04 #ifdef ZsensorHCSR04
# include "TheengsCommon.h"
# include "config_HCSR04.h"
unsigned long timeHCSR04 = 0; unsigned long timeHCSR04 = 0;
@@ -29,6 +29,8 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZsensorHCSR501 #ifdef ZsensorHCSR501
# include "TheengsCommon.h"
# include "config_HCSR501.h"
void setupHCSR501() { void setupHCSR501() {
Log.notice(F("HCSR501 pin: %d" CR), HCSR501_GPIO); Log.notice(F("HCSR501 pin: %d" CR), HCSR501_GPIO);
@@ -41,6 +41,7 @@
# include <stdint.h> # include <stdint.h>
# include "SparkFunHTU21D.h" # include "SparkFunHTU21D.h"
# include "TheengsCommon.h"
# include "Wire.h" // Library for communication with I2C / TWI devices # include "Wire.h" // Library for communication with I2C / TWI devices
# include "config_HTU21.h" # include "config_HTU21.h"
@@ -37,6 +37,12 @@
#ifdef ZsensorINA226 #ifdef ZsensorINA226
# include <Wire.h> # include <Wire.h>
# include "TheengsCommon.h"
# include "config_INA226.h"
static void writeRegister(byte reg, word value);
static word readRegister(byte reg);
float rShunt = 0.1; // Shunt Widerstand festlegen, hier 0.1 Ohm float rShunt = 0.1; // Shunt Widerstand festlegen, hier 0.1 Ohm
const int INA226_ADDR = 0x40; // A0 und A1 auf GND > Adresse 40 Hex auf Seite 18 im Datenblatt const int INA226_ADDR = 0x40; // A0 und A1 auf GND > Adresse 40 Hex auf Seite 18 im Datenblatt
@@ -77,7 +83,7 @@ void MeasureINA226() {
} }
} }
static void writeRegister(byte reg, word value) { void writeRegister(byte reg, word value) {
Wire.beginTransmission(INA226_ADDR); Wire.beginTransmission(INA226_ADDR);
Wire.write(reg); Wire.write(reg);
Wire.write((value >> 8) & 0xFF); Wire.write((value >> 8) & 0xFF);
@@ -85,7 +91,7 @@ static void writeRegister(byte reg, word value) {
Wire.endTransmission(); Wire.endTransmission();
} }
static word readRegister(byte reg) { word readRegister(byte reg) {
word res = 0x0000; word res = 0x0000;
Wire.beginTransmission(INA226_ADDR); Wire.beginTransmission(INA226_ADDR);
Wire.write(reg); Wire.write(reg);
@@ -41,6 +41,7 @@
# include <stdint.h> # include <stdint.h>
# include "Temperature_LM75_Derived.h" # include "Temperature_LM75_Derived.h"
# include "TheengsCommon.h"
# include "Wire.h" // Library for communication with I2C / TWI devices # include "Wire.h" // Library for communication with I2C / TWI devices
# include "config_LM75.h" # include "config_LM75.h"
+5 -1
View File
@@ -36,10 +36,14 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZsensorMQ2 #ifdef ZsensorMQ2
# include "TheengsCommon.h"
# include "Wire.h" # include "Wire.h"
# include "config_MQ2.h"
# include "math.h" # include "math.h"
//Time used to wait for an interval before resending measured values
unsigned long timemq2 = 0;
void setupZsensorMQ2() { void setupZsensorMQ2() {
Log.notice(F("Setup MQ2 detection on pin: %d" CR), MQ2SENSORDETECTPIN); Log.notice(F("Setup MQ2 detection on pin: %d" CR), MQ2SENSORDETECTPIN);
pinMode(MQ2SENSORDETECTPIN, INPUT); // declare GPIOInput pin as input_pullup to prevent floating. Pin will be high when not connected to ground pinMode(MQ2SENSORDETECTPIN, INPUT); // declare GPIOInput pin as input_pullup to prevent floating. Pin will be high when not connected to ground
@@ -24,14 +24,21 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifdef ZsensorRN8209 #include "User_config.h"
# include "ArduinoJson.h" #ifdef ZsensorRN8209
# include "driver/uart.h" # include <TheengsUtils.h>
# include "rn8209_flash.h" # include <driver/uart.h>
# include "rn8209c_user.h" # include <rn8209_flash.h>
# include <rn8209c_user.h>
# include "TheengsCommon.h"
# include "config_RN8209.h"
extern "C" bool init_8209c_interface(); extern "C" bool init_8209c_interface();
extern void overLimitCurrent(float RN8209current);
extern bool ProcessLock;
float voltage = 0; float voltage = 0;
float current = 0; float current = 0;
@@ -112,7 +119,7 @@ void setupRN8209() {
init_8209c_interface(); init_8209c_interface();
xTaskCreate(rn8209_loop, "rn8209_loop", RN8209_TASK_STACK_SIZE_OVERRIDE, NULL, 10, &rn8209TaskHandle); xTaskCreate(rn8209_loop, "rn8209_loop", RN8209_TASK_STACK_SIZE_OVERRIDE, NULL, 10, &rn8209TaskHandle);
//esp_task_wdt_add(rn8209TaskHandle); //esp_task_wdt_add(rn8209TaskHandle);
Log.trace(F("ZsensorRN8209 setup done " CR)); Log.trace(F("sensorRN8209 setup done " CR));
} }
#endif // ZsensorRN8209 #endif // ZsensorRN8209
@@ -3,6 +3,8 @@
#ifdef ZsensorSHTC3 #ifdef ZsensorSHTC3
# include <SparkFun_SHTC3.h> # include <SparkFun_SHTC3.h>
# include "TheengsCommon.h"
SHTC3 mySHTC3; SHTC3 mySHTC3;
//Time used to wait for an interval before resending temp and hum //Time used to wait for an interval before resending temp and hum
@@ -38,10 +38,14 @@
#include "User_config.h" #include "User_config.h"
#ifdef ZsensorTEMT6000 #ifdef ZsensorTEMT6000
# include "TheengsCommon.h"
# include "Wire.h" # include "Wire.h"
# include "config_TEMT6000.h"
# include "math.h" # include "math.h"
//Time used to wait for an interval before resending measured values
static unsigned long timetemt6000 = 0;
void setupZsensorTEMT6000() { void setupZsensorTEMT6000() {
Log.notice(F("Setup TEMT6000 on pin: %i" CR), TEMT6000LIGHTSENSORPIN); Log.notice(F("Setup TEMT6000 on pin: %i" CR), TEMT6000LIGHTSENSORPIN);
pinMode(TEMT6000LIGHTSENSORPIN, INPUT); pinMode(TEMT6000LIGHTSENSORPIN, INPUT);
@@ -43,9 +43,15 @@
# include <Adafruit_Sensor.h> # include <Adafruit_Sensor.h>
# include <Adafruit_TSL2561_U.h> # include <Adafruit_TSL2561_U.h>
# include "TheengsCommon.h"
# include "Wire.h" # include "Wire.h"
# include "config_TSL2561.h"
# include "math.h" # include "math.h"
//Time used to wait for an interval before resending measured values
static unsigned long timetsl2561 = 0;
//int TSL2561_i2c_addr = 0x37; // Light Sensor I2C Address (Set in Adafruit library)
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345); Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);
void displaySensorDetails(void) { void displaySensorDetails(void) {
@@ -23,14 +23,12 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <HardwareSerial.h>
#include "ArduinoJson.h"
#include "User_config.h" #include "User_config.h"
#include "config_Touch.h"
#ifdef ZsensorTouch #ifdef ZsensorTouch
# include "TheengsCommon.h"
# include "config_Touch.h"
# ifndef ESP32 # ifndef ESP32
# error Only supported on esp32 # error Only supported on esp32
# endif # endif
+65 -28
View File
@@ -23,11 +23,10 @@
*/ */
#include "User_config.h" #include "User_config.h"
#if defined(ZwebUI) && defined(ESP32) #if defined(ZwebUI) && defined(ESP32)
# include <ArduinoJson.h>
# include <SPIFFS.h> # include <SPIFFS.h>
# include <WebServer.h> // Docs for this are here - https://github.com/espressif/arduino-esp32/tree/master/libraries/WebServer # include <WebServer.h> // Docs for this are here - https://github.com/espressif/arduino-esp32/tree/master/libraries/WebServer
# include <WiFi.h>
# include "ArduinoLog.h"
# include "config_WebContent.h" # include "config_WebContent.h"
# include "config_WebUI.h" # include "config_WebUI.h"
@@ -39,15 +38,34 @@
# include "config_SSD1306.h" # include "config_SSD1306.h"
# endif # endif
extern String stateRFMeasures();
uint32_t requestToken = 0; uint32_t requestToken = 0;
QueueHandle_t webUIQueue; QueueHandle_t webUIQueue;
WebServer server(80); WebServer server(80);
webUIQueueMessage* currentWebUIMessage;
extern JsonArray modules;
extern char discovery_prefix[];
extern String latestVersion;
bool WebUIConfig_save();
void sendRestartPage();
bool WebUIConfig_load();
void WebUIConfig_init();
void addLog(const uint8_t* buffer, size_t size);
/*------------------- External functions ----------------------*/ /*------------------- External functions ----------------------*/
extern void eraseConfig(); extern void eraseConfig();
extern unsigned long uptime(); extern unsigned long uptime();
extern void ESPRestart(byte reason);
extern void XtoSYS(const char* topicOri, JsonObject& SYSdata);
extern String stateMeasures();
extern void MQTTHttpsFWUpdate(const char* topicOri, JsonObject& HttpsFwUpdateData);
extern void receivingDATA(const char* topicOri, const char* datacallback);
/*------------------- Web Console Globals ----------------------*/ /*------------------- Web Console Globals ----------------------*/
@@ -284,30 +302,6 @@ void AddLogData(uint32_t loglevel, const char* log_data, const char* log_data_pa
} }
} }
bool NeedLogRefresh(uint32_t req_loglevel, uint32_t index) {
if (!log_buffer) {
return false;
} // Leave now if there is no buffer available
# ifdef ESP32
// this takes the mutex, and will be release when the class is destroyed -
// i.e. when the functon leaves You CAN call mutex.give() to leave early.
TasAutoMutex mutex((SemaphoreHandle_t*)&log_buffer_mutex);
# endif // ESP32
// Skip initial buffer fill
if (strlen(log_buffer) < LOG_BUFFER_SIZE / 2) {
return false;
}
char* line;
size_t len;
if (!GetLog(req_loglevel, &index, &line, &len)) {
return false;
}
return ((line - log_buffer) < LOG_BUFFER_SIZE / 4);
}
bool GetLog(uint32_t req_loglevel, uint32_t* index_p, char** entry_pp, size_t* len_p) { bool GetLog(uint32_t req_loglevel, uint32_t* index_p, char** entry_pp, size_t* len_p) {
if (!log_buffer) { if (!log_buffer) {
return false; return false;
@@ -365,6 +359,30 @@ bool GetLog(uint32_t req_loglevel, uint32_t* index_p, char** entry_pp, size_t* l
return false; return false;
} }
bool NeedLogRefresh(uint32_t req_loglevel, uint32_t index) {
if (!log_buffer) {
return false;
} // Leave now if there is no buffer available
# ifdef ESP32
// this takes the mutex, and will be release when the class is destroyed -
// i.e. when the functon leaves You CAN call mutex.give() to leave early.
TasAutoMutex mutex((SemaphoreHandle_t*)&log_buffer_mutex);
# endif // ESP32
// Skip initial buffer fill
if (strlen(log_buffer) < LOG_BUFFER_SIZE / 2) {
return false;
}
char* line;
size_t len;
if (!GetLog(req_loglevel, &index, &line, &len)) {
return false;
}
return ((line - log_buffer) < LOG_BUFFER_SIZE / 4);
}
/*------------------- Local functions ----------------------*/ /*------------------- Local functions ----------------------*/
# ifdef WEBUI_DEVELOPMENT # ifdef WEBUI_DEVELOPMENT
@@ -937,6 +955,11 @@ void handleLO() {
} }
# ifdef ZgatewayLORA # ifdef ZgatewayLORA
# include "config_LORA.h"
extern void LORAConfig_fromJson(JsonObject& LORAdata);
extern String stateLORAMeasures();
extern LORAConfig_s LORAConfig;
/** /**
* @brief /LA - Configure LORA Page * @brief /LA - Configure LORA Page
* T: handleLA: uri: /la, args: 11, method: 1 * T: handleLA: uri: /la, args: 11, method: 1
@@ -1108,6 +1131,17 @@ std::map<int, String> activeReceiverOptions = {
# endif # endif
}; };
struct RFConfig_s {
float frequency;
int rssiThreshold;
int newOokThreshold;
int activeReceiver;
};
extern RFConfig_s RFConfig;
bool validFrequency(float mhz);
void RFConfig_fromJson(JsonObject& RFdata);
bool isValidReceiver(int receiverId) { bool isValidReceiver(int receiverId) {
// Check if the receiverId exists in the activeReceiverOptions map // Check if the receiverId exists in the activeReceiverOptions map
return activeReceiverOptions.find(receiverId) != activeReceiverOptions.end(); return activeReceiverOptions.find(receiverId) != activeReceiverOptions.end();
@@ -1360,6 +1394,7 @@ void handleIN() {
// }1 json-oled }2 true } }1 Cloud }2 cloudEnabled}2true}1c // }1 json-oled }2 true } }1 Cloud }2 cloudEnabled}2true}1c
# if defined(ZgatewayBT) # if defined(ZgatewayBT)
String stateBTMeasures(bool start);
informationDisplay += "1<BR>BT}2}1"; // }1 the bracket is not needed as the previous message ends with } informationDisplay += "1<BR>BT}2}1"; // }1 the bracket is not needed as the previous message ends with }
informationDisplay += stateBTMeasures(false); informationDisplay += stateBTMeasures(false);
# endif # endif
@@ -1608,7 +1643,7 @@ void notFound() {
} }
void WebUISetup() { void WebUISetup() {
WEBUI_TRACE_LOG(F("ZwebUI setup start" CR)); WEBUI_TRACE_LOG(F("webUI setup start" CR));
WebUIConfig_load(); WebUIConfig_load();
webUIQueue = xQueueCreate(5, sizeof(webUIQueueMessage*)); webUIQueue = xQueueCreate(5, sizeof(webUIQueueMessage*));
@@ -1663,7 +1698,7 @@ void WebUISetup() {
Log.trace(F("[WebUI] WebUI Secure %T" CR), webUISecure); Log.trace(F("[WebUI] WebUI Secure %T" CR), webUISecure);
Log.notice(F("OpenMQTTGateway URL: http://%s/" CR), WiFi.localIP().toString().c_str()); Log.notice(F("OpenMQTTGateway URL: http://%s/" CR), WiFi.localIP().toString().c_str());
displayPrint("URL: http://", (char*)WiFi.localIP().toString().c_str()); displayPrint("URL: http://", (char*)WiFi.localIP().toString().c_str());
Log.notice(F("ZwebUI setup done" CR)); Log.notice(F("webUI setup done" CR));
} }
unsigned long nextWebUIMessage = uptime() + DISPLAY_WEBUI_INTERVAL; unsigned long nextWebUIMessage = uptime() + DISPLAY_WEBUI_INTERVAL;
@@ -1674,7 +1709,9 @@ void WebUILoop() {
if (uptime() >= nextWebUIMessage && uxQueueMessagesWaiting(webUIQueue)) { if (uptime() >= nextWebUIMessage && uxQueueMessagesWaiting(webUIQueue)) {
webUIQueueMessage* message = nullptr; webUIQueueMessage* message = nullptr;
xQueueReceive(webUIQueue, &message, portMAX_DELAY); xQueueReceive(webUIQueue, &message, portMAX_DELAY);
# if defined(ZdisplaySSD1306)
newSSD1306Message = true; newSSD1306Message = true;
# endif
if (currentWebUIMessage) { if (currentWebUIMessage) {
free(currentWebUIMessage); free(currentWebUIMessage);
-408
View File
@@ -1,408 +0,0 @@
/**
*
* @file HTTPUpdate.cpp based om ESP8266HTTPUpdate.cpp
* @date 16.10.2018
* @author Markus Sattler
*
* Copyright (c) 2015 Markus Sattler. All rights reserved.
* This file is part of the ESP32 Http Updater.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef ESP32
# include "zzHTTPUpdate.h"
# include <StreamString.h>
# include <esp_ota_ops.h> // get running partition
# include <esp_partition.h>
// To do extern "C" uint32_t _SPIFFS_start;
// To do extern "C" uint32_t _SPIFFS_end;
HTTPUpdate::HTTPUpdate(void)
: _httpClientTimeout(8000), _ledPin(-1) {
_followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;
}
HTTPUpdate::HTTPUpdate(int httpClientTimeout)
: _httpClientTimeout(httpClientTimeout), _ledPin(-1) {
_followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;
}
HTTPUpdate::~HTTPUpdate(void) {
}
HTTPUpdateResult HTTPUpdate::update(WiFiClient& client, const String& url, const String& currentVersion) {
HTTPClient http;
if (!http.begin(client, url)) {
return HTTP_UPDATE_FAILED;
}
return handleUpdate(http, currentVersion, false);
}
HTTPUpdateResult HTTPUpdate::updateSpiffs(HTTPClient& httpClient, const String& currentVersion) {
return handleUpdate(httpClient, currentVersion, true);
}
HTTPUpdateResult HTTPUpdate::updateSpiffs(WiFiClient& client, const String& url, const String& currentVersion) {
HTTPClient http;
if (!http.begin(client, url)) {
return HTTP_UPDATE_FAILED;
}
return handleUpdate(http, currentVersion, true);
}
HTTPUpdateResult HTTPUpdate::update(HTTPClient& httpClient,
const String& currentVersion) {
return handleUpdate(httpClient, currentVersion, false);
}
HTTPUpdateResult HTTPUpdate::update(WiFiClient& client, const String& host, uint16_t port, const String& uri,
const String& currentVersion) {
HTTPClient http;
if (!http.begin(client, host, port, uri)) {
return HTTP_UPDATE_FAILED;
}
return handleUpdate(http, currentVersion, false);
}
/**
* return error code as int
* @return int error code
*/
int HTTPUpdate::getLastError(void) {
return _lastError;
}
/**
* return error code as String
* @return String error
*/
String HTTPUpdate::getLastErrorString(void) {
if (_lastError == 0) {
return String(); // no error
}
// error from Update class
if (_lastError > 0) {
StreamString error;
Update.printError(error);
error.trim(); // remove line ending
return String("Update error: ") + error;
}
// error from http client
if (_lastError > -100) {
return String("HTTP error: ") + HTTPClient::errorToString(_lastError);
}
switch (_lastError) {
case HTTP_UE_TOO_LESS_SPACE:
return "Not Enough space";
case HTTP_UE_SERVER_NOT_REPORT_SIZE:
return "Server Did Not Report Size";
case HTTP_UE_SERVER_FILE_NOT_FOUND:
return "File Not Found (404)";
case HTTP_UE_SERVER_FORBIDDEN:
return "Forbidden (403)";
case HTTP_UE_SERVER_WRONG_HTTP_CODE:
return "Wrong HTTP Code";
case HTTP_UE_SERVER_FAULTY_MD5:
return "Wrong MD5";
case HTTP_UE_BIN_VERIFY_HEADER_FAILED:
return "Verify Bin Header Failed";
case HTTP_UE_BIN_FOR_WRONG_FLASH:
return "New Binary Does Not Fit Flash Size";
case HTTP_UE_NO_PARTITION:
return "Partition Could Not be Found";
}
return String();
}
String getSketchSHA256() {
const size_t HASH_LEN = 32; // SHA-256 digest length
uint8_t sha_256[HASH_LEN] = {0};
// get sha256 digest for running partition
if (esp_partition_get_sha256(esp_ota_get_running_partition(), sha_256) == 0) {
char buffer[2 * HASH_LEN + 1];
for (size_t index = 0; index < HASH_LEN; index++) {
uint8_t nibble = (sha_256[index] & 0xf0) >> 4;
buffer[2 * index] = nibble < 10 ? char(nibble + '0') : char(nibble - 10 + 'A');
nibble = sha_256[index] & 0x0f;
buffer[2 * index + 1] = nibble < 10 ? char(nibble + '0') : char(nibble - 10 + 'A');
}
buffer[2 * HASH_LEN] = '\0';
return String(buffer);
} else {
return String();
}
}
/**
*
* @param http HTTPClient *
* @param currentVersion const char *
* @return HTTPUpdateResult
*/
HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& currentVersion, bool spiffs) {
HTTPUpdateResult ret = HTTP_UPDATE_FAILED;
// use HTTP/1.0 for update since the update handler not support any transfer Encoding
http.useHTTP10(true);
http.setTimeout(_httpClientTimeout);
http.setFollowRedirects(_followRedirects);
http.setUserAgent("ESP32-http-Update");
http.addHeader("Cache-Control", "no-cache");
http.addHeader("x-ESP32-STA-MAC", WiFi.macAddress());
http.addHeader("x-ESP32-AP-MAC", WiFi.softAPmacAddress());
http.addHeader("x-ESP32-free-space", String(ESP.getFreeSketchSpace()));
http.addHeader("x-ESP32-sketch-size", String(ESP.getSketchSize()));
String sketchMD5 = ESP.getSketchMD5();
if (sketchMD5.length() != 0) {
http.addHeader("x-ESP32-sketch-md5", sketchMD5);
}
// Add also a SHA256
String sketchSHA256 = getSketchSHA256();
if (sketchSHA256.length() != 0) {
http.addHeader("x-ESP32-sketch-sha256", sketchSHA256);
}
http.addHeader("x-ESP32-chip-size", String(ESP.getFlashChipSize()));
http.addHeader("x-ESP32-sdk-version", ESP.getSdkVersion());
if (spiffs) {
http.addHeader("x-ESP32-mode", "spiffs");
} else {
http.addHeader("x-ESP32-mode", "sketch");
}
if (currentVersion && currentVersion[0] != 0x00) {
http.addHeader("x-ESP32-version", currentVersion);
}
const char* headerkeys[] = {"x-MD5"};
size_t headerkeyssize = sizeof(headerkeys) / sizeof(char*);
// track these headers
http.collectHeaders(headerkeys, headerkeyssize);
int code = http.GET();
int len = http.getSize();
if (code <= 0) {
log_e("HTTP error: %s\n", http.errorToString(code).c_str());
_lastError = code;
http.end();
return HTTP_UPDATE_FAILED;
}
log_d("Header read fin.\n");
log_d("Server header:\n");
log_d(" - code: %d\n", code);
log_d(" - len: %d\n", len);
if (http.hasHeader("x-MD5")) {
log_d(" - MD5: %s\n", http.header("x-MD5").c_str());
}
log_d("ESP32 info:\n");
log_d(" - free Space: %d\n", ESP.getFreeSketchSpace());
log_d(" - current Sketch Size: %d\n", ESP.getSketchSize());
if (currentVersion && currentVersion[0] != 0x00) {
log_d(" - current version: %s\n", currentVersion.c_str());
}
switch (code) {
case HTTP_CODE_OK: ///< OK (Start Update)
if (len > 0) {
bool startUpdate = true;
if (spiffs) {
const esp_partition_t* _partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, NULL);
if (!_partition) {
_lastError = HTTP_UE_NO_PARTITION;
return HTTP_UPDATE_FAILED;
}
if (len > _partition->size) {
log_e("spiffsSize to low (%d) needed: %d\n", _partition->size, len);
startUpdate = false;
}
} else {
int sketchFreeSpace = ESP.getFreeSketchSpace();
if (!sketchFreeSpace) {
_lastError = HTTP_UE_NO_PARTITION;
return HTTP_UPDATE_FAILED;
}
if (len > sketchFreeSpace) {
log_e("FreeSketchSpace to low (%d) needed: %d\n", sketchFreeSpace, len);
startUpdate = false;
}
}
if (!startUpdate) {
_lastError = HTTP_UE_TOO_LESS_SPACE;
ret = HTTP_UPDATE_FAILED;
} else {
WiFiClient* tcp = http.getStreamPtr();
// To do? WiFiUDP::stopAll();
// To do? WiFiClient::stopAllExcept(tcp);
delay(100);
int command;
if (spiffs) {
command = U_SPIFFS;
log_d("runUpdate spiffs...\n");
} else {
command = U_FLASH;
log_d("runUpdate flash...\n");
}
if (!spiffs) {
/* To do
uint8_t buf[4];
if(tcp->peekBytes(&buf[0], 4) != 4) {
log_e("peekBytes magic header failed\n");
_lastError = HTTP_UE_BIN_VERIFY_HEADER_FAILED;
http.end();
return HTTP_UPDATE_FAILED;
}
*/
// check for valid first magic byte
// if(buf[0] != 0xE9) {
if (tcp->peek() != 0xE9) {
log_e("Magic header does not start with 0xE9\n");
_lastError = HTTP_UE_BIN_VERIFY_HEADER_FAILED;
http.end();
return HTTP_UPDATE_FAILED;
}
/* To do
uint32_t bin_flash_size = ESP.magicFlashChipSize((buf[3] & 0xf0) >> 4);
// check if new bin fits to SPI flash
if(bin_flash_size > ESP.getFlashChipRealSize()) {
log_e("New binary does not fit SPI Flash size\n");
_lastError = HTTP_UE_BIN_FOR_WRONG_FLASH;
http.end();
return HTTP_UPDATE_FAILED;
}
*/
}
if (runUpdate(*tcp, len, http.header("x-MD5"), command)) {
ret = HTTP_UPDATE_OK;
log_d("Update ok\n");
http.end();
if (_rebootOnUpdate && !spiffs) {
ESP.restart();
}
} else {
ret = HTTP_UPDATE_FAILED;
log_e("Update failed\n");
}
}
} else {
_lastError = HTTP_UE_SERVER_NOT_REPORT_SIZE;
ret = HTTP_UPDATE_FAILED;
log_e("Content-Length was 0 or wasn't set by Server?!\n");
}
break;
case HTTP_CODE_NOT_MODIFIED:
///< Not Modified (No updates)
ret = HTTP_UPDATE_NO_UPDATES;
break;
case HTTP_CODE_NOT_FOUND:
_lastError = HTTP_UE_SERVER_FILE_NOT_FOUND;
ret = HTTP_UPDATE_FAILED;
break;
case HTTP_CODE_FORBIDDEN:
_lastError = HTTP_UE_SERVER_FORBIDDEN;
ret = HTTP_UPDATE_FAILED;
break;
default:
_lastError = HTTP_UE_SERVER_WRONG_HTTP_CODE;
ret = HTTP_UPDATE_FAILED;
log_e("HTTP Code is (%d)\n", code);
break;
}
http.end();
return ret;
}
/**
* write Update to flash
* @param in Stream&
* @param size uint32_t
* @param md5 String
* @return true if Update ok
*/
bool HTTPUpdate::runUpdate(Stream& in, uint32_t size, String md5, int command) {
StreamString error;
if (!Update.begin(size, command, _ledPin, _ledOn)) {
_lastError = Update.getError();
Update.printError(error);
error.trim(); // remove line ending
log_e("Update.begin failed! (%s)\n", error.c_str());
return false;
}
if (md5.length()) {
if (!Update.setMD5(md5.c_str())) {
_lastError = HTTP_UE_SERVER_FAULTY_MD5;
log_e("Update.setMD5 failed! (%s)\n", md5.c_str());
return false;
}
}
// To do: the SHA256 could be checked if the server sends it
if (Update.writeStream(in) != size) {
_lastError = Update.getError();
Update.printError(error);
error.trim(); // remove line ending
log_e("Update.writeStream failed! (%s)\n", error.c_str());
return false;
}
if (!Update.end()) {
_lastError = Update.getError();
Update.printError(error);
error.trim(); // remove line ending
log_e("Update.end failed! (%s)\n", error.c_str());
return false;
}
return true;
}
# if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_HTTPUPDATE)
HTTPUpdate httpUpdate;
# endif
#endif
-113
View File
@@ -1,113 +0,0 @@
/**
*
* @file HTTPUpdate.h based on ESP8266HTTPUpdate.h
* @date 16.10.2018
* @author Markus Sattler
*
* Copyright (c) 2015 Markus Sattler. All rights reserved.
* This file is part of the ESP32 Http Updater.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef ESP32
# ifndef ___zzHTTP_UPDATE_H___
# define ___zzHTTP_UPDATE_H___
# include <Arduino.h>
# include <HTTPClient.h>
# include <Update.h>
# include <WiFi.h>
# include <WiFiClient.h>
# include <WiFiUdp.h>
/// note we use HTTP client errors too so we start at 100
# define HTTP_UE_TOO_LESS_SPACE (-100)
# define HTTP_UE_SERVER_NOT_REPORT_SIZE (-101)
# define HTTP_UE_SERVER_FILE_NOT_FOUND (-102)
# define HTTP_UE_SERVER_FORBIDDEN (-103)
# define HTTP_UE_SERVER_WRONG_HTTP_CODE (-104)
# define HTTP_UE_SERVER_FAULTY_MD5 (-105)
# define HTTP_UE_BIN_VERIFY_HEADER_FAILED (-106)
# define HTTP_UE_BIN_FOR_WRONG_FLASH (-107)
# define HTTP_UE_NO_PARTITION (-108)
enum HTTPUpdateResult {
HTTP_UPDATE_FAILED,
HTTP_UPDATE_NO_UPDATES,
HTTP_UPDATE_OK
};
typedef HTTPUpdateResult t_httpUpdate_return; // backward compatibility
class HTTPUpdate {
public:
HTTPUpdate(void);
HTTPUpdate(int httpClientTimeout);
~HTTPUpdate(void);
void rebootOnUpdate(bool reboot) {
_rebootOnUpdate = reboot;
}
/**
* set redirect follow mode. See `followRedirects_t` enum for avaliable modes.
* @param follow
*/
void setFollowRedirects(followRedirects_t follow) {
_followRedirects = follow;
}
void setLedPin(int ledPin = -1, uint8_t ledOn = HIGH) {
_ledPin = ledPin;
_ledOn = ledOn;
}
t_httpUpdate_return update(WiFiClient& client, const String& url, const String& currentVersion = "");
t_httpUpdate_return update(WiFiClient& client, const String& host, uint16_t port, const String& uri = "/",
const String& currentVersion = "");
t_httpUpdate_return updateSpiffs(WiFiClient& client, const String& url, const String& currentVersion = "");
t_httpUpdate_return update(HTTPClient& httpClient,
const String& currentVersion = "");
t_httpUpdate_return updateSpiffs(HTTPClient& httpClient, const String& currentVersion = "");
int getLastError(void);
String getLastErrorString(void);
protected:
t_httpUpdate_return handleUpdate(HTTPClient& http, const String& currentVersion, bool spiffs = false);
bool runUpdate(Stream& in, uint32_t size, String md5, int command = U_FLASH);
int _lastError;
bool _rebootOnUpdate = true;
private:
int _httpClientTimeout;
followRedirects_t _followRedirects;
int _ledPin;
uint8_t _ledOn;
};
# if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_HTTPUPDATE)
extern HTTPUpdate httpUpdate;
# endif
# endif /* ___HTTP_UPDATE_H___ */
#endif
+6
View File
@@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x1F0000,
app1, app, ota_1, 0x200000,0x1F0000,
spiffs, data, spiffs, 0x3F0000,0x10000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x1F0000
5 app1 app ota_1 0x200000 0x1F0000
6 spiffs data spiffs 0x3F0000 0x10000
+11 -11
View File
@@ -114,15 +114,15 @@ extra_configs =
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[libraries] [libraries]
arduinojson = ArduinoJson@6.18.3 arduinojson = ArduinoJson@6.18.5
arduinolog = https://github.com/1technophile/Arduino-Log.git#f634509 arduinolog = https://github.com/1technophile/Arduino-Log.git#f634509
picomqtt = PicoMQTT@1.1.1 picomqtt = PicoMQTT@1.1.1
rc-switch = https://github.com/1technophile/rc-switch.git#98537e9 rc-switch = https://github.com/1technophile/rc-switch.git#98537e9
newremoteswitch = https://github.com/1technophile/NewRemoteSwitch.git#8eb980e newremoteswitch = https://github.com/1technophile/NewRemoteSwitch.git#8eb980e
ble = https://github.com/h2zero/NimBLE-Arduino.git#2.2.1 ble = https://github.com/h2zero/NimBLE-Arduino.git#2.2.1
irremoteesp = IRremoteESP8266@2.8.5 irremoteesp = https://github.com/theengs/IRremoteESP8266#arduinov3
lora = https://github.com/sandeepmistry/arduino-LoRa.git#f4a1d27 lora = https://github.com/sandeepmistry/arduino-LoRa.git#f4a1d27
esppilight = ESPiLight@0.17.0 esppilight = https://github.com/theengs/ESPiLight#b9dd7a1
rfWeatherStation = WeatherStationDataRx@0.3.1 rfWeatherStation = WeatherStationDataRx@0.3.1
rfm69 = https://github.com/LowPowerLab/RFM69.git#2e915ea rfm69 = https://github.com/LowPowerLab/RFM69.git#2e915ea
rfm69spi = https://github.com/lowpowerlab/spiflash.git#9c0c2b9 rfm69spi = https://github.com/lowpowerlab/spiflash.git#9c0c2b9
@@ -136,19 +136,19 @@ htu21 = SparkFun HTU21D Humidity and Temperature Sensor Breakout@1.1.3
ahtx0 = Adafruit AHTX0 ahtx0 = Adafruit AHTX0
ina226 = https://github.com/jarzebski/Arduino-INA226.git#968a684 ina226 = https://github.com/jarzebski/Arduino-INA226.git#968a684
a6lib = https://github.com/h2zero/A6lib a6lib = https://github.com/h2zero/A6lib
wifimanager32 = https://github.com/tzapu/WiFiManager.git#9f5981e wifimanager32 = https://github.com/h2zero/WiFiManager.git#1ac24f4
wifimanager8266 = https://github.com/tzapu/WiFiManager.git#2.0.5-beta wifimanager8266 = https://github.com/tzapu/WiFiManager.git#2.0.5-beta
ethernet = Ethernet ethernet = Ethernet
esp8266_mdns = esp8266_mdns esp8266_mdns = esp8266_mdns
wire = Wire wire = Wire
fastled = fastled/FastLED@3.5.0 fastled = fastled/FastLED@3.9.15
adafruit_neopixel = adafruit/Adafruit NeoPixel@^1.11.0 adafruit_neopixel = adafruit/Adafruit NeoPixel@^1.11.0
onewire = paulstoffregen/OneWire@2.3.7 onewire = https://github.com/h2zero/OneWire#GPIO-fix
dallastemperature = DallasTemperature dallastemperature = DallasTemperature
m5stickc = M5StickC@0.2.0 m5stickc = M5StickC@0.2.5
m5stickcp = https://github.com/m5stack/M5StickC-Plus.git#0.0.2 m5stickcp = https://github.com/m5stack/M5StickC-Plus.git#0.1.1
m5stack = M5Stack@0.3.1 m5stack = M5Stack@0.4.6
m5tough = https://github.com/m5stack/M5Tough.git#b502416 m5tough = https://github.com/m5stack/M5Tough.git#ccf49e1
smartrc-cc1101-driver-lib = SmartRC-CC1101-Driver-Lib@2.5.7 smartrc-cc1101-driver-lib = SmartRC-CC1101-Driver-Lib@2.5.7
stl = https://github.com/mike-matera/ArduinoSTL.git#7411816 stl = https://github.com/mike-matera/ArduinoSTL.git#7411816
shtc3 = https://github.com/sparkfun/SparkFun_SHTC3_Arduino_Library shtc3 = https://github.com/sparkfun/SparkFun_SHTC3_Arduino_Library
@@ -176,7 +176,7 @@ monitor_speed = 115200
[com] [com]
esp8266_platform = espressif8266@4.2.1 esp8266_platform = espressif8266@4.2.1
esp32_platform = espressif32@6.1.0 esp32_platform = https://github.com/pioarduino/platform-espressif32#53.03.11
esp32_solo_platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.02.00/platform-espressif32.zip esp32_solo_platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.02.00/platform-espressif32.zip
atmelavr_platform = atmelavr@3.3.0 atmelavr_platform = atmelavr@3.3.0
+84 -23
View File
@@ -125,6 +125,8 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y
# end of TLS Key Exchange Methods # end of TLS Key Exchange Methods
CONFIG_MBEDTLS_DHM_C=y
# #
# Arduino Configuration # Arduino Configuration
# #
@@ -151,7 +153,6 @@ CONFIG_ARDUINO_UDP_RUN_CORE0=y
# CONFIG_ARDUINO_UDP_RUN_NO_AFFINITY is not set # CONFIG_ARDUINO_UDP_RUN_NO_AFFINITY is not set
CONFIG_ARDUINO_UDP_RUNNING_CORE=0 CONFIG_ARDUINO_UDP_RUNNING_CORE=0
CONFIG_ARDUINO_UDP_TASK_PRIORITY=3 CONFIG_ARDUINO_UDP_TASK_PRIORITY=3
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n
# CONFIG_ARDUINO_ISR_IRAM is not set # CONFIG_ARDUINO_ISR_IRAM is not set
# CONFIG_DISABLE_HAL_LOCKS is not set # CONFIG_DISABLE_HAL_LOCKS is not set
@@ -177,35 +178,95 @@ CONFIG_ARDUHAL_PARTITION_SCHEME_MIN_SPIFFS=y
CONFIG_ARDUHAL_PARTITION_SCHEME="min_spiffs" CONFIG_ARDUHAL_PARTITION_SCHEME="min_spiffs"
# CONFIG_AUTOCONNECT_WIFI is not set # CONFIG_AUTOCONNECT_WIFI is not set
CONFIG_ARDUINO_SELECTIVE_COMPILATION=y CONFIG_ARDUINO_SELECTIVE_COMPILATION=y
CONFIG_ARDUINO_SELECTIVE_ArduinoOTA=y
CONFIG_ARDUINO_SELECTIVE_AsyncUDP=y
# CONFIG_ARDUINO_SELECTIVE_AzureIoT is not set
# CONFIG_ARDUINO_SELECTIVE_BLE is not set
# CONFIG_ARDUINO_SELECTIVE_BluetoothSerial is not set
CONFIG_ARDUINO_SELECTIVE_DNSServer=y
CONFIG_ARDUINO_SELECTIVE_EEPROM=y
CONFIG_ARDUINO_SELECTIVE_ESP32=y
CONFIG_ARDUINO_SELECTIVE_ESPmDNS=y
CONFIG_ARDUINO_SELECTIVE_FFat=y
CONFIG_ARDUINO_SELECTIVE_FS=y
CONFIG_ARDUINO_SELECTIVE_HTTPClient=y
CONFIG_ARDUINO_SELECTIVE_LITTLEFS=y
CONFIG_ARDUINO_SELECTIVE_NetBIOS=y
CONFIG_ARDUINO_SELECTIVE_Preferences=y
CONFIG_ARDUINO_SELECTIVE_SD=y
CONFIG_ARDUINO_SELECTIVE_SD_MMC=y
# CONFIG_ARDUINO_SELECTIVE_SimpleBLE is not set
CONFIG_ARDUINO_SELECTIVE_SPI=y CONFIG_ARDUINO_SELECTIVE_SPI=y
CONFIG_ARDUINO_SELECTIVE_SPIFFS=y CONFIG_ARDUINO_SELECTIVE_Wire=y
CONFIG_ARDUINO_SELECTIVE_ESP_SR=y
# CONFIG_ARDUINO_SELECTIVE_EEPROM is not set
CONFIG_ARDUINO_SELECTIVE_Preferences=y
CONFIG_ARDUINO_SELECTIVE_Ticker=y CONFIG_ARDUINO_SELECTIVE_Ticker=y
CONFIG_ARDUINO_SELECTIVE_Update=y CONFIG_ARDUINO_SELECTIVE_Update=y
# CONFIG_ARDUINO_SELECTIVE_Zigbee is not set
CONFIG_ARDUINO_SELECTIVE_FS=y
CONFIG_ARDUINO_SELECTIVE_SD=y
CONFIG_ARDUINO_SELECTIVE_SD_MMC=y
CONFIG_ARDUINO_SELECTIVE_SPIFFS=y
CONFIG_ARDUINO_SELECTIVE_FFat=y
CONFIG_ARDUINO_SELECTIVE_LittleFS=y
CONFIG_ARDUINO_SELECTIVE_Network=y
CONFIG_ARDUINO_SELECTIVE_Ethernet=y
CONFIG_ARDUINO_SELECTIVE_PPP=y
CONFIG_ARDUINO_SELECTIVE_ArduinoOTA=y
CONFIG_ARDUINO_SELECTIVE_AsyncUDP=y
CONFIG_ARDUINO_SELECTIVE_DNSServer=y
CONFIG_ARDUINO_SELECTIVE_ESPmDNS=y
CONFIG_ARDUINO_SELECTIVE_HTTPClient=y
# CONFIG_ARDUINO_SELECTIVE_Matter is not set
CONFIG_ARDUINO_SELECTIVE_NetBIOS=y
CONFIG_ARDUINO_SELECTIVE_WebServer=y CONFIG_ARDUINO_SELECTIVE_WebServer=y
CONFIG_ARDUINO_SELECTIVE_WiFi=y CONFIG_ARDUINO_SELECTIVE_WiFi=y
CONFIG_ARDUINO_SELECTIVE_WiFiClientSecure=y CONFIG_ARDUINO_SELECTIVE_NetworkClientSecure=y
CONFIG_ARDUINO_SELECTIVE_WiFiProv=y # CONFIG_ARDUINO_SELECTIVE_WiFiProv is not set
CONFIG_ARDUINO_SELECTIVE_Wire=y # CONFIG_ARDUINO_SELECTIVE_BLE is not set
# CONFIG_ARDUINO_SELECTIVE_BluetoothSerial is not set
# CONFIG_ARDUINO_SELECTIVE_SimpleBLE is not set
# CONFIG_ARDUINO_SELECTIVE_RainMaker is not set
# CONFIG_ARDUINO_SELECTIVE_OpenThread is not set
# CONFIG_ARDUINO_SELECTIVE_Insights is not set
# end of Arduino Configuration
# end of Arduino Configuration # end of Arduino Configuration
# CONFIG_ESP32_WIFI_IRAM_OPT is not set # CONFIG_ESP32_WIFI_IRAM_OPT is not set
# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set # CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
CONFIG_BOOTLOADER_LOG_LEVEL=0
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
CONFIG_LOG_DEFAULT_LEVEL=1
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
CONFIG_ESP_IPC_TASK_STACK_SIZE=1024
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2048
CONFIG_ESP_TASK_WDT_PANIC=y
CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=8
CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM=8
CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM=16
CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1024
CONFIG_HEAP_POISONING_LIGHT=y
CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
CONFIG_HTTPD_WS_SUPPORT=y
# CONFIG_LOG_COLORS is not set
# CONFIG_LWIP_DHCP_DOES_ARP_CHECK is not set
CONFIG_LWIP_TCP_SYNMAXRTX=6
CONFIG_LWIP_TCP_MSS=1436
CONFIG_LWIP_TCP_RTO_TIME=3000
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=4096
CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0=y
CONFIG_LWIP_MAX_SOCKETS=16
CONFIG_LWIP_IP_FORWARD=y
CONFIG_LWIP_IPV4_NAPT=y
CONFIG_LWIP_DHCP_RESTORE_LAST_IP=n
CONFIG_LWIP_DHCP_OPTIONS_LEN=128
CONFIG_LWIP_SNTP_MAX_SERVERS=3
CONFIG_LWIP_SNTP_UPDATE_DELAY=10800000
CONFIG_LWIP_DHCP_GET_NTP_SRV=y
CONFIG_LWIP_IPV6_AUTOCONFIG=y
CONFIG_LWIP_IPV6_DHCP6=y
CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS=2
CONFIG_LWIP_PPP_SUPPORT=y
CONFIG_LWIP_PPP_NOTIFY_PHASE_SUPPORT=y
CONFIG_LWIP_PPP_PAP_SUPPORT=y
CONFIG_LWIP_PPP_ENABLE_IPV6=n
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_DEFAULT=y
CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT=y
CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM=y
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y