From c83f8396aaa4779b20b0346a25547c801c1a2898 Mon Sep 17 00:00:00 2001 From: PaulVua Date: Tue, 17 Mar 2026 18:09:39 +0100 Subject: [PATCH] WiFi status: detection live wlan0 au lieu de se fier a la DB Le WIFI_status en DB peut etre desynchronise (ex: reconnexion manuelle via SSH). Maintenant get_config_sqlite detecte le vrai etat de wlan0 via nmcli et corrige la DB si necessaire. Co-Authored-By: Claude Opus 4.6 (1M context) --- html/launcher.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/html/launcher.php b/html/launcher.php index 53bdbaa..c0f39a0 100755 --- a/html/launcher.php +++ b/html/launcher.php @@ -66,10 +66,26 @@ if ($type == "get_config_sqlite") { $result[$key] = $parsed_value; } + // Detect real WiFi status from wlan0 (DB value may be stale) + $wlan0_conn = trim(shell_exec("nmcli -t -f GENERAL.CONNECTION device show wlan0 2>/dev/null | cut -d: -f2")); + if (!empty($wlan0_conn) && $wlan0_conn !== '--') { + $is_hotspot = (stripos($wlan0_conn, 'hotspot') !== false); + $real_status = $is_hotspot ? 'hotspot' : 'connected'; + } else { + $real_status = 'disconnected'; + } + + // Update DB if out of sync + if (isset($result['WIFI_status']) && $result['WIFI_status'] !== $real_status) { + $update_stmt = $db->prepare("UPDATE config_table SET value = ? WHERE key = 'WIFI_status'"); + $update_stmt->execute([$real_status]); + } + $result['WIFI_status'] = $real_status; + // Return JSON response header('Content-Type: application/json'); echo json_encode($result, JSON_PRETTY_PRINT); - + } catch (PDOException $e) { // Return error as JSON header('Content-Type: application/json');