pull/11/head
Christopher Young 2015-08-20 12:54:46 -04:00
rodzic cfd8b9fcaf
commit 1ba6f744ea
2 zmienionych plików z 12 dodań i 15 usunięć

Wyświetl plik

@ -17,7 +17,6 @@ import (
const (
stratuxVersion = "v0.1"
configLocation = "/etc/stratux.conf"
ipadAddr = "192.168.10.255:4000" // Port 4000 for FreeFlight RANGR.
managementAddr = "127.0.0.1:9110"
maxDatagramSize = 8192
UPLINK_BLOCK_DATA_BITS = 576
@ -357,11 +356,10 @@ func parseInput(buf string) ([]byte, uint16) {
}
type settings struct {
UAT_Enabled bool
ES_Enabled bool
GPS_Enabled bool
GDLOutputPorts []uint16
UAT_Enabled bool
ES_Enabled bool
GPS_Enabled bool
GDLOutputPorts []uint16
}
type status struct {
@ -492,7 +490,7 @@ func main() {
go gpsReader()
}
//TODO: network stuff
//TODO: network stuff
// Start the heartbeat message loop in the background, once per second.
go heartBeatSender()

Wyświetl plik

@ -1,19 +1,18 @@
package main
import (
"log"
"time"
"io/ioutil"
"strings"
"strconv"
"log"
"net"
"strconv"
"strings"
"time"
)
var messageQueue chan []byte
var outSockets map[string]*net.UDPConn
var dhcpLeases map[string]string
// Read the "dhcpd.leases" file and parse out IP/hostname.
func getDHCPLeases() (map[string]string, error) {
dat, err := ioutil.ReadFile("/var/lib/dhcp/dhcpd.leases")
@ -94,14 +93,14 @@ func messageQueueSender() {
dhcpRefresh := time.NewTicker(30 * time.Second)
for {
select {
case msg := <- messageQueue:
case msg := <-messageQueue:
sendToAllConnectedClients(msg)
case <-secondTimer.C:
getNetworkStats()
case <-dhcpRefresh.C:
refreshConnectedClients()
}
}
}
@ -114,4 +113,4 @@ func initNetwork() {
outSockets = make(map[string]*net.UDPConn)
refreshConnectedClients()
go messageQueueSender()
}
}