foscam

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

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 6 Imported by: 0

README

go-foscam

tests codecov

Go Library for Foscam IP Cameras

Supported Cameras

  • FI9800P
  • FI8919W

Supported Functionalities

  • ChangeMotionStatus
  • GetMotionStatus (WIP)

Run the example

$ cd go-foscam

$ cat << EOF > .envrc
export FOSCAM_URL=http(s)://<host>:<port>
export FOSCAM_USER=<user>
export FOSCAM_PASSWORD=<password>
EOF

$ make run/example

To Do

  • Add more functionalities
  • Support more cameras

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCameraInvalidModel = errors.New("invalid model")

ErrCameraInvalidModel is the error thrown for an invalid camera model.

Functions

This section is empty.

Types

type BadResponseError

type BadResponseError struct {
	Want any
	Got  any
}

BadResponseError represents a bad response from the camera.

func (*BadResponseError) Error

func (b *BadResponseError) Error() string

type BadStatusError

type BadStatusError struct {
	URL      string
	Status   int
	Expected int
}

BadStatusError represents an error in the status code returned by the camera.

func (*BadStatusError) Error

func (b *BadStatusError) Error() string

type Camera

type Camera interface {
	ChangeMotionStatus(enable bool) error
}

Camera is the common interface implemented by all camera models.

func NewCamera

func NewCamera(m Model, cfg Config, client ...HTTPClient) (cam Camera, err error)

NewCamera is a camera interface factory. Creates a camera by providing its model and configuration. HTTPCLient is the client used to make requests to the cameras. Default is `http.Client`.

type CameraError

type CameraError struct {
	Msg string
}

CameraError represents a camera generic error.

func (*CameraError) Error

func (c *CameraError) Error() string

type Config

type Config struct {
	URL      string `url:"-"`
	User     string `url:"usr"`
	Password string `url:"pwd"`
}

Config is the camera configuration.

type HTTPClient

type HTTPClient interface {
	Get(url string) (*http.Response, error)
}

HTTPClient interface.

type Model

type Model uint8

Model is the camera model

const (
	FI9800P Model = iota
	FI8919W
)

Allowed models

func (Model) String

func (m Model) String() string

String returns the string representation of the camera model.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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