[v1.7.0] Add support for IC880A Board
This commit is contained in:
parent
251b178ad6
commit
3b98e1878c
@ -1,70 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
|
||||||
using BlubbFish.Utils;
|
using BlubbFish.Utils;
|
||||||
using BlubbFish.Utils.IoT.Bots;
|
using BlubbFish.Utils.IoT.Bots;
|
||||||
using BlubbFish.Utils.IoT.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
using BlubbFish.Utils.IoT.Events;
|
using BlubbFish.Utils.IoT.Events;
|
||||||
|
using Fraunhofer.Fit.IoT.MqttMap.Model;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls_broken {
|
namespace Fraunhofer.Fit.IoT.MqttMap {
|
||||||
class Botclient {
|
|
||||||
|
|
||||||
public Botclient(Int32 paketrssi, Int32 rssi, Double snr, String updatetime, Double lat, Double lon, Double hdop, Int32 battery, Boolean fix) {
|
|
||||||
this.PacketRssi = paketrssi;
|
|
||||||
this.Rssi = rssi;
|
|
||||||
this.Snr = snr;
|
|
||||||
this.Upatedtime = updatetime;
|
|
||||||
this.Latitude = lat;
|
|
||||||
this.Longitude = lon;
|
|
||||||
this.Hdop = hdop;
|
|
||||||
this.Battery = battery;
|
|
||||||
this.Fix = fix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Int32 PacketRssi { get; private set; }
|
|
||||||
public Int32 Rssi { get; private set; }
|
|
||||||
public Double Snr { get; private set; }
|
|
||||||
public String Upatedtime { get; private set; }
|
|
||||||
public Double Latitude { get; private set; }
|
|
||||||
public Double Longitude { get; private set; }
|
|
||||||
public Double Hdop { get; private set; }
|
|
||||||
public Int32 Battery { get; private set; }
|
|
||||||
public Boolean Fix { get; private set; }
|
|
||||||
|
|
||||||
public virtual Dictionary<String, Object> ToDictionary() {
|
|
||||||
Dictionary<String, Object> dictionary = new Dictionary<String, Object>();
|
|
||||||
foreach (PropertyInfo item in this.GetType().GetProperties()) {
|
|
||||||
if (item.CanRead && item.GetValue(this) != null) {
|
|
||||||
if (item.GetValue(this).GetType().GetMethod("ToDictionary") != null) {
|
|
||||||
dictionary.Add(item.Name, item.GetValue(this).GetType().GetMethod("ToDictionary").Invoke(item.GetValue(this), null));
|
|
||||||
} else if (item.GetValue(this).GetType().HasInterface(typeof(IDictionary))) {
|
|
||||||
Dictionary<String, Object> subdict = new Dictionary<String, Object>();
|
|
||||||
foreach (DictionaryEntry subitem in (IDictionary)item.GetValue(this)) {
|
|
||||||
if (subitem.Value.GetType().GetMethod("ToDictionary") != null) {
|
|
||||||
subdict.Add(subitem.Key.ToString(), subitem.Value.GetType().GetMethod("ToDictionary").Invoke(subitem.Value, null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dictionary.Add(item.Name, subdict);
|
|
||||||
} else if (item.GetValue(this).GetType().BaseType == typeof(Enum)) {
|
|
||||||
dictionary.Add(item.Name, Helper.GetEnumDescription((Enum)item.GetValue(this)));
|
|
||||||
} else {
|
|
||||||
dictionary.Add(item.Name, item.GetValue(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dictionary;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Googlelocation : Webserver
|
class Googlelocation : Webserver
|
||||||
{
|
{
|
||||||
private readonly Dictionary<String, List<Botclient>> locations = new Dictionary<String, List<Botclient>>();
|
private readonly Dictionary<String, Botclient> locations = new Dictionary<String, Botclient>();
|
||||||
|
|
||||||
public Googlelocation(ADataBackend backend, Dictionary<String, String> settings, InIReader requests) : base(backend, settings, requests) { }
|
public Googlelocation(ADataBackend backend, Dictionary<String, String> settings, InIReader requests) : base(backend, settings, requests) { }
|
||||||
|
|
||||||
@ -75,7 +25,7 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls_broken {
|
|||||||
&& d.ContainsKey("Rssi") && d["Rssi"].IsInt
|
&& d.ContainsKey("Rssi") && d["Rssi"].IsInt
|
||||||
&& d.ContainsKey("Snr") && d["Snr"].IsDouble
|
&& d.ContainsKey("Snr") && d["Snr"].IsDouble
|
||||||
&& d.ContainsKey("Receivedtime") && d["Receivedtime"].IsString
|
&& d.ContainsKey("Receivedtime") && d["Receivedtime"].IsString
|
||||||
&& d.ContainsKey("BatteryLevel") && d["BatteryLevel"].IsInt
|
&& d.ContainsKey("BatteryLevel") && d["BatteryLevel"].IsDouble
|
||||||
&& d.ContainsKey("Gps") && d["Gps"].IsObject
|
&& d.ContainsKey("Gps") && d["Gps"].IsObject
|
||||||
&& d["Gps"].ContainsKey("Latitude") && d["Gps"]["Latitude"].IsDouble
|
&& d["Gps"].ContainsKey("Latitude") && d["Gps"]["Latitude"].IsDouble
|
||||||
&& d["Gps"].ContainsKey("Longitude") && d["Gps"]["Longitude"].IsDouble
|
&& d["Gps"].ContainsKey("Longitude") && d["Gps"]["Longitude"].IsDouble
|
||||||
@ -83,12 +33,12 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls_broken {
|
|||||||
&& d["Gps"].ContainsKey("Fix") && d["Gps"]["Fix"].IsBoolean
|
&& d["Gps"].ContainsKey("Fix") && d["Gps"]["Fix"].IsBoolean
|
||||||
&& d.ContainsKey("Name") && d["Name"].IsString) {
|
&& d.ContainsKey("Name") && d["Name"].IsString) {
|
||||||
String name = (String)d["Name"];
|
String name = (String)d["Name"];
|
||||||
Botclient b = new Botclient((Int32)d["PacketRssi"], (Int32)d["Rssi"], (Double)d["Snr"], (String)d["Receivedtime"], (Double)d["Gps"]["Latitude"], (Double)d["Gps"]["Longitude"], (Double)d["Gps"]["Hdop"], (Int32)d["BatteryLevel"], (Boolean)d["Gps"]["Fix"]);
|
Botclient b = new Botclient((Int32)d["PacketRssi"], (Int32)d["Rssi"], (Double)d["Snr"], (String)d["Receivedtime"], (Double)d["Gps"]["Latitude"], (Double)d["Gps"]["Longitude"], (Double)d["Gps"]["Hdop"], (Double)d["BatteryLevel"], (Boolean)d["Gps"]["Fix"]);
|
||||||
if (b.Fix) {
|
if (b.Fix) {
|
||||||
if (this.locations.ContainsKey(name)) {
|
if (this.locations.ContainsKey(name)) {
|
||||||
this.locations[name].Add(b);
|
this.locations[name] = b;
|
||||||
} else {
|
} else {
|
||||||
this.locations.Add(name, new List<Botclient> { b });
|
this.locations.Add(name,b);
|
||||||
}
|
}
|
||||||
Console.WriteLine("Koodinate erhalten!");
|
Console.WriteLine("Koodinate erhalten!");
|
||||||
} else {
|
} else {
|
||||||
|
56
mqtt-map/Model/Botclient.cs
Normal file
56
mqtt-map/Model/Botclient.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using BlubbFish.Utils;
|
||||||
|
|
||||||
|
namespace Fraunhofer.Fit.IoT.MqttMap.Model {
|
||||||
|
class Botclient {
|
||||||
|
|
||||||
|
public Botclient(Int32 paketrssi, Int32 rssi, Double snr, String updatetime, Double lat, Double lon, Double hdop, Double battery, Boolean fix) {
|
||||||
|
this.PacketRssi = paketrssi;
|
||||||
|
this.Rssi = rssi;
|
||||||
|
this.Snr = snr;
|
||||||
|
this.Upatedtime = updatetime;
|
||||||
|
this.Latitude = lat;
|
||||||
|
this.Longitude = lon;
|
||||||
|
this.Hdop = hdop;
|
||||||
|
this.Battery = battery;
|
||||||
|
this.Fix = fix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Int32 PacketRssi { get; private set; }
|
||||||
|
public Int32 Rssi { get; private set; }
|
||||||
|
public Double Snr { get; private set; }
|
||||||
|
public String Upatedtime { get; private set; }
|
||||||
|
public Double Latitude { get; private set; }
|
||||||
|
public Double Longitude { get; private set; }
|
||||||
|
public Double Hdop { get; private set; }
|
||||||
|
public Double Battery { get; private set; }
|
||||||
|
public Boolean Fix { get; private set; }
|
||||||
|
|
||||||
|
public virtual Dictionary<String, Object> ToDictionary() {
|
||||||
|
Dictionary<String, Object> dictionary = new Dictionary<String, Object>();
|
||||||
|
foreach (PropertyInfo item in this.GetType().GetProperties()) {
|
||||||
|
if (item.CanRead && item.GetValue(this) != null) {
|
||||||
|
if (item.GetValue(this).GetType().GetMethod("ToDictionary") != null) {
|
||||||
|
dictionary.Add(item.Name, item.GetValue(this).GetType().GetMethod("ToDictionary").Invoke(item.GetValue(this), null));
|
||||||
|
} else if (item.GetValue(this).GetType().HasInterface(typeof(IDictionary))) {
|
||||||
|
Dictionary<String, Object> subdict = new Dictionary<String, Object>();
|
||||||
|
foreach (DictionaryEntry subitem in (IDictionary)item.GetValue(this)) {
|
||||||
|
if (subitem.Value.GetType().GetMethod("ToDictionary") != null) {
|
||||||
|
subdict.Add(subitem.Key.ToString(), subitem.Value.GetType().GetMethod("ToDictionary").Invoke(subitem.Value, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dictionary.Add(item.Name, subdict);
|
||||||
|
} else if (item.GetValue(this).GetType().BaseType == typeof(Enum)) {
|
||||||
|
dictionary.Add(item.Name, Helper.GetEnumDescription((Enum)item.GetValue(this)));
|
||||||
|
} else {
|
||||||
|
dictionary.Add(item.Name, item.GetValue(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dictionary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,9 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using BlubbFish.Utils;
|
using BlubbFish.Utils;
|
||||||
using BlubbFish.Utils.IoT.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
using Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls_broken;
|
|
||||||
|
|
||||||
namespace mqtt_map {
|
namespace Fraunhofer.Fit.IoT.MqttMap {
|
||||||
class Program {
|
class Program {
|
||||||
static void Main(String[] args) {
|
static void Main(String[] args) {
|
||||||
InIReader.SetSearchPath(new List<String>() { "/etc/mqttmap", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mqttmap" });
|
InIReader.SetSearchPath(new List<String>() { "/etc/mqttmap", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mqttmap" });
|
||||||
@ -20,7 +19,7 @@ namespace mqtt_map {
|
|||||||
}
|
}
|
||||||
InIReader ini = InIReader.GetInstance("settings");
|
InIReader ini = InIReader.GetInstance("settings");
|
||||||
ADataBackend b = (ADataBackend)ABackend.GetInstance(ini.GetSection("mqtt"), ABackend.BackendType.Data);
|
ADataBackend b = (ADataBackend)ABackend.GetInstance(ini.GetSection("mqtt"), ABackend.BackendType.Data);
|
||||||
new Googlelocation(b, ini.GetSection("google"), InIReader.GetInstance("requests"));
|
new Googlelocation(b, ini.GetSection("webserver"), InIReader.GetInstance("requests"));
|
||||||
while(true) {
|
while(true) {
|
||||||
System.Threading.Thread.Sleep(1000);
|
System.Threading.Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
[index.html]
|
[js/nav.js]
|
||||||
your_api_key=abc
|
your_api_key=abc
|
||||||
|
start_location=50.7, 7.2
|
@ -2,6 +2,5 @@
|
|||||||
type=mqtt
|
type=mqtt
|
||||||
server=127.0.0.1
|
server=127.0.0.1
|
||||||
|
|
||||||
[google]
|
[webserver]
|
||||||
api_key=abc
|
|
||||||
prefix=http://+:8080/
|
prefix=http://+:8080/
|
@ -6,8 +6,8 @@
|
|||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProjectGuid>{95D6F48A-9488-42A6-A973-941B45B26DB8}</ProjectGuid>
|
<ProjectGuid>{95D6F48A-9488-42A6-A973-941B45B26DB8}</ProjectGuid>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RootNamespace>mqtt_map</RootNamespace>
|
<RootNamespace>Fraunhofer.Fit.IoT.MqttMap</RootNamespace>
|
||||||
<AssemblyName>mqtt-map</AssemblyName>
|
<AssemblyName>mqttmap</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
@ -46,6 +46,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Googlelocation.cs" />
|
<Compile Include="Googlelocation.cs" />
|
||||||
|
<Compile Include="Model\Botclient.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
var mymap = L.map('bigmap').setView([51.396851, 12.401617], 15);
|
var mymap = L.map('bigmap').setView([{%START_LOCATION%}], 14);
|
||||||
|
|
||||||
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
|
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
|
||||||
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
||||||
@ -16,16 +16,17 @@ function datarunner() {
|
|||||||
xhttp.open("GET", "http://{%REQUEST_URL_HOST%}:8080/loc", true);
|
xhttp.open("GET", "http://{%REQUEST_URL_HOST%}:8080/loc", true);
|
||||||
xhttp.send();
|
xhttp.send();
|
||||||
}
|
}
|
||||||
|
//https://leafletjs.com/reference-1.4.0.html#marker
|
||||||
function parsedata() {
|
function parsedata() {
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
var obj = JSON.parse(this.responseText);
|
var items = JSON.parse(this.responseText);
|
||||||
for (var names in obj) {
|
for (var key in items) {
|
||||||
if (obj.hasOwnProperty(names)) {
|
if (items.hasOwnProperty(key)) {
|
||||||
var markeritem = obj[names];
|
var markeritem = items[key];
|
||||||
|
if (!markers.hasOwnProperty(key)) {
|
||||||
if (!markers.hasOwnProperty(names)) {
|
markers[key] = L.marker([markeritem['Latitude'], markeritem['Longitude']]).addTo(mymap);
|
||||||
markers[names] = L.marker([51.396851, 12.401617]).addTo(mymap);
|
} else {
|
||||||
|
markers[key].setLatLng([markeritem['Latitude'], markeritem['Longitude']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user