Matthias Nott
9 days ago 1bf6e76e31383aef77e42943fc2caf350cf7e096
lib/services/mqtt_service.dart
....@@ -11,6 +11,7 @@
1111 import 'package:path_provider/path_provider.dart' as pp;
1212 import 'package:mqtt_client/mqtt_client.dart';
1313 import 'package:mqtt_client/mqtt_server_client.dart';
14
+import 'package:typed_data/typed_data.dart';
1415 import 'package:shared_preferences/shared_preferences.dart';
1516 import 'package:uuid/uuid.dart';
1617
....@@ -665,6 +666,15 @@
665666 /// Current timestamp in milliseconds.
666667 int _now() => DateTime.now().millisecondsSinceEpoch;
667668
669
+ /// Publish raw bytes to a topic. Used by TraceService for log streaming.
670
+ void publishRaw(String topic, Uint8Buffer payload, MqttQos qos) {
671
+ final client = _client;
672
+ if (client == null || client.connectionStatus?.state != MqttConnectionState.connected) return;
673
+ try {
674
+ client.publishMessage(topic, qos, payload);
675
+ } catch (_) {}
676
+ }
677
+
668678 /// Publish a JSON payload to an MQTT topic.
669679 void _publish(String topic, Map<String, dynamic> payload, MqttQos qos) {
670680 final client = _client;