device

package
v0.0.0-...-ebd6d4f Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDeviceActivationSecretIncorrect = errors.New("device activation_secret is incorrect")
)

Functions

This section is empty.

Types

type Device

type Device struct {
	ID                   uint                  `json:"id"`
	Name                 string                `json:"name"`
	DeviceType           devicetype.DeviceType `json:"device_type"`
	BuildingID           uint                  `json:"building_id"`
	ActivationSecret     string                `json:"activation_secret,omitempty"` // This can be removed if a device uses JWT's too.
	ActivationSecretHash string                `json:"-"`                           // This can be removed if a device uses JWT's too.
	ActivatedAt          *time.Time            `json:"activated_at"`
	AuthorizationToken   string                `json:"authorization_token,omitempty"`
	Uploads              []upload.Upload       `json:"uploads,omitempty"`
	LatestUpload         *time.Time            `json:"latest_upload"`
}

A Device is collects measurements in a subject's building.

func MakeDevice

func MakeDevice(name string, deviceType devicetype.DeviceType, buildingID uint, activationSecret string) Device

Create a new Device.

func (*Device) Activate

func (d *Device) Activate(activationSecret string) error

Activate a device.

func (*Device) AddUpload

func (d *Device) AddUpload(upload upload.Upload)

Add an upload to a device.

type DeviceRepository

type DeviceRepository interface {
	Find(device Device) (Device, error)
	FindCloudFeedAuthCreationTimeFromDeviceID(deviceID uint) (*time.Time, error)
	GetProperties(device Device) ([]property.Property, error)
	GetMeasurements(device Device, filters map[string]string) ([]measurement.Measurement, error)
	GetAll() ([]Device, error)
	Create(Device) (Device, error)
	Update(Device) (Device, error)
	Delete(Device) error
}

A DeviceRepository can load, store and delete devices.

Jump to

Keyboard shortcuts

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