[BF] Fixing Senml

[NF] Senml now has a configure option to setup the guid
[NF] Zway-Bot now listen on /exit
[NF] Implment searchpath for Zway-Bot (/etc/zwaybot and %appdata%/zwaybot)
This commit is contained in:
2018-05-07 16:52:24 +00:00
parent affbfc79fc
commit 29caf6f6f6
27 changed files with 267 additions and 195 deletions
@@ -45,7 +45,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Librarys\mqtt\M2Mqtt\M2Mqtt.csproj">
<ProjectReference Include="..\..\..\..\..\Librarys\mqtt\M2Mqtt\M2Mqtt_4.7.1.csproj">
<Project>{a11aef5a-b246-4fe8-8330-06db73cc8074}</Project>
<Name>M2Mqtt</Name>
</ProjectReference>
+4 -6
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using BlubbFish.Utils.IoT.Events;
using uPLibrary.Networking.M2Mqtt;
using uPLibrary.Networking.M2Mqtt.Messages;
@@ -8,10 +9,7 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
public class Mqtt : ADataBackend, IDisposable {
private MqttClient client;
public override event MqttMessage MessageIncomming;
public override event MqttMessage MessageSending;
public Mqtt(Dictionary<String, String> settings) {
public Mqtt(Dictionary<String, String> settings) : base(settings) {
if(settings.ContainsKey("port")) {
this.client = new MqttClient(settings["server"], Int32.Parse(settings["port"]), false, null, null, MqttSslProtocols.None);
} else {
@@ -27,12 +25,12 @@ namespace BlubbFish.Utils.IoT.Connector.Data {
}
private void Client_MqttMsgPublishReceived(Object sender, MqttMsgPublishEventArgs e) {
this.MessageIncomming?.Invoke(this, new MqttEventArgs(Encoding.UTF8.GetString(e.Message), e.Topic));
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.MessageSending?.Invoke(this, new MqttEventArgs(data, topic));
this.NotifyClientSending(new DataEvent(data, topic, DateTime.Now));
}
#region IDisposable Support
Binary file not shown.
Binary file not shown.
Binary file not shown.