Skip to content

Commit 585df9a

Browse files
authored
[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
1 parent 6e77efb commit 585df9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1273
-1291
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ dependencies.lock
1515
sdkconfig.*
1616
!sdkconfig.defaults
1717
__pycache__
18-
*.pem
18+
*.pem
19+
managed_components

environments.ini

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ custom_hardware = Theengs Plug
188188
platform = ${com.esp32_platform}
189189
board = esp32dev
190190
extra_scripts = ${com-esp32.extra_scripts}
191-
board_build.partitions = min_spiffs.csv
191+
board_build.partitions = partitions/no_coredump.csv
192192
lib_deps =
193193
${com-esp32.lib_deps}
194194
${libraries.ble}
@@ -270,6 +270,7 @@ build_flags =
270270
[env:esp32dev-rf]
271271
platform = ${com.esp32_platform}
272272
board = esp32dev
273+
board_build.partitions = min_spiffs.csv
273274
lib_deps =
274275
${com-esp32.lib_deps}
275276
${libraries.rc-switch}
@@ -311,6 +312,7 @@ custom_description = Gateway using ESPilight library only, need CC1101
311312
[env:esp32dev-somfy-cc1101]
312313
platform = ${com.esp32_platform}
313314
board = esp32dev
315+
board_build.partitions = min_spiffs.csv
314316
lib_deps =
315317
${com-esp32.lib_deps}
316318
${libraries.somfy_remote}
@@ -342,6 +344,7 @@ custom_description = Gateway using Somfy Remote and ESPilight library, need CC11
342344
[env:esp32dev-weatherstation]
343345
platform = ${com.esp32_platform}
344346
board = esp32dev
347+
board_build.partitions = min_spiffs.csv
345348
lib_deps =
346349
${com-esp32.lib_deps}
347350
${libraries.rfWeatherStation}
@@ -354,6 +357,7 @@ custom_description = Gateway to retrieve weather station data Ventus W174/W132 (
354357
[env:esp32dev-gf-sun-inverter]
355358
platform = ${com.esp32_platform}
356359
board = esp32dev
360+
board_build.partitions = min_spiffs.csv
357361
lib_deps =
358362
${com-esp32.lib_deps}
359363
${libraries.emodbus}
@@ -598,10 +602,10 @@ custom_description = BLE gateway using wifi
598602
custom_hardware = OLIMEX ESP32 Gateway
599603

600604
[env:esp32-m5stick-ble]
601-
platform = ${com.esp32_platform}
605+
602606
board = m5stack-core-esp32
603607
extra_scripts = ${com-esp32.extra_scripts}
604-
board_build.partitions = min_spiffs.csv
608+
board_build.partitions = partitions/no_coredump.csv
605609
lib_deps =
606610
${com-esp32.lib_deps}
607611
${libraries.ble}
@@ -622,7 +626,7 @@ custom_description = Expandable module with BLE gateway, display, and little IR
622626
custom_hardware = M5Stick Grey
623627

624628
[env:esp32-m5stack-ble]
625-
platform = ${com.esp32_platform}
629+
626630
board = m5stack-core-esp32
627631
extra_scripts = ${com-esp32.extra_scripts}
628632
board_build.partitions = min_spiffs.csv
@@ -647,7 +651,7 @@ custom_description = Expandable module with BLE gateway and display
647651
custom_hardware = M5Stack Core
648652

649653
[env:esp32-m5tough-ble]
650-
platform = ${com.esp32_platform}
654+
651655
board = m5stack-core-esp32
652656
extra_scripts = ${com-esp32.extra_scripts}
653657
board_build.partitions = min_spiffs.csv
@@ -666,7 +670,7 @@ custom_description = Expandable module with BLE gateway and display, suitable fo
666670
custom_hardware = M5Tough rugged
667671

668672
[env:esp32-m5stick-c-ble]
669-
platform = ${com.esp32_platform}
673+
670674
board = m5stick-c
671675
extra_scripts = ${com-esp32.extra_scripts}
672676
board_build.partitions = min_spiffs.csv
@@ -697,10 +701,10 @@ custom_description = Expandable module with BLE gateway, display, and little IR
697701
custom_hardware = M5Stick C
698702

699703
[env:esp32-m5stick-cp-ble]
700-
platform = ${com.esp32_platform}
704+
701705
board = pico32
702706
extra_scripts = ${com-esp32.extra_scripts}
703-
board_build.partitions = min_spiffs.csv
707+
board_build.partitions = partitions/no_coredump.csv
704708
lib_deps =
705709
${com-esp32.lib_deps}
706710
${libraries.ble}
@@ -731,7 +735,7 @@ custom_hardware = M5Stick CP
731735
platform = ${com.esp32_platform}
732736
board = pico32
733737
extra_scripts = ${com-esp32.extra_scripts}
734-
board_build.partitions = min_spiffs.csv
738+
board_build.partitions = partitions/no_coredump.csv
735739
lib_deps =
736740
${com-esp32.lib_deps}
737741
${libraries.ble}
@@ -762,7 +766,7 @@ custom_hardware = M5 ATOM Matrix
762766
platform = ${com.esp32_platform}
763767
board = pico32
764768
extra_scripts = ${com-esp32.extra_scripts}
765-
board_build.partitions = min_spiffs.csv
769+
board_build.partitions = partitions/no_coredump.csv
766770
lib_deps =
767771
${com-esp32.lib_deps}
768772
${libraries.ble}
@@ -785,7 +789,7 @@ custom_description = Compact enclosure ESP32 with BLE gateway
785789
custom_hardware = M5 ATOM Lite
786790

787791
[env:esp32doitv1-aithinker-r01-sx1278]
788-
platform = ${com.esp32_platform}
792+
789793
board = esp32doit-devkit-v1
790794
board_build.partitions = min_spiffs.csv
791795
lib_deps =
@@ -864,7 +868,7 @@ upload_flags =
864868
--port=8266
865869

866870
[env:esp32dev-rtl_433]
867-
platform = ${com.esp32_platform}
871+
868872
board = esp32dev
869873
board_build.partitions = min_spiffs.csv
870874
lib_deps =
@@ -904,7 +908,7 @@ build_flags =
904908
custom_description = Gateway using RTL_433_ESP library, need CC1101
905909

906910
[env:heltec-rtl_433]
907-
platform = ${com.esp32_platform}
911+
908912
board = heltec_wifi_lora_32_V2
909913
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
910914
board_build.partitions = min_spiffs.csv
@@ -933,7 +937,7 @@ custom_description = Gateway using RTL_433_ESP and RadioLib
933937
custom_hardware = ESP32 HELTEC LORA32 V2
934938

935939
[env:heltec-rtl_433-fsk]
936-
platform = ${com.esp32_platform}
940+
937941
board = heltec_wifi_lora_32_V2
938942
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
939943
board_build.partitions = min_spiffs.csv
@@ -991,7 +995,7 @@ custom_description = Heltec BLE gateway with adaptive scanning activated, automa
991995
custom_hardware = ESP32 HELTEC LORA32 V2
992996

993997
[env:lilygo-rtl_433]
994-
platform = ${com.esp32_platform}
998+
995999
board = ttgo-lora32-v21
9961000
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
9971001
board_build.partitions = min_spiffs.csv
@@ -1020,7 +1024,7 @@ custom_description = For ESP32, Gateway using RTL_433_ESP and RadioLib
10201024
custom_hardware = ESP32 LILYGO LoRa32 V2.1
10211025

10221026
[env:lilygo-rtl_433-fsk]
1023-
platform = ${com.esp32_platform}
1027+
10241028
board = ttgo-lora32-v21
10251029
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
10261030
board_build.partitions = min_spiffs.csv
@@ -1078,7 +1082,7 @@ custom_description = LilyGo BLE gateway with adaptive scanning activated, automa
10781082
custom_hardware = ESP32 LILYGO LoRa32 V2.1
10791083

10801084
[env:esp32dev-multi_receiver]
1081-
platform = ${com.esp32_platform}
1085+
10821086
board = esp32dev
10831087
board_build.partitions = min_spiffs.csv
10841088
lib_deps =
@@ -1896,11 +1900,16 @@ framework = arduino, espidf
18961900
board = esp32dev
18971901
extra_scripts = ${com-esp32.extra_scripts}
18981902
board_build.partitions = partitions/min_spiffs.csv
1903+
board_build.embed_txtfiles =
1904+
managed_components/espressif__esp_insights/server_certs/https_server.crt
1905+
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
1906+
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
1907+
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
18991908
lib_deps =
19001909
${com-esp32.lib_deps}
19011910
${libraries.decoder}
1902-
h2zero/esp-nimble-cpp@2.0.1
1903-
h2zero/NimBLEOta@0.1.0
1911+
h2zero/esp-nimble-cpp@2.1.1
1912+
h2zero/NimBLEOta@0.2.0
19041913
build_flags =
19051914
${com-esp32.build_flags}
19061915
'-DZgatewayBT="BT"'
@@ -1909,5 +1918,4 @@ build_flags =
19091918
'-DGateway_Name="OMG_ESP32_BLE"'
19101919
'-DUSE_BLUFI=1'
19111920
'-DenableMultiGTWSync=false'
1912-
'-DCONFIG_NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT=31'
19131921
custom_description = Regular BLE gateway based on esp-idf with adaptive scanning activated, automatically adapts the scan parameters depending on your devices

main/TheengsCommon.h

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#pragma once
2+
3+
#include "User_config.h"
4+
5+
#define ARDUINOJSON_USE_LONG_LONG 1
6+
#define ARDUINOJSON_ENABLE_STD_STRING 1
7+
#include <ArduinoJson.h>
8+
#include <ArduinoLog.h>
9+
10+
#if defined(ESP32)
11+
# include <Preferences.h>
12+
extern Preferences preferences;
13+
#endif
14+
15+
// Flags definition for white list, black list, discovery management
16+
#define device_flags_init 0 << 0
17+
#define device_flags_isDisc 1 << 0
18+
#define device_flags_isWhiteL 1 << 1
19+
#define device_flags_isBlackL 1 << 2
20+
#define device_flags_connect 1 << 3
21+
#define isWhite(device) device->isWhtL
22+
#define isBlack(device) device->isBlkL
23+
#define isDiscovered(device) device->isDisc
24+
25+
enum GatewayState {
26+
WAITING_ONBOARDING,
27+
ONBOARDING,
28+
OFFLINE,
29+
NTWK_CONNECTED,
30+
BROKER_CONNECTED,
31+
PROCESSING,
32+
NTWK_DISCONNECTED,
33+
BROKER_DISCONNECTED,
34+
LOCAL_OTA_IN_PROGRESS,
35+
REMOTE_OTA_IN_PROGRESS,
36+
SLEEPING,
37+
ERROR
38+
};
39+
40+
enum PowerMode {
41+
DEACTIVATED = -1,
42+
ALWAYS_ON,
43+
INTERVAL,
44+
ACTION
45+
};
46+
47+
struct SYSConfig_s {
48+
bool mqtt; // if true the gateway will publish the received data on the MQTT broker
49+
bool serial; // if true the gateway will publish the received data on the SERIAL
50+
bool blufi; // if true the gateway will be accesible with blufi
51+
bool offline;
52+
bool discovery; // HA discovery convention
53+
#ifdef LED_ADDRESSABLE
54+
int rgbbrightness; // brightness of the RGB LED
55+
#endif
56+
enum PowerMode powerMode;
57+
};
58+
59+
extern GatewayState gatewayState;
60+
extern SYSConfig_s SYSConfig;
61+
extern bool ready_to_sleep;
62+
extern char mqtt_topic[];
63+
extern char gateway_name[];
64+
extern unsigned long lastDiscovery; // Time of the last discovery to trigger automaticaly to off after DiscoveryAutoOffTimer
65+
66+
extern bool enqueueJsonObject(const StaticJsonDocument<JSON_MSG_BUFFER>& jsonDoc, int timeout);
67+
extern bool enqueueJsonObject(const StaticJsonDocument<JSON_MSG_BUFFER>& jsonDoc);
68+
extern void buildTopicFromId(JsonObject& Jsondata, const char* origin);
69+
extern bool pubMQTT(const char* topic, const char* payload);
70+
extern bool pubMQTT(const char* topic, const char* payload, bool retainFlag);
71+
extern bool pubMQTT(String topic, const char* payload);
72+
extern bool pubMQTT(const char* topic, unsigned long payload);
73+
extern bool pubMQTT(const char* topic, unsigned long long payload);
74+
extern bool pubMQTT(const char* topic, String payload);
75+
extern bool pubMQTT(String topic, String payload);
76+
extern bool pubMQTT(String topic, int payload);
77+
extern bool pubMQTT(String topic, unsigned long long payload);
78+
extern bool pubMQTT(String topic, float payload);
79+
extern bool pubMQTT(const char* topic, float payload);
80+
extern bool pubMQTT(const char* topic, int payload);
81+
extern bool pubMQTT(const char* topic, unsigned int payload);
82+
extern bool pubMQTT(const char* topic, long payload);
83+
extern bool pubMQTT(const char* topic, double payload);
84+
extern bool pubMQTT(String topic, unsigned long payload);
85+
extern unsigned long uptime();
86+
extern bool cmpToMainTopic(const char*, const char*);
87+
extern bool pub(const char*, const char*, bool);
88+
extern bool pub(const char*, const char*);
89+
90+
template <typename T>
91+
void Config_update(JsonObject& data, const char* key, T& var) {
92+
if (data.containsKey(key)) {
93+
if (var != data[key].as<T>()) {
94+
var = data[key].as<T>();
95+
Log.notice(F("Config %s changed to: %T" CR), key, data[key].as<T>());
96+
} else {
97+
Log.notice(F("Config %s unchanged, currently: %T" CR), key, data[key].as<T>());
98+
}
99+
}
100+
}

0 commit comments

Comments
 (0)