Skip to content
This repository has been archived by the owner on Aug 19, 2023. It is now read-only.

Latest commit

 

History

History
51 lines (43 loc) · 2.51 KB

README.md

File metadata and controls

51 lines (43 loc) · 2.51 KB

This repo has moved to https://github.com/ChrisPulman/MQTTnet.Rx

License Build Nuget NuGet

MQTTnet.Rx.SerialPort

MQTTnet.Rx.SerialPort

A Reactive SerialPort for MQTTnet Broker

Create a Mqtt Client to Publish data from an Observable SerialPort

Create.MqttClient()
    .WithClientOptions(a => a.WithTcpServer("localhost", 9000))
    .PublishMessage(_message)
    .Subscribe(r => Console.WriteLine($"{r.ReasonCode} [{r.PacketIdentifier}]"));

Create a Managed Mqtt Client to Publish data from an Observable SerialPort Subscribe

Create.ManagedMqttClient()
    .WithManagedClientOptions(a =>
        a.WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
            .WithClientOptions(c =>
                c.WithTcpServer("localhost", 9000)))
    .PublishMessage(_message)
    .Subscribe(r => Console.WriteLine($"{r.ApplicationMessage.Id} [{r.ApplicationMessage.ApplicationMessage.Topic}] value : {r.ApplicationMessage.ApplicationMessage.ConvertPayloadToString()}"));

Create a Mqtt Client Subscribe to a Topic that will interact with the SerialPort

Create.MqttClient()
    .WithClientOptions(a => a.WithTcpServer("localhost", 9000))
    .SubscribeToTopic("FromMilliseconds")
    .Subscribe(r => Console.WriteLine($"{r.ReasonCode} [{r.ApplicationMessage.Topic}] value : {r.ApplicationMessage.ConvertPayloadToString()}"));

Create a Managed Mqtt Client to Subscribe to a Topic that will interact with the SerialPort

Create.ManagedMqttClient()
    .WithManagedClientOptions(a =>
        a.WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
            .WithClientOptions(c =>
                c.WithTcpServer("localhost", 9000)))
    .SubscribeToTopic("FromMilliseconds")
    .Subscribe(r => Console.WriteLine($"{r.ReasonCode} [{r.ApplicationMessage.Topic}] value : {r.ApplicationMessage.ConvertPayloadToString()}"));