Documentation
¶
Overview ¶
Package dms3libs audio provides audio services for dms3 device components
Package dms3libs configuration structures and variables ¶
Package dms3libs provides motion detector application services for dms3 device components ¶
Package dms3libs file provides file services for dms3 device components ¶
Package dms3libs log provides logging services for dms3 device components ¶
Package dms3libs network provides networking services for dms3 device components ¶
Package dms3libs OS provides operating system information services for dms3 device components ¶
Package dms3libs process provides process-related services for dms3 device components ¶
Package dms3libs util provides utility services for dms3 device components
Index ¶
- Constants
- Variables
- func CheckErr(err error)
- func CheckFileLocation(configPath string, fileDir string, fileLocation *string, filename string)
- func CopyDir(srcDir string, destDir string)
- func CopyFile(src string, dest string)
- func CountFilesInDir(srcDir string) int
- func CreateLogger(logger *StructLogging)
- func DeviceInstaller(binFiles, configDirs []string)
- func FindMacs(macsToFind []string) bool
- func Format24H(time string) string
- func FormatDateTime(value time.Time) string
- func GetDeviceDetails(element DeviceDetails) string
- func GetDeviceHostname() string
- func GetDeviceOSName() string
- func GetFunctionName() string
- func GetImageDimensions(imagePath string) (int, int)
- func GetPackageDir() string
- func GetProjectVersion() string
- func InitComponent(configPath, componentName, componentTOML string, config interface{}, ...)
- func IsFile(filename string) bool
- func LoadComponentConfig(structConfig interface{}, configFile string)
- func LoadLibConfig(configFile string)
- func LogDebug(msg string)
- func LogFatal(msg string)
- func LogInfo(msg string)
- func MkDir(newPath string)
- func ModVal(number int, val int) int
- func PingHosts(ipBase string, ipRange []int) error
- func PlayAudio(audioFile string)
- func RmDir(dir string)
- func RunCommand(cmd string) (res []byte, err error)
- func SecondsSince(value time.Time) uint32
- func SetLogFileLocation(config *StructLogging)
- func StartStopApplication(state MotionDetectorState, application string) bool
- func StripRet(value []byte) []byte
- func To24H(value time.Time) string
- func Uptime(startTime time.Time) string
- func WalkDir(dirname string) map[string]int
- type DeviceDetails
- type MotionDetectorState
- type StructLogging
Constants ¶
const ( DMS3Mail = "dms3mail" DMS3Client = "dms3client" DMS3Server = "dms3server" DMS3Libs = "dms3libs" DMS3Release = "dms3_release" DMS3Dashboard = "dms3dashboard" DMS3Config = "config" DMS3clientTOML = "dms3client.toml" DMS3serverTOML = "dms3server.toml" DMS3libsTOML = "dms3libs.toml" DMS3buildTOML = "dms3build.toml" DMS3dashboardTOML = "dms3dashboard.toml" DMS3mailTOML = "dms3mail.toml" )
Configuration file names
Variables ¶
global logging objects
var ( ErrInvalidConfiguration = errors.New("invalid configuration") ErrNoCommand = errors.New("empty command provided") )
var LibConfig *structConfig
LibConfig contains dms3Libs configuration settings read from TOML file
var MotionDetector = motionDetectorStruct{ // contains filtered or unexported fields }
MotionDetector represents the motion detector application running on the clients (e.g., motion)
Functions ¶
func CheckErr ¶
func CheckErr(err error)
CheckErr does simple error management (no logging dependencies)
func CheckFileLocation ¶
CheckFileLocation checks/sets the location of file and pathname passed in as defined in various TOML config files, returning a fully qualified path
func CountFilesInDir ¶
CountFilesInDir recursively counts the files in the dir passed in
func CreateLogger ¶
func CreateLogger(logger *StructLogging)
CreateLogger creates an application log file (1) or redirects to STDOUT (2) based on logDevice
func DeviceInstaller ¶
func DeviceInstaller(binFiles, configDirs []string)
Setup performs common installer tasks and takes a list of binary and config files to copy
func FindMacs ¶
FindMacs uses 'ip neigh' to find mac address(es) passed in, returning true if any mac passed in is found (e.g., mac1|mac2|mac3)
func FormatDateTime ¶
FormatDateTime formats time to "date at time"
func GetDeviceDetails ¶
func GetDeviceDetails(element DeviceDetails) string
GetDeviceDetails returns device details of the local machine
func GetDeviceHostname ¶
func GetDeviceHostname() string
GetDeviceHostname returns the name of the local machine
func GetDeviceOSName ¶
func GetDeviceOSName() string
GetDeviceOSName returns the OS release name (NAME) and version ID (VERSION_ID) from a parse of the /etc/os-release file found in most Linux-based distributions
func GetFunctionName ¶
func GetFunctionName() string
GetFunctionName uses reflection (runtime) to return current function name
func GetImageDimensions ¶
GetImageDimensions returns the (width, height) of an image passed in
func GetPackageDir ¶
func GetPackageDir() string
GetPackageDir returns the absolute path of the calling package
func GetProjectVersion ¶
func GetProjectVersion() string
GetProjectVersion returns the current project version string to the caller
func InitComponent ¶
func InitComponent(configPath, componentName, componentTOML string, config interface{}, logging *StructLogging)
InitComponent initializes the common configuration and logging for a dms3 component.
func LoadComponentConfig ¶
func LoadComponentConfig(structConfig interface{}, configFile string)
LoadComponentConfig loads a TOML configuration file of client/server configs into parameter values
func LoadLibConfig ¶
func LoadLibConfig(configFile string)
LoadLibConfig loads a TOML configuration file of system commands into parameter values
func LogDebug ¶
func LogDebug(msg string)
LogDebug generates a debug log message based on loggingLevel
func LogFatal ¶
func LogFatal(msg string)
LogFatal generates a fatal log message based on loggingLevel
func LogInfo ¶
func LogInfo(msg string)
LogInfo generates an informational log message based on loggingLevel
func PingHosts ¶
PingHosts uses 'ping' to ping a range of IP addresses, returning an error if the command fails
func PlayAudio ¶
func PlayAudio(audioFile string)
PlayAudio uses the shell aplay command (system default) to play audioFile
func RunCommand ¶
RunCommand is a simple wrapper for the exec.Command() call
NOTE: this call is blocking (non-threaded)
func SecondsSince ¶
SecondsSince returns seconds passed since value passed
func SetLogFileLocation ¶
func SetLogFileLocation(config *StructLogging)
SetLogFileLocation sets the location of the log file based on TOML configuration
func StartStopApplication ¶
func StartStopApplication(state MotionDetectorState, application string) bool
StartStopApplication enables/disables the application passed in based on state
Types ¶
type DeviceDetails ¶
type DeviceDetails int
DeviceDetails defines the set of available device details available in GetDeviceDetails
const ( Sysname DeviceDetails = iota Machine Release )
types of DMS3 devices
type MotionDetectorState ¶
type MotionDetectorState int
MotionDetectorState defines the motion detector application state type
const ( Stop MotionDetectorState = iota Start )
states of the motion detector application