Make WiFi TX power configurable, document ESP32-S3 pins
The transmit power was hardcoded to 19.5 dBm. Some setups need a lower value (device right next to the AP, weak 3.3V rail), so it is now a user setting instead of a per-chip constant. - wlan.cpp: load/save/apply TX power (0.1 dBm steps, NVS key wifi_txpwr, default 195), re-applied on GOT_IP so it survives a reconnect - website.cpp: /api/wifi-power GET/POST with validation - setup.html: "WiFi Settings" card - README.md/README.de.md: pin table gets an ESP32-S3 column plus a warning that GPIO19/20 are the native USB data lines - config.cpp: same warning next to the HX711 pin definitions Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b8cfa1ce98
commit
a5ba8a901a
8 files changed
+186
-26
No files matched your search
@@ -87,6 +87,24 @@
|
||||
</div>
|
||||
<div id="sleepStatusMessage" style="margin-top: 0.5rem;"></div>
|
||||
</div>
|
||||
|
||||
<div class="fm-card">
|
||||
<h2>WiFi Settings</h2>
|
||||
|
||||
<div class="fm-form-group" style="margin-top: 1rem;">
|
||||
<label class="fm-label" for="txPowerSelect">WiFi Transmit Power</label>
|
||||
<select id="txPowerSelect" class="fm-input">
|
||||
<option value="195">19.5 dBm (default, maximum range)</option>
|
||||
<option value="170">17 dBm</option>
|
||||
<option value="150">15 dBm</option>
|
||||
<option value="130">13 dBm</option>
|
||||
<option value="110">11 dBm</option>
|
||||
<option value="85">8.5 dBm (lowest)</option>
|
||||
</select>
|
||||
<p style="font-size: 0.8rem; margin-top: 0.5rem;">Only lower this if your router keeps dropping the device, or if it sits right next to the access point. Applies immediately, no restart needed.</p>
|
||||
</div>
|
||||
<div id="txPowerStatusMessage" style="margin-top: 0.5rem;"></div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -160,6 +178,45 @@
|
||||
});
|
||||
});
|
||||
|
||||
// WiFi transmit power setting
|
||||
fetch('/api/wifi-power')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const sel = document.getElementById('txPowerSelect');
|
||||
const val = String(data.txPower);
|
||||
let matched = false;
|
||||
for (let i = 0; i < sel.options.length; i++) {
|
||||
if (sel.options[i].value === val) { sel.value = val; matched = true; break; }
|
||||
}
|
||||
if (!matched) sel.value = '195';
|
||||
})
|
||||
.catch(error => console.error('Error fetching wifi power:', error));
|
||||
|
||||
document.getElementById('txPowerSelect').addEventListener('change', function() {
|
||||
const msg = document.getElementById('txPowerStatusMessage');
|
||||
fetch('/api/wifi-power', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ txPower: parseInt(this.value) })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
msg.textContent = 'Saved.';
|
||||
msg.style.color = 'var(--success-text)';
|
||||
setTimeout(() => { msg.textContent = ''; }, 2000);
|
||||
} else {
|
||||
msg.textContent = 'Error saving setting.';
|
||||
msg.style.color = 'var(--error-text)';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
msg.textContent = 'Error saving setting.';
|
||||
msg.style.color = 'var(--error-text)';
|
||||
console.error('Error saving wifi power:', error);
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById('registerBtn').addEventListener('click', () => {
|
||||
const url = document.getElementById('filamanUrl').value;
|
||||
const code = document.getElementById('deviceCode').value;
|
||||
|
||||
Reference in new issue
Block a user