From 3a6b529cba10c0e8a28931c1fca2e5390d2470ac Mon Sep 17 00:00:00 2001 From: PaulVua Date: Tue, 10 Feb 2026 10:39:02 +0100 Subject: [PATCH] feat(ui): add WiFi/network info to self-test Add informational network status check at the beginning of self-test: - Shows connection mode (Hotspot, WiFi, or Ethernet) - Displays SSID/connection name - Shows IP address and hostname.local - Add wifi_status endpoint in launcher.php using nmcli Co-Authored-By: Claude Opus 4.5 --- html/launcher.php | 47 ++++++++++++++++++++++++++++++++ html/saraR4.html | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) diff --git a/html/launcher.php b/html/launcher.php index 42d3036..5f8a66a 100755 --- a/html/launcher.php +++ b/html/launcher.php @@ -542,6 +542,53 @@ if ($type == "linux_memory") { echo $output; } +if ($type == "wifi_status") { + header('Content-Type: application/json'); + + $result = array( + 'connected' => false, + 'mode' => 'unknown', + 'ssid' => '', + 'ip' => '', + 'hostname' => '' + ); + + // Get hostname + $result['hostname'] = trim(shell_exec('hostname')); + + // Get wlan0 connection info + $connection = trim(shell_exec("nmcli -t -f GENERAL.CONNECTION device show wlan0 2>/dev/null | cut -d: -f2")); + + if (!empty($connection) && $connection != '--') { + $result['connected'] = true; + $result['ssid'] = $connection; + + // Check if it's a hotspot + if (strpos(strtolower($connection), 'hotspot') !== false || strpos($connection, 'nebuleair') !== false) { + $result['mode'] = 'hotspot'; + } else { + $result['mode'] = 'wifi'; + } + + // Get IP address + $ip = trim(shell_exec("nmcli -t -f IP4.ADDRESS device show wlan0 2>/dev/null | head -1 | cut -d: -f2 | cut -d/ -f1")); + if (!empty($ip)) { + $result['ip'] = $ip; + } + } else { + // Check if eth0 is connected + $eth_ip = trim(shell_exec("nmcli -t -f IP4.ADDRESS device show eth0 2>/dev/null | head -1 | cut -d: -f2 | cut -d/ -f1")); + if (!empty($eth_ip)) { + $result['connected'] = true; + $result['mode'] = 'ethernet'; + $result['ssid'] = 'Ethernet'; + $result['ip'] = $eth_ip; + } + } + + echo json_encode($result); +} + if ($type == "sshTunnel") { $ssh_port=$_GET['ssh_port']; $command = 'sudo ssh -i /var/www/.ssh/id_rsa -f -N -R "'.$ssh_port.':localhost:22" -p 50221 -o StrictHostKeyChecking=no "airlab_server1@aircarto.fr"'; diff --git a/html/saraR4.html b/html/saraR4.html index e802b86..67e91d2 100755 --- a/html/saraR4.html +++ b/html/saraR4.html @@ -375,6 +375,15 @@
+ +
+
+ WiFi / Network +
Waiting...
+
+ Pending +
+
@@ -1511,6 +1520,10 @@ function resetSelfTestUI() {
`; // Reset test items + document.getElementById('test_wifi_status').className = 'badge bg-secondary'; + document.getElementById('test_wifi_status').textContent = 'Pending'; + document.getElementById('test_wifi_detail').textContent = 'Waiting...'; + document.getElementById('test_modem_status').className = 'badge bg-secondary'; document.getElementById('test_modem_status').textContent = 'Pending'; document.getElementById('test_modem_detail').textContent = 'Waiting...'; @@ -1605,6 +1618,62 @@ async function selfTestSequence() { let testsFailed = 0; try { + // Step 0: Check WiFi / Network status (informational, no pass/fail) + document.getElementById('selftest_status').innerHTML = ` +
+
+ Checking network status... +
`; + + updateTestStatus('wifi', 'Checking...', 'Getting network info...', 'bg-info'); + + try { + const wifiResponse = await new Promise((resolve, reject) => { + $.ajax({ + url: 'launcher.php?type=wifi_status', + dataType: 'json', + method: 'GET', + success: function(data) { + addSelfTestLog(`WiFi status: ${JSON.stringify(data)}`); + resolve(data); + }, + error: function(xhr, status, error) { + addSelfTestLog(`WiFi status error: ${error}`); + reject(new Error(error)); + } + }); + }); + + if (wifiResponse.connected) { + let modeIcon = ''; + let modeLabel = ''; + let badgeClass = 'bg-info'; + + if (wifiResponse.mode === 'hotspot') { + modeIcon = '📡'; + modeLabel = 'Hotspot'; + badgeClass = 'bg-warning text-dark'; + } else if (wifiResponse.mode === 'wifi') { + modeIcon = '📶'; + modeLabel = 'WiFi'; + badgeClass = 'bg-info'; + } else if (wifiResponse.mode === 'ethernet') { + modeIcon = '🔌'; + modeLabel = 'Ethernet'; + badgeClass = 'bg-info'; + } + + const detailText = `${wifiResponse.ssid} | ${wifiResponse.ip} | ${wifiResponse.hostname}.local`; + updateTestStatus('wifi', modeLabel, detailText, badgeClass); + } else { + updateTestStatus('wifi', 'Disconnected', 'No network connection', 'bg-secondary'); + } + } catch (error) { + updateTestStatus('wifi', 'Error', error.message, 'bg-secondary'); + } + + await delay(500); + // Step 1: Enable config mode document.getElementById('selftest_status').innerHTML = `