mqttclient

package
v0.0.0-...-df163ab Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mqtt

type Mqtt struct {
	Type          string      `json:"type"` // tcp, ws, wss
	Broker        string      `json:"broker"`
	Port          string      `json:"port"`
	CertFile      string      `json:"certFile"`
	KeyFile       string      `json:"keyFile"`
	CaCertFile    string      `json:"caFile"`
	Username      string      `json:"username"`
	Password      string      `json:"password"`
	Topics        []MqttTopic `json:"topics"`
	AutoReconnect bool        `json:"reconnect"`
}

type MqttClient

type MqttClient struct {
	Config Mqtt

	Client        mqtt.Client
	Queue         *queue.MessageQueue
	DocDBconn     *documents.DocDB
	DB            *sql.DB
	SignalRClient signalr.Client

	AppServer string
	ApiKey    string
	// contains filtered or unexported fields
}

func NewMqttClient

func NewMqttClient(configurations Mqtt) *MqttClient

NewMqttClient creates a new instance of MqttClient with the given configurations. It initializes the MqttClient with the provided configurations and returns a pointer to the created MqttClient. The MqttClient is initialized with the following parameters: - mqttBrokertype: a string representing the type of the MQTT broker (tcp, ws, wss). - mqttBroker: a string representing the MQTT broker address. - mqttPort: a string representing the MQTT broker port. - certFile: a string representing the certificate file path. - keyFile: a string representing the key file path. - caCertFile: a string representing the CA certificate file path. - mqttClientID: a string representing the MQTT client ID. - mqttTopics: a slice of MqttTopic structs representing the MQTT topics to subscribe to. - iLog: a logger.Log struct representing the logger. - Client: a mqtt.Client struct representing the MQTT client.

func NewMqttClientbyExternal

func NewMqttClientbyExternal(configurations Mqtt, DB *sql.DB, DocDBconn *documents.DocDB, SignalRClient signalr.Client) *MqttClient

NewMqttClientbyExternal creates a new instance of MqttClient with the provided configurations, database connection, document database connection, and SignalR client. It initializes the MqttClient with the given configurations and returns the created MqttClient instance. The MqttClient is initialized with the following parameters: - mqttBrokertype: a string representing the type of the MQTT broker (tcp, ws, wss). - mqttBroker: a string representing the MQTT broker address. - mqttPort: a string representing the MQTT broker port. - certFile: a string representing the certificate file path. - keyFile: a string representing the key file path. - caCertFile: a string representing the CA certificate file path. - mqttClientID: a string representing the MQTT client ID. - mqttTopics: a slice of MqttTopic structs representing the MQTT topics to subscribe to. - iLog: a logger.Log struct representing the logger.

func (*MqttClient) CallWebService

func (mqttClient *MqttClient) CallWebService(msg mqtt.Message, topic string, handler string)

func (*MqttClient) Connect

func (mqttClient *MqttClient) Connect() error

func (*MqttClient) Initialize_mqttClient

func (mqttClient *MqttClient) Initialize_mqttClient()

func (*MqttClient) MonitorAndReconnect

func (mqttClient *MqttClient) MonitorAndReconnect()

func (*MqttClient) Publish

func (mqttClient *MqttClient) Publish(topic string, payload string)

func (*MqttClient) SubscribeTopics

func (mqttClient *MqttClient) SubscribeTopics()

type MqttConfig

type MqttConfig struct {
	Mqtts  []Mqtt `json:"mqtts"`
	ApiKey string `json:"apikey"`
}

type MqttTopic

type MqttTopic struct {
	Topic   string `json:"topic"`
	Qos     byte   `json:"qos"`
	Handler string `json:"handler"`
	Mode    string `json:"mode"`
	Type    string `json:"type"`
}

Jump to

Keyboard shortcuts

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