summaryrefslogtreecommitdiff
path: root/src/main.go
diff options
context:
space:
mode:
authorxengineering <mail2xengineering@protonmail.com>2021-06-13 12:54:28 +0200
committerxengineering <mail2xengineering@protonmail.com>2021-06-13 13:01:26 +0200
commit9d5a2f9870e52bfc0fe6db8c27981f29d91dcb55 (patch)
treee3856fbbd1bc7c429472d950e7f1d46e5cf2fae3 /src/main.go
parentc015034ba2e0bfd8464ae444792552a4b354eb0d (diff)
downloadbirdscan-9d5a2f9870e52bfc0fe6db8c27981f29d91dcb55.tar
birdscan-9d5a2f9870e52bfc0fe6db8c27981f29d91dcb55.tar.zst
birdscan-9d5a2f9870e52bfc0fe6db8c27981f29d91dcb55.zip
Implement working State Machine
Diffstat (limited to 'src/main.go')
-rw-r--r--src/main.go25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/main.go b/src/main.go
index dfcf706..af82e8f 100644
--- a/src/main.go
+++ b/src/main.go
@@ -5,25 +5,40 @@ package main
import (
"flag"
"log"
- "time"
"os"
"io/ioutil"
"encoding/json"
)
+var (
+ camera Machine
+)
+
type config struct {
WebConfig webConfig `json:"webserver"`
}
func main() {
+
+ // read command line arguments
configPath := readFlags()
+
+ // set up log and print startup message
log.SetFlags(0) // disable timestamp because systemd takes care of that
log.Println("Starting birdscan")
+
+ // read config file
cfg := readConfig(configPath)
- go runServer(&cfg.WebConfig)
- for {
- time.Sleep(1 * time.Second)
- }
+
+ // setup camera state machine
+ camera = newCamStateMachine()
+
+ // start goroutines
+ server := NewWebServer(&cfg.WebConfig)
+ go server.run() // http server
+
+ // run camera state machine
+ camera.run()
}
func readFlags() string {