// Package main is the entry point for the RemoteRig central hub. package main import ( "fmt" "log" "os" "time" "gopkg.in/yaml.v3" ) // Config holds the application configuration. type Config struct { DBPath string `yaml:"db_path"` APIKey string `yaml:"api_key"` Port string `yaml:"port"` ReadTimeout time.Duration `yaml:"read_timeout"` WriteTimeout time.Duration `yaml:"write_timeout"` IdleTimeout time.Duration `yaml:"idle_timeout"` MQTT struct { Broker string `yaml:"broker"` ClientID string `yaml:"client_id"` } `yaml:"mqtt"` Platform struct { Type string `yaml:"type"` MaxCameras int `yaml:"max_cameras"` } `yaml:"platform"` } func main() { log.Println("RemoteRig hub starting...") // Load config cfg, err := loadConfig("config.yaml") if err != nil { log.Fatalf("Failed to load config: %v", err) } // Print config values log.Printf("Database: %s", cfg.DBPath) log.Printf("API key set: %t", cfg.APIKey != "") log.Printf("Server port: %s", cfg.Port) log.Printf("MQTT broker: %s", cfg.MQTT.Broker) log.Printf("Platform: %s (max %d cameras)", cfg.Platform.Type, cfg.Platform.MaxCameras) log.Println("RemoteRig hub ready") } func loadConfig(path string) (*Config, error) { data, err := os.ReadFile(path) if err != nil { return nil, fmt.Errorf("read config file: %w", err) } var cfg Config if err := yaml.Unmarshal(data, &cfg); err != nil { return nil, fmt.Errorf("parse config: %w", err) } // Defaults if cfg.Port == "" { cfg.Port = "8080" } if cfg.DBPath == "" { cfg.DBPath = "remoterig.db" } if cfg.MQTT.Broker == "" { cfg.MQTT.Broker = "localhost:1883" } if cfg.MQTT.ClientID == "" { cfg.MQTT.ClientID = "remoterig-hub" } return &cfg, nil }