Browse Source

Add legacy support for older config files (using gpsd_addr)

blockmurder 1 month ago
parent
commit
e166b85665
2 changed files with 9 additions and 0 deletions
  1. 4 0
      cfg/config.go
  2. 5 0
      config.go

+ 4 - 0
cfg/config.go

@@ -64,6 +64,9 @@ type Config struct {
 	// See GPSdConfig.
 	GPSd GPSdConfig `json:gpsd`
 
+	// Legacy support for old config files
+	GPSdAddrLegacy string `json:"gpsd_addr"`
+
 	// Command schedule (cron-like syntax).
 	//
 	// Examples:
@@ -248,6 +251,7 @@ var DefaultConfig Config = Config{
 		UseServerTime: false,
 		Addr:          "localhost:2947", // Default listen address for GPSd
 	},
+	GPSdAddrLegacy: "",
 	Schedule:          map[string]string{},
 	HamlibRigs:        map[string]HamlibConfig{},
 }

+ 5 - 0
config.go

@@ -41,6 +41,11 @@ func LoadConfig(path string, fallback cfg.Config) (config cfg.Config, err error)
 		config.Pactor = cfg.DefaultConfig.Pactor
 	}
 
+	//TODO: Remove after some release cycles (2019-09-29)
+	if config.GPSdAddrLegacy != "" {
+		config.GPSd.Addr = config.GPSdAddrLegacy
+	}
+
 	return config, nil
 }