diff --git a/api/aliases.go b/api/aliases.go index 0b9900b..c990234 100644 --- a/api/aliases.go +++ b/api/aliases.go @@ -48,24 +48,19 @@ func (api *ApiAliases) cleaner() { count -= 1 } } - if nodeinfo.Settings != nil { - if nodeinfo.Settings.Freq24 != nil { - count += 2 - if alias.Freq24.TxPower == nodeinfo.Settings.Freq24.TxPower { - count -= 1 - } - if alias.Freq24.Channel == nodeinfo.Settings.Freq24.Channel { - count -= 1 - } + if nodeinfo.Wireless != nil { + count += 4 + if alias.Wireless.Channel24 == nodeinfo.Wireless.Channel24 { + count -= 1 } - if nodeinfo.Settings.Freq5 != nil { - count += 2 - if alias.Freq5.TxPower == nodeinfo.Settings.Freq5.TxPower { - count -= 1 - } - if alias.Freq5.Channel == nodeinfo.Settings.Freq5.Channel { - count -= 1 - } + if alias.Wireless.TxPower24 == nodeinfo.Wireless.TxPower24 { + count -= 1 + } + if alias.Wireless.Channel5 == nodeinfo.Wireless.Channel5 { + count -= 1 + } + if alias.Wireless.TxPower5 == nodeinfo.Wireless.TxPower5 { + count -= 1 } } } diff --git a/data/breminale.go b/data/breminale.go index b937304..e46e088 100644 --- a/data/breminale.go +++ b/data/breminale.go @@ -1,13 +1,10 @@ package data -type Frequence struct { - TxPower uint32 `json:"txpower"` - Channel uint32 `json:"channel"` -} - -type Settings struct { - Freq24 *Frequence `json:"freq24,omitempty"` - Freq5 *Frequence `json:"freq5,omitempty"` +type Wireless struct { + TxPower24 uint32 `json:"txpower24"` + Channel24 uint32 `json:"channel24"` + TxPower5 uint32 `json:"txpower5"` + Channel5 uint32 `json:"channel5"` } type SwitchPort struct { Speed uint32 `json:"speed"` diff --git a/data/nodeinfo.go b/data/nodeinfo.go index 3a4b2fc..5080aab 100644 --- a/data/nodeinfo.go +++ b/data/nodeinfo.go @@ -10,7 +10,7 @@ type NodeInfo struct { Software Software `json:"software"` Hardware Hardware `json:"hardware"` VPN bool `json:"vpn"` - Settings *Settings `json:"settings,omitempty"` + Wireless *Wireless `json:"wireless,omitempty"` } type BatInterface struct { Interfaces struct { diff --git a/models/aliases.go b/models/aliases.go index 3e3fa7d..c506738 100644 --- a/models/aliases.go +++ b/models/aliases.go @@ -11,10 +11,9 @@ import ( ) type Alias struct { - Hostname string `json:"hostname,omitempty"` - Location *data.Location `json:"location,omitempty"` - Freq24 *data.Frequence `json:"freq24,omitempty"` - Freq5 *data.Frequence `json:"freq5,omitempty"` + Hostname string `json:"hostname,omitempty"` + Location *data.Location `json:"location,omitempty"` + Wireless *data.Wireless `json:"wireless,omitempty"` } // Nodes struct: cache DB of Node's structs diff --git a/models/ansible.go b/models/ansible.go index d3b1993..0833abf 100644 --- a/models/ansible.go +++ b/models/ansible.go @@ -29,13 +29,11 @@ func GenerateAnsible(nodes *Nodes, aliases map[string]*Alias) *Ansible { Address: node.Nodeinfo.Network.Addresses[0], Hostname: alias.Hostname, } - if alias.Freq24 != nil { - vars.Channel24 = alias.Freq24.Channel - vars.TxPower24 = alias.Freq24.TxPower - } - if alias.Freq5 != nil { - vars.Channel5 = alias.Freq5.Channel - vars.TxPower5 = alias.Freq5.TxPower + if alias.Wireless != nil { + vars.Channel24 = alias.Wireless.Channel24 + vars.TxPower24 = alias.Wireless.TxPower24 + vars.Channel5 = alias.Wireless.Channel5 + vars.TxPower5 = alias.Wireless.TxPower5 } if alias.Location != nil { vars.GeoLatitude = alias.Location.Latitude