From 9aea0e7837ae0ea3d417f3d2afd8554cd71f123d Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Wed, 25 Mar 2026 15:27:00 +0100
Subject: [PATCH] feat: show connection status detail in app bar during connect
---
lib/services/mqtt_service.dart | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/lib/services/mqtt_service.dart b/lib/services/mqtt_service.dart
index 4e34697..8277d8f 100644
--- a/lib/services/mqtt_service.dart
+++ b/lib/services/mqtt_service.dart
@@ -56,6 +56,7 @@
// Callbacks
void Function(ConnectionStatus status)? onStatusChanged;
+ void Function(String detail)? onStatusDetail; // "Probing local...", "Scanning network..."
void Function(Map<String, dynamic> message)? onMessage;
void Function()? onOpen;
void Function()? onClose;
@@ -117,6 +118,7 @@
if (config.vpnHost != null && config.vpnHost!.isNotEmpty) hosts.add(config.vpnHost!);
if (config.host.isNotEmpty) hosts.add(config.host);
_mqttLog('MQTT: probing ${hosts.length} hosts in parallel: ${hosts.join(", ")}');
+ onStatusDetail?.call('Probing ${hosts.length} hosts...');
// Probe all configured hosts in parallel — first to respond wins
String? winner;
@@ -143,6 +145,7 @@
if (winner != null && !_intentionalClose) {
_mqttLog('MQTT: probe winner: $winner, connecting...');
+ onStatusDetail?.call('Connecting to $winner...');
try {
if (await _tryConnect(winner, clientId, timeout: 5000)) return;
} catch (e) {
@@ -152,6 +155,7 @@
// All hosts failed — retry after delay
_mqttLog('MQTT: all attempts failed, retrying in 5s');
+ onStatusDetail?.call('No server found, retrying...');
_setStatus(ConnectionStatus.reconnecting);
Future.delayed(const Duration(seconds: 5), () {
if (!_intentionalClose && _status != ConnectionStatus.connected) {
@@ -201,6 +205,7 @@
// Fallback: scan local subnet for MQTT port (handles Personal Hotspot)
_mqttLog('MQTT: Bonjour failed, trying subnet scan...');
+ onStatusDetail?.call('Scanning local network...');
return _scanSubnetForMqtt();
}
--
Gitblit v1.3.1