Compare commits

..

6 Commits

Author SHA1 Message Date
e5eb4c8740 [1.4.0] Cleanup 2022-01-09 14:02:35 +01:00
9a94ff97d2 make mirror on github.com
also remove a disconnet on the first start
2021-08-22 00:41:55 +02:00
51bfd52095 newer c# lang 2021-04-10 01:02:20 +02:00
d7f2ccd4af Make netcore as default, also using 3.1 now 2021-01-09 00:13:14 +01:00
47cdef0959 Thread Abort in netcore is not working 2019-12-01 17:53:57 +01:00
35ba2b8135 change to netcore 2019-11-29 14:45:10 +01:00
9 changed files with 248 additions and 172 deletions

37
Changelog.md Normal file
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

View File

@ -0,0 +1,43 @@

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}") = "ConnectorDataMqtt", "ConnectorDataMqtt\ConnectorDataMqtt-4.7.1.csproj", "{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils-IoT\Utils-IoT\Utils-IoT-4.7.1.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}"
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}") = "litjson_4.7.1", "..\..\Librarys\litjson\litjson\litjson_4.7.1.csproj", "{91A14CD2-2940-4500-8193-56D37EDDDBAA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{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
{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
{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
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B90F7B1F-FDD8-4B59-AAA5-218655C2716C}
EndGlobalSection
EndGlobal

View File

@ -1,15 +1,17 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio Version 16
VisualStudioVersion = 15.0.28307.136 VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorDataMqtt", "ConnectorDataMqtt\ConnectorDataMqtt.csproj", "{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorDataMqtt", "ConnectorDataMqtt\ConnectorDataMqtt.csproj", "{5D7A8892-6687-4FE2-85D1-12B49782EDF0}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils-IoT\Utils-IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils-IoT", "..\Utils-IoT\Utils-IoT\Utils-IoT.csproj", "{45837342-5906-4906-AB49-971767D9E180}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "M2Mqtt_4.7.1", "..\..\Librarys\mqtt\M2Mqtt\M2Mqtt_4.7.1.csproj", "{A11AEF5A-B246-4FE8-8330-06DB73CC8074}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "M2Mqtt", "..\..\Librarys\mqtt\M2Mqtt\M2Mqtt.csproj", "{05B829EF-6F4F-496D-8936-35D7F2179DF0}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "litjson_4.7.1", "..\..\Librarys\litjson\litjson\litjson_4.7.1.csproj", "{91A14CD2-2940-4500-8193-56D37EDDDBAA}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "litjson", "..\..\Librarys\litjson\litjson\litjson.csproj", "{CA22D3E9-4195-453D-9CE0-3EBC672E6D06}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils", "..\Utils\Utils\Utils.csproj", "{19424C4A-D024-484A-BE65-09C7C529A2C4}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -17,27 +19,31 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5D7A8892-6687-4FE2-85D1-12B49782EDF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {5D7A8892-6687-4FE2-85D1-12B49782EDF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {5D7A8892-6687-4FE2-85D1-12B49782EDF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Release|Any CPU.Build.0 = Release|Any CPU {5D7A8892-6687-4FE2-85D1-12B49782EDF0}.Release|Any CPU.Build.0 = Release|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {45837342-5906-4906-AB49-971767D9E180}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU {45837342-5906-4906-AB49-971767D9E180}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU {45837342-5906-4906-AB49-971767D9E180}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.Build.0 = Release|Any CPU {45837342-5906-4906-AB49-971767D9E180}.Release|Any CPU.Build.0 = Release|Any CPU
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {05B829EF-6F4F-496D-8936-35D7F2179DF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Debug|Any CPU.Build.0 = Debug|Any CPU {05B829EF-6F4F-496D-8936-35D7F2179DF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Release|Any CPU.ActiveCfg = Release|Any CPU {05B829EF-6F4F-496D-8936-35D7F2179DF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Release|Any CPU.Build.0 = Release|Any CPU {05B829EF-6F4F-496D-8936-35D7F2179DF0}.Release|Any CPU.Build.0 = Release|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CA22D3E9-4195-453D-9CE0-3EBC672E6D06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Debug|Any CPU.Build.0 = Debug|Any CPU {CA22D3E9-4195-453D-9CE0-3EBC672E6D06}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Release|Any CPU.ActiveCfg = Release|Any CPU {CA22D3E9-4195-453D-9CE0-3EBC672E6D06}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B90F7B1F-FDD8-4B59-AAA5-218655C2716C} SolutionGuid = {92985FD1-A967-4AE1-B2E0-5E938C0A7D6A}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -0,0 +1,57 @@
<?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>{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BlubbFish.Utils.IoT.Connector.Data</RootNamespace>
<AssemblyName>ConnectorDataMqtt</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Mqtt.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="..\CHANGELOG.md" />
<Content Include="..\CONTRIBUTING.md" />
<Content Include="..\LICENSE" />
<Content Include="..\README.md" />
</ItemGroup>
<ItemGroup>
<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-IoT\Utils-IoT\Utils-IoT.csproj">
<Project>{b870e4d5-6806-4a0b-b233-8907eedc5afc}</Project>
<Name>Utils-IoT</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,56 +1,46 @@
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk">
<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> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <TargetFramework>netcoreapp3.1</TargetFramework>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BlubbFish.Utils.IoT.Connector.Data</RootNamespace> <RootNamespace>BlubbFish.Utils.IoT.Connector.Data</RootNamespace>
<AssemblyName>ConnectorDataMqtt</AssemblyName> <AssemblyName>ConnectorDataMqtt</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> <Company>BlubbFish</Company>
<FileAlignment>512</FileAlignment> <Authors>BlubbFish</Authors>
<TargetFrameworkProfile /> <Version>1.4.0</Version>
</PropertyGroup> <Copyright>Copyright © BlubbFish 2017 - 09.01.2022</Copyright>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <Description>ADataBackend Connector that connects to mqtt using M2Mqtt</Description>
<DebugSymbols>true</DebugSymbols> <PackageLicenseFile>LICENSE</PackageLicenseFile>
<DebugType>full</DebugType> <PackageProjectUrl>http://git.blubbfish.net/vs_utils/ConnectorDataMqtt</PackageProjectUrl>
<Optimize>false</Optimize> <RepositoryUrl>http://git.blubbfish.net/vs_utils/ConnectorDataMqtt.git</RepositoryUrl>
<OutputPath>bin\Debug\</OutputPath> <RepositoryType>git</RepositoryType>
<DefineConstants>DEBUG;TRACE</DefineConstants> <PackageReleaseNotes>
<ErrorReport>prompt</ErrorReport> 1.4.0 Cleanup
<WarningLevel>4</WarningLevel> 1.3.0 Default netcore
</PropertyGroup> 1.2.0 Add netcore
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 1.1.0 Rewrite Module to reconnect itselfs, so you dont need to watch over the the state of the connection
<DebugType>pdbonly</DebugType> 1.0.0.0 Init
<Optimize>true</Optimize> </PackageReleaseNotes>
<OutputPath>bin\Release\</OutputPath> <NeutralLanguage>de-DE</NeutralLanguage>
<DefineConstants>TRACE</DefineConstants> <PackageId>Mqtt.Data.Connector.IoT.Utils.BlubbFish</PackageId>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Mqtt.cs" /> <ProjectReference Include="..\..\..\Librarys\mqtt\M2Mqtt\M2Mqtt.csproj" />
<Compile Include="Properties\AssemblyInfo.cs" /> <ProjectReference Include="..\..\Utils-IoT\Utils-IoT\Utils-IoT.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="..\CONTRIBUTING.md" /> <Content Include="../CHANGELOG.md" />
<Content Include="..\LICENSE" /> <Content Include="../CONTRIBUTING.md" />
<Content Include="..\README.md" /> <Content Include="../LICENSE" />
<Content Include="../README.md" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\Librarys\mqtt\M2Mqtt\M2Mqtt_4.7.1.csproj"> <None Include="..\LICENSE">
<Project>{a11aef5a-b246-4fe8-8330-06db73cc8074}</Project> <Pack>True</Pack>
<Name>M2Mqtt_4.7.1</Name> <PackagePath></PackagePath>
</ProjectReference> </None>
<ProjectReference Include="..\..\Utils-IoT\Utils-IoT\Utils-IoT.csproj">
<Project>{b870e4d5-6806-4a0b-b233-8907eedc5afc}</Project>
<Name>Utils-IoT</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="System" /> </Project>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,38 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RootNamespace>BlubbFish.Utils.IoT.Connector.Data</RootNamespace>
<AssemblyName>ConnectorDataMqtt</AssemblyName>
<Company>BlubbFish</Company>
<Authors>BlubbFish</Authors>
<Version>1.1.0</Version>
<Copyright>Copyright © BlubbFish 2017 - 27.05.2019</Copyright>
<Description>ADataBackend Connector that connects to mqtt using M2Mqtt</Description>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>http://git.blubbfish.net/vs_utils/ConnectorDataMqtt</PackageProjectUrl>
<RepositoryUrl>http://git.blubbfish.net/vs_utils/ConnectorDataMqtt.git</RepositoryUrl>
<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>
<NeutralLanguage>de-DE</NeutralLanguage>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Librarys\mqtt\M2Mqtt\M2Mqtt_Core.csproj" />
<ProjectReference Include="..\..\Utils-IoT\Utils-IoT\Utils-IoT_Core.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="../CONTRIBUTING.md" />
<Content Include="../LICENSE" />
<Content Include="../README.md" />
</ItemGroup>
<ItemGroup>
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Project>

View File

@ -11,9 +11,11 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
public class Mqtt : ADataBackend, IDisposable { public class Mqtt : ADataBackend, IDisposable {
private MqttClient client; private MqttClient client;
private Thread connectionWatcher; private Thread connectionWatcher;
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.Mqtt()"); Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.Mqtt(" + this.ToString()+")");
Int32 port = 1883; Int32 port = 1883;
if(this.settings.ContainsKey("port")) { if(this.settings.ContainsKey("port")) {
port = Int32.Parse(this.settings["port"]); port = Int32.Parse(this.settings["port"]);
@ -22,35 +24,59 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
this.ConnectionWatcher(); this.ConnectionWatcher();
} }
public override String ToString() {
String ret = "mqtt://";
if (this.settings.ContainsKey("user")) {
ret += this.settings["user"];
if (this.settings.ContainsKey("pass")) {
ret += ":" + this.settings["pass"];
}
ret += "@";
}
ret += this.settings["server"];
if (this.settings.ContainsKey("port")) {
ret += ":" + this.settings["port"];
}
if (this.settings.ContainsKey("topic")) {
ret += "/" + this.settings["topic"];
}
return ret;
}
#region ConectionManage #region ConectionManage
private void ConnectionWatcher() { private void ConnectionWatcher() {
this.connectionWatcher = new Thread(this.ConnectionWatcherRunner); this.connectionWatcher = new Thread(this.ConnectionWatcherRunner);
this.connectionWatcherRunning = true;
this.connectionWatcher.Start(); this.connectionWatcher.Start();
} }
private void ConnectionWatcherRunner() { private void ConnectionWatcherRunner() {
while(true) { while(this.connectionWatcherRunning) {
try { try {
if(!this.IsConnected) { if(!this.IsConnected) {
this.Reconnect(); this.Reconnect();
Thread.Sleep(1000);
} }
Thread.Sleep(500); Thread.Sleep(10);
} catch(Exception) { } } catch(Exception) { }
} }
} }
private void Reconnect() { private void Reconnect() {
Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.Mqtt.Reconnect()"); if(!this.firstStart) {
if(this.IsConnected) { if(this.IsConnected) {
this.Disconnect(true); 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.Mqtt.Disconnect()"); Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.Disconnect(" + this.ToString() + ")");
this.client.MqttMsgPublishReceived -= this.Client_MqttMsgPublishReceived; this.client.MqttMsgPublishReceived -= this.Client_MqttMsgPublishReceived;
this.Unsubscripe(); this.Unsubscripe();
if(complete) { if(complete) {
@ -59,7 +85,7 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
} }
private void Connect() { private void Connect() {
Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.Mqtt.Connect()"); Console.WriteLine("BlubbFish.Utils.IoT.Connector.Data.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"])
@ -102,15 +128,17 @@ 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) {try { if(disposing) {
try { try {
this.connectionWatcher.Abort(); this.connectionWatcherRunning = false;
this.connectionWatcher = null; while(this.connectionWatcher != null && this.connectionWatcher.IsAlive) {
} catch { } Thread.Sleep(10);
}
this.connectionWatcher = null;
this.Disconnect(true); this.Disconnect(true);
} catch (Exception) { } } catch (Exception) { }
} }

View File

@ -1,49 +0,0 @@

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

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))