cleanup and fix broker start

This commit is contained in:
saji 2023-04-29 17:34:35 -05:00
parent f0db7da230
commit c58b4b1543

View file

@ -29,19 +29,13 @@ var serveCmd = &cli.Command{
}, },
} }
type session struct {
conn net.Conn
send chan gotelem.Body
recv chan gotelem.Body
quit chan bool
}
func serve() { func serve() {
broker := NewBroker(3) broker := NewBroker(3)
// start the can listener // start the can listener
go vcanTest() go vcanTest()
go canHandler(broker) go canHandler(broker)
go broker.Start()
ln, err := net.Listen("tcp", ":8082") ln, err := net.Listen("tcp", ":8082")
if err != nil { if err != nil {
fmt.Printf("Error listening: %v\n", err) fmt.Printf("Error listening: %v\n", err)
@ -91,7 +85,7 @@ func handleCon(conn net.Conn, broker *Broker) {
case rxBody := <-rxPkts: case rxBody := <-rxPkts:
// do nothing for now. // do nothing for now.
fmt.Printf("got a body %v\n", rxBody) fmt.Printf("got a body %v\n", rxBody)
case <-time.NewTimer(1 * time.Second).C: // time out. case <-time.After(1 * time.Second): // time out.
fmt.Printf("timeout\n") fmt.Printf("timeout\n")
data := gotelem.StatusBody{ data := gotelem.StatusBody{
BatteryPct: 1.2, BatteryPct: 1.2,