Make Deb of 1.2.0 of Lorabot
This commit is contained in:
parent
f1636e9033
commit
c3ab7b897b
@ -45,7 +45,6 @@
|
||||
<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" />
|
||||
@ -86,6 +85,9 @@
|
||||
<None Include="app.manifest">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="config-example\scral.conf.example">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="config-example\mqtt.conf.example">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
@ -95,6 +97,14 @@
|
||||
<None Include="config-example\txtout.conf.example">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="dpkg\control" />
|
||||
<None Include="dpkg\create-Builds.bat" />
|
||||
<None Include="dpkg\make-deb.sh" />
|
||||
<None Include="dpkg\postinst" />
|
||||
<None Include="dpkg\preinst" />
|
||||
<None Include="dpkg\prerm" />
|
||||
<None Include="dpkg\lorabot-logrotate" />
|
||||
<None Include="dpkg\lorabot.service" />
|
||||
<None Include="gpio.2.44">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
@ -105,9 +115,5 @@
|
||||
<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>
|
@ -1,87 +0,0 @@
|
||||
/*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() {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
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.Events;
|
||||
using LitJson;
|
||||
|
||||
using LitJson;
|
||||
|
||||
namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
|
||||
public class Scral : AModul<LoraController> {
|
||||
private readonly List<String> nodes = new List<String>();
|
||||
@ -33,40 +33,40 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
|
||||
}
|
||||
this.SendUpdate(l);
|
||||
} catch { }
|
||||
}
|
||||
|
||||
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 }
|
||||
};
|
||||
}
|
||||
|
||||
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 }
|
||||
};
|
||||
if(this.RequestString("scral/puetz/dexels/wearable/localization", JsonMapper.ToJson(d), false, RequestMethod.PUT) == null) {
|
||||
this.Register(l);
|
||||
}
|
||||
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"));
|
||||
}
|
||||
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() { }
|
||||
@ -114,5 +114,5 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls {
|
||||
PUT
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,9 @@ 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.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
[assembly: AssemblyVersion("1.2.0")]
|
||||
[assembly: AssemblyFileVersion("1.2.0")]
|
||||
/*
|
||||
* 1.1.0.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
|
||||
*/
|
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.
6
Lora-Bot/bin/Release/config-example/scral.conf.example
Normal file
6
Lora-Bot/bin/Release/config-example/scral.conf.example
Normal file
@ -0,0 +1,6 @@
|
||||
[modul]
|
||||
config=private
|
||||
|
||||
[settings]
|
||||
type=mqtt
|
||||
server=localhost
|
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
[google]
|
||||
api_key = 12345345345673645
|
2
Lora-Bot/config-example/scral.conf.example
Normal file
2
Lora-Bot/config-example/scral.conf.example
Normal file
@ -0,0 +1,2 @@
|
||||
[modul]
|
||||
config=private
|
9
Lora-Bot/dpkg/control
Normal file
9
Lora-Bot/dpkg/control
Normal file
@ -0,0 +1,9 @@
|
||||
Package: lorabot
|
||||
Version: x.x-x
|
||||
Section: base
|
||||
Priority: optional
|
||||
Architecture: any
|
||||
Depends: mono-complete (>= 5.4.1.6)
|
||||
Maintainer: BlubbFish <dev@blubbfish.net>
|
||||
Description: Lora-Bot
|
||||
Lora-Bot is a Lora gateway
|
2
Lora-Bot/dpkg/create-Builds.bat
Normal file
2
Lora-Bot/dpkg/create-Builds.bat
Normal file
@ -0,0 +1,2 @@
|
||||
bash.exe -c "./make-deb.sh armhf"
|
||||
pause
|
10
Lora-Bot/dpkg/lorabot-logrotate
Normal file
10
Lora-Bot/dpkg/lorabot-logrotate
Normal file
@ -0,0 +1,10 @@
|
||||
/var/log/lorabot.log {
|
||||
compress
|
||||
copytruncate
|
||||
daily
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
rotate 4
|
||||
size=10M
|
||||
}
|
20
Lora-Bot/dpkg/lorabot.service
Normal file
20
Lora-Bot/dpkg/lorabot.service
Normal file
@ -0,0 +1,20 @@
|
||||
# If you modify this, please also make sure to edit init.sh
|
||||
|
||||
[Unit]
|
||||
Description=Lora-Bot
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/usr/local/bin/lorabot
|
||||
ExecStart=/usr/bin/mono /usr/local/bin/lorabot/Lora-Bot.exe
|
||||
KillMode=control-group
|
||||
TimeoutStopSec=5
|
||||
Restart=on-failure
|
||||
StandardOutput=null
|
||||
StandardError=syslog
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Alias=lorabot.service
|
51
Lora-Bot/dpkg/make-deb.sh
Normal file
51
Lora-Bot/dpkg/make-deb.sh
Normal file
@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
HOMEDIR="/home/blubb"
|
||||
ROOT="$HOMEDIR/deb"
|
||||
OUTPUT="../bin/Release"
|
||||
|
||||
EXEC="$ROOT/usr/local/bin/lorabot"
|
||||
CONFIG="$ROOT/etc/lorabot"
|
||||
SYSTEMD="$ROOT/lib/systemd/system"
|
||||
LOGROTATE="$ROOT/etc/logrotate.d"
|
||||
|
||||
DEBIAN="$ROOT/DEBIAN"
|
||||
VMAJOR=$(grep -e "^\[assembly: AssemblyVersion(\"" ../Properties/AssemblyInfo.cs | cut -d'"' -f 2 | cut -d'.' -f 1)
|
||||
VMINOR=$(grep -e "^\[assembly: AssemblyVersion(\"" ../Properties/AssemblyInfo.cs | cut -d'"' -f 2 | cut -d'.' -f 2)
|
||||
VBUILD=$(grep -e "^\[assembly: AssemblyVersion(\"" ../Properties/AssemblyInfo.cs | cut -d'"' -f 2 | cut -d'.' -f 3)
|
||||
ARCHT=$1
|
||||
|
||||
mkdir -p $EXEC
|
||||
mkdir -p $CONFIG
|
||||
mkdir -p $DEBIAN
|
||||
mkdir -p $SYSTEMD
|
||||
mkdir -p $LOGROTATE
|
||||
|
||||
cp control $DEBIAN
|
||||
cp preinst $DEBIAN
|
||||
cp postinst $DEBIAN
|
||||
cp prerm $DEBIAN
|
||||
sed -i s/Version:\ x\.x-x/"Version: $VMAJOR.$VMINOR-$VBUILD"/ $DEBIAN/control
|
||||
sed -i s/Architecture:\ any/"Architecture: $ARCHT"/ $DEBIAN/control
|
||||
chmod 755 $DEBIAN -R
|
||||
|
||||
cp lorabot.service $SYSTEMD
|
||||
chmod 644 $SYSTEMD/lorabot.service
|
||||
|
||||
cp $OUTPUT/*.exe $EXEC/
|
||||
cp $OUTPUT/gpio.2.44 $EXEC/
|
||||
cp $OUTPUT/libwiringPi.so.2.44 $EXEC/
|
||||
find $OUTPUT -name \*.dll ! -name Mono.Posix.dll -exec cp {} $EXEC/ \;
|
||||
chmod 644 $EXEC/*
|
||||
chmod 755 $EXEC
|
||||
|
||||
cp $OUTPUT/config-example/* $CONFIG
|
||||
chmod 644 $CONFIG/*
|
||||
chmod 755 $CONFIG
|
||||
|
||||
cp lorabot-logrotate $LOGROTATE/lorabot
|
||||
chmod 644 $LOGROTATE/*
|
||||
|
||||
dpkg-deb --build $ROOT
|
||||
mv $HOMEDIR/deb.deb ../../../Builds/"$ARCHT-lorabot_$VMAJOR.$VMINOR-$VBUILD.deb"
|
||||
rm $HOMEDIR/deb -r
|
8
Lora-Bot/dpkg/postinst
Normal file
8
Lora-Bot/dpkg/postinst
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
systemctl enable lorabot
|
||||
systemctl daemon-reload
|
||||
if [[ $(systemctl is-active lorabot || true) == "active" ]]
|
||||
then
|
||||
service lorabot restart
|
||||
fi
|
2
Lora-Bot/dpkg/preinst
Normal file
2
Lora-Bot/dpkg/preinst
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
|
3
Lora-Bot/dpkg/prerm
Normal file
3
Lora-Bot/dpkg/prerm
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
service lorabot stop
|
@ -1,44 +0,0 @@
|
||||
<!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