()
| 20337 | if (!el) return; |
| 20338 | el.textContent = message || ''; |
| 20339 | el.classList.toggle('hidden', !message); |
| 20340 | } |
| 20341 | |
| 20342 | async function startAPMode() { |
| 20343 | // Known up front that this adapter cannot be an access point: say so |
| 20344 | // instead of asking to disconnect Wi-Fi for a hotspot that cannot start. |
| 20345 | if (wifiApBlocker) { |
| 20346 | setApModeNotice(wifiApBlocker); |
| 20347 | addConsoleMessage(`AP Mode not available: ${wifiApBlocker}`, 'error'); |
| 20348 | return; |
| 20349 | } |
| 20350 | if (!confirm('Start AP Mode?\n\nThis will:\n• Disconnect from current Wi-Fi\n• Start "Ragnar" access point\n• Enable 3-minute smart cycling\n• Allow Wi-Fi configuration via AP\n\nContinue?')) { |
| 20351 | return; |
| 20352 | } |
| 20353 | |
| 20354 | try { |
| 20355 | addConsoleMessage('Starting AP Mode...', 'info'); |
| 20356 | updateWifiStatus('Starting AP Mode...', 'connecting'); |
| 20357 | |
| 20358 | const data = await postAPI('/api/wifi/ap/enable', {}); |
| 20359 | |
| 20360 | if (data.success) { |
| 20361 | setApModeNotice(''); |
| 20362 | addConsoleMessage(`AP Mode started: ${data.ap_config.ssid}`, 'success'); |
| 20363 | updateWifiStatus( |
| 20364 | `AP Mode Active: "${data.ap_config.ssid}" | ${data.ap_config.timeout}s timeout | Smart cycling enabled`, |
| 20365 | 'ap-mode' |
| 20366 | ); |
| 20367 | |
| 20368 | // Auto-refresh Wi-Fi status |
| 20369 | setTimeout(refreshWifiStatus, 2000); |
| 20370 | } else { |
| 20371 | const reason = data.error || data.message || 'unknown error'; |
| 20372 | addConsoleMessage(`Failed to start AP Mode: ${reason}`, 'error'); |
| 20373 | updateWifiStatus(`Failed to start AP Mode: ${reason}`, 'error'); |
| 20374 | setApModeNotice(reason === data.error ? reason : `AP Mode was not started: ${reason}`); |
| 20375 | setTimeout(refreshWifiStatus, 2000); |
| 20376 | } |
| 20377 | |
| 20378 | } catch (error) { |
nothing calls this directly
no test coverage detected