Notification and parking zones
All checks were successful
Build, Push and Run Container / build (push) Successful in 37s

This commit is contained in:
2025-08-20 12:00:41 +02:00
parent 326c46cb27
commit a9121cf48e
8 changed files with 138316 additions and 10 deletions

View File

@@ -22,9 +22,27 @@ public class MQTTClient : IHostedService
this.client.ApplicationMessageReceivedAsync += (e) =>
{
string message = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
logger.LogInformation("Message received: {Message}", message);
messageProcessor.ProcessMessage(message);
string topic = e.ApplicationMessage.Topic;
if (topic.IndexOf("/", StringComparison.Ordinal) > 0)
{
string[] parts = topic.Split('/'); //telemetry/5YJ3E7EB7KF291652/v/Location
if (parts is ["telemetry", _, "v", _])
{
string vin = parts[1];
string field = parts[3];
string? message = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
logger.LogInformation("Message received: {Message}", message);
messageProcessor.ProcessMessage(vin, field.ToLowerInvariant(), message.StripQuotes());
}
else
logger.LogWarning("Topic not passed to message processor: {Topic}", topic);
}
else
logger.LogWarning("Topic not passed to message processor: {Topic}", topic);
return Task.CompletedTask;
};
}
@@ -64,4 +82,6 @@ public class MQTTClient : IHostedService
public class MQTTClientConfiguration
{
}
}
file static class StringExtensions { public static string StripQuotes(this string value) => value.Trim('"'); }