mqtt-map added

This commit is contained in:
BlubbFish 2018-08-11 23:10:30 +00:00
commit 3a1d3f27cc
9 changed files with 585 additions and 0 deletions

61
mqtt-map.sln Normal file
View File

@ -0,0 +1,61 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mqtt-map", "mqtt-map\mqtt-map.csproj", "{95D6F48A-9488-42A6-A973-941B45B26DB8}"
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}") = "ConnectorDataMqtt", "..\Utils\IoT\Connector\Data\Mqtt\ConnectorDataMqtt.csproj", "{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}"
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}") = "M2Mqtt_4.7.1", "..\Librarys\mqtt\M2Mqtt\M2Mqtt_4.7.1.csproj", "{A11AEF5A-B246-4FE8-8330-06DB73CC8074}"
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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{95D6F48A-9488-42A6-A973-941B45B26DB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{95D6F48A-9488-42A6-A973-941B45B26DB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95D6F48A-9488-42A6-A973-941B45B26DB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95D6F48A-9488-42A6-A973-941B45B26DB8}.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
{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
{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
{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
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1534B636-9FC8-49BB-BB14-FC403ECDF889}
EndGlobalSection
EndGlobal

6
mqtt-map/App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
</startup>
</configuration>

183
mqtt-map/Googlelocation.cs Normal file
View File

@ -0,0 +1,183 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading;
using BlubbFish.Utils.IoT.Bots;
using BlubbFish.Utils.IoT.Connector;
using BlubbFish.Utils.IoT.Events;
using LitJson;
namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls_broken {
class Botclient {
public Botclient(Int32 paketrssi, Int32 rssi, Double snr, String updatetime, Double lat, Double lon, Double hdop, Int32 sat, Boolean fix) {
this.PacketRssi = paketrssi;
this.Rssi = rssi;
this.Snr = snr;
this.Upatedtime = updatetime;
this.Latitude = lat;
this.Longitude = lon;
this.Hdop = hdop;
this.Satelites = sat;
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 Satelites { 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 {
private readonly HttpListener _listener = new HttpListener();
private readonly Dictionary<String, List<Botclient>> locations = new Dictionary<String, List<Botclient>>();
private readonly Dictionary<String, String> config;
public Googlelocation(ADataBackend backend, Dictionary<String, String> settings) {
this.config = settings;
backend.MessageIncomming += this.Backend_MessageIncomming;
this._listener.Prefixes.Add("http://"+ this.config["prefix"] + ":8080/");
this._listener.Start();
this.Run();
}
private void Backend_MessageIncomming(Object sender, BackendEvent e) {
try {
JsonData d = JsonMapper.ToObject(e.Message);
if (d.ContainsKey("PacketRssi") && d["PacketRssi"].IsInt
&& d.ContainsKey("Rssi") && d["Rssi"].IsInt
&& d.ContainsKey("Snr") && d["Snr"].IsDouble
&& d.ContainsKey("Upatedtime") && d["Upatedtime"].IsString
&& d.ContainsKey("Gps") && d["Gps"].IsObject
&& d["Gps"].ContainsKey("Breitengrad") && d["Gps"]["Breitengrad"].IsDouble
&& d["Gps"].ContainsKey("Laengengrad") && d["Gps"]["Laengengrad"].IsDouble
&& d["Gps"].ContainsKey("Hdop") && d["Gps"]["Hdop"].IsDouble
&& d["Gps"].ContainsKey("Satelites") && d["Gps"]["Satelites"].IsInt
&& d["Gps"].ContainsKey("Fix") && d["Gps"]["Fix"].IsBoolean
&& d.ContainsKey("Name") && d["Name"].IsString) {
String name = (String)d["Name"];
Botclient b = new Botclient((Int32)d["PacketRssi"], (Int32)d["Rssi"], (Double)d["Snr"], (String)d["Upatedtime"], (Double)d["Gps"]["Breitengrad"], (Double)d["Gps"]["Laengengrad"], (Double)d["Gps"]["Hdop"], (Int32)d["Gps"]["Satelites"], (Boolean)d["Gps"]["Fix"]);
if (b.Fix) {
if (this.locations.ContainsKey(name)) {
this.locations[name].Add(b);
} else {
this.locations.Add(name, new List<Botclient> { b });
}
Console.WriteLine("Koodinate erhalten!");
} else {
Console.WriteLine("Daten erhalten! (Kein Fix)");
}
}
} catch { }
}
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["api_key"]);
file = file.Replace("{%REQUEST-PAGE%}", request.Url.Host);
return file;
}
catch { return "500"; }
}
return "404";
}
if (request.Url.PathAndQuery.StartsWith("/loc?i=")) {
try {
String requeststrings = request.Url.PathAndQuery.Substring(7);
Dictionary<String, Int32> requestquerys = new Dictionary<String, Int32>();
if (requeststrings.Length != 0) {
foreach (String requeststring in requeststrings.Split(';')) {
String[] item = requeststring.Split(':');
requestquerys.Add(item[0], Int32.Parse(item[1]));
}
}
Dictionary<String, Object> ret = new Dictionary<String, Object>();
foreach (KeyValuePair<String, List<Botclient>> devices in this.locations) {
if(!requestquerys.ContainsKey(devices.Key) || (requestquerys.ContainsKey(devices.Key) && devices.Value.Count > requestquerys[devices.Key])) {
Int32 qindex = requestquerys.ContainsKey(devices.Key)?requestquerys[devices.Key]:0;
Dictionary<String, Object> subret = new Dictionary<String, Object>();
Int32 i = 0;
List<Botclient> sub = devices.Value.GetRange(qindex, devices.Value.Count - qindex);
foreach (Botclient item in sub) {
subret.Add(i++.ToString(), item);
}
ret.Add(devices.Key, subret);
}
}
Console.WriteLine("Koordiante abgefragt!");
return JsonMapper.ToJson(ret);
} catch {
return "{}";
}
}
return "<h1>Works</h1>"+ request.Url.PathAndQuery;
}
public void Dispose() {
this._listener.Stop();
this._listener.Close();
}
}
}

23
mqtt-map/Program.cs Normal file
View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using BlubbFish.Utils;
using BlubbFish.Utils.IoT.Connector;
using Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls_broken;
namespace mqtt_map {
class Program {
static void Main(String[] args) {
if(!InIReader.ConfigExist("settings")) {
Console.WriteLine("settings.ini not found!");
Console.ReadLine();
return;
}
InIReader ini = InIReader.GetInstance("settings");
ADataBackend b = (ADataBackend)ABackend.GetInstance(ini.GetSection("mqtt"), ABackend.BackendType.Data);
new Googlelocation(b, ini.GetSection("google"));
while(true) {
System.Threading.Thread.Sleep(1000);
}
}
}
}

View File

@ -0,0 +1,36 @@
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("mqtt-map")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("mqtt-map")]
[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("95d6f48a-9488-42a6-a973-941b45b26db8")]
// 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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

