Skip to content

Commit

Permalink
Merge pull request #923 from helgeerbe/merge-v24.4.12
Browse files Browse the repository at this point in the history
merge upstream tag v24.4.12, resolve conflicts (helgeerbe), fix eslint errors (schlimmchen) and adopt new web api method to save code duplication (schlimmchen).
  • Loading branch information
schlimmchen authored Apr 29, 2024
2 parents 4e36c8c + d3b306e commit 4cf596e
Show file tree
Hide file tree
Showing 84 changed files with 995 additions and 1,610 deletions.
2 changes: 0 additions & 2 deletions include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
#define POWERMETER_MAX_HTTP_JSON_PATH_STRLEN 256
#define POWERMETER_HTTP_TIMEOUT 1000

#define JSON_BUFFER_SIZE 15360

struct CHANNEL_CONFIG_T {
uint16_t MaxChannelPower;
char Name[CHAN_MAX_NAME_STRLEN];
Expand Down
6 changes: 3 additions & 3 deletions include/MqttHandleHass.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ class MqttHandleHassClass {
void publishInverterNumber(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* icon, const char* category, const char* commandTopic, const char* stateTopic, const char* unitOfMeasure, const int16_t min = 1, const int16_t max = 100);
void publishInverterBinarySensor(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* subTopic, const char* payload_on, const char* payload_off);

static void createInverterInfo(DynamicJsonDocument& doc, std::shared_ptr<InverterAbstract> inv);
static void createDtuInfo(DynamicJsonDocument& doc);
static void createInverterInfo(JsonDocument& doc, std::shared_ptr<InverterAbstract> inv);
static void createDtuInfo(JsonDocument& doc);

static void createDeviceInfo(DynamicJsonDocument& doc, const String& name, const String& identifiers, const String& configuration_url, const String& manufacturer, const String& model, const String& sw_version, const String& via_device = "");
static void createDeviceInfo(JsonDocument& doc, const String& name, const String& identifiers, const String& configuration_url, const String& manufacturer, const String& model, const String& sw_version, const String& via_device = "");

static String getDtuUniqueId();
static String getDtuUrl();
Expand Down
3 changes: 1 addition & 2 deletions include/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Utils {
static uint64_t generateDtuSerial();
static int getTimezoneOffset();
static void restartDtu();
static bool checkJsonAlloc(const DynamicJsonDocument& doc, const char* function, const uint16_t line);
static bool checkJsonOverflow(const DynamicJsonDocument& doc, const char* function, const uint16_t line);
static bool checkJsonAlloc(const JsonDocument& doc, const char* function, const uint16_t line);
static void removeAllFiles();
};
5 changes: 5 additions & 0 deletions include/WebApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "WebApi_webapp.h"
#include "WebApi_ws_console.h"
#include "WebApi_ws_live.h"
#include <AsyncJson.h>
#include "WebApi_ws_vedirect_live.h"
#include "WebApi_vedirect.h"
#include "WebApi_ws_Huawei.h"
Expand All @@ -45,6 +46,10 @@ class WebApiClass {

static void writeConfig(JsonVariant& retMsg, const WebApiError code = WebApiError::GenericSuccess, const String& message = "Settings saved!");

static bool parseRequestData(AsyncWebServerRequest* request, AsyncJsonResponse* response, JsonDocument& json_document);
static uint64_t parseSerialFromRequest(AsyncWebServerRequest* request, String param_name = "inv");
static bool sendJsonResponse(AsyncWebServerRequest* request, AsyncJsonResponse* response, const char* function, const uint16_t line);

private:
AsyncWebServer _server;

Expand Down
3 changes: 2 additions & 1 deletion include/WebApi_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ enum WebApiError {
GenericBase = 1000,
GenericSuccess,
GenericNoValueFound,
GenericDataTooLarge,
GenericDataTooLarge, // not used anymore
GenericParseError,
GenericValueMissing,
GenericWriteFailed,
GenericInternalServerError,

DtuBase = 2000,
DtuSerialZero,
Expand Down
2 changes: 0 additions & 2 deletions include/WebApi_mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <ESPAsyncWebServer.h>
#include <TaskSchedulerDeclarations.h>

#define MQTT_JSON_DOC_SIZE 10240

class WebApiMqttClass {
public:
void init(AsyncWebServer& server, Scheduler& scheduler);
Expand Down
2 changes: 1 addition & 1 deletion include/WebApi_ws_Huawei.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class WebApiWsHuaweiLiveClass {
void init(AsyncWebServer& server, Scheduler& scheduler);

private:
void generateJsonResponse(JsonVariant& root);
void generateCommonJsonResponse(JsonVariant& root);
void onLivedataStatus(AsyncWebServerRequest* request);
void onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len);

Expand Down
2 changes: 1 addition & 1 deletion include/WebApi_ws_battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class WebApiWsBatteryLiveClass {
void init(AsyncWebServer& server, Scheduler& scheduler);

private:
void generateJsonResponse(JsonVariant& root);
void generateCommonJsonResponse(JsonVariant& root);
void onLivedataStatus(AsyncWebServerRequest* request);
void onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len);

Expand Down
2 changes: 1 addition & 1 deletion include/WebApi_ws_vedirect_live.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class WebApiWsVedirectLiveClass {
void init(AsyncWebServer& server, Scheduler& scheduler);

private:
void generateJsonResponse(JsonVariant& root, bool fullUpdate);
void generateCommonJsonResponse(JsonVariant& root, bool fullUpdate);
static void populateJson(const JsonObject &root, const VeDirectMpptController::data_t &mpptData);
void onLivedataStatus(AsyncWebServerRequest* request);
void onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len);
Expand Down
6 changes: 3 additions & 3 deletions lib/Hoymiles/src/HoymilesRadio.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include "TimeoutHelper.h"
#include "commands/CommandAbstract.h"
#include "types.h"
#include <memory>
#include <ThreadSafeQueue.h>
#include <TimeoutHelper.h>
#include <memory>

class HoymilesRadio {
public:
Expand Down Expand Up @@ -43,4 +43,4 @@ class HoymilesRadio {
bool _busyFlag = false;

TimeoutHelper _rxTimeout;
};
};
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HMT_4CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ bool HMT_4CH::isValidSerial(const uint64_t serial)

String HMT_4CH::typeName() const
{
return F("HMT-1600/1800/2000-4T");
return "HMT-1600/1800/2000-4T";
}

const byteAssign_t* HMT_4CH::getByteAssignment() const
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HMT_6CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool HMT_6CH::isValidSerial(const uint64_t serial)

String HMT_6CH::typeName() const
{
return F("HMT-1800/2250-6T");
return "HMT-1800/2250-6T";
}

const byteAssign_t* HMT_6CH::getByteAssignment() const
Expand Down
Empty file added lib/ThreadSafeQueue/README.md
Empty file.
13 changes: 13 additions & 0 deletions lib/ThreadSafeQueue/library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "ThreadSafeQueue",
"keywords": "queue, threadsafe",
"description": "An Arduino for ESP32 thread safe queue implementation",
"authors": {
"name": "Thomas Basler"
},
"version": "0.0.1",
"frameworks": "arduino",
"platforms": [
"espressif32"
]
}
File renamed without changes.
Empty file added lib/TimeoutHelper/README.md
Empty file.
13 changes: 13 additions & 0 deletions lib/TimeoutHelper/library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "TimeoutHelper",
"keywords": "timeout",
"description": "An Arduino for ESP32 timeout helper",
"authors": {
"name": "Thomas Basler"
},
"version": "0.0.1",
"frameworks": "arduino",
"platforms": [
"espressif32"
]
}
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions patches/async_tcp/event_queue_size.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --color -ruN a/.pio/libdeps/$$$env$$$/AsyncTCP-esphome/src/AsyncTCP.cpp b/.pio/libdeps/$$$env$$$/AsyncTCP-esphome/src/AsyncTCP.cpp
--- a/.pio/libdeps/$$$env$$$/AsyncTCP-esphome/src/AsyncTCP.cpp
+++ b/.pio/libdeps/$$$env$$$/AsyncTCP-esphome/src/AsyncTCP.cpp
@@ -97,7 +97,7 @@

static inline bool _init_async_event_queue(){
if(!_async_queue){
- _async_queue = xQueueCreate(32, sizeof(lwip_event_packet_t *));
+ _async_queue = xQueueCreate(CONFIG_ASYNC_TCP_EVENT_QUEUE_SIZE, sizeof(lwip_event_packet_t *));
if(!_async_queue){
return false;
}
diff --color -ruN a/.pio/libdeps/$$$env$$$/AsyncTCP-esphome/src/AsyncTCP.h b/.pio/libdeps/$$$env$$$/AsyncTCP-esphome/src/AsyncTCP.h
--- a/.pio/libdeps/$$$env$$$/AsyncTCP-esphome/src/AsyncTCP.h
+++ b/.pio/libdeps/$$$env$$$/AsyncTCP-esphome/src/AsyncTCP.h
@@ -53,6 +53,10 @@
#define CONFIG_ASYNC_TCP_STACK_SIZE 8192 * 2
#endif

+#ifndef CONFIG_ASYNC_TCP_EVENT_QUEUE_SIZE
+#define CONFIG_ASYNC_TCP_EVENT_QUEUE_SIZE 32
+#endif
+
class AsyncClient;

#define ASYNC_MAX_ACK_TIME 5000
13 changes: 0 additions & 13 deletions patches/esp32c3/EspAsyncWebserver.patch

This file was deleted.

13 changes: 7 additions & 6 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ extra_configs =
custom_ci_action = generic,generic_esp32,generic_esp32s3,generic_esp32s3_usb

framework = arduino
platform = espressif32@6.5.0
platform = espressif32@6.6.0

build_flags =
-DPIOENV=\"$PIOENV\"
-D_TASK_STD_FUNCTION=1
-D_TASK_THREAD_SAFE=1
-DCONFIG_ASYNC_TCP_EVENT_QUEUE_SIZE=128
-Wall -Wextra -Wunused -Wmisleading-indentation -Wduplicated-cond -Wlogical-op -Wnull-dereference
; Have to remove -Werror because of
; https://github.com/espressif/arduino-esp32/issues/9044 and
Expand All @@ -36,8 +37,8 @@ build_unflags =
-std=gnu++11

lib_deps =
mathieucarbou/ESP Async WebServer @ 2.8.1
bblanchon/ArduinoJson @ ^6.21.5
mathieucarbou/ESP Async WebServer @ 2.9.0
bblanchon/ArduinoJson @ ^7.0.4
https://github.com/bertmelis/espMqttClient.git#v1.6.0
nrf24/RF24 @ ^1.4.8
olikraus/U8g2 @ ^2.35.15
Expand All @@ -64,7 +65,7 @@ board_build.embed_files =
webapp_dist/js/app.js.gz
webapp_dist/site.webmanifest

custom_patches =
custom_patches = async_tcp

monitor_filters = esp32_exception_decoder, time, log2file, colorize
monitor_speed = 115200
Expand Down Expand Up @@ -92,13 +93,13 @@ build_flags = ${env.build_flags}

[env:generic_esp32c3]
board = esp32-c3-devkitc-02
custom_patches = ${env.custom_patches},esp32c3
custom_patches = ${env.custom_patches}
build_flags = ${env.build_flags}


[env:generic_esp32c3_usb]
board = esp32-c3-devkitc-02
custom_patches = ${env.custom_patches},esp32c3
custom_patches = ${env.custom_patches}
build_flags = ${env.build_flags}
-DARDUINO_USB_MODE=1
-DARDUINO_USB_CDC_ON_BOOT=1
Expand Down
Loading

0 comments on commit 4cf596e

Please sign in to comment.