first commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<RootNamespace>BlubbFish.IoT.Pocsag.BosServerStorage</RootNamespace>
|
||||
<Version>1.1.2</Version>
|
||||
<Description>1.1.2 Fix searchpath for config
|
||||
1.1.1 Fix InvariantGlobalization, so Linux will start the app
|
||||
1.1.0 Rewrite from Mysql to Influx
|
||||
1.0.0 Init</Description>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Utils\Bot-Utils\Bot-Utils\Bot-Utils.csproj" />
|
||||
<ProjectReference Include="..\..\Utils\ConnectorDataMqtt\ConnectorDataMqtt\ConnectorDataMqtt.csproj" />
|
||||
<ProjectReference Include="..\..\Utils\Utils-IoT\Utils-IoT\Utils-IoT.csproj" />
|
||||
<ProjectReference Include="..\..\Utils\Utils\Utils\Utils.csproj" />
|
||||
<ProjectReference Include="..\BosServerDatatypes\BosServerDatatypes.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="config-example\settings.conf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
using BlubbFish.IoT.Pocsag.BosServerDatatypes.Influx;
|
||||
using BlubbFish.IoT.Pocsag.BosServerDatatypes.Mqtt;
|
||||
using BlubbFish.Utils;
|
||||
using BlubbFish.Utils.IoT.Bots;
|
||||
using BlubbFish.Utils.IoT.Connector;
|
||||
using BlubbFish.Utils.IoT.Events;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerStorage {
|
||||
class Program : ABot {
|
||||
private readonly ABackend mqtt;
|
||||
private readonly Dictionary<String, String> bosconf;
|
||||
|
||||
static void Main(String[] args) => new Program(args, true, "bsstorage");
|
||||
|
||||
public Program(String[] args, Boolean fileLogging, String configSearchPath) : base(args, fileLogging, configSearchPath) {
|
||||
this.mqtt = ABackend.GetInstance(InIReader.GetInstance("settings").GetSection("backend"));
|
||||
this.mqtt.MessageIncomming += this.Mqtt_MessageIncomming;
|
||||
this.mqtt.MessageSending += this.Mqtt_MessageSending;
|
||||
|
||||
this.bosconf = InIReader.GetInstance("settings").GetSection("bosserverstorage");
|
||||
|
||||
this.SendMqtt(new Message("Anwendung BosServerStorage Version " + Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion + " gestartet."));
|
||||
this.WaitForShutdown();
|
||||
this.SendMqtt(new Message("Anwendung BosServerStorage wurde beendet... Ob das so soll?"));
|
||||
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
private void Mqtt_MessageSending(Object sender, BackendEvent mqtt) {
|
||||
try {
|
||||
Console.WriteLine("=> MQTT [" + mqtt.From.ToString() + "]: " + mqtt.Message);
|
||||
} catch(Exception ex) {
|
||||
Helper.WriteError("Backend_MessageSending(): " + ex.Message + "\n\n" + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
private void Mqtt_MessageIncomming(Object sender, BackendEvent mqtt) {
|
||||
try {
|
||||
Console.WriteLine("<= MQTT [" + mqtt.From.ToString() + "]: " + mqtt.Message);
|
||||
if(AMqttMessage.CheckJson(mqtt.Message, typeof(PocsagParsed))) {
|
||||
this.SendMqtt(new InfluxStorage(new Bosmon(PocsagParsed.ConvertJson(mqtt.Message)).ToInfluxString()));
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
Helper.WriteError("Backend_MessageIncomming(): " + ex.Message + "\n\n" + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
private void SendMqtt(AMqttMessage msg) {
|
||||
try {
|
||||
((Utils.IoT.Connector.Data.Mqtt)this.mqtt).Send(this.bosconf["topic"] + "/" + msg.Datatype, msg.ToJson());
|
||||
} catch(Exception e) {
|
||||
Helper.WriteError("SendMqtt(): " + e.Message + "\n\n" + e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
if(this.mqtt != null) {
|
||||
this.mqtt.Dispose();
|
||||
}
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
[logging]
|
||||
path=/var/log/bsstorage.log
|
||||
debug=true
|
||||
|
||||
[backend]
|
||||
type=Mqtt
|
||||
backendtype=Data
|
||||
server=localhost
|
||||
topic=bosmon/pocsag-parsed
|
||||
|
||||
[bosserverstorage]
|
||||
topic=bosmon
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
CSPROJFILE="BosServerStorage.csproj"
|
||||
VMAJOR=$(grep -e "<Version>" ../$CSPROJFILE | cut -d'>' -f 2 | cut -d'<' -f 1 | cut -d'.' -f 1)
|
||||
VMINOR=$(grep -e "<Version>" ../$CSPROJFILE | cut -d'>' -f 2 | cut -d'<' -f 1 | cut -d'.' -f 2)
|
||||
VBUILD=$(grep -e "<Version>" ../$CSPROJFILE | cut -d'>' -f 2 | cut -d'<' -f 1 | cut -d'.' -f 3)
|
||||
|
||||
mkdir -p ../deb
|
||||
mkdir -p ../Builds
|
||||
|
||||
export NAME=bsstorage
|
||||
export MAINAINER="BlubbFish <dev@blubbfish.net>"
|
||||
export VERSION="$VMAJOR.$VMINOR-$VBUILD"
|
||||
export DESCRIPTION="bsstorage converts parsed pocsag messages to influx format"
|
||||
export DEPENDENCIES="dotnet-runtime-8.0 (>= 8.0.0)"
|
||||
export LOGFILE="/var/log/bsstorage.log"
|
||||
|
||||
export EXEPATH=BosServerStorage.dll
|
||||
export RUNNER=/usr/share/dotnet/dotnet
|
||||
export COPYEXEC="../bin/Release/netcoreapp3.1/*.dll ../bin/Release/netcoreapp3.1/BosServerStorage.deps.json ../bin/Release/netcoreapp3.1/BosServerStorage.runtimeconfig.json"
|
||||
|
||||
export COPYCONFIG="../bin/Release/netcoreapp3.1/config-example/*.conf"
|
||||
export CONFIGREPLACEASK=settings.conf
|
||||
|
||||
cd ../deb
|
||||
export PLATFORM=armhf
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/control-build.sh | bash
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/pre-post-build.sh | bash
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/service-build.sh | bash
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/logrotate-build.sh | bash
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/build-deb.sh | bash
|
||||
|
||||
export PLATFORM=amd64
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/control-build.sh | bash
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/build-deb.sh | bash
|
||||
|
||||
cd ..
|
||||
rm deb -rf
|
||||
|
||||
cp Builds/* ../../Builds/
|
||||
rm Builds -rf
|
||||
Reference in New Issue
Block a user