Erweiterungen

This commit is contained in:
Sven committed 2026-02-14 09:03:34 +01:00
1 parent bb3dc9e856
commit 4961aec177
1 file changed
+7 -29
+7 -29
View File
@@ -143,16 +143,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
Uint8Buffer uint8Buffer = Uint8Buffer();
uint8Buffer.addAll(willMessageUtf8);
_mqttClient!.connectionMessage = MqttConnectMessage()
.withClientIdentifier(Util.getAppUuid())
.authenticateAs("app", "apppwd")
.withSessionExpiryInterval(2700)
.withWillProperties(willProperties)
.withWillTopic("$_toServerTopic$_clientId/connection_lost")
.withWillQos(MqttQos.atMostOnce)
.keepAliveFor(60)
.withWillPayload(uint8Buffer)
.will();
_mqttClient!.connectionMessage = MqttConnectMessage().withClientIdentifier(Util.getAppUuid()).authenticateAs("app", "apppwd").withSessionExpiryInterval(2700).withWillProperties(willProperties).withWillTopic("$_toServerTopic$_clientId/connection_lost").withWillQos(MqttQos.atMostOnce).keepAliveFor(60).withWillPayload(uint8Buffer).will();
}
await _mqttClient!.connect();
@@ -227,9 +218,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
var topicArray = message.variableHeader?.topicName;
var topicArraySplited = topicArray!.split("/");
var topic = topicArraySplited.length > 7
? topicArraySplited.sublist(7).join('/')
: (topicArraySplited.length == 8 ? topicArraySplited[7] : "");
var topic = topicArraySplited.length > 7 ? topicArraySplited.sublist(7).join('/') : (topicArraySplited.length == 8 ? topicArraySplited[7] : "");
if (topic.endsWith('/')) {
topic = topic.substring(0, topic.length - 1);
}
@@ -385,10 +374,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
box.removeAll();
box.put(ranking);
sendMessage(
routingKey: Constants.messageTopicRankingUpdated,
payload: RankingUpdated(),
);
sendMessage(routingKey: Constants.messageTopicRankingUpdated, payload: RankingUpdated());
}
void _jobMessageReceived(payloadData) async {
@@ -404,13 +390,11 @@ class MqttCore with ProducerMixin, ConsumerMixin {
if (existingJob != null) {
// Update existing job - preserve the ID
newJob.id = existingJob.id;
// Ensure files are updated even if the job already exists
// This handles migration from old app versions without files support
if (payloadData['files'] != null) {
newJob.files = (payloadData['files'] as List<dynamic>)
.map((e) => TourFile.fromJson(e as Map<String, dynamic>))
.toList();
newJob.files = (payloadData['files'] as List<dynamic>).map((e) => TourFile.fromJson(e as Map<String, dynamic>)).toList();
}
}
@@ -478,10 +462,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
var deviceLogRequest = DeviceLogRequest.fromJson(payloadData);
final box = MyApp.objectBoxStore.box<LogEntry>();
final query = box.query(
LogEntry_.time.greaterThan(deviceLogRequest.startDateTime.millisecondsSinceEpoch)
.and(LogEntry_.time.lessThan(deviceLogRequest.endDateTime.millisecondsSinceEpoch))
).build();
final query = box.query(LogEntry_.time.greaterThan(deviceLogRequest.startDateTime.millisecondsSinceEpoch).and(LogEntry_.time.lessThan(deviceLogRequest.endDateTime.millisecondsSinceEpoch))).build();
var logEintries = query.find();
query.close();
@@ -502,7 +483,6 @@ class MqttCore with ProducerMixin, ConsumerMixin {
box.removeMany(messages.map((e) => e.id).toList());
}
void _startReconnectTimer() {
connectionState = ConnectionStateEnum.notConnected;
@@ -663,7 +643,6 @@ class MqttCore with ProducerMixin, ConsumerMixin {
} else {
_publishMessage("track", <String, dynamic>{}, false);
}
} catch (ex) {
Util.logException("Error in periodic track timer: {$ex}");
}
@@ -763,8 +742,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
void _commandLogoutReceived(Map<String, dynamic> payload) {
try {
String timestamp = payload['timestamp']?.toString() ?? 'Unknown timestamp';
Util.logInfo('Command logout received with timestamp: $timestamp');
Util.logInfo('Command logout received');
// Disconnect MQTT client gracefully
_disconnectMqttClient();