Documentation ¶
Overview ¶
This package handles all the APIs provided by `wazigate-system`
Index ¶
- Constants
- Variables
- func APIDocs(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func ActivateAPMode() error
- func BlackoutEnabled(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func CloudAccessible(withLogs bool) bool
- func DeleteNetWiFi(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func DockerAction(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func DockerLogs(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func DockerStatus(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func DockerStatusById(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func GetGWBootstatus(withLogs bool) (bool, string)
- func GetNetInfo(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func GetNetWiFi(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func GetRootPath() string
- func GetSystemConf(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func GetTime(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func GetTimeZone(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func GetTimeZoneAuto(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func GetTimeZones(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func GoMonitor() error
- func HomeLink(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func Init() error
- func InternetAccessible(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func ListenAndServeHTTP()
- func Monitor(messages chan interface{})
- func NetConns(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func NetWiFiScan(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func OledWriteMessage(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func ResourceUsage(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func RunBlackoutManager() error
- func RunButtonsManager() error
- func RunFanManager() error
- func RunLEDManager() error
- func RunOLEDManager() error
- func RunTimezoneManager() error
- func SSH(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func SetNetAP(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func SetNetAPMode(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func SetNetWiFi(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func SetSystemConf(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func SetSystemTime(newDate string) error
- func SetTime(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func SetTimeZone(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func SocketRequest(addr string, url string, method string, contentType string, body io.Reader, ...) (string, error)
- func SystemReboot(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func SystemShutdown(resp http.ResponseWriter, req *http.Request, params routing.Params)
- func UI(resp http.ResponseWriter, req *http.Request, params routing.Params)
- type AccessPointRequest
- type Configuration
- type DeleteWifiReq
- type WifiReq
Constants ¶
const FAN_PIN = "GPIO5" // PIN #29
const LED1_PIN = "GPIO27" // PIN #13
const LED2_PIN = "GPIO22" // PIN #15
const POWER_IN_PIN = "GPIO23" // PIN #16
The GPIO pin that receives a signal when the main power is cut
const PWR_BTN = "GPIO26" // PIN #37
const SHUTDOWN_COUNTDOWN = 3 // for n seconds the button needs to be held down to activate shutdown procedure
const WiFi_BTN = "GPIO6" // PIN #31
const WiFi_BTN_COUNTDOWN = 3 // for n seconds the button needs to be held down to revert the wifi/web ui settings
Variables ¶
var DEBUG_MODE bool //DEBUG mode sends the errors via the HTTP responds
var ETH_DEVICE string //Ethernet Interface
var OledBuffer string // A Shared buffer for showing message on the OLED
var OledCurrentMsg string // The message which is showing on the OLED at the moment
var PackageJSON []byte // set by main.go
var WIFI_DEVICE string //Wifi Interface which can be set via env
Functions ¶
func BlackoutEnabled ¶
This function implements GET /blackout It returns a boolean value indicating whether the Wazigate is equipped with a blackout protection circuit
func CloudAccessible ¶
Checks if Waziup cloud is accessible
func DeleteNetWiFi ¶
DeleteNetWiFi implements DELETE /net/wifi
func DockerAction ¶
This function implements POST /docker/:cId/:action It receives typical actions that can be done to a container such as: start, stop, restart
func DockerLogs ¶
This function implements GET /docker/:cId/logs It retrieves the logs for a given container Id It can be called this way to receive only the `N` recent logs: `/docker/:cId/logs/:tail`
func DockerStatus ¶
This function implements GET /docker
func DockerStatusById ¶
This function implements GET /docker/:cId
func GetGWBootstatus ¶
This function provides the booting up information to be shown on the OLED
func GetNetInfo ¶
GetNetInfo implements GET /net
func GetNetWiFi ¶
GetNetWiFi implements GET /net/wifi
func GetRootPath ¶
func GetRootPath() string
This function retrieves the root path of where the binary is being executed
func GetSystemConf ¶
Implements GET /conf
func GetTimeZone ¶
GetTimeZone implements GET /timezone
func GetTimeZoneAuto ¶
GetTimeZoneAuto implements GET /timezone/auto
func GetTimeZones ¶
GetTimeZones implements GET /timezones and provide a list of available timezones
func InternetAccessible ¶
InternetAccessible implements GET /internet
func NetWiFiScan ¶
Implements GET /net/wifi/scanning
func OledWriteMessage ¶
This function implements POST|PUT /oled API
func ResourceUsage ¶
This function implements GET /usage It provides the CPU, RAM and Storage (e.g. Disk) usage
func RunBlackoutManager ¶
func RunBlackoutManager() error
This function monitors the power input in the new boards and check if there is black out then shuts down the gateway
func RunButtonsManager ¶
func RunButtonsManager() error
This function handles the push buttons on WaziHAT
func RunFanManager ¶
func RunFanManager() error
This function is constantly (every 5 seconds) checking the CPU temperature and if it goes beyond the threshold defined in the dahsboard, it triggers the fan
func RunOLEDManager ¶
func RunOLEDManager() error
OLED Controller This function gets the gateway status periodically and updates the OLED
func RunTimezoneManager ¶
func RunTimezoneManager() error
This function initializes the timezone configuration and it is called on startup to set the timezone according to the configs
func SetNetAPMode ¶
implements POST /net/wifi/mode/ap
func SetNetWiFi ¶
SetNetWiFi implements POST/PUT /net/wifi
func SetSystemConf ¶
Implements POST|PUT /conf
func SetSystemTime ¶
func SetTimeZone ¶
Implements POST|PUT /timezone
func SocketRequest ¶
func SocketRequest(addr string, url string, method string, contentType string, body io.Reader, withLogs bool) (string, error)
SocketRequest makes a request to a unix socket
func SystemReboot ¶
Implements POST|PUT /reboot
func SystemShutdown ¶
Implements POST|PUT /shutdown
Types ¶
type AccessPointRequest ¶
type Configuration ¶
type Configuration struct { SetupWizard bool `json:"setup_wizard"` FanTriggerTemp float64 `json:"fan_trigger_temp"` // At which temperature the Fan should start OLEDHaltTimeout int `json:"oled_halt_timeout"` // After what time the OLED goes off LocalTimezone string `json:"local_timezone"` // Local time zone }
Configuration keeps the general config of the settings app
var Config Configuration // the main configuration object
type DeleteWifiReq ¶
type DeleteWifiReq struct {
SSID string `json:"ssid"`
}