Commit 4580fe0b by Martin Kotula

Hub mqtt fixes:

parent bf46c2c2
...@@ -25,14 +25,10 @@ namespace Pi.Hub.Api.Controllers ...@@ -25,14 +25,10 @@ namespace Pi.Hub.Api.Controllers
public object Write([FromBody]object obj) public object Write([FromBody]object obj)
{ {
string serialized = JsonConvert.SerializeObject(obj); string serialized = JsonConvert.SerializeObject(obj);
//System.IO.File.AppendAllLines("C:\\apps\\msgs.txt", new[] { $",{{\"object\":{serialized},\"timestamp\":\"{DateTime.Now:F}\"}}" });
var client = new MqttClient("test.mosquitto.org"); var client = new MqttClient("test.mosquitto.org");
string[] topic = { "e1s/iot.challange" }; string topic = "e1s/iot.challange" ;
byte[] qosLevels = { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE };
client.Subscribe(topic, qosLevels);
client.Connect(Guid.NewGuid().ToString()); client.Connect(Guid.NewGuid().ToString());
client.Publish("e1s/iot.challange", Encoding.UTF8.GetBytes(serialized)); client.Publish(topic, Encoding.UTF8.GetBytes(serialized),MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE, false);
client.Disconnect(); client.Disconnect();
return new return new
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifiers>win-arm;linux-arm;x86</RuntimeIdentifiers> <RuntimeIdentifiers>win-arm;linux-arm;x86</RuntimeIdentifiers>
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
......
...@@ -29,7 +29,8 @@ namespace Pi.Hub.Api ...@@ -29,7 +29,8 @@ namespace Pi.Hub.Api
WebHost WebHost
.CreateDefaultBuilder(args) .CreateDefaultBuilder(args)
.UseStartup<Startup>() .UseStartup<Startup>()
.UseKestrel(opt => opt.Listen(IPAddress.Parse(configuration["PiHub:Address"]), int.Parse(configuration["PiHub:Port"]))) // .UseKestrel(opt => opt.Listen(IPAddress.Parse(configuration["PiHub:Address"]), int.Parse(configuration["PiHub:Port"])))
.UseKestrel()
.Build(); .Build();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment