diff --git a/ConnectorDataMqtt/ConnectorDataMqtt.csproj b/ConnectorDataMqtt/ConnectorDataMqtt.csproj
index 8e15ce5..f45ec2d 100644
--- a/ConnectorDataMqtt/ConnectorDataMqtt.csproj
+++ b/ConnectorDataMqtt/ConnectorDataMqtt.csproj
@@ -34,6 +34,11 @@
+
+
+
+
+
{a11aef5a-b246-4fe8-8330-06db73cc8074}
diff --git a/ConnectorDataMqtt/ConnectorDataMqtt_Core.csproj b/ConnectorDataMqtt/ConnectorDataMqtt_Core.csproj
new file mode 100644
index 0000000..a645e70
--- /dev/null
+++ b/ConnectorDataMqtt/ConnectorDataMqtt_Core.csproj
@@ -0,0 +1,38 @@
+
+
+
+ netcoreapp3.0
+ BlubbFish.Utils.IoT.Connector.Data
+ ConnectorDataMqtt
+ BlubbFish
+ BlubbFish
+ 1.1.0
+ Copyright © BlubbFish 2017 - 27.05.2019
+ ADataBackend Connector that connects to mqtt using M2Mqtt
+ LICENSE
+ http://git.blubbfish.net/vs_utils/ConnectorDataMqtt
+ http://git.blubbfish.net/vs_utils/ConnectorDataMqtt.git
+ git
+ 1.1.0 Rewrite Module to reconnect itselfs, so you dont need to watch over the the state of the connection
+ de-DE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+
+
+
+
+
diff --git a/ConnectorDataMqtt/Mqtt.cs b/ConnectorDataMqtt/Mqtt.cs
index f22e6d7..2a1bdc8 100644
--- a/ConnectorDataMqtt/Mqtt.cs
+++ b/ConnectorDataMqtt/Mqtt.cs
@@ -61,23 +61,17 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
private void Connect() {
Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.Mqtt.Connect()");
this.client.MqttMsgPublishReceived += this.Client_MqttMsgPublishReceived;
- if (this.settings.ContainsKey("user") && this.settings.ContainsKey("pass")) {
- this.client.Connect(Guid.NewGuid().ToString(), this.settings["user"], this.settings["pass"]);
- } else {
- this.client.Connect(Guid.NewGuid().ToString());
- }
+ _ = this.settings.ContainsKey("user") && this.settings.ContainsKey("pass")
+ ? this.client.Connect(Guid.NewGuid().ToString(), this.settings["user"], this.settings["pass"])
+ : this.client.Connect(Guid.NewGuid().ToString());
this.Subscripe();
}
#endregion
#region Subscription
- private void Unsubscripe() {
- if(this.settings.ContainsKey("topic")) {
- this.client.Unsubscribe(this.settings["topic"].Split(';'));
- } else {
- this.client.Unsubscribe(new String[] { "#" });
- }
- }
+ private void Unsubscripe() => _ = this.settings.ContainsKey("topic")
+ ? this.client.Unsubscribe(this.settings["topic"].Split(';'))
+ : this.client.Unsubscribe(new String[] { "#" });
private void Subscripe() {
if(this.settings.ContainsKey("topic")) {
@@ -86,34 +80,29 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
for(Int32 i = 0; i < qos.Length; i++) {
qos[i] = MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE;
}
- this.client.Subscribe(this.settings["topic"].Split(';'), qos);
+ _ = this.client.Subscribe(this.settings["topic"].Split(';'), qos);
} else {
- this.client.Subscribe(new String[] { "#" }, new Byte[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE });
+ _ = this.client.Subscribe(new String[] { "#" }, new Byte[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE });
}
}
#endregion
- private async void Client_MqttMsgPublishReceived(Object sender, MqttMsgPublishEventArgs e) => await Task.Run(() => {
- this.NotifyClientIncomming(new DataEvent(Encoding.UTF8.GetString(e.Message), e.Topic, DateTime.Now));
- });
+ private async void Client_MqttMsgPublishReceived(Object sender, MqttMsgPublishEventArgs e) => await Task.Run(() => this.NotifyClientIncomming(new DataEvent(Encoding.UTF8.GetString(e.Message), e.Topic, DateTime.Now)));
public override void Send(String topic, String data) {
- this.client.Publish(topic, Encoding.UTF8.GetBytes(data));
+ _ = this.client.Publish(topic, Encoding.UTF8.GetBytes(data));
this.NotifyClientSending(new DataEvent(data, topic, DateTime.Now));
}
+ public void Send(String topic, Byte[] data) {
+ _ = this.client.Publish(topic, data);
+ this.NotifyClientSending(new DataEvent(Encoding.UTF8.GetString(data), topic, DateTime.Now));
+ }
+
#region IDisposable Support
private Boolean disposedValue = false;
- public override Boolean IsConnected {
- get {
- if(this.client != null) {
- return this.client.IsConnected;
- } else {
- return false;
- }
- }
- }
+ public override Boolean IsConnected => this.client != null ? this.client.IsConnected : false;
protected virtual void Dispose(Boolean disposing) {
if(!this.disposedValue) {
diff --git a/ConnectorDataMqtt/Properties/AssemblyInfo.cs b/ConnectorDataMqtt/Properties/AssemblyInfo.cs
index c7aacff..1bb6ff5 100644
--- a/ConnectorDataMqtt/Properties/AssemblyInfo.cs
+++ b/ConnectorDataMqtt/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
-using System.Reflection;
+#if !NETCOREAPP
+using System.Reflection;
using System.Resources;
using System.Runtime.InteropServices;
@@ -10,7 +11,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("BlubbFish")]
[assembly: AssemblyProduct("ConnectorDataMqtt")]
-[assembly: AssemblyCopyright("Copyright © 2017 - 27.05.2019")]
+[assembly: AssemblyCopyright("Copyright © BlubbFish 2017 - 27.05.2019")]
[assembly: AssemblyTrademark("© BlubbFish")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("de-DE")]
@@ -35,7 +36,8 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.1.0")]
+#endif
/*
* 1.1.0 Rewrite Module to reconnect itselfs, so you dont need to watch over the the state of the connection
- */
\ No newline at end of file
+ */
diff --git a/ConnectorDataMqtt_Core.sln b/ConnectorDataMqtt_Core.sln
new file mode 100644
index 0000000..30afb65
--- /dev/null
+++ b/ConnectorDataMqtt_Core.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29519.87
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorDataMqtt_Core", "ConnectorDataMqtt\ConnectorDataMqtt_Core.csproj", "{5D7A8892-6687-4FE2-85D1-12B49782EDF0}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils-IoT_Core", "..\Utils-IoT\Utils-IoT\Utils-IoT_Core.csproj", "{45837342-5906-4906-AB49-971767D9E180}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "M2Mqtt_Core", "..\..\Librarys\mqtt\M2Mqtt\M2Mqtt_Core.csproj", "{05B829EF-6F4F-496D-8936-35D7F2179DF0}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "litjson_Core", "..\..\Librarys\litjson\litjson\litjson_Core.csproj", "{CA22D3E9-4195-453D-9CE0-3EBC672E6D06}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils_Core", "..\Utils\Utils\Utils_Core.csproj", "{19424C4A-D024-484A-BE65-09C7C529A2C4}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {5D7A8892-6687-4FE2-85D1-12B49782EDF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5D7A8892-6687-4FE2-85D1-12B49782EDF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5D7A8892-6687-4FE2-85D1-12B49782EDF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5D7A8892-6687-4FE2-85D1-12B49782EDF0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {45837342-5906-4906-AB49-971767D9E180}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {45837342-5906-4906-AB49-971767D9E180}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {45837342-5906-4906-AB49-971767D9E180}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {45837342-5906-4906-AB49-971767D9E180}.Release|Any CPU.Build.0 = Release|Any CPU
+ {05B829EF-6F4F-496D-8936-35D7F2179DF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {05B829EF-6F4F-496D-8936-35D7F2179DF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {05B829EF-6F4F-496D-8936-35D7F2179DF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {05B829EF-6F4F-496D-8936-35D7F2179DF0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CA22D3E9-4195-453D-9CE0-3EBC672E6D06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CA22D3E9-4195-453D-9CE0-3EBC672E6D06}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CA22D3E9-4195-453D-9CE0-3EBC672E6D06}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CA22D3E9-4195-453D-9CE0-3EBC672E6D06}.Release|Any CPU.Build.0 = Release|Any CPU
+ {19424C4A-D024-484A-BE65-09C7C529A2C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {19424C4A-D024-484A-BE65-09C7C529A2C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {19424C4A-D024-484A-BE65-09C7C529A2C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {19424C4A-D024-484A-BE65-09C7C529A2C4}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {92985FD1-A967-4AE1-B2E0-5E938C0A7D6A}
+ EndGlobalSection
+EndGlobal