2018-11-07 19:07:15 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
2020-05-03 12:04:08 +00:00
|
|
|
"strings"
|
2018-11-07 19:07:15 +00:00
|
|
|
|
2020-05-03 12:04:08 +00:00
|
|
|
"github.com/volker-raschek/flucky/pkg/config"
|
|
|
|
"github.com/volker-raschek/flucky/pkg/daemon"
|
|
|
|
"github.com/volker-raschek/go-logger/pkg/logger"
|
2018-11-07 19:07:15 +00:00
|
|
|
)
|
|
|
|
|
2019-09-01 10:27:06 +00:00
|
|
|
var (
|
|
|
|
version string
|
|
|
|
)
|
2018-11-07 19:07:15 +00:00
|
|
|
|
|
|
|
func main() {
|
2020-05-03 12:04:08 +00:00
|
|
|
// sversion, err := semver.NewVersion(version)
|
|
|
|
// if err != nil {
|
|
|
|
// log.Printf("The sematic versioning is invalid: %v", version)
|
|
|
|
// os.Exit(1)
|
|
|
|
// }
|
|
|
|
|
|
|
|
cnfString := `{
|
|
|
|
"device": {
|
|
|
|
"id": "d0c600bc-6eab-4b9b-b93f-dc0477b4658f",
|
|
|
|
"name": "poseidon",
|
|
|
|
"location": null,
|
|
|
|
"last_contact": null,
|
|
|
|
"creation_date": "2020-04-23T22:09:20.932+02:00"
|
|
|
|
},
|
|
|
|
"storage_endpoint": "postgres://postgres:postgres@markus-pc.trier.cryptic.systems:5432/postgres?sslmode=disable",
|
|
|
|
"sensors": [
|
|
|
|
{
|
|
|
|
"id": "1c180121-9e98-4053-a6f6-4ed7fad3935b",
|
|
|
|
"name": "bme280",
|
|
|
|
"location": "",
|
|
|
|
"wire_id": null,
|
|
|
|
"i2c_bus": 1,
|
|
|
|
"i2c_address": 118,
|
|
|
|
"gpio_number": null,
|
|
|
|
"model": "BME280",
|
|
|
|
"enabled": true,
|
|
|
|
"last_contact": null,
|
|
|
|
"tick_duration": "5s",
|
|
|
|
"device_id": "d0c600bc-6eab-4b9b-b93f-dc0477b4658f",
|
|
|
|
"creation_date": "2020-04-23T22:09:20.934+02:00"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": "5cebd127-8976-4b66-b1bb-e551f26c4af4",
|
|
|
|
"name": "ds18b20_2",
|
|
|
|
"location": "",
|
|
|
|
"wire_id": "28-02131dbffeaa",
|
|
|
|
"i2c_bus": null,
|
|
|
|
"i2c_address": null,
|
|
|
|
"gpio_number": null,
|
|
|
|
"model": "DS18B20",
|
|
|
|
"enabled": true,
|
|
|
|
"last_contact": null,
|
|
|
|
"tick_duration": "1m",
|
|
|
|
"device_id": "d0c600bc-6eab-4b9b-b93f-dc0477b4658f",
|
|
|
|
"creation_date": "2020-04-23T22:09:27.901+02:00"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": "579628cc-b667-4b56-b305-73256c0c9dce",
|
|
|
|
"name": "ds18b20",
|
|
|
|
"location": "",
|
|
|
|
"wire_id": "28-01131646f11d",
|
|
|
|
"i2c_bus": null,
|
|
|
|
"i2c_address": null,
|
|
|
|
"gpio_number": null,
|
|
|
|
"model": "DS18B20",
|
|
|
|
"enabled": true,
|
|
|
|
"last_contact": null,
|
|
|
|
"tick_duration": "1m",
|
|
|
|
"device_id": "d0c600bc-6eab-4b9b-b93f-dc0477b4658f",
|
|
|
|
"creation_date": "2020-04-23T22:09:56.468+02:00"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}`
|
|
|
|
|
|
|
|
cnf, err := config.Decode(strings.NewReader(cnfString))
|
2019-09-01 10:27:06 +00:00
|
|
|
if err != nil {
|
2020-05-03 12:04:08 +00:00
|
|
|
log.Fatal(err)
|
2019-09-01 10:27:06 +00:00
|
|
|
}
|
|
|
|
|
2020-05-03 12:04:08 +00:00
|
|
|
flogger := logger.NewDefaultLogger(logger.LogLevelDebug)
|
|
|
|
|
|
|
|
err = daemon.Start(cnf, flogger)
|
2020-01-13 21:26:41 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2018-11-07 19:07:15 +00:00
|
|
|
}
|