feat: SpaceAPI v15 support
Delete types/v14.go, replace with v15.go.
Rename internal types to not include message version.
I don't currently see the need to support multiple message
versions that have incompatible layouts.
v15 is backwards compatible with v14, so the config example now
specifies both.
Rename the "response" field in the config file to "static" as
dynamic/static makes more sense from the user's perspective.
(Internally it's still SpaceapidConfig.{Dynamic,Response}
to align with type names and usage.)
This commit is contained in:
parent
b5a286a237
commit
fd3cae1866
10 changed files with 293 additions and 196 deletions
|
|
@ -16,11 +16,11 @@ const (
|
|||
|
||||
// MergeOldState merges a given SpaceAPIResponse with the state saved at the time of last program exit and then deletes
|
||||
// the file containing the old state.
|
||||
func MergeOldState(response *types.SpaceAPIResponseV14) {
|
||||
func MergeOldState(response *types.SpaceAPIResponse) {
|
||||
var (
|
||||
err error
|
||||
oldState []byte
|
||||
persistedState types.PersistentStateV14
|
||||
persistedState types.PersistentSpaceState
|
||||
)
|
||||
|
||||
log.Println("Merging old state from", persistentStatePath, "...")
|
||||
|
|
@ -48,7 +48,7 @@ func MergeOldState(response *types.SpaceAPIResponseV14) {
|
|||
}
|
||||
|
||||
// Merge state
|
||||
response.State = persistedState.State
|
||||
response.State.FromPersistentSpaceState(persistedState)
|
||||
|
||||
// Merge sensors
|
||||
for key, environmentSensors := range persistedState.Sensors {
|
||||
|
|
@ -72,7 +72,7 @@ removeOld:
|
|||
}
|
||||
}
|
||||
|
||||
func SaveCurrentState(response types.SpaceAPIResponseV14) {
|
||||
func SaveCurrentState(response types.SpaceAPIResponse) {
|
||||
// Create state directory if not present
|
||||
err := os.MkdirAll(persistentStateDir, 0750)
|
||||
if err != nil {
|
||||
|
|
@ -87,7 +87,7 @@ func SaveCurrentState(response types.SpaceAPIResponseV14) {
|
|||
defer file.Close()
|
||||
|
||||
// Create persistent state
|
||||
persistentStateV14 := types.PersistentStateV14{
|
||||
persistentStateV14 := types.PersistentSpaceState{
|
||||
State: struct {
|
||||
Open bool `json:"open"`
|
||||
LastChange int64 `json:"lastchange"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue