mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-13 05:53:06 +01:00
allow to set the AP password if we can do hardware reset
This commit is contained in:
@@ -14,8 +14,9 @@ class GwWifi{
|
||||
unsigned long lastApAccess=0;
|
||||
unsigned long apShutdownTime=0;
|
||||
bool apActive=false;
|
||||
bool fixedApPass=true;
|
||||
public:
|
||||
GwWifi(const GwConfigHandler *config,GwLog *log);
|
||||
GwWifi(const GwConfigHandler *config,GwLog *log, bool fixedApPass=true);
|
||||
void setup();
|
||||
void loop();
|
||||
bool clientConnected();
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
|
||||
const char *AP_password = "esp32nmea2k";
|
||||
|
||||
GwWifi::GwWifi(const GwConfigHandler *config,GwLog *log){
|
||||
GwWifi::GwWifi(const GwConfigHandler *config,GwLog *log, bool fixedApPass){
|
||||
this->config=config;
|
||||
this->logger=log;
|
||||
wifiClient=config->getConfigItem(config->wifiClient,true);
|
||||
wifiSSID=config->getConfigItem(config->wifiSSID,true);
|
||||
wifiPass=config->getConfigItem(config->wifiPass,true);
|
||||
this->fixedApPass=fixedApPass;
|
||||
}
|
||||
void GwWifi::setup(){
|
||||
logger->logString("Wifi setup");
|
||||
@@ -17,7 +18,12 @@ void GwWifi::setup(){
|
||||
IPAddress AP_subnet(255, 255, 255, 0);
|
||||
WiFi.mode(WIFI_MODE_APSTA); //enable both AP and client
|
||||
const char *ssid=config->getConfigItem(config->systemName)->asCString();
|
||||
WiFi.softAP(ssid,AP_password);
|
||||
if (fixedApPass){
|
||||
WiFi.softAP(ssid,AP_password);
|
||||
}
|
||||
else{
|
||||
WiFi.softAP(ssid,config->getConfigItem(config->apPassword)->asCString());
|
||||
}
|
||||
delay(100);
|
||||
WiFi.softAPConfig(AP_local_ip, AP_gateway, AP_subnet);
|
||||
logger->logString("WifiAP created: ssid=%s,adress=%s",
|
||||
|
||||
Reference in New Issue
Block a user