mqtttestclient

package module
v0.0.0-...-1ff67b1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

README

MQTT-Testclient

Library for creating MQTT Devices with random names and values

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Value interface{}
	// contains filtered or unexported fields
}

Device holds a device with a topic and value

func CreateRandomDevice

func CreateRandomDevice(dataType string) *Device

CreateRandomDevice creates a random device with specified topic parameters

func CreateRandomDevices

func CreateRandomDevices(count int) []*Device

CreateRandomDevices creates random devices of type, adds to Devices

func (*Device) SetValueToRandom

func (device *Device) SetValueToRandom(timer int, max int, millisecondBetweenValuechange int)

SetValueToRandom sets the device to a random variable on a timer. Max ignored on non-analog.

type Station

type Station struct {
	Devices []*Device
	// contains filtered or unexported fields
}

Station Holds various devices as part of a station

func CreateRandomStations

func CreateRandomStations(count int) []*Station

CreateRandomStations creates an array of Random Stations

type TestClient

type TestClient struct {
	Opts       *MQTT.ClientOptions
	PahoClient MQTT.Client
	Message    MQTT.Message
	Seq        uint64
	Namespace  string
	GroupID    string
	EdgeNodeID string
	Stations   []*Station
}

TestClient class

func CreateTestClient

func CreateTestClient(brokerIP string, port string, clientID string) *TestClient

CreateTestClient creates a test client and populated it with random devices/points

func NewClient

func NewClient(ip string, port string, clientID string) *TestClient

NewClient Creates a client

func (TestClient) CreateRandomStations

func (testClient TestClient) CreateRandomStations(stationsNum int, pointsNum int, millisecondBetweenValuechange int) []*Station

CreateRandomStations Return array of random stations with random devices with random values

func (*TestClient) GetSequence

func (testClient *TestClient) GetSequence() uint64

GetSequence adds 1 to sequence and gets the sequence number (cap of 255 then returns to 0)

func (TestClient) PublishPoints

func (testClient TestClient) PublishPoints(millsecondBetweenBroadcast int)

PublishPoints a

func (TestClient) SendMessage

func (testClient TestClient) SendMessage(topic string, message interface{})

SendMessage Sends a message

func (*TestClient) WriteData

func (testClient *TestClient) WriteData(station *Station, msgType string)

WriteData writes a message for all devices in Devices. msgType can be either DDATA or DBIRTH.

func (*TestClient) WriteNBirth

func (testClient *TestClient) WriteNBirth()

WriteNBirth writes the NBirth message

Jump to

Keyboard shortcuts

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