Commit 4580fe0b by Martin Kotula

Hub mqtt fixes:

parent bf46c2c2
......@@ -25,14 +25,10 @@ namespace Pi.Hub.Api.Controllers
public object Write([FromBody]object 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");
string[] topic = { "e1s/iot.challange" };
byte[] qosLevels = { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE };
client.Subscribe(topic, qosLevels);
string topic = "e1s/iot.challange" ;
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();
return new
......
......@@ -4,7 +4,6 @@
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifiers>win-arm;linux-arm;x86</RuntimeIdentifiers>
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
......
......@@ -29,7 +29,8 @@ namespace Pi.Hub.Api
WebHost
.CreateDefaultBuilder(args)
.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();
}
}
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