Documentation
¶
Index ¶
- func CreateCloudEvent(t string, source string, data string) (cloudevents.Event, error)
- func GetBroadcastAddress() (string, error)
- func MarshallCloudEvent(event cloudevents.Event) ([]byte, error)
- func UnmarshalCloudEvent(bytes []byte) (cloudevents.Event, error)
- type Config
- type Connection
- type MQTT
- type MQTTClient
- func (c *MQTTClient) Disconnect() error
- func (c *MQTTClient) Publish(topic string, qos byte, retained bool, payload interface{}) error
- func (c *MQTTClient) Receive() <-chan []byte
- func (c *MQTTClient) Send(topic string, ce cloudevents.Event) error
- func (c *MQTTClient) SendMessage(topic string, data string) error
- func (c *MQTTClient) SendRaw(topic string, raw []byte) error
- type UDP
- type UDPConn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateCloudEvent ¶
CreateCloudEvent creates a CloudEvent JSON.
func GetBroadcastAddress ¶
func MarshallCloudEvent ¶
func MarshallCloudEvent(event cloudevents.Event) ([]byte, error)
MarshallCloudEvent converts a CloudEvent struct to a JSON byte array.
func UnmarshalCloudEvent ¶
func UnmarshalCloudEvent(bytes []byte) (cloudevents.Event, error)
UnmarshalCloudEvent converts a JSON byte array to a CloudEvent struct.
Types ¶
type Config ¶
type Config struct { MQTT MQTT `mapstructure:"mqtt"` UDP UDP `mapstructure:"udp"` LogLevel string `mapstructure:"log_level"` ConfigFolder string }
Config represents the application configuration.
func LoadConfig ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func (*Connection) Receive ¶
func (c *Connection) Receive() chan []byte
func (*Connection) RemoteAddress ¶
func (*Connection) Send ¶
func (c *Connection) Send(ip string, port int, ce cloudevents.Event) error
type MQTT ¶
type MQTT struct { ClientId string `mapstructure:"client_id"` Endpoint string `mapstructure:"endpoint"` Protocol string `mapstructure:"protocol"` Port int `mapstructure:"port"` CaFile string `mapstructure:"ca_file"` CertFile string `mapstructure:"cert_file"` KeyFile string `mapstructure:"key_file"` TopicIn string `mapstructure:"topic_in"` TopicOut string `mapstructure:"topic_out"` }
type MQTTClient ¶
type MQTTClient struct {
// contains filtered or unexported fields
}
MQTTClient struct
func NewClient ¶
func NewClient(broker, clientId, certFile, keyFile, caFile, topic string) (*MQTTClient, error)
NewClient creates a new MQTT client to connect to AWS IoT Core.
func (*MQTTClient) Disconnect ¶
func (c *MQTTClient) Disconnect() error
Disconnect disconnects the MQTT client.
func (*MQTTClient) Publish ¶
func (c *MQTTClient) Publish(topic string, qos byte, retained bool, payload interface{}) error
Publish sends a message to the specified topic.
func (*MQTTClient) Receive ¶
func (c *MQTTClient) Receive() <-chan []byte
Receive returns the receive channel for MQTT messages.
func (*MQTTClient) Send ¶
func (c *MQTTClient) Send(topic string, ce cloudevents.Event) error
Send sends a message to the specified topic.
func (*MQTTClient) SendMessage ¶
func (c *MQTTClient) SendMessage(topic string, data string) error
Send Message as Cloudevent
type UDPConn ¶
type UDPConn struct {
// contains filtered or unexported fields
}
UDP connection struct
func NewConnection ¶
NewConnection creates a new UDP connection.
Click to show internal directories.
Click to hide internal directories.