model

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const THING_CLASS_HUMIDITY = "humidity"
View Source
const THING_CLASS_PRESSURE = "pressure"
View Source
const THING_CLASS_TEMPERATURE = "temperature"
View Source
const THING_TYPE_DEVICE = "device"
View Source
const THING_TYPE_SENSOR = "sensor"
View Source
const THING_TYPE_SWITCH = "switch"

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	Email string `json:"email"`
	jwt.StandardClaims
}

Struct that will be encoded to a JWT. We add jwt.StandardClaims as an embedded type, to provide fields like expiry time

type Credentials

type Credentials struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

Used to read the email and password from the token request body (signin use case)

type Org

type Org struct {
	Id               primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	Name             string             `json:"name"`
	Description      string             `json:"description"`
	Created          int32              `json:"created"`
	InfluxDb         string             `json:"influxdb"`
	InfluxDbUsername string             `json:"influxdb_username" bson:"influxdb_username"`
	InfluxDbPassword string             `json:"influxdb_password" bson:"influxdb_password"`
	MqttUsername     string             `json:"mqtt_username" bson:"mqtt_username"`
	MqttPassword     string             `json:"mqtt_password" bson:"mqtt_password"`
	MysqlDb          string             `json:"mysqldb"`
	MysqlDbUsername  string             `json:"mysqldb_username" bson:"mysqldb_username"`
	MysqlDbPassword  string             `json:"mysqldb_password" bson:"mysqldb_password"`
}

Represents org as stored in database

type OrgUser

type OrgUser struct {
	OrgId   primitive.ObjectID `json:"org_id" bson:"org_id,omitempty"`
	UserId  primitive.ObjectID `json:"user_id" bson:"user_id,omitempty"`
	Created int32              `json:"created"`
}

Represents assignment of user to org

type PiotDevicePacket

type PiotDevicePacket struct {
	Device        string              `json:"device"`
	DeviceShort   string              `json:"d"`
	Ip            *string             `json:"ip,omitempty"`
	WifiSSID      *string             `json:"wifi-ssid,omitempty"`
	WifiStrength  *float32            `json:"wifi-strength,omitempty"`
	Readings      []PiotSensorReading `json:"readings"`
	ReadingsShort []PiotSensorReading `json:"r"`
}

type PiotSensorReading

type PiotSensorReading struct {
	Address      string   `json:"address"`
	AddressShort string   `json:"a"`
	Temperature  *float32 `json:"t,omitempty"`
	Humidity     *float32 `json:"h,omitempty"`
	Pressure     *float32 `json:"p,omitempty"`
}

type ResponseResult

type ResponseResult struct {
	Error  string `json:"error"`
	Result string `json:"result"`
}

type SensorData

type SensorData struct {

	// Last value
	Value string `json:"value" bson:"value"`

	// The MQTT topic where sensor values are published
	MeasurementTopic string `json:"measurement_topic" bson:"measurement_topic"`

	// The template for parsing value from MQTT payload, empty value means use
	// payload as it is. Else the value is extraced according to
	// https://github.com/tidwall/gjson
	MeasurementValue string `json:"measurement_value" bson:"measurement_value"`

	// Time when last measurement was received
	MeasurementLast int32 `json:"measurement_last" bson:"measurement_last"`

	// Type of sensor measurement
	Class string `json:"class" bson:"class"`

	// Defines the number of seconds since last measurement for which the
	// measurement is valid
	Validity int32 `json:"validity" bson:"validity"`

	// The unit of measurement that the sensor is expressed in.
	Unit string `json:"unit bson"unit""`
}

Represents measurements for things that are sensors

type SwitchData

type SwitchData struct {
	State bool `json:"state" bson:"state"`

	// Topic to send commands
	CommandTopic string `json:"command_topic" bson:"command_topic"`

	// Send command to switch on
	CommandOn string `json:"command_on" bson:"command_on"`

	// Send command to switch off
	CommandOff string `json:"command_off" bson:"command_off"`

	// Topic to receive switch state (ON or OFF)
	StateTopic string `json:"state_topic" bson:"state_topic"`

	// Value that represents ON state
	StateOn string `json:"state_on" bson:"state_on"`

	// Value that represents OFF state
	StateOff string `json:"state_off" bson:"state_off"`
}

Represents switch (e.g. high voltage power switch)

type Thing

