driver

package
v0.0.0-...-3883b96 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Protocol     = "mqtt"
	CommandTopic = "CommandTopic"
)

Constants related to protocol properties

View Source
const (
	AuthModeUsernamePassword = "usernamepassword"
	AuthModeNone             = "none"
)

Constants related to MQTT security

View Source
const (
	CustomConfigSectionName = "MQTTBrokerInfo"
	WritableInfoSectionName = CustomConfigSectionName + "/Writable"
)

Constants related to custom configuration

Variables

This section is empty.

Functions

func GetCredentials

func GetCredentials(secretPath string) (config.Credentials, error)

func NewProtocolDriver

func NewProtocolDriver() sdkModel.ProtocolDriver

func SetCredentials

func SetCredentials(uri *url.URL, category string, authMode string, secretPath string) error

func SetCredentialsNonSecureTemp

func SetCredentialsNonSecureTemp(uri *url.URL, category string, authMode string, username string, password string) error

This is a temporary work around until there is a practical way to set the mqtt credential in the security vault

Types

type BoolData

type BoolData struct {
	Data bool `json:"data"`
}

type Driver

type Driver struct {
	Logger           logger.LoggingClient
	AsyncCh          chan<- *sdkModel.AsyncValues
	CommandResponses sync.Map
	// contains filtered or unexported fields
}

func (*Driver) AddDevice

func (d *Driver) AddDevice(deviceName string, protocols map[string]models.ProtocolProperties, adminState models.AdminState) error

AddDevice is a callback function that is invoked when a new Device associated with this Device Service is added

func (*Driver) DisconnectDevice

func (d *Driver) DisconnectDevice(deviceName string, protocols map[string]models.ProtocolProperties) error

func (*Driver) HandleReadCommands

func (d *Driver) HandleReadCommands(deviceName string, protocols map[string]models.ProtocolProperties, reqs []sdkModel.CommandRequest) ([]*sdkModel.CommandValue, error)

func (*Driver) HandleWriteCommands

func (d *Driver) HandleWriteCommands(deviceName string, protocols map[string]models.ProtocolProperties, reqs []sdkModel.CommandRequest, params []*sdkModel.CommandValue) error

func (*Driver) Initialize

func (d *Driver) Initialize(lc logger.LoggingClient, asyncCh chan<- *sdkModel.AsyncValues, deviceCh chan<- []sdkModel.DiscoveredDevice) error

func (*Driver) RemoveDevice

func (d *Driver) RemoveDevice(deviceName string, protocols map[string]models.ProtocolProperties) error

RemoveDevice is a callback function that is invoked when a Device associated with this Device Service is removed

func (*Driver) Stop

func (d *Driver) Stop(force bool) error

Stop the protocol-specific DS code to shutdown gracefully, or if the force parameter is 'true', immediately. The driver is responsible for closing any in-use channels, including the channel used to send async readings (if supported).

func (*Driver) UpdateDevice

func (d *Driver) UpdateDevice(deviceName string, protocols map[string]models.ProtocolProperties, adminState models.AdminState) error

UpdateDevice is a callback function that is invoked when a Device associated with this Device Service is updated

type IntData

type IntData struct {
	Data int `json:"data"`
}

type MQTTBrokerInfo

type MQTTBrokerInfo struct {
	Schema    string
	Host      string
	Port      int
	Qos       int
	KeepAlive int
	ClientId  string

	CredentialsRetryTime  int
	CredentialsRetryWait  int
	ConnEstablishingRetry int
	ConnRetryWaitTime     int

	AuthMode        string
	CredentialsPath string

	// Temp fields
	Username string
	Password string

	IncomingTopic string
	ResponseTopic string

	Writable WritableInfo
}

func (*MQTTBrokerInfo) Validate

func (info *MQTTBrokerInfo) Validate() errors.EdgeX

Validate ensures your custom configuration has proper values.

type ServiceConfig

type ServiceConfig struct {
	MQTTBrokerInfo MQTTBrokerInfo
}

func (*ServiceConfig) UpdateFromRaw

func (sw *ServiceConfig) UpdateFromRaw(rawConfig interface{}) bool

UpdateFromRaw updates the service's full configuration from raw data received from the Service Provider.

type WritableInfo

type WritableInfo struct {
	// ResponseFetchInterval specifies the retry interval(milliseconds) to fetch the command response from the MQTT broker
	ResponseFetchInterval int
}

Jump to

Keyboard shortcuts

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