-
-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Wireguard Tunnel #524
Open
janchri
wants to merge
49
commits into
tbnobody:master
Choose a base branch
from
janchri:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
ee20151
quick & dirty wireguard version for openDTU
janchri f69ecb5
Plaformio_override.ini update
janchri b8376cb
Fix timezone/configTime() in beginWireGuard()
janchri 245cdb0
Add wireguard to Configuration.h & WebApi
janchri cddde6c
Fix linking error -> class name was wrong in WebApi_wireguard.cpp
janchri 177fa4d
fix typo
janchri 1cf3abc
Minor fixes due to code quality
janchri 1147b34
Create new Class Files for Wireguard; improve encapsulation
janchri 3e0a9da
wireguardclass created; better encapsulation
janchri f71f8c0
changed gitignore for debugging, added private keys
janchri 3497dcb
minor fix: typo + defaults_wireguard.h added for storing secret keys/…
janchri 5fb1789
Merge branch 'tbnobody:master' into master
janchri 71591aa
fix array length of key variable to [45]
janchri aeec268
v3.2.2
janchri e3e3c87
Minor fixes in backend + first frontend integration for wireguard
janchri 5c52cad
Fix language files; added EN, FR missing!
janchri 269075d
restart needed for wireguard setup changes; working on a fix
janchri 4ec13fb
Merge branch 'tbnobody:master' into master
janchri 0294f2e
Update vuejs frontend
janchri 92ad765
fix .gitignore
janchri 0cb91b7
quick & dirty wireguard version for openDTU
janchri 9ec6a3a
Plaformio_override.ini update
janchri e8e10f7
Fix timezone/configTime() in beginWireGuard()
janchri 21c6e5b
Add wireguard to Configuration.h & WebApi
janchri ff21d4d
Fix linking error -> class name was wrong in WebApi_wireguard.cpp
janchri d54c1ed
fix typo
janchri f7f939a
Minor fixes due to code quality
janchri ffebfaa
Create new Class Files for Wireguard; improve encapsulation
janchri 9f62701
wireguardclass created; better encapsulation
janchri e970e52
changed gitignore for debugging, added private keys
janchri 9b76496
minor fix: typo + defaults_wireguard.h added for storing secret keys/…
janchri 46bcfb5
fix array length of key variable to [45]
janchri d1e9ab7
v3.2.2
janchri 7732e07
Minor fixes in backend + first frontend integration for wireguard
janchri 3cc7f05
Fix language files; added EN, FR missing!
janchri b8ce458
restart needed for wireguard setup changes; working on a fix
janchri 52c55b9
Update vuejs frontend
janchri 5743df3
fix .gitignore
janchri 7db01c9
merge upstream/master and wireguard
janchri 7ca107c
merge frontend app.js.gz
janchri bd201b9
Merge remote-tracking branch 'upstream/master'
janchri bb996fc
merge apps.js.gz with upstream/master
janchri de21805
Merge remote-tracking branch 'upstream/master'
janchri 76b730b
Merge branch 'master' of https://github.com/tbnobody/OpenDTU
janchri a3a06cc
Merge upstream/master
janchri 29ad6b2
Merge upstream/master webapp
janchri d8440f6
added allowedIp/allowedMask + Shelly3em support
janchri c23218e
set shelly to 3sec polling
janchri 01a7b2e
Shelly 3sec polling
janchri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"C_Cpp.clang_format_style": "WebKit" | ||
"C_Cpp.clang_format_style": "WebKit", | ||
"files.associations": { | ||
"tcpip_adapter.h": "c" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <HTTPClient.h> | ||
|
||
class MqttHandleShelly3EMClass { | ||
public: | ||
void init(); | ||
void loop(); | ||
|
||
private: | ||
uint32_t _lastPublish; | ||
HTTPClient http; | ||
}; | ||
|
||
extern MqttHandleShelly3EMClass MqttHandleShelly3EM; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
#pragma once | ||
|
||
#include <ESPAsyncWebServer.h> | ||
|
||
class WebApiWireguardClass { | ||
public: | ||
void init(AsyncWebServer* server); | ||
void loop(); | ||
|
||
private: | ||
void onWireguardStatus(AsyncWebServerRequest* request); | ||
void onWireguardAdminGet(AsyncWebServerRequest* request); | ||
void onWireguardAdminPost(AsyncWebServerRequest* request); | ||
|
||
AsyncWebServer* _server; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
#pragma once | ||
|
||
#include <WireGuard-ESP32.h> | ||
|
||
class WireguardSettingsClass { | ||
public: | ||
WireguardSettingsClass(); | ||
void init(); | ||
void loop(); | ||
|
||
private: | ||
WireGuard wg; | ||
void endWireGuard(); | ||
void beginWireGuard(); | ||
}; | ||
|
||
extern WireguardSettingsClass WireguardSettings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* | ||
* Copyright (C) 2023 Christoph Jans and others | ||
*/ | ||
#include "MqttHandleShelly3EM.h" | ||
#include "Configuration.h" | ||
#include "MqttSettings.h" | ||
#include "NetworkSettings.h" | ||
#include <Hoymiles.h> | ||
#include "MessageOutput.h" | ||
#include <ArduinoJson.h> | ||
|
||
MqttHandleShelly3EMClass MqttHandleShelly3EM; | ||
|
||
void MqttHandleShelly3EMClass::init() | ||
{ | ||
http.setReuse(true); | ||
} | ||
|
||
void MqttHandleShelly3EMClass::loop() | ||
{ | ||
if ( !MqttSettings.getConnected() ) { | ||
return; | ||
} | ||
|
||
//const CONFIG_T& config = Configuration.get(); | ||
//if (millis() - _lastPublish > (config.Mqtt_PublishInterval * 1000)) { | ||
if (millis() - _lastPublish > (3 * 999)) { | ||
// Send request | ||
MessageOutput.println(F("Polling SHEM-3... ")); | ||
http.begin("http://192.168.1.103/status"); | ||
int httpCode = http.GET(); | ||
|
||
if (httpCode == 200) { | ||
// Parse response | ||
DynamicJsonDocument doc(2048); | ||
DeserializationError error = deserializeJson(doc, http.getStream()); | ||
|
||
// Check for errors | ||
if (error) { | ||
MessageOutput.print(F("deserializeJson() failed: ")); | ||
MessageOutput.println(error.c_str()); | ||
} else{ | ||
// Publish values | ||
MqttSettings.publishGeneric("shelly3EM/type", "SHEM-3", 0, Configuration.get().Mqtt_Retain); | ||
MqttSettings.publishGeneric("shelly3EM/status/unixtime", doc["unixtime"], 0, Configuration.get().Mqtt_Retain); | ||
MqttSettings.publishGeneric("shelly3EM/status/total_power", doc["total_power"], 0, Configuration.get().Mqtt_Retain); | ||
|
||
int i = 0; | ||
for (JsonObject emeter : doc["emeters"].as<JsonArray>()) { | ||
MqttSettings.publishGeneric("shelly3EM/status/"+String(i)+"/power", emeter["power"], 0, Configuration.get().Mqtt_Retain); | ||
MqttSettings.publishGeneric("shelly3EM/status/"+String(i)+"/pf", emeter["pf"], 0, Configuration.get().Mqtt_Retain); | ||
MqttSettings.publishGeneric("shelly3EM/status/"+String(i)+"/current", emeter["current"], 0, Configuration.get().Mqtt_Retain); | ||
MqttSettings.publishGeneric("shelly3EM/status/"+String(i)+"/voltage", emeter["voltage"], 0, Configuration.get().Mqtt_Retain); | ||
MqttSettings.publishGeneric("shelly3EM/status/"+String(i)+"/is_valid", emeter["is_valid"], 0, Configuration.get().Mqtt_Retain); | ||
MqttSettings.publishGeneric("shelly3EM/status/"+String(i)+"/total", emeter["total"], 0, Configuration.get().Mqtt_Retain); | ||
MqttSettings.publishGeneric("shelly3EM/status/"+String(i)+"/total_returned", emeter["total_returned"], 0, Configuration.get().Mqtt_Retain); | ||
i++; | ||
} | ||
} | ||
} | ||
else{ | ||
// Falls HTTP-Error | ||
MessageOutput.println("Shelly 3EM Connection Error: " + String(httpCode)); | ||
} | ||
_lastPublish = millis(); | ||
|
||
// Disconnect | ||
http.end(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to pin the exact version so this stays reproducible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ESPHome uses this in their platformio.ini:
droscy/[email protected] ; wireguard
@janchri would it be better to use the Library that Tomoyuki Sakurai created for ESP-IDF and Simone Rosetto already maintains for ESPHOME ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And that is also fork because of some esphome optimizations, but works perfectly.
Maybe it make sense to start new attempt with this "esphome" fork...