Skip to content

Commit

Permalink
#34: do not show apPassword in the config UI if the change is not all…
Browse files Browse the repository at this point in the history
…owed. Also do not print this on startup. Introduce FORCE_AP_PWCHANGE to allow extensions to force pw change ability
  • Loading branch information
andreas committed Mar 10, 2022
1 parent db7647a commit 52c598f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/wifi/GWWifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class GwWifi{
bool fixedApPass=true;
bool clientIsConnected=false;
public:
const char *AP_password = "esp32nmea2k";
GwWifi(const GwConfigHandler *config,GwLog *log, bool fixedApPass=true);
void setup();
void loop();
Expand Down
1 change: 0 additions & 1 deletion lib/wifi/GwWifi.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "GWWifi.h"

const char *AP_password = "esp32nmea2k";

GwWifi::GwWifi(const GwConfigHandler *config,GwLog *log, bool fixedApPass){
this->config=config;
Expand Down
8 changes: 7 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ GwConfigHandler config(&logger);
#ifdef GWBUTTON_PIN
bool fixedApPass=false;
#else
#ifdef FORCE_AP_PWCHANGE
bool fixedApPass=false;
#else
bool fixedApPass=true;
#endif
#endif
GwWifi gwWifi(&config,&logger,fixedApPass);
GwChannelList channels(&logger,&config);
GwBoatData boatData(&logger);
Expand Down Expand Up @@ -420,6 +424,7 @@ class CapabilitiesRequest : public GwRequestMessage{
#ifdef GWBUTTON_PIN
json["hardwareReset"]="true";
#endif
json["apPwChange"] = fixedApPass?"false":"true";
serializeJson(json,result);
}
};
Expand Down Expand Up @@ -473,6 +478,7 @@ class SetConfigRequest : public GwRequestMessage
for (StringMap::iterator it = args.begin(); it != args.end(); it++)
{
if (it->first.indexOf("_")>= 0) continue;
if (it->first == GwConfigDefinitions::apPassword && fixedApPass) continue;
bool rt = config.updateValue(it->first, it->second);
if (!rt)
{
Expand Down Expand Up @@ -741,7 +747,7 @@ void setup() {
GWSYNCHRONIZED(&mainLock);
userCodeHandler.startUserTasks(MIN_USER_TASK);
}
logger.logString("wifi AP pass: %s",config.getString(config.apPassword).c_str());
logger.logString("wifi AP pass: %s",fixedApPass? gwWifi.AP_password:config.getString(config.apPassword).c_str());
logger.logString("admin pass: %s",config.getString(config.adminPassword).c_str());
logger.logDebug(GwLog::LOG,"setup done");
}
Expand Down
3 changes: 2 additions & 1 deletion web/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@
"default": "esp32nmea2k",
"check": "checkApPass",
"description": "set the password for the Wifi access point",
"category": "system"
"category": "system",
"condition":{"apPwChange":"true"}
},
{
"name": "useAdminPass",
Expand Down

0 comments on commit 52c598f

Please sign in to comment.