add new feature to make wifi ap invisible
This commit is contained in:
		@@ -46,7 +46,7 @@ void APSettingsService::manageAP() {
 | 
			
		||||
void APSettingsService::startAP() {
 | 
			
		||||
  Serial.println(F("Starting software access point"));
 | 
			
		||||
  WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask);
 | 
			
		||||
  WiFi.softAP(_state.ssid.c_str(), _state.password.c_str());
 | 
			
		||||
  WiFi.softAP(_state.ssid.c_str(), _state.password.c_str(), 1, !_state.networkVisible);
 | 
			
		||||
  if (!_dnsServer) {
 | 
			
		||||
    IPAddress apIp = WiFi.softAPIP();
 | 
			
		||||
    Serial.print(F("Starting captive portal on "));
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,10 @@
 | 
			
		||||
#define FACTORY_AP_PASSWORD "esp-react"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef FACTORY_AP_VISIBLE
 | 
			
		||||
#define FACTORY_AP_VISIBLE true
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef FACTORY_AP_LOCAL_IP
 | 
			
		||||
#define FACTORY_AP_LOCAL_IP "192.168.4.1"
 | 
			
		||||
#endif
 | 
			
		||||
@@ -53,10 +57,11 @@ class APSettings {
 | 
			
		||||
  IPAddress localIP;
 | 
			
		||||
  IPAddress gatewayIP;
 | 
			
		||||
  IPAddress subnetMask;
 | 
			
		||||
  bool networkVisible;
 | 
			
		||||
 | 
			
		||||
  bool operator==(const APSettings& settings) const {
 | 
			
		||||
    return provisionMode == settings.provisionMode && ssid == settings.ssid && password == settings.password &&
 | 
			
		||||
           localIP == settings.localIP && gatewayIP == settings.gatewayIP && subnetMask == settings.subnetMask;
 | 
			
		||||
           localIP == settings.localIP && gatewayIP == settings.gatewayIP && subnetMask == settings.subnetMask && networkVisible == settings.networkVisible;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static void read(APSettings& settings, JsonObject& root) {
 | 
			
		||||
@@ -66,6 +71,7 @@ class APSettings {
 | 
			
		||||
    root["local_ip"] = settings.localIP.toString();
 | 
			
		||||
    root["gateway_ip"] = settings.gatewayIP.toString();
 | 
			
		||||
    root["subnet_mask"] = settings.subnetMask.toString();
 | 
			
		||||
    root["network_visible"] = settings.networkVisible;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static StateUpdateResult update(JsonObject& root, APSettings& settings) {
 | 
			
		||||
@@ -81,6 +87,7 @@ class APSettings {
 | 
			
		||||
    }
 | 
			
		||||
    newSettings.ssid = root["ssid"] | FACTORY_AP_SSID;
 | 
			
		||||
    newSettings.password = root["password"] | FACTORY_AP_PASSWORD;
 | 
			
		||||
    newSettings.networkVisible = root["network_visible"] | FACTORY_AP_VISIBLE;
 | 
			
		||||
 | 
			
		||||
    JsonUtils::readIP(root, "local_ip", newSettings.localIP, FACTORY_AP_LOCAL_IP);
 | 
			
		||||
    JsonUtils::readIP(root, "gateway_ip", newSettings.gatewayIP, FACTORY_AP_GATEWAY_IP);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user