2024-04-03 11:40:46 +07:00
|
|
|
#include "AgWiFiConnector.h"
|
2024-04-04 18:35:15 +07:00
|
|
|
#include "Libraries/WiFiManager/WiFiManager.h"
|
2024-04-03 11:40:46 +07:00
|
|
|
|
2024-06-19 15:17:48 +07:00
|
|
|
#define WIFI_CONNECT_COUNTDOWN_MAX 180
|
2024-04-03 21:26:04 +07:00
|
|
|
#define WIFI_HOTSPOT_PASSWORD_DEFAULT "cleanair"
|
|
|
|
|
|
|
|
#define WIFI() ((WiFiManager *)(this->wifi))
|
|
|
|
|
2024-04-04 18:35:15 +07:00
|
|
|
/**
|
2024-04-07 16:39:01 +07:00
|
|
|
* @brief Set reference AirGradient instance
|
2024-04-04 18:35:15 +07:00
|
|
|
*
|
2024-04-07 16:39:01 +07:00
|
|
|
* @param ag Point to AirGradient instance
|
2024-04-04 18:35:15 +07:00
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
void WifiConnector::setAirGradient(AirGradient *ag) { this->ag = ag; }
|
2024-04-03 21:26:04 +07:00
|
|
|
|
2024-04-04 18:35:15 +07:00
|
|
|
/**
|
2024-04-07 16:39:01 +07:00
|
|
|
* @brief Construct a new Ag Wi Fi Connector:: Ag Wi Fi Connector object
|
2024-04-04 18:35:15 +07:00
|
|
|
*
|
2024-04-07 16:39:01 +07:00
|
|
|
* @param disp OledDisplay
|
|
|
|
* @param log Stream
|
|
|
|
* @param sm StateMachine
|
2024-04-04 18:35:15 +07:00
|
|
|
*/
|
2024-04-12 06:18:48 +07:00
|
|
|
WifiConnector::WifiConnector(OledDisplay &disp, Stream &log, StateMachine &sm,
|
|
|
|
Configuration &config)
|
2024-04-11 06:33:56 +07:00
|
|
|
: PrintLog(log, "WifiConnector"), disp(disp), sm(sm), config(config) {}
|
2024-06-15 15:40:50 +07:00
|
|
|
|
2024-04-07 16:39:01 +07:00
|
|
|
WifiConnector::~WifiConnector() {}
|
2024-04-03 21:26:04 +07:00
|
|
|
|
2024-04-04 18:35:15 +07:00
|
|
|
/**
|
|
|
|
* @brief Connection to WIFI AP process. Just call one times
|
|
|
|
*
|
|
|
|
* @return true Success
|
|
|
|
* @return false Failure
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
bool WifiConnector::connect(void) {
|
2024-04-03 21:26:04 +07:00
|
|
|
if (wifi == NULL) {
|
|
|
|
wifi = new WiFiManager();
|
|
|
|
if (wifi == NULL) {
|
|
|
|
logError("Create 'WiFiManger' failed");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-26 15:47:49 +07:00
|
|
|
WiFi.begin();
|
|
|
|
String wifiSSID = WIFI()->getWiFiSSID(true);
|
|
|
|
if (wifiSSID.isEmpty()) {
|
|
|
|
logInfo("Connected WiFi is empty, connect to default wifi \"" +
|
|
|
|
String(this->defaultSsid) + String("\""));
|
|
|
|
|
|
|
|
/** Set wifi connect */
|
|
|
|
WiFi.begin(this->defaultSsid, this->defaultPassword);
|
|
|
|
|
|
|
|
/** Wait for wifi connect to AP */
|
|
|
|
int count = 0;
|
|
|
|
while (WiFi.status() != WL_CONNECTED) {
|
|
|
|
delay(1000);
|
|
|
|
count++;
|
|
|
|
if (count >= 15) {
|
|
|
|
logError("Try connect to default wifi \"" + String(this->defaultSsid) +
|
|
|
|
String("\" failed"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-03 21:26:04 +07:00
|
|
|
WIFI()->setConfigPortalBlocking(false);
|
2024-04-22 14:24:01 +07:00
|
|
|
WIFI()->setConnectTimeout(15);
|
2024-04-04 10:36:59 +07:00
|
|
|
WIFI()->setTimeout(WIFI_CONNECT_COUNTDOWN_MAX);
|
2024-04-03 21:26:04 +07:00
|
|
|
|
|
|
|
WIFI()->setAPCallback([this](WiFiManager *obj) { _wifiApCallback(); });
|
|
|
|
WIFI()->setSaveConfigCallback([this]() { _wifiSaveConfig(); });
|
|
|
|
WIFI()->setSaveParamsCallback([this]() { _wifiSaveParamCallback(); });
|
2024-06-19 10:33:02 +07:00
|
|
|
WIFI()->setConfigPortalTimeoutCallback([this]() {_wifiTimeoutCallback();});
|
2024-06-25 16:43:50 +07:00
|
|
|
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_3() || ag->isBasic()) {
|
2024-09-15 08:23:32 +07:00
|
|
|
disp.setText("Connect to", "WiFi", "...");
|
2024-04-03 21:26:04 +07:00
|
|
|
} else {
|
|
|
|
logInfo("Connecting to WiFi...");
|
|
|
|
}
|
2024-04-04 18:35:15 +07:00
|
|
|
ssid = "airgradient-" + ag->deviceId();
|
2024-06-15 15:40:50 +07:00
|
|
|
|
|
|
|
// ssid = "AG-" + String(ESP.getChipId(), HEX);
|
2024-04-07 16:39:01 +07:00
|
|
|
WIFI()->setConfigPortalTimeout(WIFI_CONNECT_COUNTDOWN_MAX);
|
2024-04-11 06:33:56 +07:00
|
|
|
|
2024-04-12 12:08:02 +07:00
|
|
|
WiFiManagerParameter postToAg("chbPostToAg",
|
|
|
|
"Prevent Connection to AirGradient Server", "T",
|
|
|
|
2, "type=\"checkbox\" ", WFM_LABEL_AFTER);
|
2024-04-11 06:33:56 +07:00
|
|
|
WIFI()->addParameter(&postToAg);
|
2024-04-12 06:18:48 +07:00
|
|
|
WiFiManagerParameter postToAgInfo(
|
2024-04-12 12:08:02 +07:00
|
|
|
"<p>Prevent connection to the AirGradient Server. Important: Only enable "
|
|
|
|
"it if you are sure you don't want to use any AirGradient cloud "
|
|
|
|
"features. As a result you will not receive automatic firmware updates "
|
|
|
|
"and your data will not reach the AirGradient dashboard.</p>");
|
2024-04-12 06:18:48 +07:00
|
|
|
WIFI()->addParameter(&postToAgInfo);
|
|
|
|
|
2024-04-03 21:26:04 +07:00
|
|
|
WIFI()->autoConnect(ssid.c_str(), WIFI_HOTSPOT_PASSWORD_DEFAULT);
|
2024-04-04 10:36:59 +07:00
|
|
|
|
2024-06-15 15:40:50 +07:00
|
|
|
logInfo("Wait for configure portal");
|
|
|
|
|
2024-04-07 16:39:01 +07:00
|
|
|
#ifdef ESP32
|
2024-04-04 10:36:59 +07:00
|
|
|
// Task handle WiFi connection.
|
2024-04-03 21:26:04 +07:00
|
|
|
xTaskCreate(
|
|
|
|
[](void *obj) {
|
2024-04-07 16:39:01 +07:00
|
|
|
WifiConnector *connector = (WifiConnector *)obj;
|
2024-04-03 21:26:04 +07:00
|
|
|
while (connector->_wifiConfigPortalActive()) {
|
|
|
|
connector->_wifiProcess();
|
2024-06-24 18:34:24 +07:00
|
|
|
vTaskDelay(1);
|
2024-04-03 21:26:04 +07:00
|
|
|
}
|
|
|
|
vTaskDelete(NULL);
|
|
|
|
},
|
|
|
|
"wifi_cfg", 4096, this, 10, NULL);
|
|
|
|
|
|
|
|
/** Wait for WiFi connect and show LED, display status */
|
|
|
|
uint32_t dispPeriod = millis();
|
|
|
|
uint32_t ledPeriod = millis();
|
|
|
|
bool clientConnectChanged = false;
|
|
|
|
|
|
|
|
AgStateMachineState stateOld = sm.getDisplayState();
|
|
|
|
while (WIFI()->getConfigPortalActive()) {
|
2024-04-04 10:36:59 +07:00
|
|
|
/** LED animatoin and display update content */
|
2024-04-03 21:26:04 +07:00
|
|
|
if (WiFi.isConnected() == false) {
|
|
|
|
/** Display countdown */
|
2024-04-04 10:36:59 +07:00
|
|
|
uint32_t ms;
|
2024-04-07 16:39:01 +07:00
|
|
|
if (ag->isOne()) {
|
2024-04-04 10:36:59 +07:00
|
|
|
ms = (uint32_t)(millis() - dispPeriod);
|
2024-04-03 21:26:04 +07:00
|
|
|
if (ms >= 1000) {
|
|
|
|
dispPeriod = millis();
|
|
|
|
sm.displayHandle();
|
|
|
|
} else {
|
|
|
|
if (stateOld != sm.getDisplayState()) {
|
|
|
|
stateOld = sm.getDisplayState();
|
|
|
|
sm.displayHandle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** LED animations */
|
|
|
|
ms = (uint32_t)(millis() - ledPeriod);
|
|
|
|
if (ms >= 100) {
|
|
|
|
ledPeriod = millis();
|
2024-04-07 16:39:01 +07:00
|
|
|
sm.handleLeds();
|
2024-04-03 21:26:04 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Check for client connect to change led color */
|
|
|
|
bool clientConnected = wifiClientConnected();
|
|
|
|
if (clientConnected != clientConnectChanged) {
|
|
|
|
clientConnectChanged = clientConnected;
|
|
|
|
if (clientConnectChanged) {
|
2024-04-07 16:39:01 +07:00
|
|
|
sm.handleLeds(AgStateMachineWiFiManagerPortalActive);
|
2024-04-03 21:26:04 +07:00
|
|
|
} else {
|
|
|
|
sm.ledAnimationInit();
|
2024-04-07 16:39:01 +07:00
|
|
|
sm.handleLeds(AgStateMachineWiFiManagerMode);
|
|
|
|
if (ag->isOne()) {
|
2024-04-03 21:26:04 +07:00
|
|
|
sm.displayHandle(AgStateMachineWiFiManagerMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-04 10:36:59 +07:00
|
|
|
|
|
|
|
delay(1); // avoid watchdog timer reset.
|
2024-04-03 21:26:04 +07:00
|
|
|
}
|
2024-06-15 15:40:50 +07:00
|
|
|
#else
|
|
|
|
_wifiProcess();
|
|
|
|
#endif
|
|
|
|
|
2024-04-03 21:26:04 +07:00
|
|
|
/** Show display wifi connect result failed */
|
|
|
|
if (WiFi.isConnected() == false) {
|
2024-04-07 16:39:01 +07:00
|
|
|
sm.handleLeds(AgStateMachineWiFiManagerConnectFailed);
|
2024-06-25 16:43:50 +07:00
|
|
|
if (ag->isOne() || ag->isPro4_2() || ag->isPro3_3() || ag->isBasic()) {
|
2024-04-03 21:26:04 +07:00
|
|
|
sm.displayHandle(AgStateMachineWiFiManagerConnectFailed);
|
|
|
|
}
|
|
|
|
delay(6000);
|
|
|
|
} else {
|
2024-04-04 10:36:59 +07:00
|
|
|
hasConfig = true;
|
2024-04-07 16:39:01 +07:00
|
|
|
logInfo("WiFi Connected: " + WiFi.SSID() + " IP: " + localIpStr());
|
2024-04-11 06:33:56 +07:00
|
|
|
|
2024-04-22 14:24:01 +07:00
|
|
|
if (hasPortalConfig) {
|
|
|
|
String result = String(postToAg.getValue());
|
|
|
|
logInfo("Setting postToAirGradient set from " +
|
|
|
|
String(config.isPostDataToAirGradient() ? "True" : "False") +
|
|
|
|
String(" to ") + String(result != "T" ? "True" : "False") +
|
|
|
|
String(" successful"));
|
|
|
|
config.setPostToAirGradient(result != "T");
|
|
|
|
}
|
|
|
|
hasPortalConfig = false;
|
2024-04-03 21:26:04 +07:00
|
|
|
}
|
2024-06-15 15:40:50 +07:00
|
|
|
|
2024-04-04 10:36:59 +07:00
|
|
|
return true;
|
2024-04-03 21:26:04 +07:00
|
|
|
}
|
|
|
|
|
2024-04-04 18:35:15 +07:00
|
|
|
/**
|
|
|
|
* @brief Disconnect to current connected WiFi AP
|
|
|
|
*
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
void WifiConnector::disconnect(void) {
|
2024-04-04 18:35:15 +07:00
|
|
|
if (WiFi.isConnected()) {
|
|
|
|
logInfo("Disconnect");
|
|
|
|
WiFi.disconnect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Has wifi STA connected to WIFI softAP (this device)
|
|
|
|
*
|
|
|
|
* @return true Connected
|
|
|
|
* @return false Not connected
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
bool WifiConnector::wifiClientConnected(void) {
|
2024-04-03 21:26:04 +07:00
|
|
|
return WiFi.softAPgetStationNum() ? true : false;
|
|
|
|
}
|
|
|
|
|
2024-04-04 18:35:15 +07:00
|
|
|
/**
|
|
|
|
* @brief Handle WiFiManage softAP setup completed callback
|
|
|
|
*
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
void WifiConnector::_wifiApCallback(void) {
|
2024-04-03 21:26:04 +07:00
|
|
|
sm.displayWiFiConnectCountDown(WIFI_CONNECT_COUNTDOWN_MAX);
|
|
|
|
sm.setDisplayState(AgStateMachineWiFiManagerMode);
|
2024-04-04 10:36:59 +07:00
|
|
|
sm.ledAnimationInit();
|
2024-04-07 16:39:01 +07:00
|
|
|
sm.handleLeds(AgStateMachineWiFiManagerMode);
|
2024-04-03 21:26:04 +07:00
|
|
|
}
|
|
|
|
|
2024-04-04 18:35:15 +07:00
|
|
|
/**
|
|
|
|
* @brief Handle WiFiManager save configuration callback
|
|
|
|
*
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
void WifiConnector::_wifiSaveConfig(void) {
|
2024-04-03 21:26:04 +07:00
|
|
|
sm.setDisplayState(AgStateMachineWiFiManagerStaConnected);
|
2024-04-07 16:39:01 +07:00
|
|
|
sm.handleLeds(AgStateMachineWiFiManagerStaConnected);
|
2024-04-03 21:26:04 +07:00
|
|
|
}
|
|
|
|
|
2024-04-04 18:35:15 +07:00
|
|
|
/**
|
|
|
|
* @brief Handle WiFiManager save parameter callback
|
|
|
|
*
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
void WifiConnector::_wifiSaveParamCallback(void) {
|
2024-04-03 21:26:04 +07:00
|
|
|
sm.ledAnimationInit();
|
2024-04-07 16:39:01 +07:00
|
|
|
sm.handleLeds(AgStateMachineWiFiManagerStaConnecting);
|
2024-04-03 21:26:04 +07:00
|
|
|
sm.setDisplayState(AgStateMachineWiFiManagerStaConnecting);
|
2024-04-22 14:24:01 +07:00
|
|
|
hasPortalConfig = true;
|
2024-04-03 11:40:46 +07:00
|
|
|
}
|
2024-04-03 21:26:04 +07:00
|
|
|
|
2024-04-04 18:35:15 +07:00
|
|
|
/**
|
|
|
|
* @brief Check that WiFiManager Configure portal active
|
|
|
|
*
|
|
|
|
* @return true Active
|
|
|
|
* @return false Not-Active
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
bool WifiConnector::_wifiConfigPortalActive(void) {
|
2024-04-03 21:26:04 +07:00
|
|
|
return WIFI()->getConfigPortalActive();
|
|
|
|
}
|
2024-06-05 19:01:25 +07:00
|
|
|
void WifiConnector::_wifiTimeoutCallback(void) { connectorTimeout = true; }
|
2024-06-15 15:40:50 +07:00
|
|
|
|
2024-04-04 18:35:15 +07:00
|
|
|
/**
|
|
|
|
* @brief Process WiFiManager connection
|
|
|
|
*
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
void WifiConnector::_wifiProcess() {
|
|
|
|
#ifdef ESP32
|
|
|
|
WIFI()->process();
|
|
|
|
#else
|
2024-06-15 15:40:50 +07:00
|
|
|
/** Wait for WiFi connect and show LED, display status */
|
|
|
|
uint32_t dispPeriod = millis();
|
|
|
|
uint32_t ledPeriod = millis();
|
|
|
|
bool clientConnectChanged = false;
|
|
|
|
AgStateMachineState stateOld = sm.getDisplayState();
|
|
|
|
|
2024-04-07 16:39:01 +07:00
|
|
|
while (WIFI()->getConfigPortalActive()) {
|
|
|
|
WIFI()->process();
|
2024-04-07 17:01:54 +07:00
|
|
|
|
2024-06-15 15:40:50 +07:00
|
|
|
if (WiFi.isConnected() == false) {
|
|
|
|
/** Display countdown */
|
|
|
|
uint32_t ms;
|
2024-06-25 16:43:50 +07:00
|
|
|
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_3() || ag->isBasic()) {
|
2024-06-15 15:40:50 +07:00
|
|
|
ms = (uint32_t)(millis() - dispPeriod);
|
|
|
|
if (ms >= 1000) {
|
|
|
|
dispPeriod = millis();
|
|
|
|
sm.displayHandle();
|
|
|
|
logInfo("displayHandle state: " + String(sm.getDisplayState()));
|
|
|
|
} else {
|
|
|
|
if (stateOld != sm.getDisplayState()) {
|
|
|
|
stateOld = sm.getDisplayState();
|
|
|
|
sm.displayHandle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-07 16:39:01 +07:00
|
|
|
|
2024-06-15 15:40:50 +07:00
|
|
|
/** LED animations */
|
|
|
|
ms = (uint32_t)(millis() - ledPeriod);
|
|
|
|
if (ms >= 100) {
|
|
|
|
ledPeriod = millis();
|
|
|
|
sm.handleLeds();
|
|
|
|
}
|
2024-04-07 16:39:01 +07:00
|
|
|
|
2024-06-15 15:40:50 +07:00
|
|
|
/** Check for client connect to change led color */
|
|
|
|
bool clientConnected = wifiClientConnected();
|
|
|
|
if (clientConnected != clientConnectChanged) {
|
|
|
|
clientConnectChanged = clientConnected;
|
|
|
|
if (clientConnectChanged) {
|
|
|
|
sm.handleLeds(AgStateMachineWiFiManagerPortalActive);
|
|
|
|
} else {
|
|
|
|
sm.ledAnimationInit();
|
|
|
|
sm.handleLeds(AgStateMachineWiFiManagerMode);
|
|
|
|
if (ag->isOne()) {
|
|
|
|
sm.displayHandle(AgStateMachineWiFiManagerMode);
|
|
|
|
}
|
|
|
|
}
|
2024-04-07 16:39:01 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-15 15:40:50 +07:00
|
|
|
delay(1);
|
2024-04-07 16:39:01 +07:00
|
|
|
}
|
2024-06-15 15:40:50 +07:00
|
|
|
|
|
|
|
// TODO This is for basic
|
2024-06-18 19:59:29 +07:00
|
|
|
if (ag->getBoardType() == DIY_BASIC) {
|
|
|
|
if (!WiFi.isConnected()) {
|
|
|
|
// disp.setText("Booting", "offline", "mode");
|
|
|
|
Serial.println("failed to connect and hit timeout");
|
|
|
|
delay(2500);
|
|
|
|
} else {
|
|
|
|
hasConfig = true;
|
|
|
|
}
|
|
|
|
}
|
2024-04-07 16:39:01 +07:00
|
|
|
#endif
|
|
|
|
}
|
2024-04-04 10:36:59 +07:00
|
|
|
|
2024-04-04 18:35:15 +07:00
|
|
|
/**
|
|
|
|
* @brief Handle and reconnect WiFi
|
|
|
|
*
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
void WifiConnector::handle(void) {
|
2024-04-04 10:36:59 +07:00
|
|
|
// Ignore if WiFi is not configured
|
|
|
|
if (hasConfig == false) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WiFi.isConnected()) {
|
|
|
|
lastRetry = millis();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Retry connect WiFi each 10sec */
|
|
|
|
uint32_t ms = (uint32_t)(millis() - lastRetry);
|
|
|
|
if (ms >= 10000) {
|
|
|
|
lastRetry = millis();
|
|
|
|
WiFi.reconnect();
|
|
|
|
logInfo("Re-Connect WiFi");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-04 18:35:15 +07:00
|
|
|
/**
|
|
|
|
* @brief Is WiFi connected
|
|
|
|
*
|
|
|
|
* @return true Connected
|
|
|
|
* @return false Disconnected
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
bool WifiConnector::isConnected(void) { return WiFi.isConnected(); }
|
2024-04-04 18:35:15 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Reset WiFi configuretion and connection, disconnect wifi before call
|
|
|
|
* this method
|
|
|
|
*
|
|
|
|
*/
|
2024-06-25 16:08:57 +07:00
|
|
|
void WifiConnector::reset(void) {
|
|
|
|
if(this->wifi == NULL) {
|
|
|
|
this->wifi = new WiFiManager();
|
|
|
|
if(this->wifi == NULL){
|
|
|
|
logInfo("reset failed");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WIFI()->resetSettings();
|
|
|
|
}
|
2024-04-04 18:35:15 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get wifi RSSI
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
int WifiConnector::RSSI(void) { return WiFi.RSSI(); }
|
2024-04-04 18:35:15 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get WIFI IP as string format ex: 192.168.1.1
|
|
|
|
*
|
|
|
|
* @return String
|
|
|
|
*/
|
2024-04-07 16:39:01 +07:00
|
|
|
String WifiConnector::localIpStr(void) { return WiFi.localIP().toString(); }
|
2024-05-13 15:07:10 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get status that wifi has configurated
|
2024-06-15 15:40:50 +07:00
|
|
|
*
|
2024-05-13 15:07:10 +07:00
|
|
|
* @return true Configurated
|
|
|
|
* @return false Not Configurated
|
|
|
|
*/
|
|
|
|
bool WifiConnector::hasConfigurated(void) {
|
|
|
|
if (WiFi.SSID().isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2024-06-05 19:01:25 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get WiFi connection porttal timeout.
|
2024-06-15 15:40:50 +07:00
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
* @return false
|
2024-06-05 19:01:25 +07:00
|
|
|
*/
|
|
|
|
bool WifiConnector::isConfigurePorttalTimeout(void) { return connectorTimeout; }
|
2024-08-26 15:47:49 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set wifi connect to default WiFi
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void WifiConnector::setDefault(void) {
|
|
|
|
WiFi.begin("airgradient", "cleanair");
|
|
|
|
}
|