Documentation ¶
Index ¶
- Constants
- type Device
- type MqttDevice
- func (obj *MqttDevice) AddEndpoint(enp endpoints.Endpoint)
- func (obj *MqttDevice) Connect() error
- func (obj *MqttDevice) Disconnect()
- func (obj *MqttDevice) GetEndpoint(uid string) endpoints.Endpoint
- func (obj *MqttDevice) RegisterOnConnectCb(cb func())
- func (obj *MqttDevice) RegisterOnConnectionLostCb(cb func(err error))
- func (obj *MqttDevice) SendConfigs()
Constants ¶
View Source
const ( TLS_PORT = 8883 // secure TLS port TCP_PORT = 1883 // not secure port )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device interface { // Connect connects Device object to HC gateway Connect() error // Disconnect disconnects Device from HC gateway Disconnect() // AddEndpoint adds new endpoint to MQTT Device AddEndpoint(enp endpoints.Endpoint) // GetEndpoint returns endpoint with given ID GetEndpoint(uid string) endpoints.Endpoint // RegisterOnConnectCb registers handler that is invoked when the connection is established RegisterOnConnectCb(cb func()) // RegisterOnConnectionLostCb registers handler that is invoked when connection is lost RegisterOnConnectionLostCb(cb func(err error)) }
Device interface that collects methods needed to connect MQTT device to HC Gateway
type MqttDevice ¶
type MqttDevice struct {
// contains filtered or unexported fields
}
MqttDevice struct that defines all method needed to connect and communicate with HC GW
func (*MqttDevice) AddEndpoint ¶
func (obj *MqttDevice) AddEndpoint(enp endpoints.Endpoint)
AddEndpoint adds new endpoint to MQTT Device
func (*MqttDevice) Connect ¶
func (obj *MqttDevice) Connect() error
Connect connects Device object to HC gateway
func (*MqttDevice) Disconnect ¶
func (obj *MqttDevice) Disconnect()
Disconnect disconnects Device from HC gateway
func (*MqttDevice) GetEndpoint ¶
func (obj *MqttDevice) GetEndpoint(uid string) endpoints.Endpoint
func (*MqttDevice) RegisterOnConnectCb ¶
func (obj *MqttDevice) RegisterOnConnectCb(cb func())
RegisterOnConnectCb registers external handler that is invoked when mqtt device is connected
func (*MqttDevice) RegisterOnConnectionLostCb ¶
func (obj *MqttDevice) RegisterOnConnectionLostCb(cb func(err error))
RegisterOnConnectionLostCb register external handler that is invoked when connection is lost
func (*MqttDevice) SendConfigs ¶
func (obj *MqttDevice) SendConfigs()
SendConfigs sends config for each endpoint
Click to show internal directories.
Click to hide internal directories.