diff --git a/Lora-Bot/Lora-Bot.csproj.user b/Lora-Bot/Lora-Bot.csproj.user
new file mode 100644
index 0000000..b6809fe
--- /dev/null
+++ b/Lora-Bot/Lora-Bot.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ -freq 868100000 -sp 8 -bw 62500 -cr 6
+
+
\ No newline at end of file
diff --git a/Lora-Bot/Moduls/Mqtt.cs b/Lora-Bot/Moduls/Mqtt.cs
index 35ca207..8b4bc16 100644
--- a/Lora-Bot/Moduls/Mqtt.cs
+++ b/Lora-Bot/Moduls/Mqtt.cs
@@ -32,23 +32,17 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
}
public override void EventLibSetter() {
- this.library.Update += this.HandleLibUpdate;
+ this.library.DataUpdate += this.HandleLibUpdate;
+ this.library.StatusUpdate += this.HandleLibUpdate;
}
protected override void LibUpadteThread(Object state) {
try {
if (this.mqttconnect) {
- DeviceUpdateEvent e = state as DeviceUpdateEvent;
- String topic = "";
- String data = "";
- if (e.Parent.GetType().HasInterface(typeof(IMqtt))) {
- IMqtt sensor = (IMqtt)e.Parent;
- topic = "lora/" + sensor.MqttTopic();
- data = sensor.ToJson();
- }
- if (topic != "" && data != "") {
- ((ADataBackend)this.mqtt).Send(topic, data);
- this.Update?.Invoke(this, new MqttEvent(topic, data));
+ if(state.GetType().HasInterface(typeof(IMqtt))) {
+ IMqtt sensor = state as IMqtt;
+ ((ADataBackend)this.mqtt).Send("lora/" + sensor.MqttTopic(), sensor.ToJson());
+ this.Update?.Invoke(this, new MqttEvent("lora/" + sensor.MqttTopic(), sensor.ToJson()));
}
}
} catch (Exception e) {
diff --git a/Lora-Bot/Moduls/Scral.cs b/Lora-Bot/Moduls/Scral.cs
index c61e69d..d59f687 100644
--- a/Lora-Bot/Moduls/Scral.cs
+++ b/Lora-Bot/Moduls/Scral.cs
@@ -7,7 +7,7 @@ using BlubbFish.Utils;
using BlubbFish.Utils.IoT.Bots;
using BlubbFish.Utils.IoT.Bots.Moduls;
using Fraunhofer.Fit.Iot.Lora;
-using Fraunhofer.Fit.Iot.Lora.Devices;
+using Fraunhofer.Fit.Iot.Lora.Trackers;
using Fraunhofer.Fit.Iot.Lora.Events;
using LitJson;
@@ -44,34 +44,34 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
}
public override void EventLibSetter() {
- this.library.Update += this.HandleLibUpdate;
+ this.library.DataUpdate += this.HandleLibUpdate;
}
protected override void LibUpadteThread(Object state) {
try {
- DeviceUpdateEvent e = state as DeviceUpdateEvent;
- LoraClient l = (LoraClient)e.Parent;
- if (!this.nodes.Contains(l.Name)) {
- this.SendRegister(l);
- this.nodes.Add(l.Name);
+ if (state is DataUpdateEvent data) {
+ if (!this.nodes.Contains(data.Name)) {
+ this.SendRegister(data);
+ this.nodes.Add(data.Name);
+ }
+ this.SendUpdate(data);
}
- this.SendUpdate(l);
} catch (Exception e) {
Helper.WriteError("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls.Scral.LibUpadteThread: " + e.Message);
}
}
- private void SendUpdate(LoraClient l) {
- if (l.Gps.Fix) {
+ private void SendUpdate(DataUpdateEvent data) {
+ if (data.Gps.Fix) {
Dictionary d = new Dictionary {
{ "type", "uwb" },
- { "tagId", l.Name },
+ { "tagId", data.Name },
{ "timestamp", DateTime.Now.ToString("o") },
- { "lat", l.Gps.Latitude },
- { "lon", l.Gps.Longitude },
- { "bearing", l.Rssi },
- { "herr", l.Gps.Hdop },
- { "battery_level", l.Snr }
+ { "lat", data.Gps.Latitude },
+ { "lon", data.Gps.Longitude },
+ { "bearing", data.Rssi },
+ { "herr", data.Gps.Hdop },
+ { "battery_level", data.Snr }
};
try {
String addr = this.config["update"]["addr"];
@@ -81,17 +81,17 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
}
} catch (Exception e) {
Helper.WriteError("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls.Scral.SendUpdate: " + e.Message);
- this.SendRegister(l);
+ this.SendRegister(data);
}
}
}
- private void SendRegister(LoraClient l) {
+ private void SendRegister(DataUpdateEvent data) {
Dictionary d = new Dictionary {
{ "device", "wearable" },
{ "sensor", "tag" },
{ "type", "uwb" },
- { "tagId", l.Name },
+ { "tagId", data.Name },
{ "timestamp", DateTime.Now.ToString("o") },
{ "unitOfMeasurements", "meters" },
{ "observationType", "propietary" },
diff --git a/Lora-Bot/Moduls/Txtout.cs b/Lora-Bot/Moduls/Txtout.cs
index d412182..b1aad76 100644
--- a/Lora-Bot/Moduls/Txtout.cs
+++ b/Lora-Bot/Moduls/Txtout.cs
@@ -4,7 +4,7 @@ using BlubbFish.Utils;
using BlubbFish.Utils.IoT.Bots.Events;
using BlubbFish.Utils.IoT.Bots.Moduls;
using Fraunhofer.Fit.Iot.Lora;
-using Fraunhofer.Fit.Iot.Lora.Devices;
+using Fraunhofer.Fit.Iot.Lora.Trackers;
using Fraunhofer.Fit.Iot.Lora.Events;
namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
@@ -25,14 +25,13 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
}
public override void EventLibSetter() {
- this.library.Update += this.HandleLibUpdate;
+ this.library.DataUpdate += this.HandleLibUpdate;
}
protected override void LibUpadteThread(Object state) {
try {
- DeviceUpdateEvent e = state as DeviceUpdateEvent;
- if (e.Parent is LoraClient l) {
- String s = l.Name + "," + l.Receivedtime.ToString("o") + "," + l.Gps.Latitude + "," + l.Gps.Longitude + ",https://www.google.de/maps?q=" + l.Gps.Latitude + "%2C" + l.Gps.Longitude + "," + l.Rssi + "," + l.PacketRssi + "," + l.Snr;
+ if(state is DataUpdateEvent data) {
+ String s = data.Name + "," + data.Receivedtime.ToString("o") + "," + data.Gps.Latitude + "," + data.Gps.Longitude + "," + data.Rssi + "," + data.PacketRssi + "," + data.Snr + ",https://www.google.de/maps?q=" + data.Gps.Latitude + "%2C" + data.Gps.Longitude;
this.file.WriteLine(s);
this.file.Flush();
this.Update?.Invoke(this, new ModulEventArgs(this.filename, "Line", s, "TXTOUT"));
diff --git a/Lora-Bot/Program.cs b/Lora-Bot/Program.cs
index 14f34b0..8a19fbb 100644
--- a/Lora-Bot/Program.cs
+++ b/Lora-Bot/Program.cs
@@ -3,33 +3,56 @@ using System.Collections.Generic;
using BlubbFish.Utils;
using BlubbFish.Utils.IoT.Bots;
using Fraunhofer.Fit.Iot.Lora;
+using Fraunhofer.Fit.Iot.Lora.Events;
namespace Fraunhofer.Fit.IoT.Bots.LoraBot {
class Program : Bot {
static void Main(String[] args) => new Program(args);
public Program(String[] args) {
InIReader.SetSearchPath(new List() { "/etc/lorabot", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\lorabot" });
- if (!InIReader.ConfigExist("settings")) {
- Helper.WriteError("No settings.ini found. Abord!");
- return;
+ CmdArgs.Instance.SetArguments(new Dictionary() {
+ { "-freq", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple) },
+ { "-bw", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple) },
+ { "-sp", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple) },
+ { "-cr", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple) },
+ }, args);
+ if (!CmdArgs.Instance.HasArgumentType("-freq") && !CmdArgs.Instance.HasArgumentType("-bw") && !CmdArgs.Instance.HasArgumentType("-sp") && !CmdArgs.Instance.HasArgumentType("-cr")) {
+ if (!InIReader.ConfigExist("settings")) {
+ Helper.WriteError("No settings.ini found. Abord!");
+ return;
+ }
+ InIReader settings = InIReader.GetInstance("settings");
+ this.logger.SetPath(settings.GetValue("logging", "path"));
+ LoraController lora = new LoraController(settings.GetSection("lora"));
+ this.ModulLoader("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls", lora);
+ this.ModulInterconnect();
+ this.ModulEvents();
+ lora.DataUpdate += this.LoraDataUpdate;
+ lora.StatusUpdate += this.LoraStatusUpdate;
+ this.WaitForShutdown();
+ Console.WriteLine("after wait");
+ this.ModulDispose();
+ Console.WriteLine("after dispose");
+ lora.Dispose();
+ Console.WriteLine("after loradisp");
+ } else if(CmdArgs.Instance.HasArgumentType("-freq") && CmdArgs.Instance.HasArgumentType("-bw") && CmdArgs.Instance.HasArgumentType("-sp") && CmdArgs.Instance.HasArgumentType("-cr")) {
+ LoraController lora = new LoraController(new Dictionary() {
+ { "frequency", CmdArgs.Instance.GetArgumentData("-freq") },
+ { "signalbandwith", CmdArgs.Instance.GetArgumentData("-bw") },
+ { "spreadingfactor", CmdArgs.Instance.GetArgumentData("-sp") },
+ { "codingrate", CmdArgs.Instance.GetArgumentData("-cr") }
+ }, false);
+ } else {
+ Helper.WriteError("Usage for Debug:\n" + CmdArgs.Instance.GetUsageList("Lora-Bot"));
}
- InIReader settings = InIReader.GetInstance("settings");
- this.logger.SetPath(settings.GetValue("logging", "path"));
- LoraController lora = new LoraController(settings.GetSection("lora"));
- this.ModulLoader("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls", lora);
- this.ModulInterconnect();
- this.ModulEvents();
- lora.Update += this.LoraDataUpdate;
- this.WaitForShutdown();
- Console.WriteLine("after wait");
- this.ModulDispose();
- Console.WriteLine("after dispose");
- lora.Dispose();
- Console.WriteLine("after loradisp");
}
- private void LoraDataUpdate(Object sender, Iot.Lora.Events.DeviceUpdateEvent e) {
- Console.WriteLine("-> Lora " + e.Parent.ToString());
+ private void LoraStatusUpdate(Object sender, StatusUpdateEvent e) {
+ Console.WriteLine("-> Lora-Status: " + e.ToString());
+ }
+
+ private void LoraDataUpdate(Object sender, DataUpdateEvent e) {
+ Console.WriteLine("-> Lora-Data: " + e.ToString());
}
}
diff --git a/Lora-Bot/Properties/AssemblyInfo.cs b/Lora-Bot/Properties/AssemblyInfo.cs
index 3a9a3eb..6684b2e 100644
--- a/Lora-Bot/Properties/AssemblyInfo.cs
+++ b/Lora-Bot/Properties/AssemblyInfo.cs
@@ -1,41 +1,46 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// Allgemeine Informationen über eine Assembly werden über die folgenden
-// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
-// die einer Assembly zugeordnet sind.
-[assembly: AssemblyTitle("LoraDisplay")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("LoraDisplay")]
-[assembly: AssemblyCopyright("Copyright © 2018")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
-// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
-// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
-[assembly: ComVisible(false)]
-
-// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
-[assembly: Guid("fb11b997-af4d-427f-96fd-4c84143057cf")]
-
-// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
-//
-// Hauptversion
-// Nebenversion
-// Buildnummer
-// Revision
-//
-// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
-// übernehmen, indem Sie "*" eingeben:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.3.0")]
-[assembly: AssemblyFileVersion("1.3.0")]
-/*
- * 1.1.0 Update Scral addresses
- * 1.2.0 Run Module Events in threads so that one Module can not block others, TXTOut now appends to the logfile
- * 1.3.0 Scral now get its config from configfile, lora now want to get battery as [0-9].[0-9]{2} value
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die einer Assembly zugeordnet sind.
+[assembly: AssemblyTitle("LoraDisplay")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("LoraDisplay")]
+[assembly: AssemblyCopyright("Copyright © 2018 - 10.10.2018")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
+// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
+// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("fb11b997-af4d-427f-96fd-4c84143057cf")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.6.0")]
+[assembly: AssemblyFileVersion("1.6.0")]
+/*
+ * 1.1.0 Update Scral addresses
+ * 1.2.0 Run Module Events in threads so that one Module can not block others, TXTOut now appends to the logfile
+ * 1.3.0 Scral now get its config from configfile, lora now want to get battery as [0-9].[0-9]{2} value
+ * 1.4.0 Adding Debugmode for finetuning Lora-Trackers
+ * 1.4.1 Remove old Wirelesscode and Rename some Classes
+ * 1.5.0 Send over Mqtt the new status items and refactoring
+ * 1.5.1 Dependencies in debian Packet cleaned
+ * 1.6.0 Implement Height in LoraBot
*/
diff --git a/Lora-Bot/bin/Release/Bot-Utils.dll b/Lora-Bot/bin/Release/Bot-Utils.dll
index eb7fd4b..aea097e 100644
Binary files a/Lora-Bot/bin/Release/Bot-Utils.dll and b/Lora-Bot/bin/Release/Bot-Utils.dll differ
diff --git a/Lora-Bot/bin/Release/ConnectorDataMqtt.dll b/Lora-Bot/bin/Release/ConnectorDataMqtt.dll
index cceb8e3..ecc30ab 100644
Binary files a/Lora-Bot/bin/Release/ConnectorDataMqtt.dll and b/Lora-Bot/bin/Release/ConnectorDataMqtt.dll differ
diff --git a/Lora-Bot/bin/Release/Iot-Interfaces.dll b/Lora-Bot/bin/Release/Iot-Interfaces.dll
index 54db89b..59664a0 100644
Binary files a/Lora-Bot/bin/Release/Iot-Interfaces.dll and b/Lora-Bot/bin/Release/Iot-Interfaces.dll differ
diff --git a/Lora-Bot/bin/Release/Lora-Bot.exe b/Lora-Bot/bin/Release/Lora-Bot.exe
index 2331adc..c8c0ffa 100644
Binary files a/Lora-Bot/bin/Release/Lora-Bot.exe and b/Lora-Bot/bin/Release/Lora-Bot.exe differ
diff --git a/Lora-Bot/bin/Release/Lora.dll b/Lora-Bot/bin/Release/Lora.dll
index c03e526..c1ea11c 100644
Binary files a/Lora-Bot/bin/Release/Lora.dll and b/Lora-Bot/bin/Release/Lora.dll differ
diff --git a/Lora-Bot/bin/Release/M2Mqtt.dll b/Lora-Bot/bin/Release/M2Mqtt.dll
index 3f67f8c..3dac2a8 100644
Binary files a/Lora-Bot/bin/Release/M2Mqtt.dll and b/Lora-Bot/bin/Release/M2Mqtt.dll differ
diff --git a/Lora-Bot/bin/Release/Utils-IoT.dll b/Lora-Bot/bin/Release/Utils-IoT.dll
index 2cd403e..d3ceff1 100644
Binary files a/Lora-Bot/bin/Release/Utils-IoT.dll and b/Lora-Bot/bin/Release/Utils-IoT.dll differ
diff --git a/Lora-Bot/bin/Release/Utils.dll b/Lora-Bot/bin/Release/Utils.dll
index f8b51d3..b4d72a6 100644
Binary files a/Lora-Bot/bin/Release/Utils.dll and b/Lora-Bot/bin/Release/Utils.dll differ
diff --git a/Lora-Bot/bin/Release/litjson.dll b/Lora-Bot/bin/Release/litjson.dll
index 693061f..3ceb162 100644
Binary files a/Lora-Bot/bin/Release/litjson.dll and b/Lora-Bot/bin/Release/litjson.dll differ
diff --git a/Lora-Bot/dpkg/control b/Lora-Bot/dpkg/control
index 701aac3..51c9246 100644
--- a/Lora-Bot/dpkg/control
+++ b/Lora-Bot/dpkg/control
@@ -3,7 +3,7 @@ Version: x.x-x
Section: base
Priority: optional
Architecture: any
-Depends: mono-complete (>= 5.4.1.6)
+Depends: mono-runtime (>= 5.16.0)
Maintainer: BlubbFish
Description: Lora-Bot
Lora-Bot is a Lora gateway