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_GATEWAY_IP=\"192.168.4.1\"
|
||||
-D FACTORY_AP_SUBNET_MASK=\"255.255.255.0\"
|
||||
-D FACTORY_AP_VISIBLE=true
|
||||
|
||||
; User credentials for admin and guest user
|
||||
-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 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 { APSettings, APProvisionMode } from './types';
|
||||
@ -91,6 +92,16 @@ class APSettingsForm extends React.Component<APSettingsFormProps> {
|
||||
onChange={handleValueChange('subnet_mask')}
|
||||
margin="normal"
|
||||
/>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
value="network_visible"
|
||||
checked={data.network_visible}
|
||||
onChange={handleValueChange("network_visible")}
|
||||
/>
|
||||
}
|
||||
label="Network visible?"
|
||||
/>
|
||||
</Fragment>
|
||||
}
|
||||
<FormActions>
|
||||
|
@ -24,4 +24,5 @@ export interface APSettings {
|
||||
local_ip: string;
|
||||
gateway_ip: string;
|
||||
subnet_mask: string;
|
||||
network_visible: boolean;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -16,6 +16,6 @@
|
||||
#define TempSensorPin D4
|
||||
|
||||
// version info
|
||||
#define VERSION "v1.2.3"
|
||||
#define VERSION "v1.2.4"
|
||||
|
||||
#endif //PUMPENSTEUERUNG_PINS_H
|
||||
|
Loading…
Reference in New Issue
Block a user