mirror of
https://github.com/cmur2/miflorad.git
synced 2025-06-26 12:30:23 +02:00
miflorad: add version
This commit is contained in:
@ -19,6 +19,9 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// program version, will be populated on build
|
||||
var version string
|
||||
|
||||
var (
|
||||
scanTimeout = flag.Duration("scantimeout", 10*time.Second, "timeout after that a scan per peripheral will be aborted")
|
||||
interval = flag.Duration("interval", 25*time.Second, "metrics collection interval")
|
||||
@ -49,6 +52,14 @@ func checkTooShortInterval() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getVersion() string {
|
||||
if version == "" {
|
||||
return "dev"
|
||||
} else {
|
||||
return version
|
||||
}
|
||||
}
|
||||
|
||||
func readData(peripheral *peripheral, client ble.Client) error {
|
||||
// re-request meta data (for battery level) if last check more than 24 hours ago
|
||||
// Source: https://github.com/open-homeautomation/miflora/blob/ffd95c3e616df8843cc8bff99c9b60765b124092/miflora/miflora_poller.py#L92
|
||||
@ -181,6 +192,8 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stderr, "miflorad version %s\n", getVersion())
|
||||
|
||||
device, err := dev.NewDevice("default")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to open device, err: %s\n", err)
|
||||
|
Reference in New Issue
Block a user