Skip to content

Commit

Permalink
check if wifi is connected before wireguard
Browse files Browse the repository at this point in the history
  • Loading branch information
pr3y committed May 7, 2024
1 parent 472ca9b commit df79552
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/wg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ void read_and_parse_file() {
void wg_setup()
{
read_and_parse_file();

if (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print("Connect to wifi before using wireguard");
displayRedStripe("CONNECT TO WIFI",TFT_WHITE, TFT_RED);
delay(5000);
return;
}

Serial.println("Adjusting system time...");
configTime(9 * 60 * 60, 0, "ntp.jst.mfeed.ad.jp", "ntp.nict.jp");
Expand Down
1 change: 1 addition & 0 deletions src/wg.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <SPIFFS.h>
#include <WiFi.h>

extern bool is_connected;

Expand Down

0 comments on commit df79552

Please sign in to comment.