iotedge

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

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

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

README

go-iotedge

Simple IoT-Server for receiving and storing timeseries

Example for a client can be found here

Timeseries

Check out this for how to set-up a postgres-database. Example query for Grafana:

SELECT
  "time",
  value as "Temperature"
FROM
  measurements where 
  $__timeFilter("time") AND
  Tag ilike 'Wemos2Temperature'

Example using Grafana

alt text

Documentation

Index

Constants

View Source
const (
	HTTPPort           int    = 3004
	URIInitDevice      string = "/init-device"
	URIUpdateSensor    string = "/update-sensor"
	URIDeviceConfigure string = "/device/configure"
	URISensorConfigure string = "/sensor/configure"
	URIUploadData      string = "/upload-data"
	URISaveTimeseries  string = "/timeseries/save"
)

Variables

This section is empty.

Functions

func SetHeaders

func SetHeaders(w http.ResponseWriter, origin string)

func StartMQTTBroker

func StartMQTTBroker(port int, dbConfig timeseries.DBConfig)

Types

type ConfigureDeviceReq

type ConfigureDeviceReq struct {
	Name     string
	Interval float32
	Buffer   int
}

type ConfigureSensorReq

type ConfigureSensorReq struct {
	Name       string
	SensorName string
	Offset     float32
}

type Device

type Device struct {
	ID          int
	Name        string
	Interval    float32
	Buffer      int
	Description string
}

type DeviceDesc

type DeviceDesc struct {
	Name        string
	Sensors     []string
	Description string
}

type Input

type Input struct {
	Method     string      `json:"Method"`
	MethodBody interface{} `json:"MethodBody"`
}

type IoTConfig

type IoTConfig struct {
	Port               int
	MQTTPort           int
	DbConfig           timeseries.DBConfig
	TimeseriesDBConfig timeseries.DBConfig
}

func GetConfig

func GetConfig() IoTConfig

type IoTEdge

type IoTEdge struct {
	Port               int
	DeviceDBConfig     timeseries.DBConfig
	TimeseriesDBConfig timeseries.DBConfig
	DB                 *sql.DB

	Timeseries timeseries.DbHandler
	// contains filtered or unexported fields
}

func New

func New(iotConfig IoTConfig) IoTEdge

func (*IoTEdge) ConfSensor

func (s *IoTEdge) ConfSensor(w http.ResponseWriter, r *http.Request)

func (*IoTEdge) Configure

func (e *IoTEdge) Configure(dev Device) error

func (*IoTEdge) ConfigureDevice

func (s *IoTEdge) ConfigureDevice(w http.ResponseWriter, r *http.Request)

func (*IoTEdge) ConfigureSensor

func (e *IoTEdge) ConfigureSensor(sensor Sensor) error

func (*IoTEdge) GetDevice

func (e *IoTEdge) GetDevice(name string) (Device, error)

func (*IoTEdge) GetOrCreateDevice

func (e *IoTEdge) GetOrCreateDevice(descr DeviceDesc) (Device, error)

func (*IoTEdge) GetSensors

func (e *IoTEdge) GetSensors(deviceID int) ([]Sensor, error)

func (*IoTEdge) Init

func (e *IoTEdge) Init(deviceDesc DeviceDesc) (Device, error)

func (*IoTEdge) InitDevice

func (s *IoTEdge) InitDevice(w http.ResponseWriter, r *http.Request)

func (*IoTEdge) InitializeDB

func (e *IoTEdge) InitializeDB() error

func (*IoTEdge) SaveTimeseries

func (s *IoTEdge) SaveTimeseries(w http.ResponseWriter, req *http.Request)

func (*IoTEdge) StartSensorServer

func (s *IoTEdge) StartSensorServer() error

func (*IoTEdge) UpdateSensorHandler

func (s *IoTEdge) UpdateSensorHandler(w http.ResponseWriter, r *http.Request)

func (*IoTEdge) UploadDataHandler

func (s *IoTEdge) UploadDataHandler(w http.ResponseWriter, r *http.Request)

type MQTTEdge

type MQTTEdge struct {
	MQTTserver *mqttserver.Server
	// contains filtered or unexported fields
}

type Output

type Output struct {
	Status string      `json:"Status"`
	Answer interface{} `json:"Answer"`
}

type Sensor

type Sensor struct {
	ID       int
	DeviceID int
	Name     string
	Offset   float32
}

type TimeSeriesValue

type TimeSeriesValue struct {
	Name  string
	Value float32
}

type TimeseriesHandler

type TimeseriesHandler struct {
	DataMessageHandler *mqtt.MessageHandler
	// contains filtered or unexported fields
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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