style: apply consistent code formatting and spacing

This commit is contained in:
2026-02-17 04:15:48 -08:00
parent f39364f67f
commit 8e9bd18676
13 changed files with 217 additions and 223 deletions

View File

@@ -4,44 +4,44 @@
void NetManager::begin(const WiFiCred* creds, int count) {
WiFi.mode(WIFI_STA);
for (int i = 0; i < count; i++)
for(int i = 0; i < count; i++)
_multi.addAP(creds[i].ssid, creds[i].pass);
Serial.println("[WIFI] Connecting...");
unsigned long t0 = millis();
while (_multi.run() != WL_CONNECTED) {
if (millis() - t0 > WIFI_CONNECT_TIMEOUT_MS) {
while(_multi.run() != WL_CONNECTED) {
if(millis() - t0 > WIFI_CONNECT_TIMEOUT_MS) {
Serial.println("[WIFI] Timeout!");
return;
}
delay(250);
}
Serial.printf("[WIFI] Connected: %s %s\n",
getSSID().c_str(), getIP().c_str());
Serial.printf("[WIFI] Connected: %s %s\n", getSSID().c_str(), getIP().c_str());
}
bool NetManager::checkConnection() {
if (WiFi.status() == WL_CONNECTED) return true;
if(WiFi.status() == WL_CONNECTED)
return true;
Serial.println("[WIFI] Reconnecting...");
return _multi.run(WIFI_CONNECT_TIMEOUT_MS) == WL_CONNECTED;
}
bool NetManager::isConnected() { return WiFi.status() == WL_CONNECTED; }
String NetManager::getSSID() { return WiFi.SSID(); }
String NetManager::getIP() { return WiFi.localIP().toString(); }
int NetManager::getRSSI() { return WiFi.RSSI(); }
bool NetManager::isConnected() { return WiFi.status() == WL_CONNECTED; }
String NetManager::getSSID() { return WiFi.SSID(); }
String NetManager::getIP() { return WiFi.localIP().toString(); }
int NetManager::getRSSI() { return WiFi.RSSI(); }
// ── NTP ─────────────────────────────────────────────────────
bool NetManager::syncNTP() {
Serial.println("[NTP] Starting sync...");
if (!_ntp) _ntp = new NTPClient(_udp, "pool.ntp.org", 0, 60000);
if(!_ntp)
_ntp = new NTPClient(_udp, "pool.ntp.org", 0, 60000);
_ntp->begin();
_ntp->forceUpdate();
_ntpReady = _ntp->isTimeSet();
Serial.printf("[NTP] %s: %s UTC\n",
_ntpReady ? "Synced" : "FAILED",
_ntpReady ? _ntp->getFormattedTime().c_str() : "--");
Serial.printf("[NTP] %s: %s UTC\n", _ntpReady ? "Synced" : "FAILED",
_ntpReady ? _ntp->getFormattedTime().c_str() : "--");
return _ntpReady;
}
@@ -54,8 +54,7 @@ String NetManager::getTimeStr() {
bool NetManager::dnsCheck(const char* host) {
IPAddress ip;
bool ok = WiFi.hostByName(host, ip);
Serial.printf("[NET] DNS %s: %s\n", ok ? "OK" : "FAIL",
ok ? ip.toString().c_str() : "");
Serial.printf("[NET] DNS %s: %s\n", ok ? "OK" : "FAIL", ok ? ip.toString().c_str() : "");
return ok;
}
@@ -64,7 +63,8 @@ bool NetManager::tlsCheck(const char* host) {
c.setInsecure();
c.setTimeout(HTTP_TIMEOUT_MS);
bool ok = c.connect(host, 443);
if (ok) c.stop();
if(ok)
c.stop();
Serial.printf("[NET] TLS %s\n", ok ? "OK" : "FAIL");
return ok;
}
@@ -81,7 +81,8 @@ int NetManager::httpGet(const char* url, String& response) {
http.begin(client, url);
int code = http.GET();
if (code > 0) response = http.getString();
if(code > 0)
response = http.getString();
http.end();
return code;
}