Remove WiFi station (client) support
- Drop station connect/status/credentials from wifi util and settings API - Remove station activation from main - Remove station UI and JS from index, settings template, and help.js - Device settings now only configure WiFi Access Point Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -170,53 +170,11 @@
|
||||
|
||||
<div class="settings-header">
|
||||
<h1>Device Settings</h1>
|
||||
<p>Configure WiFi and device settings</p>
|
||||
<p>Configure WiFi Access Point settings</p>
|
||||
</div>
|
||||
|
||||
<div id="message" class="message"></div>
|
||||
|
||||
<!-- WiFi Station Settings -->
|
||||
<div class="settings-section">
|
||||
<h2>WiFi Station (Client) Settings</h2>
|
||||
|
||||
<div id="station-status" class="status-info">
|
||||
<h3>Connection Status</h3>
|
||||
<p>Loading...</p>
|
||||
</div>
|
||||
|
||||
<form id="station-form">
|
||||
<div class="form-group">
|
||||
<label for="station-ssid">SSID (Network Name)</label>
|
||||
<input type="text" id="station-ssid" name="ssid" placeholder="Enter WiFi network name" required>
|
||||
<small>The name of the WiFi network to connect to</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="station-password">Password</label>
|
||||
<input type="password" id="station-password" name="password" placeholder="Enter WiFi password">
|
||||
<small>Leave empty for open networks</small>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="station-ip">IP Address (Optional)</label>
|
||||
<input type="text" id="station-ip" name="ip" placeholder="192.168.1.100">
|
||||
<small>Static IP address (leave empty for DHCP)</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="station-gateway">Gateway (Optional)</label>
|
||||
<input type="text" id="station-gateway" name="gateway" placeholder="192.168.1.1">
|
||||
<small>Gateway/router IP address</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<button type="submit" class="btn btn-primary btn-full">Connect</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- WiFi Access Point Settings -->
|
||||
<div class="settings-section">
|
||||
<h2>WiFi Access Point Settings</h2>
|
||||
@@ -264,47 +222,6 @@
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// Load station status
|
||||
async function loadStationStatus() {
|
||||
try {
|
||||
const response = await fetch('/settings/wifi/station');
|
||||
const status = await response.json();
|
||||
|
||||
const statusEl = document.getElementById('station-status');
|
||||
if (status.connected) {
|
||||
statusEl.innerHTML = `
|
||||
<h3>Connection Status: <span class="status-connected">Connected</span></h3>
|
||||
<p><strong>SSID:</strong> ${status.ssid || 'N/A'}</p>
|
||||
<p><strong>IP Address:</strong> ${status.ip || 'N/A'}</p>
|
||||
<p><strong>Gateway:</strong> ${status.gateway || 'N/A'}</p>
|
||||
<p><strong>Netmask:</strong> ${status.netmask || 'N/A'}</p>
|
||||
<p><strong>DNS:</strong> ${status.dns || 'N/A'}</p>
|
||||
`;
|
||||
} else {
|
||||
statusEl.innerHTML = `
|
||||
<h3>Connection Status: <span class="status-disconnected">Disconnected</span></h3>
|
||||
<p>Not connected to any WiFi network</p>
|
||||
`;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading station status:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Load saved station credentials
|
||||
async function loadStationCredentials() {
|
||||
try {
|
||||
const response = await fetch('/settings/wifi/station/credentials');
|
||||
const creds = await response.json();
|
||||
|
||||
if (creds.ssid) document.getElementById('station-ssid').value = creds.ssid;
|
||||
if (creds.ip) document.getElementById('station-ip').value = creds.ip;
|
||||
if (creds.gateway) document.getElementById('station-gateway').value = creds.gateway;
|
||||
} catch (error) {
|
||||
console.error('Error loading station credentials:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Load AP status and config
|
||||
async function loadAPStatus() {
|
||||
try {
|
||||
@@ -334,39 +251,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Station form submission
|
||||
document.getElementById('station-form').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = {
|
||||
ssid: document.getElementById('station-ssid').value,
|
||||
password: document.getElementById('station-password').value,
|
||||
ip: document.getElementById('station-ip').value || null,
|
||||
gateway: document.getElementById('station-gateway').value || null
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch('/settings/wifi/station', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(formData)
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
showMessage('WiFi station connected successfully!', 'success');
|
||||
setTimeout(loadStationStatus, 1000);
|
||||
} else {
|
||||
showMessage(`Error: ${result.error || 'Failed to connect'}`, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showMessage(`Error: ${error.message}`, 'error');
|
||||
}
|
||||
});
|
||||
|
||||
// AP form submission
|
||||
document.getElementById('ap-form').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
@@ -415,15 +299,10 @@
|
||||
});
|
||||
|
||||
// Load all data on page load
|
||||
loadStationStatus();
|
||||
loadStationCredentials();
|
||||
loadAPStatus();
|
||||
|
||||
// Refresh status every 10 seconds
|
||||
setInterval(() => {
|
||||
loadStationStatus();
|
||||
loadAPStatus();
|
||||
}, 10000);
|
||||
setInterval(loadAPStatus, 10000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user