Update Lora
This commit is contained in:
parent
135e605231
commit
8381319596
42
Lora-Bot.sln
42
Lora-Bot.sln
@ -7,6 +7,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lora-Bot", "Lora-Bot\Lora-B
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lora", "..\Lora\Lora\Lora.csproj", "{85A78B05-5843-4E4D-8C56-4BCB12613750}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iot-Interfaces", "..\Utils\IoT\Interfaces\Iot-Interfaces.csproj", "{4DAADA29-C600-4CF3-8AD3-9C97C8D7F632}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "litjson_4.7.1", "..\Librarys\litjson\litjson\litjson_4.7.1.csproj", "{91A14CD2-2940-4500-8193-56D37EDDDBAA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bot-Utils", "..\Utils\Bot-Utils\Bot-Utils.csproj", "{BB7BFCB5-3DB0-49E1-802A-3CE3EECC59F9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\Utils\Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorDataMqtt", "..\Utils\IoT\Connector\Data\Mqtt\ConnectorDataMqtt.csproj", "{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils\IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "M2Mqtt_4.7.1", "..\Librarys\mqtt\M2Mqtt\M2Mqtt_4.7.1.csproj", "{A11AEF5A-B246-4FE8-8330-06DB73CC8074}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -21,6 +35,34 @@ Global
|
||||
{85A78B05-5843-4E4D-8C56-4BCB12613750}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{85A78B05-5843-4E4D-8C56-4BCB12613750}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{85A78B05-5843-4E4D-8C56-4BCB12613750}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4DAADA29-C600-4CF3-8AD3-9C97C8D7F632}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4DAADA29-C600-4CF3-8AD3-9C97C8D7F632}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4DAADA29-C600-4CF3-8AD3-9C97C8D7F632}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4DAADA29-C600-4CF3-8AD3-9C97C8D7F632}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BB7BFCB5-3DB0-49E1-802A-3CE3EECC59F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BB7BFCB5-3DB0-49E1-802A-3CE3EECC59F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BB7BFCB5-3DB0-49E1-802A-3CE3EECC59F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BB7BFCB5-3DB0-49E1-802A-3CE3EECC59F9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -31,6 +31,9 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@ -42,14 +45,69 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Moduls\Googlelocation.cs" />
|
||||
<Compile Include="Moduls\Mqtt.cs" />
|
||||
<Compile Include="Moduls\Scral.cs" />
|
||||
<Compile Include="Moduls\Txtout.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Utils\IoT\Connector\Data\Mqtt\ConnectorDataMqtt.csproj">
|
||||
<Project>{ee6c8f68-ed46-4c1c-abdd-cfcdf75104f2}</Project>
|
||||
<Name>ConnectorDataMqtt</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Utils\IoT\Utils-IoT.csproj">
|
||||
<Project>{b870e4d5-6806-4a0b-b233-8907eedc5afc}</Project>
|
||||
<Name>Utils-IoT</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
|
||||
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
|
||||
<Name>Utils</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Librarys\litjson\litjson\litjson_4.7.1.csproj">
|
||||
<Project>{91a14cd2-2940-4500-8193-56d37edddbaa}</Project>
|
||||
<Name>litjson_4.7.1</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Lora\Lora\Lora.csproj">
|
||||
<Project>{85a78b05-5843-4e4d-8c56-4bcb12613750}</Project>
|
||||
<Name>Lora</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Utils\Bot-Utils\Bot-Utils.csproj">
|
||||
<Project>{bb7bfcb5-3db0-49e1-802a-3ce3eecc59f9}</Project>
|
||||
<Name>Bot-Utils</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Utils\IoT\Interfaces\Iot-Interfaces.csproj">
|
||||
<Project>{4daada29-c600-4cf3-8ad3-9c97c8d7f632}</Project>
|
||||
<Name>Iot-Interfaces</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.manifest">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="config-example\mqtt.conf.example">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="config-example\settings.conf.example">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="config-example\txtout.conf.example">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="gpio.2.44">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="libwiringPi.so.2.44">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="lora.sh">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="config-example\googlelocation.conf.example" />
|
||||
<Content Include="resources\google.html" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
87
Lora-Bot/Moduls/Googlelocation.cs
Normal file
87
Lora-Bot/Moduls/Googlelocation.cs
Normal file
@ -0,0 +1,87 @@
|
||||
/*using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using BlubbFish.Utils;
|
||||
using BlubbFish.Utils.IoT.Bots.Moduls;
|
||||
using Fraunhofer.Fit.Iot.Lora;
|
||||
using Fraunhofer.Fit.Iot.Lora.Devices;
|
||||
using LitJson;
|
||||
|
||||
namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls_broken {
|
||||
class Googlelocation : AModul<LoraController> {
|
||||
private readonly HttpListener _listener = new HttpListener();
|
||||
private readonly Dictionary<String, Queue<LoraClient>> locations = new Dictionary<String, Queue<LoraClient>>();
|
||||
|
||||
public override event ModulEvent Update;
|
||||
|
||||
public Googlelocation(LoraController lib, InIReader settings) : base(lib, settings) {
|
||||
this._listener.Prefixes.Add("http://+:8080/");
|
||||
this._listener.Start();
|
||||
this.Run();
|
||||
}
|
||||
|
||||
private void Run() {
|
||||
ThreadPool.QueueUserWorkItem((o) => {
|
||||
Console.WriteLine("Webserver is Running...");
|
||||
try {
|
||||
while(this._listener.IsListening) {
|
||||
ThreadPool.QueueUserWorkItem((c) => {
|
||||
HttpListenerContext ctx = c as HttpListenerContext;
|
||||
try {
|
||||
String rstr = this.SendResponse(ctx.Request);
|
||||
Byte[] buf = Encoding.UTF8.GetBytes(rstr);
|
||||
ctx.Response.ContentLength64 = buf.Length;
|
||||
ctx.Response.OutputStream.Write(buf, 0, buf.Length);
|
||||
}
|
||||
catch { }
|
||||
finally {
|
||||
ctx.Response.OutputStream.Close();
|
||||
}
|
||||
}, this._listener.GetContext());
|
||||
}
|
||||
}
|
||||
catch { };
|
||||
});
|
||||
}
|
||||
|
||||
private String SendResponse(HttpListenerRequest request) {
|
||||
if(request.Url.PathAndQuery == "/") {
|
||||
if(File.Exists("resources/google.html")) {
|
||||
try {
|
||||
String file = File.ReadAllText("resources/google.html");
|
||||
file = file.Replace("{%YOUR_API_KEY%}", this.config["google"]["api_key"]);
|
||||
return file;
|
||||
}
|
||||
catch { return "500"; }
|
||||
}
|
||||
return "404";
|
||||
}
|
||||
if(request.Url.PathAndQuery == "/loc") {
|
||||
Dictionary<String, Object> ret = new Dictionary<String, Object>();
|
||||
foreach (KeyValuePair<String, Queue<LoraClient>> devices in this.locations) {
|
||||
Dictionary<String, Object> subret = new Dictionary<String, Object>();
|
||||
Int32 i = 0;
|
||||
foreach (LoraClient item in devices.Value) {
|
||||
subret.Add(i++.ToString(), item.ToDictionary());
|
||||
}
|
||||
ret.Add(devices.Key, subret);
|
||||
}
|
||||
return JsonMapper.ToJson(ret);
|
||||
}
|
||||
return "<h1>Works</h1>"+ request.Url.PathAndQuery;
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
this._listener.Stop();
|
||||
this._listener.Close();
|
||||
}
|
||||
|
||||
protected override void UpdateConfig() {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
49
Lora-Bot/Moduls/Mqtt.cs
Normal file
49
Lora-Bot/Moduls/Mqtt.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using BlubbFish.Utils;
|
||||
using BlubbFish.Utils.IoT.Bots;
|
||||
using BlubbFish.Utils.IoT.Bots.Events;
|
||||
using BlubbFish.Utils.IoT.Bots.Moduls;
|
||||
using BlubbFish.Utils.IoT.Connector;
|
||||
using BlubbFish.Utils.IoT.Interfaces;
|
||||
using Fraunhofer.Fit.Iot.Lora;
|
||||
using Fraunhofer.Fit.Iot.Lora.Events;
|
||||
|
||||
namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
|
||||
class Mqtt : Mqtt<LoraController> {
|
||||
public override event ModulEvent Update;
|
||||
|
||||
public Mqtt(LoraController lib, InIReader settings) : base(lib, settings) { }
|
||||
|
||||
protected override void Connect() {
|
||||
this.mqtt = ABackend.GetInstance(this.config["settings"], ABackend.BackendType.Data);
|
||||
//this.mqtt.MessageIncomming += this.EventInput;
|
||||
this.library.Update += this.EventOutput;
|
||||
Console.WriteLine("Connect!");
|
||||
}
|
||||
|
||||
protected override void Disconnect() {
|
||||
this.library.Update -= this.EventOutput;
|
||||
if (this.mqtt != null) {
|
||||
this.mqtt.Dispose();
|
||||
}
|
||||
this.mqtt = null;
|
||||
Console.WriteLine("Disconnect!");
|
||||
}
|
||||
|
||||
protected virtual void EventOutput(Object sender, DeviceUpdateEvent e) {
|
||||
String topic = "";
|
||||
String data = "";
|
||||
if (e.Parent.GetType().HasInterface(typeof(IMqtt))) {
|
||||
IMqtt sensor = (IMqtt)e.Parent;
|
||||
topic = "lora/" + sensor.MqttTopic();
|
||||
data = sensor.ToJson();
|
||||
}
|
||||
Console.WriteLine(topic);
|
||||
Console.WriteLine(data);
|
||||
if (topic != "" && data != "") {
|
||||
((ADataBackend)this.mqtt).Send(topic, data);
|
||||
this.Update?.Invoke(this, new MqttEvent(topic, data));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
130
Lora-Bot/Moduls/Scral.cs
Normal file
130
Lora-Bot/Moduls/Scral.cs
Normal file
@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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 LitJson;
|
||||
|
||||
namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls
|
||||
{
|
||||
public class Scral : AModul<LoraController>
|
||||
{
|
||||
private readonly List<String> nodes = new List<String>();
|
||||
public override event ModulEvent Update;
|
||||
private Object getLock = new Object();
|
||||
private String server = "https://portal.monica-cloud.eu/";
|
||||
public Scral(LoraController lib, InIReader settings) : base(lib, settings)
|
||||
{
|
||||
lib.Update += Lib_Update;
|
||||
}
|
||||
|
||||
private void Lib_Update(object sender, Iot.Lora.Events.DeviceUpdateEvent e)
|
||||
{
|
||||
LoraClient l = (LoraClient)e.Parent;
|
||||
if (!nodes.Contains(l.Name))
|
||||
{
|
||||
this.Register(l);
|
||||
this.nodes.Add(l.Name);
|
||||
}
|
||||
this.SendUpdate(l);
|
||||
|
||||
}
|
||||
|
||||
private void SendUpdate(LoraClient l) {
|
||||
if (l.Gps.Fix) {
|
||||
Dictionary<String, Object> d = new Dictionary<String, Object> {
|
||||
{ "type", "uwb"},
|
||||
{ "tagId", l.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}
|
||||
};
|
||||
this.RequestString("scral/puetz/dexels/wearable/localization", JsonMapper.ToJson(d), false, RequestMethod.PUT);
|
||||
this.Update?.Invoke(this, new BlubbFish.Utils.IoT.Bots.Events.ModulEventArgs("scral/puetz/dexels/wearable/localization", "PUT", JsonMapper.ToJson(d), "SCRAL"));
|
||||
}
|
||||
}
|
||||
|
||||
private void Register(LoraClient l) {
|
||||
Dictionary<String, Object> d = new Dictionary<String, Object> {
|
||||
{ "device", "wearable" },
|
||||
{ "sensor", "tag" },
|
||||
{ "type", "uwb" },
|
||||
{ "tagId", l.Name},
|
||||
{ "timestamp", DateTime.Now.ToString("o") },
|
||||
{ "unitOfMeasurements", "meters" },
|
||||
{ "observationType", "propietary" },
|
||||
{ "state", "active" }
|
||||
};
|
||||
this.RequestString("scral/puetz/dexels/wearable", JsonMapper.ToJson(d), false, RequestMethod.POST);
|
||||
this.Update?.Invoke(this, new BlubbFish.Utils.IoT.Bots.Events.ModulEventArgs("scral/puetz/dexels/wearable", "POST", JsonMapper.ToJson(d), "SCRAL"));
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void UpdateConfig() { }
|
||||
|
||||
private String RequestString(String address, String json = "", Boolean withoutput = true, RequestMethod method = RequestMethod.GET)
|
||||
{
|
||||
String ret = null;
|
||||
lock (this.getLock)
|
||||
{
|
||||
HttpWebRequest request = WebRequest.CreateHttp(this.server + address);
|
||||
request.Timeout = 5000;
|
||||
if (method == RequestMethod.POST || method == RequestMethod.PUT)
|
||||
{
|
||||
Byte[] requestdata = Encoding.ASCII.GetBytes(json);
|
||||
request.ContentLength = requestdata.Length;
|
||||
request.Method = method.ToString();
|
||||
request.ContentType = "application/json";
|
||||
using (Stream stream = request.GetRequestStream())
|
||||
{
|
||||
stream.Write(requestdata, 0, requestdata.Length);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||
{
|
||||
if (response.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
Console.Error.WriteLine("Benutzer oder Passwort falsch!");
|
||||
throw new Exception("Benutzer oder Passwort falsch!");
|
||||
}
|
||||
if (withoutput)
|
||||
{
|
||||
StreamReader reader = new StreamReader(response.GetResponseStream());
|
||||
ret = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Helper.WriteError("Konnte keine Verbindung zum Razzbery Server herstellen. Resource: \"" + this.server + address + "\" Fehler: " + e.Message);
|
||||
return null;
|
||||
//throw new Exceptions.ConnectionException("Konnte keine Verbindung zum Razzbery Server herstellen: " + e.Message);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private enum RequestMethod
|
||||
{
|
||||
GET,
|
||||
POST,
|
||||
PUT
|
||||
}
|
||||
}
|
||||
}
|
41
Lora-Bot/Moduls/Txtout.cs
Normal file
41
Lora-Bot/Moduls/Txtout.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
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.Events;
|
||||
|
||||
namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
|
||||
public class Txtout : AModul<LoraController> {
|
||||
public override event ModulEvent Update;
|
||||
|
||||
private readonly String filename;
|
||||
private readonly StreamWriter file;
|
||||
|
||||
public Txtout(LoraController lib, InIReader settings) : base(lib, settings) {
|
||||
if (this.config.ContainsKey("general") && this.config["general"].ContainsKey("path")) {
|
||||
this.filename = this.config["general"]["path"];
|
||||
this.file = new StreamWriter(this.filename);
|
||||
this.library.Update += this.Library_Update;
|
||||
}
|
||||
}
|
||||
|
||||
private void Library_Update(Object sender, DeviceUpdateEvent e) {
|
||||
if (sender 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;
|
||||
this.file.WriteLine(s);
|
||||
this.file.Flush();
|
||||
this.Update?.Invoke(this, new ModulEventArgs(this.filename, "Line", s, "TXTOUT"));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
this.file.Flush();
|
||||
this.file.Close();
|
||||
}
|
||||
|
||||
protected override void UpdateConfig() {}
|
||||
}
|
||||
}
|
@ -1,14 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlubbFish.Utils;
|
||||
using BlubbFish.Utils.IoT.Bots;
|
||||
using BlubbFish.Utils.IoT.Interfaces;
|
||||
using Fraunhofer.Fit.Iot.Lora;
|
||||
|
||||
namespace LoraDisplay {
|
||||
class Program {
|
||||
static void Main(String[] args) {
|
||||
LoraController l = new LoraController();
|
||||
}
|
||||
namespace Fraunhofer.Fit.IoT.Bots.LoraBot {
|
||||
class Program : Bot<LoraController> {
|
||||
static void Main(String[] args) => new Program(args);
|
||||
public Program(String[] args) {
|
||||
InIReader.SetSearchPath(new List<String>() { "/etc/lorabot", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\lorabot" });
|
||||
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.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.UpdateTime + "]: " + e.Parent.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -32,5 +32,8 @@ using System.Runtime.InteropServices;
|
||||
// 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.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
/*
|
||||
* 1.1.0.0 Update Scral addresses
|
||||
*/
|
76
Lora-Bot/app.manifest
Normal file
76
Lora-Bot/app.manifest
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC-Manifestoptionen
|
||||
Wenn Sie die Ebene der Benutzerkontensteuerung für Windows ändern möchten, ersetzen Sie den
|
||||
Knoten "requestedExecutionLevel" wie folgt.
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
Durch Angabe des Elements "requestedExecutionLevel" wird die Datei- und Registrierungsvirtualisierung deaktiviert.
|
||||
Entfernen Sie dieses Element, wenn diese Virtualisierung aus Gründen der Abwärtskompatibilität
|
||||
für die Anwendung erforderlich ist.
|
||||
-->
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- Eine Liste der Windows-Versionen, unter denen diese Anwendung getestet
|
||||
und für die sie entwickelt wurde. Wenn Sie die Auskommentierung der entsprechenden Elemente aufheben,
|
||||
wird von Windows automatisch die kompatibelste Umgebung ausgewählt. -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<!-- Gibt an, dass die Anwendung mit DPI-Werten kompatibel ist und von Windows nicht automatisch auf höhere
|
||||
DPI-Werte skaliert wird. WPF-Anwendungen (Windows Presentation Foundation) sind automatisch mit DPI-Werten kompatibel und müssen sich nicht
|
||||
anmelden. Für Windows Forms-Anwendungen für .NET Framework 4.6, die sich für diese Einstellung anmelden, muss
|
||||
auch die Einstellung "'EnableWindowsFormsHighDpiAutoResizing" in der "app.config" auf "true" festgelegt werden. -->
|
||||
<!--
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
-->
|
||||
|
||||
<!-- Designs für allgemeine Windows-Steuerelemente und -Dialogfelder (Windows XP und höher) aktivieren -->
|
||||
<!--
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
</assembly>
|
BIN
Lora-Bot/bin/Release/Bot-Utils.dll
Normal file
BIN
Lora-Bot/bin/Release/Bot-Utils.dll
Normal file
Binary file not shown.
BIN
Lora-Bot/bin/Release/ConnectorDataMqtt.dll
Normal file
BIN
Lora-Bot/bin/Release/ConnectorDataMqtt.dll
Normal file
Binary file not shown.
BIN
Lora-Bot/bin/Release/Iot-Interfaces.dll
Normal file
BIN
Lora-Bot/bin/Release/Iot-Interfaces.dll
Normal file
Binary file not shown.
BIN
Lora-Bot/bin/Release/Lora-Bot.exe
Normal file
BIN
Lora-Bot/bin/Release/Lora-Bot.exe
Normal file
Binary file not shown.
BIN
Lora-Bot/bin/Release/Lora.dll
Normal file
BIN
Lora-Bot/bin/Release/Lora.dll
Normal file
Binary file not shown.
BIN
Lora-Bot/bin/Release/M2Mqtt.dll
Normal file
BIN
Lora-Bot/bin/Release/M2Mqtt.dll
Normal file
Binary file not shown.
BIN
Lora-Bot/bin/Release/Unosquare.RaspberryIO.dll
Normal file
BIN
Lora-Bot/bin/Release/Unosquare.RaspberryIO.dll
Normal file
Binary file not shown.
BIN
Lora-Bot/bin/Release/Unosquare.Swan.Lite.dll
Normal file
BIN
Lora-Bot/bin/Release/Unosquare.Swan.Lite.dll
Normal file
Binary file not shown.
BIN
Lora-Bot/bin/Release/Unosquare.Swan.dll
Normal file
BIN
Lora-Bot/bin/Release/Unosquare.Swan.dll
Normal file
Binary file not shown.
BIN
Lora-Bot/bin/Release/Utils-IoT.dll
Normal file
BIN
Lora-Bot/bin/Release/Utils-IoT.dll
Normal file
Binary file not shown.
BIN
Lora-Bot/bin/Release/Utils.dll
Normal file
BIN
Lora-Bot/bin/Release/Utils.dll
Normal file
Binary file not shown.
6
Lora-Bot/bin/Release/config-example/mqtt.conf.example
Normal file
6
Lora-Bot/bin/Release/config-example/mqtt.conf.example
Normal file
@ -0,0 +1,6 @@
|
||||
[modul]
|
||||
config=private
|
||||
|
||||
[settings]
|
||||
type=mqtt
|
||||
server=localhost
|
@ -0,0 +1,8 @@
|
||||
[logging]
|
||||
path=/var/log/lorabot.log
|
||||
|
||||
[lora]
|
||||
frequency=868100000
|
||||
spreadingfactor=8
|
||||
signalbandwith=125000
|
||||
codingrate=6
|
2
Lora-Bot/bin/Release/config-example/txtout.conf.example
Normal file
2
Lora-Bot/bin/Release/config-example/txtout.conf.example
Normal file
@ -0,0 +1,2 @@
|
||||
[general]
|
||||
path=/home/pi/coords.txt
|
BIN
Lora-Bot/bin/Release/gpio.2.44
Normal file
BIN
Lora-Bot/bin/Release/gpio.2.44
Normal file
Binary file not shown.
BIN
Lora-Bot/bin/Release/litjson.dll
Normal file
BIN
Lora-Bot/bin/Release/litjson.dll
Normal file
Binary file not shown.
5
Lora-Bot/bin/Release/lora.sh
Normal file
5
Lora-Bot/bin/Release/lora.sh
Normal file
@ -0,0 +1,5 @@
|
||||
for(( ; ; ))
|
||||
do
|
||||
sudo mono --debug Lora-Bot.exe
|
||||
done
|
||||
|
2
Lora-Bot/config-example/googlelocation.conf.example
Normal file
2
Lora-Bot/config-example/googlelocation.conf.example
Normal file
@ -0,0 +1,2 @@
|
||||
[google]
|
||||
api_key = 12345345345673645
|
6
Lora-Bot/config-example/mqtt.conf.example
Normal file
6
Lora-Bot/config-example/mqtt.conf.example
Normal file
@ -0,0 +1,6 @@
|
||||
[modul]
|
||||
config=private
|
||||
|
||||
[settings]
|
||||
type=mqtt
|
||||
server=localhost
|
8
Lora-Bot/config-example/settings.conf.example
Normal file
8
Lora-Bot/config-example/settings.conf.example
Normal file
@ -0,0 +1,8 @@
|
||||
[logging]
|
||||
path=/var/log/lorabot.log
|
||||
|
||||
[lora]
|
||||
frequency=868100000
|
||||
spreadingfactor=8
|
||||
signalbandwith=125000
|
||||
codingrate=6
|
2
Lora-Bot/config-example/txtout.conf.example
Normal file
2
Lora-Bot/config-example/txtout.conf.example
Normal file
@ -0,0 +1,2 @@
|
||||
[general]
|
||||
path=/home/pi/coords.txt
|
BIN
Lora-Bot/gpio.2.44
Normal file
BIN
Lora-Bot/gpio.2.44
Normal file
Binary file not shown.
5
Lora-Bot/lora.sh
Normal file
5
Lora-Bot/lora.sh
Normal file
@ -0,0 +1,5 @@
|
||||
for(( ; ; ))
|
||||
do
|
||||
sudo mono --debug Lora-Bot.exe
|
||||
done
|
||||
|
44
Lora-Bot/resources/google.html
Normal file
44
Lora-Bot/resources/google.html
Normal file
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Google Map</title>
|
||||
<style>
|
||||
/* Always set the map height explicitly to define the size of the div
|
||||
* element that contains the map. */
|
||||
#map {
|
||||
height: 100%;
|
||||
}
|
||||
/* Optional: Makes the sample page fill the window. */
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Google Map</h1>
|
||||
<div id="map"></div>
|
||||
<script>
|
||||
|
||||
function initMap() {
|
||||
var myLatLng = {lat: -25.363, lng: 131.044};
|
||||
|
||||
var map = new google.maps.Map(document.getElementById('map'), {
|
||||
zoom: 4,
|
||||
center: myLatLng
|
||||
});
|
||||
|
||||
var marker = new google.maps.Marker({
|
||||
position: myLatLng,
|
||||
map: map,
|
||||
title: 'Hello World!'
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script async defer src="https://maps.googleapis.com/maps/api/js?key={%YOUR_API_KEY%}&callback=initMap">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user