controllers

package
v0.0.0-...-05b221b Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MessagePubHandler mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {
	switch {
	case strings.Contains(msg.Topic(), "/switch/basic/"):
		MessageUpdateStatus(msg.Payload())
	}

}

Functions

func DefaultSubscribeHandler

func DefaultSubscribeHandler(client mqtt.Client)

func MessageUpdateStatus

func MessageUpdateStatus(message []byte) error

func Publish

func Publish(client mqtt.Client)

func Subscribe

func Subscribe(client mqtt.Client)

func UpdateStatus

func UpdateStatus(w http.ResponseWriter, r *http.Request)

Types

type UpdateStatusRequest

type UpdateStatusRequest struct {
	MoistureValue int    `json:"moistureValue"`
	Mode          string `json:"mode"`
	Moistures     []struct {
		MoistureValue float64 `json:"vl"`
		SensorPin     int     `json:"seP"`
		LEDpin        int     `json:"leP"`
		SensorName    string  `json:"seN"`
	} `json:"moistures"`
	Switchs []struct {
		Value bool   `json:"vl"`
		ID    int    `json:"id"`
		Uuid  string `json:"uuid"`
		Pin   int    `json:"swP"`
		Name  string `json:"swN"`
	} `json:"switchs"`
	Humiditys []struct {
		HumidityValue float64 `json:"hVl"`
		Temperature   float64 `json:"tVl"`
		SensorPin     int     `json:"seP"`
		SensorName    string  `json:"seN"`
	} `json:"humiditys"`
}

Jump to

Keyboard shortcuts

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