mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
add BSSID and Channel to network settings, full_scan
This commit is contained in:
@@ -82,7 +82,9 @@ const WiFiSettingsForm: FC = () => {
|
||||
if (selectedNetwork) {
|
||||
updateState('networkSettings', (current_data) => ({
|
||||
ssid: selectedNetwork.ssid,
|
||||
password: '',
|
||||
bssid: selectedNetwork.bssid,
|
||||
channel: selectedNetwork.channel,
|
||||
password: current_data ? current_data.password : '',
|
||||
hostname: current_data?.hostname,
|
||||
static_ip_config: false,
|
||||
enableIPv6: false,
|
||||
@@ -117,6 +119,12 @@ const WiFiSettingsForm: FC = () => {
|
||||
} catch (errors: any) {
|
||||
setFieldErrors(errors);
|
||||
}
|
||||
deselectNetwork();
|
||||
};
|
||||
|
||||
const setCancel = async () => {
|
||||
deselectNetwork();
|
||||
await loadData();
|
||||
};
|
||||
|
||||
const restart = async () => {
|
||||
@@ -139,10 +147,17 @@ const WiFiSettingsForm: FC = () => {
|
||||
</ListItemAvatar>
|
||||
<ListItemText
|
||||
primary={selectedNetwork.ssid}
|
||||
secondary={'Security: ' + networkSecurityMode(selectedNetwork) + ', Ch: ' + selectedNetwork.channel}
|
||||
secondary={
|
||||
'Security: ' +
|
||||
networkSecurityMode(selectedNetwork) +
|
||||
', Ch: ' +
|
||||
selectedNetwork.channel +
|
||||
', bssid: ' +
|
||||
selectedNetwork.bssid
|
||||
}
|
||||
/>
|
||||
<ListItemSecondaryAction>
|
||||
<IconButton onClick={deselectNetwork}>
|
||||
<IconButton onClick={setCancel}>
|
||||
<DeleteIcon />
|
||||
</IconButton>
|
||||
</ListItemSecondaryAction>
|
||||
@@ -160,6 +175,27 @@ const WiFiSettingsForm: FC = () => {
|
||||
margin="normal"
|
||||
/>
|
||||
)}
|
||||
<ValidatedTextField
|
||||
fieldErrors={fieldErrors}
|
||||
name="bssid"
|
||||
label={'BSSID (leave blank for SSID only)'}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.bssid}
|
||||
onChange={updateFormValue}
|
||||
margin="normal"
|
||||
/>
|
||||
<ValidatedTextField
|
||||
fieldErrors={fieldErrors}
|
||||
name="channel"
|
||||
label="Channel (0=auto)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={numberValue(data.channel)}
|
||||
onChange={updateFormValue}
|
||||
type="number"
|
||||
margin="normal"
|
||||
/>
|
||||
{(!selectedNetwork || !isNetworkOpen(selectedNetwork)) && (
|
||||
<ValidatedPasswordField
|
||||
fieldErrors={fieldErrors}
|
||||
@@ -296,7 +332,7 @@ const WiFiSettingsForm: FC = () => {
|
||||
</MessageBox>
|
||||
)}
|
||||
|
||||
{!restartNeeded && dirtyFlags && dirtyFlags.length !== 0 && (
|
||||
{!restartNeeded && (selectedNetwork || (dirtyFlags && dirtyFlags.length !== 0)) && (
|
||||
<ButtonRow>
|
||||
<Button
|
||||
startIcon={<CancelIcon />}
|
||||
|
||||
@@ -65,7 +65,9 @@ const WiFiNetworkSelector: FC<WiFiNetworkSelectorProps> = ({ networkList }) => {
|
||||
</ListItemAvatar>
|
||||
<ListItemText
|
||||
primary={network.ssid}
|
||||
secondary={'Security: ' + networkSecurityMode(network) + ', Ch: ' + network.channel}
|
||||
secondary={
|
||||
'Security: ' + networkSecurityMode(network) + ', Ch: ' + network.channel + ', bssid: ' + network.bssid
|
||||
}
|
||||
/>
|
||||
<ListItemIcon>
|
||||
<Badge badgeContent={network.rssi + 'dBm'}>
|
||||
|
||||
@@ -37,6 +37,8 @@ export interface NetworkStatus {
|
||||
|
||||
export interface NetworkSettings {
|
||||
ssid: string;
|
||||
bssid: string;
|
||||
channel: number;
|
||||
password: string;
|
||||
hostname: string;
|
||||
static_ip_config: boolean;
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { NetworkSettings } from 'types';
|
||||
export const createNetworkSettingsValidator = (networkSettings: NetworkSettings) =>
|
||||
new Schema({
|
||||
ssid: [{ type: 'string', max: 32, message: 'SSID must be 32 characters or less' }],
|
||||
bssid: [{ type: 'string', max: 17, message: 'BSSID must be 17 characters or empty' }],
|
||||
password: { type: 'string', max: 64, message: 'Password must be 64 characters or less' },
|
||||
hostname: [{ required: true, message: 'Hostname is required' }, HOSTNAME_VALIDATOR],
|
||||
...(networkSettings.static_ip_config && {
|
||||
@@ -17,5 +18,9 @@ export const createNetworkSettingsValidator = (networkSettings: NetworkSettings)
|
||||
tx_power: [
|
||||
{ required: true, message: 'Tx Power is required' },
|
||||
{ type: 'number', min: 0, max: 20, message: 'Tx Power must be between 0 and 20dBm' }
|
||||
],
|
||||
channel: [
|
||||
{ required: true, message: 'Channel is required' },
|
||||
{ type: 'number', min: 0, max: 13, message: 'Channel must be between 0 and 13' }
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user