Skip to content

Commit

Permalink
Merge upstream tag 'v24.9.30' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen committed Sep 30, 2024
2 parents cbad181 + 99a37fe commit 185ac36
Show file tree
Hide file tree
Showing 32 changed files with 1,220 additions and 261 deletions.
137 changes: 136 additions & 1 deletion docs/DeviceProfiles/opendtu_fusion.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[
{
"name": "OpenDTU Fusion v1",
"links": [
{"name": "Information", "url": "https://github.com/markusdd/OpenDTUFusionDocs"}
],
"nrf24": {
"miso": 48,
"mosi": 35,
Expand All @@ -25,6 +28,9 @@
},
{
"name": "OpenDTU Fusion v1 with SSD1306 Display",
"links": [
{"name": "Information", "url": "https://github.com/markusdd/OpenDTUFusionDocs"}
],
"nrf24": {
"miso": 48,
"mosi": 35,
Expand Down Expand Up @@ -54,6 +60,9 @@
},
{
"name": "OpenDTU Fusion v1 with SH1106 Display",
"links": [
{"name": "Information", "url": "https://github.com/markusdd/OpenDTUFusionDocs"}
],
"nrf24": {
"miso": 48,
"mosi": 35,
Expand Down Expand Up @@ -83,6 +92,9 @@
},
{
"name": "OpenDTU Fusion v2 with CMT2300A and NRF24",
"links": [
{"name": "Information", "url": "https://github.com/markusdd/OpenDTUFusionDocs"}
],
"nrf24": {
"miso": 48,
"mosi": 35,
Expand Down Expand Up @@ -115,6 +127,9 @@
},
{
"name": "OpenDTU Fusion v2 with CMT2300A, NRF24 and SH1106 Display",
"links": [
{"name": "Information", "url": "https://github.com/markusdd/OpenDTUFusionDocs"}
],
"nrf24": {
"miso": 48,
"mosi": 35,
Expand Down Expand Up @@ -152,6 +167,9 @@
},
{
"name": "OpenDTU Fusion v2 with CMT2300A, NRF24 and SSD1306 Display",
"links": [
{"name": "Information", "url": "https://github.com/markusdd/OpenDTUFusionDocs"}
],
"nrf24": {
"miso": 48,
"mosi": 35,
Expand Down Expand Up @@ -186,5 +204,122 @@
"data": 2,
"clk": 1
}
},
{
"name": "OpenDTU Fusion v2 PoE",
"links": [
{"name": "Information", "url": "https://github.com/markusdd/OpenDTUFusionDocs"}
],
"nrf24": {
"miso": 48,
"mosi": 35,
"clk": 36,
"irq": 47,
"en": 38,
"cs": 37
},
"cmt": {
"clk": 6,
"cs": 4,
"fcs": 21,
"sdio": 5,
"gpio2": 3,
"gpio3": 8
},
"w5500": {
"mosi": 40,
"miso": 41,
"sclk": 39,
"cs": 42,
"int": 44,
"rst": 43
},
"led": {
"led0": 17,
"led1": 18
},
"display": {
"type": 0,
"data": 2,
"clk": 1
}
},
{
"name": "OpenDTU Fusion v2 PoE with SH1106 Display",
"links": [
{"name": "Information", "url": "https://github.com/markusdd/OpenDTUFusionDocs"}
],
"nrf24": {
"miso": 48,
"mosi": 35,
"clk": 36,
"irq": 47,
"en": 38,
"cs": 37
},
"cmt": {
"clk": 6,
"cs": 4,
"fcs": 21,
"sdio": 5,
"gpio2": 3,
"gpio3": 8
},
"w5500": {
"mosi": 40,
"miso": 41,
"sclk": 39,
"cs": 42,
"int": 44,
"rst": 43
},
"led": {
"led0": 17,
"led1": 18
},
"display": {
"type": 3,
"data": 2,
"clk": 1
}
},
{
"name": "OpenDTU Fusion v2 PoE with SSD1306 Display",
"links": [
{"name": "Information", "url": "https://github.com/markusdd/OpenDTUFusionDocs"}
],
"nrf24": {
"miso": 48,
"mosi": 35,
"clk": 36,
"irq": 47,
"en": 38,
"cs": 37
},
"cmt": {
"clk": 6,
"cs": 4,
"fcs": 21,
"sdio": 5,
"gpio2": 3,
"gpio3": 8
},
"w5500": {
"mosi": 40,
"miso": 41,
"sclk": 39,
"cs": 42,
"int": 44,
"rst": 43
},
"led": {
"led0": 17,
"led1": 18
},
"display": {
"type": 2,
"data": 2,
"clk": 1
}
}
]
]
8 changes: 5 additions & 3 deletions include/NetworkSettings.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include "W5500.h"
#include <DNSServer.h>
#include <TaskSchedulerDeclarations.h>
#include <WiFi.h>
Expand All @@ -23,10 +24,10 @@ enum class network_event {
NETWORK_EVENT_MAX
};

typedef std::function<void(network_event event)> NetworkEventCb;
typedef std::function<void(network_event event)> DtuNetworkEventCb;

typedef struct NetworkEventCbList {
NetworkEventCb cb;
DtuNetworkEventCb cb;
network_event event;

NetworkEventCbList()
Expand All @@ -53,7 +54,7 @@ class NetworkSettingsClass {
bool isConnected() const;
network_mode NetworkMode() const;

bool onEvent(NetworkEventCb cbEvent, const network_event event = network_event::NETWORK_EVENT_MAX);
bool onEvent(DtuNetworkEventCb cbEvent, const network_event event = network_event::NETWORK_EVENT_MAX);
void raiseEvent(const network_event event);

private:
Expand Down Expand Up @@ -83,6 +84,7 @@ class NetworkSettingsClass {
bool _ethConnected = false;
std::vector<NetworkEventCbList_t> _cbEventList;
bool _lastMdnsEnabled = false;
std::unique_ptr<W5500> _w5500;
};

extern NetworkSettingsClass NetworkSettings;
8 changes: 8 additions & 0 deletions include/PinMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ struct PinMapping_t {
int8_t cmt_gpio3;
int8_t cmt_sdio;

int8_t w5500_mosi;
int8_t w5500_miso;
int8_t w5500_sclk;
int8_t w5500_cs;
int8_t w5500_int;
int8_t w5500_rst;

int8_t eth_phy_addr;
bool eth_enabled;
int eth_power;
Expand Down Expand Up @@ -72,6 +79,7 @@ class PinMappingClass {

bool isValidNrf24Config() const;
bool isValidCmt2300Config() const;
bool isValidW5500Config() const;
bool isValidEthConfig() const;
bool isValidHuaweiConfig() const;

Expand Down
29 changes: 29 additions & 0 deletions include/W5500.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include <Arduino.h>
#include <driver/spi_master.h>
#include <esp_eth.h> // required for esp_eth_handle_t
#include <esp_netif.h>

#include <memory>

class W5500 {
private:
explicit W5500(spi_device_handle_t spi, gpio_num_t pin_int);

public:
W5500(const W5500&) = delete;
W5500& operator=(const W5500&) = delete;
~W5500();

static std::unique_ptr<W5500> setup(int8_t pin_mosi, int8_t pin_miso, int8_t pin_sclk, int8_t pin_cs, int8_t pin_int, int8_t pin_rst);
String macAddress();

private:
static bool connection_check_spi(spi_device_handle_t spi);
static bool connection_check_interrupt(gpio_num_t pin_int);

esp_eth_handle_t eth_handle;
esp_netif_t* eth_netif;
};
1 change: 1 addition & 0 deletions include/WebApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class WebApiClass {
public:
WebApiClass();
void init(Scheduler& scheduler);
void reload();

static bool checkCredentials(AsyncWebServerRequest* request);
static bool checkCredentialsReadonly(AsyncWebServerRequest* request);
Expand Down
2 changes: 2 additions & 0 deletions include/WebApi_ws_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ class WebApiWsConsoleClass {
public:
WebApiWsConsoleClass();
void init(AsyncWebServer& server, Scheduler& scheduler);
void reload();

private:
AsyncWebSocket _ws;
AuthenticationMiddleware _simpleDigestAuth;

Task _wsCleanupTask;
void wsCleanupTaskCb();
Expand Down
2 changes: 2 additions & 0 deletions include/WebApi_ws_live.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class WebApiWsLiveClass {
public:
WebApiWsLiveClass();
void init(AsyncWebServer& server, Scheduler& scheduler);
void reload();

private:
static void generateInverterCommonJsonResponse(JsonObject& root, std::shared_ptr<InverterAbstract> inv);
Expand All @@ -27,6 +28,7 @@ class WebApiWsLiveClass {
void onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len);

AsyncWebSocket _ws;
AuthenticationMiddleware _simpleDigestAuth;

uint32_t _lastPublishOnBatteryFull = 0;
uint32_t _lastPublishVictron = 0;
Expand Down
Loading

0 comments on commit 185ac36

Please sign in to comment.