Update for Lorabot
This commit is contained in:
parent
64cbe250bc
commit
8670c8116f
6
Lora-Bot/Lora-Bot.csproj.user
Normal file
6
Lora-Bot/Lora-Bot.csproj.user
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||||
|
<StartArguments>-freq 868100000 -sp 8 -bw 62500 -cr 6</StartArguments>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
@ -32,23 +32,17 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void EventLibSetter() {
|
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) {
|
protected override void LibUpadteThread(Object state) {
|
||||||
try {
|
try {
|
||||||
if (this.mqttconnect) {
|
if (this.mqttconnect) {
|
||||||
DeviceUpdateEvent e = state as DeviceUpdateEvent;
|
if(state.GetType().HasInterface(typeof(IMqtt))) {
|
||||||
String topic = "";
|
IMqtt sensor = state as IMqtt;
|
||||||
String data = "";
|
((ADataBackend)this.mqtt).Send("lora/" + sensor.MqttTopic(), sensor.ToJson());
|
||||||
if (e.Parent.GetType().HasInterface(typeof(IMqtt))) {
|
this.Update?.Invoke(this, new MqttEvent("lora/" + sensor.MqttTopic(), sensor.ToJson()));
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -7,7 +7,7 @@ using BlubbFish.Utils;
|
|||||||
using BlubbFish.Utils.IoT.Bots;
|
using BlubbFish.Utils.IoT.Bots;
|
||||||
using BlubbFish.Utils.IoT.Bots.Moduls;
|
using BlubbFish.Utils.IoT.Bots.Moduls;
|
||||||
using Fraunhofer.Fit.Iot.Lora;
|
using Fraunhofer.Fit.Iot.Lora;
|
||||||
using Fraunhofer.Fit.Iot.Lora.Devices;
|
using Fraunhofer.Fit.Iot.Lora.Trackers;
|
||||||
using Fraunhofer.Fit.Iot.Lora.Events;
|
using Fraunhofer.Fit.Iot.Lora.Events;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
@ -44,34 +44,34 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void EventLibSetter() {
|
public override void EventLibSetter() {
|
||||||
this.library.Update += this.HandleLibUpdate;
|
this.library.DataUpdate += this.HandleLibUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LibUpadteThread(Object state) {
|
protected override void LibUpadteThread(Object state) {
|
||||||
try {
|
try {
|
||||||
DeviceUpdateEvent e = state as DeviceUpdateEvent;
|
if (state is DataUpdateEvent data) {
|
||||||
LoraClient l = (LoraClient)e.Parent;
|
if (!this.nodes.Contains(data.Name)) {
|
||||||
if (!this.nodes.Contains(l.Name)) {
|
this.SendRegister(data);
|
||||||
this.SendRegister(l);
|
this.nodes.Add(data.Name);
|
||||||
this.nodes.Add(l.Name);
|
}
|
||||||
|
this.SendUpdate(data);
|
||||||
}
|
}
|
||||||
this.SendUpdate(l);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Helper.WriteError("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls.Scral.LibUpadteThread: " + e.Message);
|
Helper.WriteError("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls.Scral.LibUpadteThread: " + e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SendUpdate(LoraClient l) {
|
private void SendUpdate(DataUpdateEvent data) {
|
||||||
if (l.Gps.Fix) {
|
if (data.Gps.Fix) {
|
||||||
Dictionary<String, Object> d = new Dictionary<String, Object> {
|
Dictionary<String, Object> d = new Dictionary<String, Object> {
|
||||||
{ "type", "uwb" },
|
{ "type", "uwb" },
|
||||||
{ "tagId", l.Name },
|
{ "tagId", data.Name },
|
||||||
{ "timestamp", DateTime.Now.ToString("o") },
|
{ "timestamp", DateTime.Now.ToString("o") },
|
||||||
{ "lat", l.Gps.Latitude },
|
{ "lat", data.Gps.Latitude },
|
||||||
{ "lon", l.Gps.Longitude },
|
{ "lon", data.Gps.Longitude },
|
||||||
{ "bearing", l.Rssi },
|
{ "bearing", data.Rssi },
|
||||||
{ "herr", l.Gps.Hdop },
|
{ "herr", data.Gps.Hdop },
|
||||||
{ "battery_level", l.Snr }
|
{ "battery_level", data.Snr }
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
String addr = this.config["update"]["addr"];
|
String addr = this.config["update"]["addr"];
|
||||||
@ -81,17 +81,17 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Helper.WriteError("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls.Scral.SendUpdate: " + e.Message);
|
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<String, Object> d = new Dictionary<String, Object> {
|
Dictionary<String, Object> d = new Dictionary<String, Object> {
|
||||||
{ "device", "wearable" },
|
{ "device", "wearable" },
|
||||||
{ "sensor", "tag" },
|
{ "sensor", "tag" },
|
||||||
{ "type", "uwb" },
|
{ "type", "uwb" },
|
||||||
{ "tagId", l.Name },
|
{ "tagId", data.Name },
|
||||||
{ "timestamp", DateTime.Now.ToString("o") },
|
{ "timestamp", DateTime.Now.ToString("o") },
|
||||||
{ "unitOfMeasurements", "meters" },
|
{ "unitOfMeasurements", "meters" },
|
||||||
{ "observationType", "propietary" },
|
{ "observationType", "propietary" },
|
||||||
|
@ -4,7 +4,7 @@ using BlubbFish.Utils;
|
|||||||
using BlubbFish.Utils.IoT.Bots.Events;
|
using BlubbFish.Utils.IoT.Bots.Events;
|
||||||
using BlubbFish.Utils.IoT.Bots.Moduls;
|
using BlubbFish.Utils.IoT.Bots.Moduls;
|
||||||
using Fraunhofer.Fit.Iot.Lora;
|
using Fraunhofer.Fit.Iot.Lora;
|
||||||
using Fraunhofer.Fit.Iot.Lora.Devices;
|
using Fraunhofer.Fit.Iot.Lora.Trackers;
|
||||||
using Fraunhofer.Fit.Iot.Lora.Events;
|
using Fraunhofer.Fit.Iot.Lora.Events;
|
||||||
|
|
||||||
namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
|
namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
|
||||||
@ -25,14 +25,13 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void EventLibSetter() {
|
public override void EventLibSetter() {
|
||||||
this.library.Update += this.HandleLibUpdate;
|
this.library.DataUpdate += this.HandleLibUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LibUpadteThread(Object state) {
|
protected override void LibUpadteThread(Object state) {
|
||||||
try {
|
try {
|
||||||
DeviceUpdateEvent e = state as DeviceUpdateEvent;
|
if(state is DataUpdateEvent data) {
|
||||||
if (e.Parent is LoraClient l) {
|
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;
|
||||||
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;
|
|
||||||
this.file.WriteLine(s);
|
this.file.WriteLine(s);
|
||||||
this.file.Flush();
|
this.file.Flush();
|
||||||
this.Update?.Invoke(this, new ModulEventArgs(this.filename, "Line", s, "TXTOUT"));
|
this.Update?.Invoke(this, new ModulEventArgs(this.filename, "Line", s, "TXTOUT"));
|
||||||
|
@ -3,33 +3,56 @@ using System.Collections.Generic;
|
|||||||
using BlubbFish.Utils;
|
using BlubbFish.Utils;
|
||||||
using BlubbFish.Utils.IoT.Bots;
|
using BlubbFish.Utils.IoT.Bots;
|
||||||
using Fraunhofer.Fit.Iot.Lora;
|
using Fraunhofer.Fit.Iot.Lora;
|
||||||
|
using Fraunhofer.Fit.Iot.Lora.Events;
|
||||||
|
|
||||||
namespace Fraunhofer.Fit.IoT.Bots.LoraBot {
|
namespace Fraunhofer.Fit.IoT.Bots.LoraBot {
|
||||||
class Program : Bot<LoraController> {
|
class Program : Bot<LoraController> {
|
||||||
static void Main(String[] args) => new Program(args);
|
static void Main(String[] args) => new Program(args);
|
||||||
public Program(String[] args) {
|
public Program(String[] args) {
|
||||||
InIReader.SetSearchPath(new List<String>() { "/etc/lorabot", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\lorabot" });
|
InIReader.SetSearchPath(new List<String>() { "/etc/lorabot", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\lorabot" });
|
||||||
if (!InIReader.ConfigExist("settings")) {
|
CmdArgs.Instance.SetArguments(new Dictionary<String, CmdArgs.VaildArguments>() {
|
||||||
Helper.WriteError("No settings.ini found. Abord!");
|
{ "-freq", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple) },
|
||||||
return;
|
{ "-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<String, String>() {
|
||||||
|
{ "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) {
|
private void LoraStatusUpdate(Object sender, StatusUpdateEvent e) {
|
||||||
Console.WriteLine("-> Lora " + e.Parent.ToString());
|
Console.WriteLine("-> Lora-Status: " + e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoraDataUpdate(Object sender, DataUpdateEvent e) {
|
||||||
|
Console.WriteLine("-> Lora-Data: " + e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("LoraDisplay")]
|
[assembly: AssemblyProduct("LoraDisplay")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
[assembly: AssemblyCopyright("Copyright © 2018 - 10.10.2018")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@ -32,10 +32,15 @@ using System.Runtime.InteropServices;
|
|||||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.3.0")]
|
[assembly: AssemblyVersion("1.6.0")]
|
||||||
[assembly: AssemblyFileVersion("1.3.0")]
|
[assembly: AssemblyFileVersion("1.6.0")]
|
||||||
/*
|
/*
|
||||||
* 1.1.0 Update Scral addresses
|
* 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.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.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
|
||||||
*/
|
*/
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,7 +3,7 @@ Version: x.x-x
|
|||||||
Section: base
|
Section: base
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Depends: mono-complete (>= 5.4.1.6)
|
Depends: mono-runtime (>= 5.16.0)
|
||||||
Maintainer: BlubbFish <dev@blubbfish.net>
|
Maintainer: BlubbFish <dev@blubbfish.net>
|
||||||
Description: Lora-Bot
|
Description: Lora-Bot
|
||||||
Lora-Bot is a Lora gateway
|
Lora-Bot is a Lora gateway
|
||||||
|
Reference in New Issue
Block a user