Documentation
¶
Index ¶
- Constants
- Variables
- func IsPermanentError(err error) bool
- type CacophonyAPI
- func (api *CacophonyAPI) DownloadFile(fileResponse *FileResponse, filePath string) error
- func (api *CacophonyAPI) GetFileDetails(fileID int) (*FileResponse, error)
- func (api *CacophonyAPI) GetSchedule() ([]byte, error)
- func (api *CacophonyAPI) JustRegistered() bool
- func (api *CacophonyAPI) Password() string
- func (api *CacophonyAPI) ReportEvent(jsonDetails []byte, times []time.Time) error
- func (api *CacophonyAPI) UploadThermalRaw(r io.Reader) error
- type CacophonyDevice
- type Config
- type Error
- type FileDetails
- type FileInfo
- type FileResponse
- type LockSafeConfig
- type PrivateConfig
Constants ¶
const ( DeviceConfigPath = "/etc/cacophony/device.yaml" RegisteredConfigPath = "/etc/cacophony/device-priv.yaml" )
Variables ¶
var Fs = afero.NewOsFs()
Functions ¶
func IsPermanentError ¶
IsPermanentError examines the supplied error and returns true if it is permanent.
Types ¶
type CacophonyAPI ¶
type CacophonyAPI struct {
// contains filtered or unexported fields
}
func NewAPI ¶
func NewAPI() (*CacophonyAPI, error)
NewAPI parses device.yaml, and creates a new CacophonyAPI and saves the generated password and ID to device-priv.yaml
func (*CacophonyAPI) DownloadFile ¶
func (api *CacophonyAPI) DownloadFile(fileResponse *FileResponse, filePath string) error
DownloadFile specified by fileResponse and save it to filePath
func (*CacophonyAPI) GetFileDetails ¶
func (api *CacophonyAPI) GetFileDetails(fileID int) (*FileResponse, error)
GetFileDetails of the supplied fileID from the Cacophony API and return FileResponse info. This can then be parsed into DownloadFile to download the file
func (*CacophonyAPI) GetSchedule ¶
func (api *CacophonyAPI) GetSchedule() ([]byte, error)
GetSchedule will get the audio schedule
func (*CacophonyAPI) JustRegistered ¶
func (api *CacophonyAPI) JustRegistered() bool
func (*CacophonyAPI) Password ¶
func (api *CacophonyAPI) Password() string
func (*CacophonyAPI) ReportEvent ¶
func (api *CacophonyAPI) ReportEvent(jsonDetails []byte, times []time.Time) error
ReportEvent described by jsonDetails and timestamps to the Cacophony API
func (*CacophonyAPI) UploadThermalRaw ¶
func (api *CacophonyAPI) UploadThermalRaw(r io.Reader) error
UploadThermalRaw uploads the file to Cacophony API as a multipartmessage with data of type thermalRaw specified
type CacophonyDevice ¶
type CacophonyDevice struct {
// contains filtered or unexported fields
}
type Config ¶
type Config struct {
ServerURL string `yaml:"server-url" json:"serverURL"`
Group string `yaml:"group" json:"groupname"`
DeviceName string `yaml:"device-name" json:"devicename"`
}
func LoadConfig ¶
LoadConfig from deviceConfigPath with a read lock
func ParseConfig ¶
ParseConfig takes supplied bytes and returns a parsed Config struct
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is returned by API calling methods. As well as an error message, it includes whether the error is permanent or not.
type FileDetails ¶
type FileInfo ¶
type FileInfo struct {
Details FileDetails
Type string
}
type FileResponse ¶
type LockSafeConfig ¶
type LockSafeConfig struct {
// contains filtered or unexported fields
}
func NewLockSafeConfig ¶
func NewLockSafeConfig(filename string) *LockSafeConfig
func (*LockSafeConfig) GetExLock ¶
func (lockSafeConfig *LockSafeConfig) GetExLock() (bool, error)
GetExLock acquires an exclusive lock on confPassword
func (*LockSafeConfig) Read ¶
func (lockSafeConfig *LockSafeConfig) Read() (*PrivateConfig, error)
ReadPassword acquires a readlock and reads the config
func (*LockSafeConfig) Unlock ¶
func (lockSafeConfig *LockSafeConfig) Unlock()
type PrivateConfig ¶
type PrivateConfig struct {
Password string `yaml:"password"`
DeviceID int `yaml:"device-id" json:"deviceID"`
}
func LoadPrivateConfig ¶
func LoadPrivateConfig() (*PrivateConfig, error)
LoadPrivateConfig acquires a readlock and reads private config
func (*PrivateConfig) IsValid ¶
func (conf *PrivateConfig) IsValid() bool
Validate checks supplied Config contains the required data