fix: sync and fetch temperatures

changes:
- add sync command to synchronize device sensor information with remote
  servers
- fix fetch functions to get temperatures
This commit is contained in:
2018-11-29 16:06:39 +01:00
parent 99ff511117
commit f8e829d3d2
13 changed files with 291 additions and 122 deletions

View File

@ -7,18 +7,13 @@ import (
"time"
)
// TypeObject ...
type TypeObject interface {
EncodeToJSON(w io.Writer) error
DecodeFromJSON(r io.Reader) error
}
// Device ...
type Device struct {
DeviceID string `json:"device_id"`
DeviceName *string `json:"device_name"`
DeviceLocation *string `json:"device_location"`
CreationDate time.Time `json:"creation_date"`
DeviceID string `json:"device_id"`
DeviceName *string `json:"device_name"`
DeviceLocation *string `json:"device_location"`
DeviceLastContact time.Time `json:"device_last_contact"`
CreationDate time.Time `json:"creation_date"`
}
// EncodeToJSON needs a writer to write the struct into json string
@ -72,14 +67,16 @@ func (h *Humidity) DecodeFromJSON(r io.Reader) error {
// Sensor ...
type Sensor struct {
SensorID string `json:"sensor_id"`
SensorName *string `json:"sensor_name"`
SensorLocation *string `json:"sensor_location"`
WireID *string `json:"wire_id"`
GPIONumber *string `json:"gpio_number"`
SensorType *string `json:"sensor_type"`
DeviceID string `json:"device_id"`
CreationDate time.Time `json:"creation_date"`
SensorID string `json:"sensor_id"`
SensorName *string `json:"sensor_name"`
SensorLocation *string `json:"sensor_location"`
WireID *string `json:"wire_id"`
GPIONumber *string `json:"gpio_number"`
SensorType *string `json:"sensor_type"`
SensorEnabled *bool `json:"sensor_enabled"`
SensorLastContact time.Time `json:"sensor_last_contact"`
DeviceID string `json:"device_id"`
CreationDate time.Time `json:"creation_date"`
}
// EncodeToJSON needs a writer to write the struct into json string