You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running Wireguard on a raspberry pi. I can connect with a number of devices (Windows, Android) and everything appears to be setup properly. I am trying to setup an ESP32 with a web server, but web server times out trying to load the web page. When I turn off wireguard I am able to access the webserver. Any advice?
// Connect to wifi
void wg_connect() {
Serial.print("WireGuard IP1: ");
Serial.println(local_ip.toString());
if (wg.begin(
local_ip, // IP address of the local interface
private_key, // Private key of the local interface
remote_address, // Address of the endpoint peer.
public_key, // Public key of the endpoint peer.
remote_port)) { // Port pf the endpoint peer.
Serial.println("WG connected2");
I am running Wireguard on a raspberry pi. I can connect with a number of devices (Windows, Android) and everything appears to be setup properly. I am trying to setup an ESP32 with a web server, but web server times out trying to load the web page. When I turn off wireguard I am able to access the webserver. Any advice?
#define DEVMODE 0 // - comment out for production mode (remove print statements)
#include <EEPROM.h>
#include <TimeLib.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebSerialLite.h>
#include <AsyncTCP.h>
#include <AsyncElegantOTA.h>
#include <ESPAsyncWebServer.h>
#include <esp_task_wdt.h>
#include <WireGuard-ESP32.h>
#include <ESPping.h>
#define PRINTLN(...) Serial.println(VA_ARGS); WebSerial.println(VA_ARGS); wifi_send(t_state,String(VA_ARGS),true)
#define PRINT(...) Serial.print(VA_ARGS); WebSerial.print(VA_ARGS); wifi_send(t_state,String(VA_ARGS))
#define PRINTLN2(...) Serial.println(VA_ARGS); WebSerial.println(VA_ARGS)
#define PRINT2(...) Serial.print(VA_ARGS); WebSerial.print(VA_ARGS)
// #define PRINTLN(...)
// #define PRINT(...)
// WIFI communication constants
#define wifi_retry_max 500
#define host "10.6.0.1"
#define ssid "xxxx"
#define password "yyyy"
#define private_key "zzz"
#define remote_address "xxxxx.duckdns.org"
#define public_key "aaaaa"
#define remote_port 51820
WiFiClient client;
static WireGuard wg;
IPAddress local_ip(10,6,0,6);
// Define OTA variables
AsyncWebServer server(80);
const char* serverIndex = "<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">\n<title>ZHM Garage</title>\n<a href=""/update"">Update firmware
<a href=""/webserial"">Web Serial
<a href=""/vars"">Variables";
void setup() {
Serial.begin(115200);
WiFi.onEvent(Wifi_connected,ARDUINO_EVENT_WIFI_STA_CONNECTED);
WiFi.onEvent(Get_IPAddress, ARDUINO_EVENT_WIFI_STA_GOT_IP);
WiFi.onEvent(Wifi_disconnected, ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
WiFi.begin(ssid, password);
delay(5000);
AsyncElegantOTA.begin(&server);
WebSerial.begin(&server);
server.begin();
}
// Main processing loop
void loop() {
if (!wg_connected) {
Serial.println("Attempting WG connection");
wg_connect();
}
//Format variable page
String SendHTML(){
String ptr = " \n";
ptr +="<meta name="viewport" content="no-cache" content="width=device-width, initial-scale=1.0, user-scalable=no">\n";
ptr +="<title>Boat Warehouse variables</title>\n";
ptr +="\n";
ptr +="
Boat Warehouse variables
\n";ptr +="\n";
ptr +="<form action="/get">";
ptr +="Debug Switch: <input type="number" value="";
ptr +=(String)debug_sw;
ptr +="" name="debug_sw">";
ptr +="<input type="submit" value="Submit">";
ptr +="
";
ptr +="<form action="/get">";
ptr +="Reboot: <input type="number" value="" name="reboot">";
ptr +="<input type="submit" value="Submit">";
ptr +="
";
ptr +="<form action="/get">";
ptr +="Alarm set on/off: <input type="number" value="" name="alarmoff">";
ptr +="<input type="submit" value="Submit">";
ptr +="
";
ptr +="<div id="webpage">\n";
ptr +="
Horn Status: ";
";ptr +=(String)state[s_horn_status];
ptr +="
ptr +="\n";
ptr +="\n";
ptr +="\n";
return ptr;
}
//WIFI Connected
void Wifi_connected(WiFiEvent_t event, WiFiEventInfo_t info){
// wifi_connected = true;
Serial.println("WIFI Connected");
}
// WIFI IP address assigned
void Get_IPAddress(WiFiEvent_t event, WiFiEventInfo_t info){
Serial.print("WiFi connected with IP: ");
Serial.println(WiFi.localIP());
configTime(9 * 60 * 60, 0, "ntp.jst.mfeed.ad.jp", "ntp.nict.jp", "time.google.com");
wg_connect();
client_connect();
}
// WIF disconnected
void Wifi_disconnected(WiFiEvent_t event, WiFiEventInfo_t info){
Serial.println("Disconnected from WIFI access point");
// Serial.print("WiFi lost connection. Reason: ");
// Serial.println(info.disconnected.reason);
Serial.println("Reconnecting...");
WiFi.begin(ssid, password);
}
// Connect to wifi
void wg_connect() {
Serial.print("WireGuard IP1: ");
Serial.println(local_ip.toString());
if (wg.begin(
local_ip, // IP address of the local interface
private_key, // Private key of the local interface
remote_address, // Address of the endpoint peer.
public_key, // Public key of the endpoint peer.
remote_port)) { // Port pf the endpoint peer.
Serial.println("WG connected2");
Serial.println(local_ip.toString());
wg_connected = true;
}
The text was updated successfully, but these errors were encountered: