Umstellung auf UTC Timestamp

This commit is contained in:
Sven committed 2025-09-10 13:40:45 +02:00
1 parent 6154bf833e
commit ac6c468870
10 files changed
+41 -107

No files matched your search

+14 -4
View File
@@ -196,6 +196,10 @@ class MqttCore with ProducerMixin, ConsumerMixin {
var buffer = Uint8Buffer();
buffer.addAll(GZipEncoder().encode(const Utf8Encoder().convert(encapsulatedMessageText)) as Iterable<int>);
// Ensure no trailing slash in topic portion
if (topic.endsWith('/')) {
topic = topic.substring(0, topic.length - 1);
}
var messageTopic = "$_toServerTopic$_clientId/$topic";
_mqttClient!.publishMessage(messageTopic, MqttQos.atMostOnce, buffer);
@@ -205,7 +209,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
return true;
} catch (ex) {
Util.logInfo("send failed!");
Util.logInfo("send failed: $ex");
}
return false;
@@ -221,7 +225,13 @@ class MqttCore with ProducerMixin, ConsumerMixin {
var topicArray = message.variableHeader?.topicName;
var topicArraySplited = topicArray!.split("/");
var topic = 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);
}
Util.logInfo('message received\ntopic: $topic\n');
Util.logInfo("size in bytes: ${message.payload.message!.length.toString()}");
@@ -592,7 +602,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
var jobs = await MyApp.isarInstance.jobs.filter().stateGreaterThan(-1).findAll();
var answer = SyncJobsMessage();
answer.utcUnixTime = DateTime.now().toUtc().millisecondsSinceEpoch ~/ 1000;
answer.utcUnixTime = Util.nowUnixSecondsUtc();
answer.pos = SyncMessagePos();
answer.pos!.time = currentPosition != null ? Util.toUnixSecondsUtc(currentPosition.timestamp.toUtc()) : 0;
@@ -682,7 +692,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
message.id = job.id;
message.state = job.state;
message.ver = job.ver;
message.utc = DateTime.now().millisecondsSinceEpoch;
message.utc = Util.nowUnixSecondsUtc();
_publishMessage('job_received', message.toJson(), false);
}
+1 -1
View File
@@ -456,7 +456,7 @@ class DecimalTextInputFormatter extends TextInputFormatter {
}
bool isJobTooFarInFuture(Job job) {
var ordertime = DateTime.parse(job.ordertime).toUtc().millisecondsSinceEpoch;
var ordertime = job.ordertime * 1000; // convert seconds to milliseconds
var dateTimeThreshold = DateTime.now().add(Duration(minutes: job.offsWarn)).toUtc().millisecondsSinceEpoch;
return ordertime > dateTimeThreshold;