app

package
v0.0.0-...-e3dce03 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

* Copyright (C) 2022 Marian Micek * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright (C) 2022 Marian Micek * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright (C) 2022 Marian Micek * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScheduleTask

func ScheduleTask(duration int, callback func())

Types

type Broker

type Broker struct {
	Host     string `json:"host"`     // mqtt server host
	Port     int    `json:"port"`     // mqtt server port
	Ssl      bool   `json:"ssl"`      // use secure connection
	User     string `json:"username"` // server username
	Password string `json:"password"` // server password
	Client   string `json:"client"`   // client id to present to server
}

type Config

type Config struct {
	System  System   `json:"system"` // system configuration
	Mqtt    Broker   `json:"mqtt"`   // mqtt configuration
	Plugins []Plugin `json:"plugins"`
}

func Configure

func Configure() (*Config, *logger.Logger)

type Plugin

type Plugin struct {
	Plugin string          `json:"plugin"`
	Config json.RawMessage `json:"config"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func StartMqtt

func StartMqtt(logger *logger.Logger, cfg *Config) *Server

func (*Server) Connect

func (server *Server) Connect(ssl bool, host string, port int, clientid string, username string, password string)

Connect to MQTT server.

func (*Server) Disconnect

func (server *Server) Disconnect()

Disconnect from server.

func (*Server) Log

func (server *Server) Log() *logger.Logger

Log event.

func (*Server) Publish

func (server *Server) Publish(topic string, value string) bool

Send value to this topic.

func (*Server) Subscribe

func (server *Server) Subscribe(topic string, callback paho.MessageHandler) bool

Subscribe to this topic.

type System

type System struct {
	Debug bool   `json:"debug"` // enable debug log
	Log   string `json:"log"`   // log file
}

Jump to

Keyboard shortcuts

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