Skip to content

Commit

Permalink
Ensure sntp complete before start wireguard, use built-in light to sh…
Browse files Browse the repository at this point in the history
…ow wifi connection and sntp warning
  • Loading branch information
weilinfox committed Sep 11, 2022
1 parent c456b45 commit 5aeab32
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "main.h"
#include "config.h"
#include "time.h"
#include "esp_sntp.h"
#include <ESP32Servo.h>
#include <WiFi.h>
#include "camera_pins.h"
Expand Down Expand Up @@ -119,21 +120,27 @@ void setup() {
#ifdef WLAN_UART_CONFIGURABLE
}
#endif
if(WiFi.waitForConnectResult() == WL_CONNECTED) {
Serial.println("done.");
} else {
// uart0.println("failed.");
analogWrite(LED_FLASH, 0);
if(WiFi.waitForConnectResult() != WL_CONNECTED) {
while(! WiFi.isConnected()) {
uart0.println("Wifi is not connected.");
analogWrite(LED_FLASH, 10);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
analogWrite(LED_FLASH, 0);
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
}
}
uart0.println("done.");

uart0.print("Start configTime: ");
uart0.print("Start sync time: ");
configTime(8 * 60 * 60, 0, ntp_server1, ntp_server2, ntp_server3);
while (sntp_get_sync_status() != SNTP_SYNC_STATUS_COMPLETED) {
uart0.println("SNTP is not completed.");
digitalWrite(LED_BUILTIN, LOW);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
}
uart0.println("done.");

uart0.print("Starting web server: ");
Expand Down

0 comments on commit 5aeab32

Please sign in to comment.