type Thing struct {

	// unique id of the thing
	Id primitive.ObjectID `json:"id" bson:"_id,omitempty"`

	// PIOT identification of the thing, this
	// arrtibute is used for processing messages coming
	// from PIOT chips via adapter
	PiotId string `json:"piot_id" bson:"piot_id"`

	// name of the thing
	Name string `json:"name" bson:"name"`

	// optional description
	Description string `json:"description" bson:"description"`

	// optional alias of the thing - used e.g. in graphs
	Alias string `json:"alias" bson:"alias"`

	// basic classification of things - device vs sensor
	Type string `json:"type" bson:"type"`

	// is thing enabled?
	Enabled bool `json:"enabled" bson:"enabled"`

	// date of thing creation
	Created int32 `json:"created" bson:"created"`

	// id of the organization thing belongs to
	OrgId primitive.ObjectID `json:"org_id" bson:"org_id"`

	// ?
	Org *Org `json:"org" bson:"org"`

	// id of the parent thing (e.g. chip - sensor relation)
	ParentId primitive.ObjectID `json:"parent_id" bson:"parent_id"`

	// is thing available
	Available bool `json:"available" bson:"available"`

	// time the thing was seen last time
	LastSeen int32 `json:"last_seen" bson:"last_seen"`

	// maximal interval (in seconds) for which device can be unseen
	// (see LastSeen attribute). Default value is 0, which disables
	// this feature
	LastSeenInterval int32 `json:"last_seen_interval" bson:"last_seen_interval"`

	// The MQTT topic subscribed to receive thing availability
	AvailabilityTopic string `json:"availability_topic" bson:"availability_topic"`
	AvailabilityYes   string `json:"availability_yes" bson:"availability_yes"`
	AvailabilityNo    string `json:"availability_no" bson:"availability_no"`

	// the MQTT topic for receiving telemetry information
	TelemetryTopic string `json:"telemetry_topic" bson:"telemetry_topic"`

	// time the thing was seen last time
	Telemetry string `json:"telemetry" bson:"telemetry"`

	// Enable or Disable pushing values to organization assigned Influx database
	StoreInfluxDb bool `json:"store_influxdb" bson:"store_influxdb"`

	// Enable or Disable storing values to mysql db assigned to organization
	StoreMysqlDb bool `json:"store_mysqldb" bson:"store_mysqldb"`

	// minimal interval (in seconds) for storing values to mysql db,
	// more values to be stored in same inteval will be ignored, only
	// first one will be stored
	StoreMysqlDbInterval int32 `json:"store_mysqldb_interval" bson:"store_mysqldb_interval"`

	// The latitude in degrees. It must be in the range [-90.0, +90.0].
	LocationLatitude float64 `json:"loc_lat" bson:"loc_lat"`

	// The longitude in degrees. It must be in the range [-180.0, +180.0].
	LocationLongitude float64 `json:"loc_lng" bson:"loc_lng"`

	// The date when location was taken (unix timestamp)
	LocationSatelites int32 `json:"loc_sat" bson:"loc_sat"`

	// The date when location was taken (unix timestamp)
	LocationTs int32 `json:"loc_ts" bson:"loc_ts"`

	// The MQTT topic subscribed to receive thing location
	LocationMqttTopic    string `json:"loc_mqtt_topic" bson:"loc_mqtt_topic"`
	LocationMqttLatValue string `json:"loc_mqtt_lat_value" bson:"loc_mqtt_lat_value"`
	LocationMqttLngValue string `json:"loc_mqtt_lng_value" bson:"loc_mqtt_lng_value"`
	LocationMqttTsValue  string `json:"loc_mqtt_ts_value" bson:"loc_mqtt_ts_value"`
	LocationMqttSatValue string `json:"loc_mqtt_sat_value" bson:"loc_mqtt_sat_value"`

	// Persistency of location changes
	LocationTracking bool `json:"loc_tracking" bson:"loc_tracking"`

	// The unit of measurement that the sensor is expressed in.
	Sensor SensorData `json:"sensor" bson:"sensor"`

	// The unit of measurement that the sensor is expressed in.
	Switch SwitchData `json:"switch" bson:"switch"`
}

Represents any device or app

type Token

type Token struct {
	Token string `json:"token"`
}

Used to serialize token as a response to authentication request

type User

type User struct {
	Id       primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	Email    string             `json:"email"`
	Password string             `json:"password"`
	Created  int32              `json:"created"`
	Orgs     []Org              `json:"orgs"`
}

Represents user as stored in database

type UserProfile

type UserProfile struct {
	Email string `json:"email"`
}

Jump to

Keyboard shortcuts

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