freifunkmanager/websocket/hd_connect.go

41 lines
1.1 KiB
Go
Raw Normal View History

package websocket
import (
log "github.com/sirupsen/logrus"
wsLib "github.com/genofire/golang-lib/websocket"
2018-07-15 21:04:17 +02:00
"github.com/FreifunkBremen/freifunkmanager/runtime"
)
2018-07-15 21:04:17 +02:00
var wifi24Channels []uint32
var wifi5Channels []uint32
func (ws *WebsocketServer) connectHandler(logger *log.Entry, msg *wsLib.Message) error {
msg.From.Write(&wsLib.Message{Subject: MessageTypeStats, Body: ws.nodes.Statistics})
for _, node := range ws.nodes.List {
msg.From.Write(&wsLib.Message{Subject: MessageTypeSystemNode, Body: node})
}
for _, node := range ws.nodes.Current {
msg.From.Write(&wsLib.Message{Subject: MessageTypeCurrentNode, Body: node})
}
2018-07-15 21:04:17 +02:00
msg.From.Write(&wsLib.Message{Subject: MessageTypeChannelsWifi24, Body: wifi24Channels})
msg.From.Write(&wsLib.Message{Subject: MessageTypeChannelsWifi5, Body: wifi5Channels})
logger.Debug("done")
return nil
}
2018-07-15 21:04:17 +02:00
func init() {
for ch, channel := range runtime.ChannelList {
if runtime.ChannelEU && !channel.AllowedInEU {
continue
}
if channel.Frequenz > runtime.FREQ_THREASHOLD {
wifi5Channels = append(wifi5Channels, ch)
} else {
wifi24Channels = append(wifi24Channels, ch)
}
}
}