client

package
v0.0.0-...-34f8474 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(host, username, passwd string) func(opts ...Option) Client

Types

type Client

type Client interface {
	// PublishRaw  for publish raw msg
	PublishRaw(ctx context.Context, payload interface{}) error

	// PublishTelemetry  for publish telemetry msg
	PublishTelemetry(ctx context.Context, payload interface{}) error

	// PublishAttribute  for publish attribute msg
	PublishAttribute(ctx context.Context, payload interface{}) error

	// PublishTelemetry  for publish telemetry msg
	PublishGatewayTelemetry(ctx context.Context, payload interface{}) error

	// PublishAttribute  for publish attribute msg
	PublishGatewayAttribute(ctx context.Context, payload interface{}) error

	SubscribeRpcReq(ctx context.Context, handler MessageHandler) error

	PublishRpcResponse(ctx context.Context, commandName, requestId string, payload interface{}) error

	// Close client
	Close()

	// Connect to IoT Hub
	Connect() (err error)
}

Client is the interface for device-sdk-go client implementation.

type Message

type Message paho.Message

Message is a message received from the broker.

type MessageHandler

type MessageHandler = func(message Message) (interface{}, error)

type MqttClient

type MqttClient struct {
	// contains filtered or unexported fields
}

func (*MqttClient) Close

func (mc *MqttClient) Close()

func (*MqttClient) Connect

func (mc *MqttClient) Connect() (err error)

Connect returns true if connection to mqtt is established

func (*MqttClient) PublishAttribute

func (mc *MqttClient) PublishAttribute(ctx context.Context, payload interface{}) error

func (*MqttClient) PublishGatewayAttribute

func (mc *MqttClient) PublishGatewayAttribute(ctx context.Context, payload interface{}) error

func (*MqttClient) PublishGatewayTelemetry

func (mc *MqttClient) PublishGatewayTelemetry(ctx context.Context, payload interface{}) error

func (*MqttClient) PublishRaw

func (mc *MqttClient) PublishRaw(ctx context.Context, payload interface{}) error

func (*MqttClient) PublishRpcResponse

func (mc *MqttClient) PublishRpcResponse(ctx context.Context, commandName, requestId string, payload interface{}) error

func (*MqttClient) PublishTelemetry

func (mc *MqttClient) PublishTelemetry(ctx context.Context, payload interface{}) error

func (*MqttClient) SubscribeRpcReq

func (mc *MqttClient) SubscribeRpcReq(ctx context.Context, handler MessageHandler) error

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithAutoReconnect

func WithAutoReconnect(b bool) Option

WithAutoReconnect SetAutoReconnect sets the MQTT AutoReconnect setting

func WithQoS

func WithQoS(i int) Option

func WithServerCert

func WithServerCert(s string) Option

func WithUseSSL

func WithUseSSL(b bool) Option

type RpcPayload

type RpcPayload struct {
	Method string         `json: "method"`
	Params map[string]any `json: "params"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL