Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c29ea883a4 | ||
|
|
9596c46a2e |
@@ -0,0 +1,3 @@
|
|||||||
|
/.vs
|
||||||
|
/ConnectorDataMosquitto/obj
|
||||||
|
/ConnectorDataMosquitto/bin
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.31112.23
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorDataMosquitto_4.7.1", "ConnectorDataMosquitto\ConnectorDataMosquitto_4.7.1.csproj", "{39235FAD-BA9D-4B51-82FC-6969967BEAE9}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT-4.7.1", "..\Utils-IoT\Utils-IoT\Utils-IoT-4.7.1.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}"
|
||||||
|
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}") = "Utils-4.7.1", "..\Utils\Utils\Utils-4.7.1.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
|
||||||
|
{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
|
||||||
|
{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
|
||||||
|
{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 = {07F7B20A-51A7-4AB2-B202-8DDDF1397EFA}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -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
|
|
||||||
+1
-1
@@ -45,7 +45,7 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\Utils-IoT.csproj">
|
<ProjectReference Include="..\..\Utils-IoT\Utils-IoT\Utils-IoT-4.7.1.csproj">
|
||||||
<Project>{b870e4d5-6806-4a0b-b233-8907eedc5afc}</Project>
|
<Project>{b870e4d5-6806-4a0b-b233-8907eedc5afc}</Project>
|
||||||
<Name>Utils-IoT</Name>
|
<Name>Utils-IoT</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
@@ -2,17 +2,14 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using BlubbFish.Utils.IoT.Events;
|
||||||
|
|
||||||
namespace BlubbFish.Utils.IoT.Connector.Data {
|
namespace BlubbFish.Utils.IoT.Connector.Data {
|
||||||
public class Mosquitto : ADataBackend, IDisposable {
|
public class Mosquitto : ADataBackend, IDisposable {
|
||||||
private Process p;
|
private Process p;
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
public override event MqttMessage MessageIncomming;
|
public Mosquitto(Dictionary<String, String> settings) : base(settings) {
|
||||||
public override event MqttMessage MessageSending;
|
|
||||||
|
|
||||||
public Mosquitto(Dictionary<String, String> 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
|
//mosquitto_sub --cafile ca.pem --cert cert.pem --key cert.key -h swb.broker.flex4grid.eu -p 8883 -t "#" -v -d
|
||||||
this.message = "";
|
this.message = "";
|
||||||
this.p = new Process();
|
this.p = new Process();
|
||||||
@@ -69,7 +66,7 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
|
|||||||
send.StartInfo.RedirectStandardError = true;
|
send.StartInfo.RedirectStandardError = true;
|
||||||
send.Start();
|
send.Start();
|
||||||
send.WaitForExit();
|
send.WaitForExit();
|
||||||
MessageSending?.Invoke(this, new MqttEventArgs(data, topic));
|
this.NotifyClientSending(new DataEvent(data, topic, DateTime.Now));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void P_ErrorDataReceived(Object sender, DataReceivedEventArgs e) {
|
private void P_ErrorDataReceived(Object sender, DataReceivedEventArgs e) {
|
||||||
@@ -85,7 +82,7 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
|
|||||||
MatchCollection matches = (new Regex("^Client mosqsub[\\|/].*received PUBLISH \\(.*,.*,.*,.*, '(.*)'.*\\)\\)\n[^ ]* (.*)$", RegexOptions.IgnoreCase | RegexOptions.Singleline)).Matches(this.message);
|
MatchCollection matches = (new Regex("^Client mosqsub[\\|/].*received PUBLISH \\(.*,.*,.*,.*, '(.*)'.*\\)\\)\n[^ ]* (.*)$", RegexOptions.IgnoreCase | RegexOptions.Singleline)).Matches(this.message);
|
||||||
String topic = matches[0].Groups[1].Value;
|
String topic = matches[0].Groups[1].Value;
|
||||||
String message = matches[0].Groups[2].Value.Trim();
|
String message = matches[0].Groups[2].Value.Trim();
|
||||||
this.MessageIncomming?.Invoke(this, new MqttEventArgs(message, topic));
|
this.NotifyClientIncomming(new DataEvent(message, topic, DateTime.Now));
|
||||||
}
|
}
|
||||||
this.message = e.Data + "\n";
|
this.message = e.Data + "\n";
|
||||||
} else {
|
} else {
|
||||||
@@ -94,9 +91,18 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Boolean IsConnected {
|
||||||
|
get {
|
||||||
|
if (!this.p.HasExited) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region IDisposable Support
|
#region IDisposable Support
|
||||||
private Boolean disposedValue = false; // Dient zur Erkennung redundanter Aufrufe.
|
private Boolean disposedValue = false; // Dient zur Erkennung redundanter Aufrufe.
|
||||||
private readonly Dictionary<String, String> settings;
|
|
||||||
|
|
||||||
protected virtual void Dispose(Boolean disposing) {
|
protected virtual void Dispose(Boolean disposing) {
|
||||||
if (!this.disposedValue) {
|
if (!this.disposedValue) {
|
||||||
|
|||||||
Reference in New Issue
Block a user