/* ESP32 WiFi Scanning example */
#include "WiFi.h"
#include <WireGuard-ESP32.h>
#include <ESPping.h>
static WireGuard wg;
IPAddress targetIP(10, 210, 144, 3); // Indirizzo IP di destinazione
char private_key[] = "mGAMbZ3A++ohXg4WutpP+6cvJf2myk78YjcetsA0Z3w="; // [Interface] PrivateKey
IPAddress local_ip(10, 210, 144, 9); // [Interface] Address
char public_key[] = "JJkxVh3E9kVrf0zlUllBTKqPSGUfxi7Ptgm2cByljlM="; // [Peer] PublicKey
char endpoint_address[] = "vpn.mauromidolo.com"; // [Peer] Endpoint
int endpoint_port = 51820; // [Peer] Endpoint
void setup() {
Serial.begin(115200);
WiFi.begin("Wokwi-GUEST");
Serial.print("Connessione in corso");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnesso alla rete WiFi");
Serial.print("Indirizzo IP: ");
Serial.println(WiFi.localIP());
Serial.println("Adjusting system time...");
configTime(9 * 60 * 60, 0, "ntp.jst.mfeed.ad.jp", "ntp.nict.jp", "time.google.com");
Serial.println("\Connessione in corso alla rete VPN");
wg.begin(
local_ip,
private_key,
endpoint_address,
public_key,
endpoint_port);
Serial.println("\nConnesso alla rete VPN");
}
void loop() {
bool pingResult = Ping.ping(targetIP);
if (pingResult) {
Serial.print("Risposta da ");
Serial.print(targetIP);
Serial.print(" in ");
Serial.print(Ping.averageTime());
Serial.println(" ms");
} else {
Serial.println("Ping non riuscito");
}
// Wait a bit before scanning again
//delay(2000);
}