wifisettings

This commit is contained in:
Martin Geno 2016-06-29 00:04:33 +02:00
parent 719cf13f87
commit e98c479cf3
5 changed files with 26 additions and 37 deletions

View File

@ -48,27 +48,22 @@ func (api *ApiAliases) cleaner() {
count -= 1 count -= 1
} }
} }
if nodeinfo.Settings != nil { if nodeinfo.Wireless != nil {
if nodeinfo.Settings.Freq24 != nil { count += 4
count += 2 if alias.Wireless.Channel24 == nodeinfo.Wireless.Channel24 {
if alias.Freq24.TxPower == nodeinfo.Settings.Freq24.TxPower {
count -= 1 count -= 1
} }
if alias.Freq24.Channel == nodeinfo.Settings.Freq24.Channel { if alias.Wireless.TxPower24 == nodeinfo.Wireless.TxPower24 {
count -= 1 count -= 1
} }
} if alias.Wireless.Channel5 == nodeinfo.Wireless.Channel5 {
if nodeinfo.Settings.Freq5 != nil {
count += 2
if alias.Freq5.TxPower == nodeinfo.Settings.Freq5.TxPower {
count -= 1 count -= 1
} }
if alias.Freq5.Channel == nodeinfo.Settings.Freq5.Channel { if alias.Wireless.TxPower5 == nodeinfo.Wireless.TxPower5 {
count -= 1 count -= 1
} }
} }
} }
}
//delete element //delete element
if count <= 0 { if count <= 0 {
delete(api.aliases.List, key) delete(api.aliases.List, key)

View File

@ -1,13 +1,10 @@
package data package data
type Frequence struct { type Wireless struct {
TxPower uint32 `json:"txpower"` TxPower24 uint32 `json:"txpower24"`
Channel uint32 `json:"channel"` Channel24 uint32 `json:"channel24"`
} TxPower5 uint32 `json:"txpower5"`
Channel5 uint32 `json:"channel5"`
type Settings struct {
Freq24 *Frequence `json:"freq24,omitempty"`
Freq5 *Frequence `json:"freq5,omitempty"`
} }
type SwitchPort struct { type SwitchPort struct {
Speed uint32 `json:"speed"` Speed uint32 `json:"speed"`

View File

@ -10,7 +10,7 @@ type NodeInfo struct {
Software Software `json:"software"` Software Software `json:"software"`
Hardware Hardware `json:"hardware"` Hardware Hardware `json:"hardware"`
VPN bool `json:"vpn"` VPN bool `json:"vpn"`
Settings *Settings `json:"settings,omitempty"` Wireless *Wireless `json:"wireless,omitempty"`
} }
type BatInterface struct { type BatInterface struct {
Interfaces struct { Interfaces struct {

View File

@ -13,8 +13,7 @@ import (
type Alias struct { type Alias struct {
Hostname string `json:"hostname,omitempty"` Hostname string `json:"hostname,omitempty"`
Location *data.Location `json:"location,omitempty"` Location *data.Location `json:"location,omitempty"`
Freq24 *data.Frequence `json:"freq24,omitempty"` Wireless *data.Wireless `json:"wireless,omitempty"`
Freq5 *data.Frequence `json:"freq5,omitempty"`
} }
// Nodes struct: cache DB of Node's structs // Nodes struct: cache DB of Node's structs

View File

@ -29,13 +29,11 @@ func GenerateAnsible(nodes *Nodes, aliases map[string]*Alias) *Ansible {
Address: node.Nodeinfo.Network.Addresses[0], Address: node.Nodeinfo.Network.Addresses[0],
Hostname: alias.Hostname, Hostname: alias.Hostname,
} }
if alias.Freq24 != nil { if alias.Wireless != nil {
vars.Channel24 = alias.Freq24.Channel vars.Channel24 = alias.Wireless.Channel24
vars.TxPower24 = alias.Freq24.TxPower vars.TxPower24 = alias.Wireless.TxPower24
} vars.Channel5 = alias.Wireless.Channel5
if alias.Freq5 != nil { vars.TxPower5 = alias.Wireless.TxPower5
vars.Channel5 = alias.Freq5.Channel
vars.TxPower5 = alias.Freq5.TxPower
} }
if alias.Location != nil { if alias.Location != nil {
vars.GeoLatitude = alias.Location.Latitude vars.GeoLatitude = alias.Location.Latitude