4 Commits
Author SHA1 Message Date
BlubbFish 5357b57489 improve logging 2026-08-04 12:11:13 +02:00
BlubbFish e5eb4c8740 [1.4.0] Cleanup 2022-01-09 14:02:35 +01:00
BlubbFish 9a94ff97d2 make mirror on github.com
also remove a disconnet on the first start
2021-08-22 00:41:55 +02:00
BlubbFish 51bfd52095 newer c# lang 2021-04-10 01:02:20 +02:00
4 changed files with 65 additions and 15 deletions
+37
View File
@@ -0,0 +1,37 @@
# Changelog
## 1.4.0 - 2022-01-09 - Cleanup
### New Features
* On first startup, not try to disconnect first
### Bugfixes
* Fixing nullpointer exception
### Changes
* Cleanup project and fixes version numbers
## 1.3.0 - 2021-01-09 - Default netcore
### New Features
* Create toString, so in logfiles the used Server is visible
* add changelog.md
### Bugfixes
### Changes
* Netcore is now the default projekt
## 1.2.0 - 2019-11-28 - Add netcore
### New Features
* add Licence, readme.md and contribute.md
* add netcore version
### Bugfixes
### Changes
* Using newer C# language version
## 1.1.0 - 2019-05-27 - Rewrite Module to reconnect itselfs, so you dont need to watch over the the state of the connection
### New Features
* Keep the connection alive and reconnect internally
### Bugfixes
### Changes
## 1.0.0.0 - 2019-02-14 - Init
### New Features
* Init release
### Bugfixes
### Changes
+12 -6
View File
@@ -6,14 +6,20 @@
<AssemblyName>ConnectorDataMqtt</AssemblyName> <AssemblyName>ConnectorDataMqtt</AssemblyName>
<Company>BlubbFish</Company> <Company>BlubbFish</Company>
<Authors>BlubbFish</Authors> <Authors>BlubbFish</Authors>
<Version>1.1.0</Version> <Version>1.4.0</Version>
<Copyright>Copyright © BlubbFish 2017 - 27.05.2019</Copyright> <Copyright>Copyright © BlubbFish 2017 - 09.01.2022</Copyright>
<Description>ADataBackend Connector that connects to mqtt using M2Mqtt</Description> <Description>ADataBackend Connector that connects to mqtt using M2Mqtt</Description>
<PackageLicenseFile>LICENSE</PackageLicenseFile> <PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>http://git.blubbfish.net/vs_utils/ConnectorDataMqtt</PackageProjectUrl> <PackageProjectUrl>http://git.blubbfish.net/vs_utils/ConnectorDataMqtt</PackageProjectUrl>
<RepositoryUrl>http://git.blubbfish.net/vs_utils/ConnectorDataMqtt.git</RepositoryUrl> <RepositoryUrl>http://git.blubbfish.net/vs_utils/ConnectorDataMqtt.git</RepositoryUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<PackageReleaseNotes>1.1.0 Rewrite Module to reconnect itselfs, so you dont need to watch over the the state of the connection</PackageReleaseNotes> <PackageReleaseNotes>
1.4.0 Cleanup
1.3.0 Default netcore
1.2.0 Add netcore
1.1.0 Rewrite Module to reconnect itselfs, so you dont need to watch over the the state of the connection
1.0.0.0 Init
</PackageReleaseNotes>
<NeutralLanguage>de-DE</NeutralLanguage> <NeutralLanguage>de-DE</NeutralLanguage>
<PackageId>Mqtt.Data.Connector.IoT.Utils.BlubbFish</PackageId> <PackageId>Mqtt.Data.Connector.IoT.Utils.BlubbFish</PackageId>
</PropertyGroup> </PropertyGroup>
@@ -25,9 +31,9 @@
<ItemGroup> <ItemGroup>
<Content Include="../CHANGELOG.md" /> <Content Include="../CHANGELOG.md" />
<Content Include="../CONTRIBUTING.md" /> <Content Include="../CONTRIBUTING.md" />
<Content Include="../LICENSE" /> <Content Include="../LICENSE" />
<Content Include="../README.md" /> <Content Include="../README.md" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+13 -8
View File
@@ -12,6 +12,7 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
private MqttClient client; private MqttClient client;
private Thread connectionWatcher; private Thread connectionWatcher;
private Boolean connectionWatcherRunning; private Boolean connectionWatcherRunning;
private Boolean firstStart = true;
public Mqtt(Dictionary<String, String> settings) : base(settings) { public Mqtt(Dictionary<String, String> settings) : base(settings) {
Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.Mqtt(" + this.ToString()+")"); Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.Mqtt(" + this.ToString()+")");
@@ -28,7 +29,7 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
if (this.settings.ContainsKey("user")) { if (this.settings.ContainsKey("user")) {
ret += this.settings["user"]; ret += this.settings["user"];
if (this.settings.ContainsKey("pass")) { if (this.settings.ContainsKey("pass")) {
ret += ":" + this.settings["pass"]; ret += ":[xxx]";
} }
ret += "@"; ret += "@";
} }
@@ -62,16 +63,20 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
} }
private void Reconnect() { private void Reconnect() {
if(this.IsConnected) { if(!this.firstStart) {
this.Disconnect(true); if(this.IsConnected) {
this.Disconnect(true);
} else {
this.Disconnect(false);
}
} else { } else {
this.Disconnect(false); this.firstStart = false;
} }
this.Connect(); this.Connect();
} }
private void Disconnect(Boolean complete) { private void Disconnect(Boolean complete) {
Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.Disconnect(" + this.ToString() + ")"); Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.Mqtt.Disconnect(" + this.ToString() + ")");
this.client.MqttMsgPublishReceived -= this.Client_MqttMsgPublishReceived; this.client.MqttMsgPublishReceived -= this.Client_MqttMsgPublishReceived;
this.Unsubscripe(); this.Unsubscripe();
if(complete) { if(complete) {
@@ -80,7 +85,7 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
} }
private void Connect() { private void Connect() {
Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.Connect(" + this.ToString() + ")"); Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.Mqtt.Connect(" + this.ToString() + ")");
this.client.MqttMsgPublishReceived += this.Client_MqttMsgPublishReceived; this.client.MqttMsgPublishReceived += this.Client_MqttMsgPublishReceived;
_ = this.settings.ContainsKey("user") && this.settings.ContainsKey("pass") _ = 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.settings["user"], this.settings["pass"])
@@ -123,14 +128,14 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
#region IDisposable Support #region IDisposable Support
private Boolean disposedValue = false; private Boolean disposedValue = false;
public override Boolean IsConnected => this.client != null ? this.client.IsConnected : false; public override Boolean IsConnected => this.client != null && this.client.IsConnected;
protected virtual void Dispose(Boolean disposing) { protected virtual void Dispose(Boolean disposing) {
if(!this.disposedValue) { if(!this.disposedValue) {
if(disposing) { if(disposing) {
try { try {
this.connectionWatcherRunning = false; this.connectionWatcherRunning = false;
while(this.connectionWatcher.IsAlive) { while(this.connectionWatcher != null && this.connectionWatcher.IsAlive) {
Thread.Sleep(10); Thread.Sleep(10);
} }
this.connectionWatcher = null; this.connectionWatcher = null;
+3 -1
View File
@@ -1,9 +1,11 @@
# BlubbFish.Utils.IoT.Connector.Data.Mqtt (ConnectorDataMqtt) # BlubbFish.Utils.IoT.Connector.Data.Mqtt (ConnectorDataMqtt)
Library that connects to Mqtt using M2Mqtt Library that connects to Mqtt using M2Mqtt
Maybe you find this Repo on Github. This is a mirror from [here](https://git.blubbfish.net/vs_utils/ConnectorDataMqtt).
## Linking to ## Linking to
### Internal ### Internal
* BlubbFish.Utils.IoT ([Utils-IoT](http://git.blubbfish.net/vs_utils/Utils-IoT)) * BlubbFish.Utils.IoT ([Utils-IoT](http://git.blubbfish.net/vs_utils/Utils-IoT))
### External ### External
* M2Mqtt * M2Mqtt ([Used Fork](https://github.com/blubbfish/mqtt), [Original](https://github.com/eclipse/paho.mqtt.m2mqtt))