(ip)
| 4068 | |
| 4069 | function _wifiSyncEnvPreset() { |
| 4070 | // Reflect a manually-typed n back into the preset dropdown (custom if no match). |
| 4071 | // Compare numerically so 5, 5.0 and "5.0" all match the same option. |
| 4072 | const sel = document.getElementById('wifi-env-preset'); if (!sel) return; |
| 4073 | const n = parseFloat(document.getElementById('wifi-ple').value); |
| 4074 | const match = [...sel.options].find(o => o.value !== 'custom' && parseFloat(o.value) === n); |
| 4075 | sel.value = match ? match.value : 'custom'; |
| 4076 | } |
| 4077 | |
| 4078 | function wifiCalibrate() { |
| 4079 | const g = id => document.getElementById(id).value; |
| 4080 | const st = document.getElementById('wifi-cal-status'); |
| 4081 | const qs = `d1=${g('wifi-cal-d1')}&rssi1=${g('wifi-cal-r1')}&d2=${g('wifi-cal-d2')}&rssi2=${g('wifi-cal-r2')}`; |
| 4082 | fetch(`/api/net/wifi/calibrate?${qs}`).then(r => r.json()).then(d => { |
| 4083 | if (d.error) { st.textContent = '⚠ ' + d.error; return; } |
| 4084 | _wifiState.calRssi0 = d.rssi_at_1m; |
| 4085 | document.getElementById('wifi-ple').value = d.path_loss_exponent; |
| 4086 | _wifiSyncEnvPreset(); |
| 4087 | st.innerHTML = `n=<b>${d.path_loss_exponent}</b>, ref <b>${d.rssi_at_1m}</b> dBm@1m — applied`; |
| 4088 | if (_wifiState.selected) wifiSelectAp(_wifiState.selected); |
| 4089 | }).catch(() => { st.textContent = 'calibration failed'; }); |
| 4090 | } |
| 4091 | |
| 4092 | function wifiCalibrateReset() { |
| 4093 | _wifiState.calRssi0 = null; |
nothing calls this directly
no test coverage detected