device

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

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

Go to latest
Published: Apr 28, 2024 License: BSD-3-Clause Imports: 21 Imported by: 9

README

Merliot Device Package

Merliot device package is a base Go package for building Merliot devices.

Documentation

Index

Constants

View Source
const UF2Magic = "Call the Doctor!  Miss you Dan."

Random string to embed in UF2 we can search for later to locate params

Variables

This section is empty.

Functions

func New

func New(id, model, name string, fs embed.FS, targets []string) dean.Thinger

New returns a new device identified with [id, model, name] tuple. fs is the device's embedded file system. targets is a list of targets support by the device. e.g. ["rpi", "nano-rp2040"].

Types

type Device

type Device struct {
	// Device is a Thing
	dean.Thing
	// Targets supported by device
	target.Targets `json:"-"`
	// ModelStruct is the model with first letter upper-case
	ModelStruct string `json:"-"`
	// WIfiAuth is a map of SSID:PASSPHRASE pairs
	WifiAuth `json:"-"`
	// DialURLs is a comma seperated list of URLs the device will dial into
	DialURLs string `json:"-"`
	// DeployParams are device deploy configuration in an html param format
	DeployParams string

	// ViewMode is current device view mode
	ViewMode `json:"-"`
	// WsScheme is the websocket scheme to use to call back into the
	// device.  Default is ws://, which is sutable for an http:// device.
	// Set to wss:// if dialing back into an https:// device.
	WsScheme string `json:"-"`

	// Administratively locked
	Locked bool `json:"-"`
	// contains filtered or unexported fields
}

func (*Device) API

func (d *Device) API(w http.ResponseWriter, r *http.Request, data any)

API is the base device's API. Derived devices can have their own API function to overide or extend this API.

func (*Device) CopyWifiAuth

func (d *Device) CopyWifiAuth(auth WifiAuth)

func (*Device) DescHtml

func (d *Device) DescHtml() []byte

DescHtml is the base device's description

func (*Device) FailSafe

func (d *Device) FailSafe()

func (*Device) GenerateUf2s

func (d *Device) GenerateUf2s(dir string) error

func (*Device) GetDeployParams

func (d *Device) GetDeployParams() string

func (*Device) Icon

func (d *Device) Icon() []byte

Icon is the base device's icon image

func (Device) LoadModule

func (d Device) LoadModule() Module

func (*Device) ParamFirstValue

func (d *Device) ParamFirstValue(key string) string

ParamFirstValue returns the first value os html param named by key

func (*Device) RenderTemplate

func (d *Device) RenderTemplate(w http.ResponseWriter, name string, data any)

RenderTemplate writes the rendered template name using data to writer

func (*Device) ServeHTTP

func (d *Device) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the base device's web server handler for /. Derived devices can override or extend with their own ServeHTTP function.

func (*Device) SetDeployParams

func (d *Device) SetDeployParams(params string)

func (*Device) SetDialURLs

func (d *Device) SetDialURLs(urls string)

func (*Device) SetLocked

func (d *Device) SetLocked(locked bool)

func (*Device) SetWifiAuth

func (d *Device) SetWifiAuth(ssids, passphrases string)

func (*Device) SetWsScheme

func (d *Device) SetWsScheme(scheme string)

func (*Device) Setup

func (d *Device) Setup()

func (*Device) SupportedTargets

func (d *Device) SupportedTargets() string

Supported Targets is the base device's targets in full format

type Devicer

type Devicer interface {
	CopyWifiAuth(WifiAuth)
	SetWsScheme(string)
	SetDialURLs(string)
	SetLocked(bool)
	GetDeployParams() string
	SetDeployParams(string)
}

type Modeler

type Modeler interface {
	Icon() []byte
	DescHtml() []byte
	SupportedTargets() string
	GenerateUf2s(string) error
}

type Module

type Module struct {
	Path    string             // go module path
	Require []*modfile.Require // required dependencies
}

type ViewMode

type ViewMode int

ViewMode is how the device is being viewed

const (
	ViewFull ViewMode = iota
	ViewTile
	ViewTileVert
	ViewTileHorz
)

type WifiAuth

type WifiAuth map[string]string // key: ssid; value: passphrase

WIfiAuth is a map of SSID:PASSPHRASE pairs

Directories

Path Synopsis
cmd
cmd
uf2

Jump to

Keyboard shortcuts

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