76
mqtt-map/app.manifest Normal file
View 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>

91
mqtt-map/mqtt-map.csproj Normal file
View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{95D6F48A-9488-42A6-A973-941B45B26DB8}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>mqtt_map</RootNamespace>
<AssemblyName>mqtt-map</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Googlelocation.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="app.manifest" />
<None Include="settings.conf.example">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="resources\google.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<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="..\..\Librarys\mqtt\M2Mqtt\M2Mqtt_4.7.1.csproj">
<Project>{a11aef5a-b246-4fe8-8330-06db73cc8074}</Project>
<Name>M2Mqtt_4.7.1</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\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>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,102 @@
<!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>
var map;
function initMap() {
var myLatLng = { lat: 50.784077, lng: 7.228756 };
map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
center: myLatLng
});
}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key={%YOUR_API_KEY%}&callback=initMap">
</script>
<script type="text/javascript">
var devices = {};
function get_elm() {
var colors = new Array(
"http://maps.google.com/mapfiles/ms/icons/green-dot.png",
"http://maps.google.com/mapfiles/ms/icons/blue-dot.png",
"http://maps.google.com/mapfiles/ms/icons/purple-dot.png",
"http://maps.google.com/mapfiles/ms/icons/yellow-dot.png",
);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
var obj = JSON.parse(this.responseText);
var i = 0;
for (var names in obj) {
if (obj.hasOwnProperty(names)) {
if (!devices.hasOwnProperty(names)) {
devices[names] = 0;
}
var list = obj[names];
var j = devices[names];
for (var pos in list) {
if (list.hasOwnProperty(pos)) {
var m = new google.maps.Marker({
icon: colors[i % colors.length],
position: new google.maps.LatLng(list[pos]["Latitude"], list[pos]["Longitude"]),
animation: google.maps.Animation.DROP
});
var infowindow = new google.maps.InfoWindow({
content: "<div>" +
"PacketRssi: " + list[pos]["PacketRssi"] + "<br>" +
"Rssi: " + list[pos]["Rssi"] + "<br>" +
"Snr: " + list[pos]["Snr"] + "<br>" +
"Upatedtime: " + list[pos]["Upatedtime"] + "<br>" +
"Hdop: " + list[pos]["Hdop"] + "<br>" +
"Satelites: " + list[pos]["Satelites"] + "<br>" +
"Fix: " + list[pos]["Fix"] +
"</div>"
});
m.addListener('click', function () {
infowindow.open(map, m);
});
m.setMap(map);
j++;
}
}
devices[names] = j;
i++;
}
}
}
};
var qstring = "";
for (var item in devices) {
if (devices.hasOwnProperty(item)) {
qstring += item + ":" + devices[item];
}
}
xhttp.open("GET", "http://{%REQUEST-PAGE%}:8080/loc?i="+qstring, true);
xhttp.send();
}
setInterval(get_elm, 5000);
</script>
</body>
</html>

View File

@ -0,0 +1,7 @@
[mqtt]
type=mqtt
server=127.0.0.1
[google]
api_key=abc
prefix=localhost