Matthias Nott
2026-03-25 9aea0e7837ae0ea3d417f3d2afd8554cd71f123d
lib/services/mqtt_service.dart
....@@ -56,6 +56,7 @@
5656
5757 // Callbacks
5858 void Function(ConnectionStatus status)? onStatusChanged;
59
+ void Function(String detail)? onStatusDetail; // "Probing local...", "Scanning network..."
5960 void Function(Map<String, dynamic> message)? onMessage;
6061 void Function()? onOpen;
6162 void Function()? onClose;
....@@ -117,6 +118,7 @@
117118 if (config.vpnHost != null && config.vpnHost!.isNotEmpty) hosts.add(config.vpnHost!);
118119 if (config.host.isNotEmpty) hosts.add(config.host);
119120 _mqttLog('MQTT: probing ${hosts.length} hosts in parallel: ${hosts.join(", ")}');
121
+ onStatusDetail?.call('Probing ${hosts.length} hosts...');
120122
121123 // Probe all configured hosts in parallel — first to respond wins
122124 String? winner;
....@@ -143,6 +145,7 @@
143145
144146 if (winner != null && !_intentionalClose) {
145147 _mqttLog('MQTT: probe winner: $winner, connecting...');
148
+ onStatusDetail?.call('Connecting to $winner...');
146149 try {
147150 if (await _tryConnect(winner, clientId, timeout: 5000)) return;
148151 } catch (e) {
....@@ -152,6 +155,7 @@
152155
153156 // All hosts failed — retry after delay
154157 _mqttLog('MQTT: all attempts failed, retrying in 5s');
158
+ onStatusDetail?.call('No server found, retrying...');
155159 _setStatus(ConnectionStatus.reconnecting);
156160 Future.delayed(const Duration(seconds: 5), () {
157161 if (!_intentionalClose && _status != ConnectionStatus.connected) {
....@@ -201,6 +205,7 @@
201205
202206 // Fallback: scan local subnet for MQTT port (handles Personal Hotspot)
203207 _mqttLog('MQTT: Bonjour failed, trying subnet scan...');
208
+ onStatusDetail?.call('Scanning local network...');
204209 return _scanSubnetForMqtt();
205210 }
206211