add new feature to make wifi ap invisible
This commit is contained in:
parent
72095dbe3e
commit
910797adaf
@ -13,6 +13,7 @@ build_flags =
|
|||||||
-D FACTORY_AP_LOCAL_IP=\"192.168.4.1\"
|
-D FACTORY_AP_LOCAL_IP=\"192.168.4.1\"
|
||||||
-D FACTORY_AP_GATEWAY_IP=\"192.168.4.1\"
|
-D FACTORY_AP_GATEWAY_IP=\"192.168.4.1\"
|
||||||
-D FACTORY_AP_SUBNET_MASK=\"255.255.255.0\"
|
-D FACTORY_AP_SUBNET_MASK=\"255.255.255.0\"
|
||||||
|
-D FACTORY_AP_VISIBLE=true
|
||||||
|
|
||||||
; User credentials for admin and guest user
|
; User credentials for admin and guest user
|
||||||
-D FACTORY_ADMIN_USERNAME=\"admin\"
|
-D FACTORY_ADMIN_USERNAME=\"admin\"
|
||||||
|
@ -3,8 +3,9 @@ import { TextValidator, ValidatorForm, SelectValidator } from 'react-material-ui
|
|||||||
|
|
||||||
import MenuItem from '@material-ui/core/MenuItem';
|
import MenuItem from '@material-ui/core/MenuItem';
|
||||||
import SaveIcon from '@material-ui/icons/Save';
|
import SaveIcon from '@material-ui/icons/Save';
|
||||||
|
import Checkbox from '@material-ui/core/Checkbox';
|
||||||
|
|
||||||
import { PasswordValidator, RestFormProps, FormActions, FormButton } from '../components';
|
import {PasswordValidator, RestFormProps, FormActions, FormButton, BlockFormControlLabel} from '../components';
|
||||||
|
|
||||||
import { isAPEnabled } from './APModes';
|
import { isAPEnabled } from './APModes';
|
||||||
import { APSettings, APProvisionMode } from './types';
|
import { APSettings, APProvisionMode } from './types';
|
||||||
@ -91,6 +92,16 @@ class APSettingsForm extends React.Component<APSettingsFormProps> {
|
|||||||
onChange={handleValueChange('subnet_mask')}
|
onChange={handleValueChange('subnet_mask')}
|
||||||
margin="normal"
|
margin="normal"
|
||||||
/>
|
/>
|
||||||
|
<BlockFormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
value="network_visible"
|
||||||
|
checked={data.network_visible}
|
||||||
|
onChange={handleValueChange("network_visible")}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Network visible?"
|
||||||
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
}
|
}
|
||||||
<FormActions>
|
<FormActions>
|
||||||
|
@ -24,4 +24,5 @@ export interface APSettings {
|
|||||||
local_ip: string;
|
local_ip: string;
|
||||||
gateway_ip: string;
|
gateway_ip: string;
|
||||||
subnet_mask: string;
|
subnet_mask: string;
|
||||||
|
network_visible: boolean;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ void APSettingsService::manageAP() {
|
|||||||
void APSettingsService::startAP() {
|
void APSettingsService::startAP() {
|
||||||
Serial.println(F("Starting software access point"));
|
Serial.println(F("Starting software access point"));
|
||||||
WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask);
|
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) {
|
if (!_dnsServer) {
|
||||||
IPAddress apIp = WiFi.softAPIP();
|
IPAddress apIp = WiFi.softAPIP();
|
||||||
Serial.print(F("Starting captive portal on "));
|
Serial.print(F("Starting captive portal on "));
|
||||||
|
@ -28,6 +28,10 @@
|
|||||||
#define FACTORY_AP_PASSWORD "esp-react"
|
#define FACTORY_AP_PASSWORD "esp-react"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef FACTORY_AP_VISIBLE
|
||||||
|
#define FACTORY_AP_VISIBLE true
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef FACTORY_AP_LOCAL_IP
|
#ifndef FACTORY_AP_LOCAL_IP
|
||||||
#define FACTORY_AP_LOCAL_IP "192.168.4.1"
|
#define FACTORY_AP_LOCAL_IP "192.168.4.1"
|
||||||
#endif
|
#endif
|
||||||
@ -53,10 +57,11 @@ class APSettings {
|
|||||||
IPAddress localIP;
|
IPAddress localIP;
|
||||||
IPAddress gatewayIP;
|
IPAddress gatewayIP;
|
||||||
IPAddress subnetMask;
|
IPAddress subnetMask;
|
||||||
|
bool networkVisible;
|
||||||
|
|
||||||
bool operator==(const APSettings& settings) const {
|
bool operator==(const APSettings& settings) const {
|
||||||
return provisionMode == settings.provisionMode && ssid == settings.ssid && password == settings.password &&
|
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) {
|
static void read(APSettings& settings, JsonObject& root) {
|
||||||
@ -66,6 +71,7 @@ class APSettings {
|
|||||||
root["local_ip"] = settings.localIP.toString();
|
root["local_ip"] = settings.localIP.toString();
|
||||||
root["gateway_ip"] = settings.gatewayIP.toString();
|
root["gateway_ip"] = settings.gatewayIP.toString();
|
||||||
root["subnet_mask"] = settings.subnetMask.toString();
|
root["subnet_mask"] = settings.subnetMask.toString();
|
||||||
|
root["network_visible"] = settings.networkVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
static StateUpdateResult update(JsonObject& root, APSettings& settings) {
|
static StateUpdateResult update(JsonObject& root, APSettings& settings) {
|
||||||
@ -81,6 +87,7 @@ class APSettings {
|
|||||||
}
|
}
|
||||||
newSettings.ssid = root["ssid"] | FACTORY_AP_SSID;
|
newSettings.ssid = root["ssid"] | FACTORY_AP_SSID;
|
||||||
newSettings.password = root["password"] | FACTORY_AP_PASSWORD;
|
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, "local_ip", newSettings.localIP, FACTORY_AP_LOCAL_IP);
|
||||||
JsonUtils::readIP(root, "gateway_ip", newSettings.gatewayIP, FACTORY_AP_GATEWAY_IP);
|
JsonUtils::readIP(root, "gateway_ip", newSettings.gatewayIP, FACTORY_AP_GATEWAY_IP);
|
||||||
|
@ -16,6 +16,6 @@
|
|||||||
#define TempSensorPin D4
|
#define TempSensorPin D4
|
||||||
|
|
||||||
// version info
|
// version info
|
||||||
#define VERSION "v1.2.3"
|
#define VERSION "v1.2.4"
|
||||||
|
|
||||||
#endif //PUMPENSTEUERUNG_PINS_H
|
#endif //PUMPENSTEUERUNG_PINS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user