Add files via upload
This commit is contained in:
parent
e299144f47
commit
80d043e706
@ -16,7 +16,6 @@
|
||||
#define NTP_MAX_TIMEZONEDESCR_STRLEN 50
|
||||
|
||||
#define MQTT_MAX_HOSTNAME_STRLEN 128
|
||||
#define MQTT_MAX_CLIENTID_STRLEN 64
|
||||
#define MQTT_MAX_USERNAME_STRLEN 64
|
||||
#define MQTT_MAX_PASSWORD_STRLEN 64
|
||||
#define MQTT_MAX_TOPIC_STRLEN 32
|
||||
@ -31,6 +30,8 @@
|
||||
|
||||
#define DEV_MAX_MAPPING_NAME_STRLEN 63
|
||||
|
||||
#define JSON_BUFFER_SIZE 12288
|
||||
|
||||
struct CHANNEL_CONFIG_T {
|
||||
uint16_t MaxChannelPower;
|
||||
char Name[CHAN_MAX_NAME_STRLEN];
|
||||
@ -48,7 +49,6 @@ struct INVERTER_CONFIG_T {
|
||||
uint8_t ReachableThreshold;
|
||||
bool ZeroRuntimeDataIfUnrechable;
|
||||
bool ZeroYieldDayOnMidnight;
|
||||
bool ClearEventlogOnMidnight;
|
||||
bool YieldDayCorrection;
|
||||
CHANNEL_CONFIG_T channel[INV_MAX_CHAN_COUNT];
|
||||
};
|
||||
@ -89,7 +89,6 @@ struct CONFIG_T {
|
||||
bool Enabled;
|
||||
char Hostname[MQTT_MAX_HOSTNAME_STRLEN + 1];
|
||||
uint32_t Port;
|
||||
char ClientId[MQTT_MAX_CLIENTID_STRLEN + 1];
|
||||
char Username[MQTT_MAX_USERNAME_STRLEN + 1];
|
||||
char Password[MQTT_MAX_PASSWORD_STRLEN + 1];
|
||||
char Topic[MQTT_MAX_TOPIC_STRLEN + 1];
|
||||
@ -155,6 +154,11 @@ struct CONFIG_T {
|
||||
uint8_t Brightness;
|
||||
} Led_Single[PINMAPPING_LED_COUNT];
|
||||
|
||||
struct {
|
||||
bool R01;
|
||||
bool R02;
|
||||
} Relay;
|
||||
|
||||
INVERTER_CONFIG_T Inverter[INV_MAX_COUNT];
|
||||
char Dev_PinMapping[DEV_MAX_MAPPING_NAME_STRLEN + 1];
|
||||
};
|
||||
|
||||
@ -63,13 +63,14 @@ private:
|
||||
void publishDtuBinarySensor(const char* name, const char* device_class, const char* category, const char* payload_on, const char* payload_off, const char* subTopic = "");
|
||||
void publishInverterField(std::shared_ptr<InverterAbstract> inv, const ChannelType_t type, const ChannelNum_t channel, const byteAssign_fieldDeviceClass_t fieldType, const bool clear = false);
|
||||
void publishInverterButton(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* icon, const char* category, const char* deviceClass, const char* subTopic, const char* payload);
|
||||
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, float step = 1.0);
|
||||
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);
|
||||
void publishBinarySensor(const char* caption, const char* subTopic, const char* payload_on, const char* payload_off);
|
||||
|
||||
static void createInverterInfo(JsonDocument& doc, std::shared_ptr<InverterAbstract> inv);
|
||||
static void createDtuInfo(JsonDocument& doc);
|
||||
static void createInverterInfo(DynamicJsonDocument& doc, std::shared_ptr<InverterAbstract> inv);
|
||||
static void createDtuInfo(DynamicJsonDocument& doc);
|
||||
|
||||
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 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 String getDtuUniqueId();
|
||||
static String getDtuUrl();
|
||||
|
||||
@ -13,9 +13,6 @@ public:
|
||||
|
||||
static String getTopic(std::shared_ptr<InverterAbstract> inv, const ChannelType_t type, const ChannelNum_t channel, const FieldId_t fieldId);
|
||||
|
||||
void subscribeTopics();
|
||||
void unsubscribeTopics();
|
||||
|
||||
private:
|
||||
void loop();
|
||||
void publishField(std::shared_ptr<InverterAbstract> inv, const ChannelType_t type, const ChannelNum_t channel, const FieldId_t fieldId);
|
||||
|
||||
@ -20,7 +20,6 @@ public:
|
||||
void unsubscribe(const String& topic);
|
||||
|
||||
String getPrefix() const;
|
||||
String getClientId();
|
||||
|
||||
private:
|
||||
void NetworkEvent(network_event event);
|
||||
@ -40,4 +39,4 @@ private:
|
||||
std::mutex _clientLock;
|
||||
};
|
||||
|
||||
extern MqttSettingsClass MqttSettings;
|
||||
extern MqttSettingsClass MqttSettings;
|
||||
@ -39,6 +39,10 @@ struct PinMapping_t {
|
||||
uint8_t display_cs;
|
||||
uint8_t display_reset;
|
||||
int8_t led[PINMAPPING_LED_COUNT];
|
||||
|
||||
uint8_t relay_r01;
|
||||
uint8_t relay_r02;
|
||||
|
||||
};
|
||||
|
||||
class PinMappingClass {
|
||||
@ -55,4 +59,4 @@ private:
|
||||
PinMapping_t _pinMapping;
|
||||
};
|
||||
|
||||
extern PinMappingClass PinMapping;
|
||||
extern PinMappingClass PinMapping;
|
||||
|
||||
24
include/Relay.h
Normal file
24
include/Relay.h
Normal file
@ -0,0 +1,24 @@
|
||||
#include "PinMapping.h"
|
||||
#include <TaskSchedulerDeclarations.h>
|
||||
#include <TimeoutHelper.h>
|
||||
|
||||
class Relay
|
||||
{
|
||||
public:
|
||||
static const uint8_t ON = 0; //!< Relay state: on.
|
||||
static const uint8_t OFF = 1; //!< Relay state: off.
|
||||
|
||||
Relay(uint8_t pin);
|
||||
void on(); //!< Turns the relay on.
|
||||
void off(); //!< Turns the relay off.
|
||||
void toggle(); //!< Toggles the relay state.
|
||||
boolean isStat(); //!< @return True iff the relay is on.
|
||||
|
||||
uint8_t getState(); //!< @return The current relay state (Relay::OFF or Relay::ON).
|
||||
void setState(uint8_t state //!< The new state to switch to (Relay::OFF or Relay::ON).
|
||||
); //!< Sets a relay state.
|
||||
|
||||
protected:
|
||||
uint8_t _state; //!< state model
|
||||
uint8_t _pin; //!< pin model
|
||||
};
|
||||
@ -10,6 +10,6 @@ public:
|
||||
static uint64_t generateDtuSerial();
|
||||
static int getTimezoneOffset();
|
||||
static void restartDtu();
|
||||
static bool checkJsonAlloc(const JsonDocument& doc, const char* function, const uint16_t line);
|
||||
static bool checkJsonAlloc(const DynamicJsonDocument& doc, const char* function, const uint16_t line);
|
||||
static void removeAllFiles();
|
||||
};
|
||||
|
||||
@ -17,12 +17,12 @@
|
||||
#include "WebApi_ntp.h"
|
||||
#include "WebApi_power.h"
|
||||
#include "WebApi_prometheus.h"
|
||||
#include "WebApi_relay.h"
|
||||
#include "WebApi_security.h"
|
||||
#include "WebApi_sysstatus.h"
|
||||
#include "WebApi_webapp.h"
|
||||
#include "WebApi_ws_console.h"
|
||||
#include "WebApi_ws_live.h"
|
||||
#include <AsyncJson.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <TaskSchedulerDeclarations.h>
|
||||
|
||||
@ -38,10 +38,6 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
@ -65,6 +61,7 @@ private:
|
||||
WebApiWebappClass _webApiWebapp;
|
||||
WebApiWsConsoleClass _webApiWsConsole;
|
||||
WebApiWsLiveClass _webApiWsLive;
|
||||
WebApiRelayClass _webApiRelay;
|
||||
};
|
||||
|
||||
extern WebApiClass WebApi;
|
||||
|
||||
@ -5,11 +5,10 @@ enum WebApiError {
|
||||
GenericBase = 1000,
|
||||
GenericSuccess,
|
||||
GenericNoValueFound,
|
||||
GenericDataTooLarge, // not used anymore
|
||||
GenericDataTooLarge,
|
||||
GenericParseError,
|
||||
GenericValueMissing,
|
||||
GenericWriteFailed,
|
||||
GenericInternalServerError,
|
||||
|
||||
DtuBase = 2000,
|
||||
DtuSerialZero,
|
||||
@ -60,7 +59,6 @@ enum WebApiError {
|
||||
MqttHassTopicLength,
|
||||
MqttHassTopicCharacter,
|
||||
MqttLwtQos,
|
||||
MqttClientIdLength,
|
||||
|
||||
NetworkBase = 8000,
|
||||
NetworkIpInvalid,
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <TaskSchedulerDeclarations.h>
|
||||
|
||||
#define MQTT_JSON_DOC_SIZE 10240
|
||||
|
||||
class WebApiMqttClass {
|
||||
public:
|
||||
void init(AsyncWebServer& server, Scheduler& scheduler);
|
||||
|
||||
16
include/WebApi_relay.h
Normal file
16
include/WebApi_relay.h
Normal file
@ -0,0 +1,16 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#pragma once
|
||||
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <TaskSchedulerDeclarations.h>
|
||||
|
||||
class WebApiRelayClass {
|
||||
public:
|
||||
void init(AsyncWebServer& server, Scheduler& scheduler);
|
||||
|
||||
private:
|
||||
void onRelayGet(AsyncWebServerRequest* request);
|
||||
void onRelayPost(AsyncWebServerRequest* request);
|
||||
|
||||
void onAuthenticateGet(AsyncWebServerRequest* request);
|
||||
};
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
#define ACCESS_POINT_NAME "OpenDTU-"
|
||||
#define ACCESS_POINT_PASSWORD "openDTU42"
|
||||
#define ACCESS_POINT_TIMEOUT 3
|
||||
#define ACCESS_POINT_TIMEOUT 3;
|
||||
#define AUTH_USERNAME "admin"
|
||||
#define SECURITY_ALLOW_READONLY true
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user