Remove test folder
This commit is contained in:
parent
72a809f7ae
commit
2e5334001f
@ -1,36 +0,0 @@
|
|||||||
using MQTTnet;
|
|
||||||
|
|
||||||
var mqttFactory = new MqttClientFactory();
|
|
||||||
IMqttClient mqttClient;
|
|
||||||
|
|
||||||
using (mqttClient = mqttFactory.CreateMqttClient())
|
|
||||||
{
|
|
||||||
var mqttClientOptions = new MqttClientOptionsBuilder()
|
|
||||||
.WithTcpServer($"10.135.51.116", 1883)
|
|
||||||
.WithCredentials($"h5", $"Merc1234")
|
|
||||||
.WithCleanSession()
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
// Setup message handling before connecting so that queued messages
|
|
||||||
// are also handled properly. When there is no event handler attached all
|
|
||||||
// received messages get lost.
|
|
||||||
mqttClient.ApplicationMessageReceivedAsync += e =>
|
|
||||||
{
|
|
||||||
Console.WriteLine("Received application message.");
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
await mqttClient.ConnectAsync(mqttClientOptions, CancellationToken.None);
|
|
||||||
Console.WriteLine("mqttClient");
|
|
||||||
|
|
||||||
//var mqttSubscribeOptions = mqttFactory.CreateSubscribeOptionsBuilder().WithTopicTemplate(topic).Build();
|
|
||||||
|
|
||||||
await mqttClient.SubscribeAsync("temperature");
|
|
||||||
|
|
||||||
Console.WriteLine("MQTT client subscribed to topic.");
|
|
||||||
|
|
||||||
Console.WriteLine("Press enter to exit.");
|
|
||||||
Console.ReadLine();
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="MQTTnet" Version="5.0.1.1416" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
Loading…
Reference in New Issue
Block a user