pimonitor

package module
v0.0.0-...-bc55f28 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: GPL-3.0 Imports: 10 Imported by: 1

README

pimonitor

utility service offering coordinated localhost REST access to the Pi GPIO and PiFACE cape (or any SPI)

Documentation

Overview

Package pimonitor watches your pi and serves piface controls to localhost.

Package pimonitor watches your pi and serves piface controls to localhost.

Index

Constants

This section is empty.

Variables

View Source
var ListenAddress = "[::1]:5050"

ListenAddress says where we listen

View Source
var PingmonFails = 5

PingmonFails tunable if you enable the piserver

View Source
var PingmonFound = 0

PingmonFound counts stats

View Source
var PingmonFrequency = 5 * time.Second

PingmonFrequency tunable if you enable the piserver

View Source
var PingmonReboot = false

PingmonReboot tunable if you enable the piserver

View Source
var PingmonTargets = []struct {
	network string
	address string
}{
	{"tcp", "192.168.10.1:80"},
	{"tcp", "192.168.10.1:443"},
	{"tcp", "192.168.10.1:53"},
	{"tcp6", "[2606:a000:4c84:82f0::1]:80"},
	{"tcp6", "[2606:a000:4c84:82f0::1]:443"},
	{"tcp6", "[2606:a000:4c84:82f0::1]:53"},
}

Functions

func CrawlLeds

func CrawlLeds(pi *pimon.PiFace)

CrawlLeds gives a visual running light indicator using the last 4 LEDS note: the first 4 outputs may affect the relays on the piface and so are not used

func HandleInputPortValue

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

HandleInputPortValue returns a byte of the 8 input pin states

func HandleInputValue

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

HandleInputValue returns the value of the specified input

func HandleOutputOff

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

HandleOutputOff does what it says on the tin

func HandleOutputOn

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

HandleOutputOn does what it says on the tin

func HandleOutputPortSetValue

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

HandleOutputPortSetValue does what it says on the tin

func HandlePingmon

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

HandlePingmon enables disables or reports on the rebooter

func HandleRelayClick

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

HandleRelayClick does what it says on the tin

func HandleRelayOff

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

HandleRelayOff does what it says on the tin

func HandleRelayOn

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

HandleRelayOn does what it says on the tin

func HandleRelayToggle

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

HandleRelayToggle does what it says on the tin

func Pingmon

func Pingmon(target string)

Pingmon watches for the network gateway (or whatevr target gets put there) and restarts the pi if it's not found several times in a row. Should try for almost a minute before it reboots, and should not reboot if one try gets thru.

func SwitchMonitor

func SwitchMonitor(pi *pimon.PiFace)

SwitchMonitor watches the piface switches and does functions Switch 0 - click relay 0 Switch 1 - click relay 1 Switch 2 - flash the lights Switch 3 - reboot Switch 2+3 - shutdown

func WriteJSON

func WriteJSON(w http.ResponseWriter, d interface{}) error

WriteJSON puts a JSON structure to the writer and sets application/json

Types

type BoolValueResponse

type BoolValueResponse struct {
	Value bool   `json:"value"`
	Error string `json:"error,omitempty"`
}

BoolValueResponse returns a boolean value and error indicator

type BootTrace

type BootTrace struct {
	Log []struct {
		BootTime    time.Time     `ldap: "boot_time"`
		RunTime     time.Duration `ldap: "run_time"`
		BootMessage string        `ldap: "boot_message"`
	} `ldap: "log"`
}

type ByteValueResponse

type ByteValueResponse struct {
	Value byte   `json:"value"`
	Error string `json:"error,omitempty"`
}

ByteValueResponse returns a boolean value and error indicator

type PiServer

type PiServer struct {
	Pi *pimon.PiFace
}

PiServer is our server struct for hanging methods

func (*PiServer) ListenAndServe

func (s *PiServer) ListenAndServe() error

ListenAndServe makes PiServer a http.Handler

type StringValueResponse

type StringValueResponse struct {
	Value string `json:"value"`
	Error string `json:"error,omitempty"`
}

StringValueResponse is for string answers

Directories

Path Synopsis
Package main collects the program CLI components including the main entrypoint
Package main collects the program CLI components including the main entrypoint
piface
Package piface is for interfacing with a PiFace Digital IO board.
Package piface is for interfacing with a PiFace Digital IO board.

Jump to

Keyboard shortcuts

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