base

package
v0.0.0-...-791007e Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DevMode ...
	DevMode = "dev"
	// PrdMode ...
	PrdMode = "prd"
)
View Source
const (
	// WsnToken is the token of wsn iot cloud
	WsnToken = "your_wsn_token"
	// WsnNumericalAPI is the api of wsn iot cloud for pushing numerical datapoints
	WsnNumericalAPI = "http://www.wsncloud.com/api/data/v1/numerical/insert"
	// WsnGenericAPI is the api of wsn iot cloud for pushing generic datapoints
	WsnGenericAPI = "http://www.wsncloud.com/api/data/v1/generic/insert"
)
View Source
const (
	// OneNetToken is the token of OneNet iot cloud
	OneNetToken = "your_onenet_token"
	// OneNetAPI is the api of OneNet iot cloud for pushing datapoints
	OneNetAPI = "http://api.heclouds.com/devices/540381180/datapoints"
)

Variables

View Source
var ErrEmpty = errors.New("empty")

ErrEmpty ...

Functions

func GetEmailList

func GetEmailList() []string

GetEmailList ...

func GetIP

func GetIP() string

GetIP ...

func Init

func Init(cfg *Config)

Init ...

func Reverse

func Reverse(s string) string

Reverse reverses the string

func SendEmail

func SendEmail(info *EmailInfo)

SendEmail ...

func WaitQuit

func WaitQuit(beforeQuitFunc func())

WaitQuit ...

Types

type Config

type Config struct {
	Led       *LedConfig       `json:"led"`
	Relay     *RelayConfig     `json:"relay"`
	StepMotor *StepMotorConfig `json:"stepmotor"`
	Wsn       *WsnConfig       `json:"wsn"`
	OneNet    *OneNetConfig    `json:"onenet"`
	Email     *EmailConfig     `json:"email"`
	EmailTo   *EmailToConfig   `json:"emailto"`
}

Config ...

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig ...

type Email

type Email struct {
	SMTP     string
	SMTPPort int
	POP      string
	POPPort  int
	Address  string
	Password string
}

Email ...

func NewEmail

func NewEmail(cfg *EmailConfig) *Email

NewEmail ...

func (*Email) Send

func (e *Email) Send(info *EmailInfo) error

Send ...

func (*Email) Start

func (e *Email) Start()

Start ...

type EmailConfig

type EmailConfig struct {
	SMTP     string `json:"smtp"`
	SMTPPort int    `json:"smtp_port"`
	POP      string `json:"pop"`
	POPPort  int    `json:"pop_port"`
	Address  string `json:"addr"`
	Password string `json:"password"`
}

EmailConfig ...

type EmailInfo

type EmailInfo struct {
	To      []string
	Subject string
	Body    string
}

EmailInfo ...

type EmailToConfig

type EmailToConfig struct {
	List []string `json:"list"`
}

EmailToConfig ...

type History

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

History ...

func NewHistory

func NewHistory(size int) *History

NewHistory ...

func (*History) Add

func (h *History) Add(v interface{})

Add ...

func (*History) Avg

func (h *History) Avg() (float64, error)

Avg ...

type LedConfig

type LedConfig struct {
	Pin uint8 `json:"pin"`
}

LedConfig ...

type Mode

type Mode string

Mode ...

type OneNetConfig

type OneNetConfig struct {
	Token string `json:"token"`
	API   string `json:"api"`
}

OneNetConfig ...

type Point

type Point struct {
	Lat float32 `json:"lat"`
	Lon float32 `json:"lon"`
}

Point is GPS point

func (*Point) String

func (p *Point) String() string

type RelayConfig

type RelayConfig struct {
	Pin uint8 `json:"pin"`
}

RelayConfig ...

type RpiModel

type RpiModel string

RpiModel ...

const (
	// RpiUnknown ...
	RpiUnknown RpiModel = "Raspberry Pi X Model"
	// Rpi0 ...
	Rpi0 RpiModel = "Raspberry Pi Zero Model"
	// RpiA ...
	RpiA RpiModel = "Raspberry Pi A Model"
	// RpiB ...
	RpiB RpiModel = "Raspberry Pi B Model"
	// Rpi2 ...
	Rpi2 RpiModel = "Raspberry Pi 2 Model"
	// Rpi3 ...
	Rpi3 RpiModel = "Raspberry Pi 3 Model"
	// Rpi4 ...
	Rpi4 RpiModel = "Raspberry Pi 4 Model"
)

func GetRpiModel

func GetRpiModel() RpiModel

GetRpiModel ...

type StepMotorConfig

type StepMotorConfig struct {
	In1 uint8 `json:"in1"`
	In2 uint8 `json:"in2"`
	In3 uint8 `json:"in3"`
	In4 uint8 `json:"in4"`
}

StepMotorConfig ...

type WsnConfig

type WsnConfig struct {
	Token string `json:"token"`
	API   string `json:"api"`
}

WsnConfig ...

Jump to

Keyboard shortcuts

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