diff --git a/ConnectorDataMosquitto/ConnectorDataMosquitto.sln b/ConnectorDataMosquitto/ConnectorDataMosquitto.sln deleted file mode 100644 index f5328c4..0000000 --- a/ConnectorDataMosquitto/ConnectorDataMosquitto.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.136 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorDataMosquitto", "ConnectorDataMosquitto\ConnectorDataMosquitto.csproj", "{39235FAD-BA9D-4B51-82FC-6969967BEAE9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils-IoT\Utils-IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.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 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {07F7B20A-51A7-4AB2-B202-8DDDF1397EFA} - EndGlobalSection -EndGlobal diff --git a/ConnectorDataMosquitto/ConnectorDataMosquitto/ConnectorDataMosquitto.csproj b/ConnectorDataMosquitto/ConnectorDataMosquitto/ConnectorDataMosquitto.csproj deleted file mode 100644 index 90b5ce8..0000000 --- a/ConnectorDataMosquitto/ConnectorDataMosquitto/ConnectorDataMosquitto.csproj +++ /dev/null @@ -1,54 +0,0 @@ - - - - - Debug - AnyCPU - {39235FAD-BA9D-4B51-82FC-6969967BEAE9} - Library - Properties - BlubbFish.Utils.IoT.Connector.Data - ConnectorDataMosquitto - v4.7.1 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - {b870e4d5-6806-4a0b-b233-8907eedc5afc} - Utils-IoT - - - - \ No newline at end of file diff --git a/ConnectorDataMosquitto/ConnectorDataMosquitto/Mosquitto.cs b/ConnectorDataMosquitto/ConnectorDataMosquitto/Mosquitto.cs deleted file mode 100644 index 9b460f3..0000000 --- a/ConnectorDataMosquitto/ConnectorDataMosquitto/Mosquitto.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text.RegularExpressions; - -namespace BlubbFish.Utils.IoT.Connector.Data { - public class Mosquitto : ADataBackend, IDisposable { - private Process p; - private String message; - - public override event MqttMessage MessageIncomming; - public override event MqttMessage MessageSending; - - public Mosquitto(Dictionary mqtt_settings) { - this.settings = mqtt_settings; - //mosquitto_sub --cafile ca.pem --cert cert.pem --key cert.key -h swb.broker.flex4grid.eu -p 8883 -t "#" -v -d - this.message = ""; - this.p = new Process(); - this.p.StartInfo.FileName = "mosquitto_sub"; - String topic = "#"; - String args = "-h " + this.settings["server"]+" "; - if(this.settings.ContainsKey("port")) { - args += "-p "+ this.settings["port"]+" "; - } - if (this.settings.ContainsKey("cafile")) { - args += "--cafile " + this.settings["cafile"] + " "; - } - if (this.settings.ContainsKey("cert")) { - args += "--cert " + this.settings["cert"] + " "; - } - if (this.settings.ContainsKey("key")) { - args += "--key " + this.settings["key"] + " "; - } - if(this.settings.ContainsKey("topic")) { - topic = this.settings["topic"]; - } - this.p.StartInfo.Arguments = args+"-t \""+ topic + "\" -v -d"; - this.p.StartInfo.CreateNoWindow = true; - this.p.StartInfo.UseShellExecute = false; - this.p.StartInfo.RedirectStandardOutput = true; - this.p.StartInfo.RedirectStandardError = true; - this.p.OutputDataReceived += this.P_OutputDataReceived; - this.p.ErrorDataReceived += this.P_ErrorDataReceived; - this.p.Start(); - this.p.BeginOutputReadLine(); - - } - - public override void Send(String topic, String data) { - Process send = new Process(); - send.StartInfo.FileName = "mosquitto_pub"; - String args = "-h " + this.settings["server"] + " "; - if (this.settings.ContainsKey("port")) { - args += "-p " + this.settings["port"] + " "; - } - if (this.settings.ContainsKey("cafile")) { - args += "--cafile " + this.settings["cafile"] + " "; - } - if (this.settings.ContainsKey("cert")) { - args += "--cert " + this.settings["cert"] + " "; - } - if (this.settings.ContainsKey("key")) { - args += "--key " + this.settings["key"] + " "; - } - send.StartInfo.Arguments = args + "-m \""+data.Replace("\"","\\\"")+"\" -t \""+topic+"\" -d"; - send.StartInfo.CreateNoWindow = true; - send.StartInfo.UseShellExecute = false; - send.StartInfo.RedirectStandardOutput = true; - send.StartInfo.RedirectStandardError = true; - send.Start(); - send.WaitForExit(); - MessageSending?.Invoke(this, new MqttEventArgs(data, topic)); - } - - private void P_ErrorDataReceived(Object sender, DataReceivedEventArgs e) { - if (e.Data != null) { - throw new NotImplementedException(e.Data); - } - } - - private void P_OutputDataReceived(Object sender, DataReceivedEventArgs e) { - if (e.Data != null) { - if (e.Data.StartsWith("Client mosqsub")) { - if (this.message != "" && this.message.IndexOf(" received PUBLISH ") > 0) { - MatchCollection matches = (new Regex("^Client mosqsub[\\|/].*received PUBLISH \\(.*,.*,.*,.*, '(.*)'.*\\)\\)\n[^ ]* (.*)$", RegexOptions.IgnoreCase | RegexOptions.Singleline)).Matches(this.message); - String topic = matches[0].Groups[1].Value; - String message = matches[0].Groups[2].Value.Trim(); - this.MessageIncomming?.Invoke(this, new MqttEventArgs(message, topic)); - } - this.message = e.Data + "\n"; - } else { - this.message += e.Data + "\n"; - } - } - } - - #region IDisposable Support - private Boolean disposedValue = false; // Dient zur Erkennung redundanter Aufrufe. - private readonly Dictionary settings; - - protected virtual void Dispose(Boolean disposing) { - if (!this.disposedValue) { - if (disposing) { - this.p.CancelOutputRead(); - if (!this.p.HasExited) { - this.p.Kill(); - } - this.p.Close(); - } - this.p = null; - this.disposedValue = true; - } - } - - ~Mosquitto() { - Dispose(false); - } - - public override void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - #endregion - } -} diff --git a/ConnectorDataMosquitto/ConnectorDataMosquitto/Properties/AssemblyInfo.cs b/ConnectorDataMosquitto/ConnectorDataMosquitto/Properties/AssemblyInfo.cs deleted file mode 100644 index 20dd49a..0000000 --- a/ConnectorDataMosquitto/ConnectorDataMosquitto/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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("ConnectorDataMosquitto")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ConnectorDataMosquitto")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[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("39235fad-ba9d-4b51-82fc-6969967beae9")] - -// 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, -// indem Sie "*" wie unten gezeigt eingeben: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")]