Exemplo n.º 1
0
func main() {

	remote := flag.String("remote", "10.50.0.25:6700", "Remote TNC server")
	sendit := flag.Bool("sendit", false, "Send message to RF (default: false)")
	flag.Parse()

	psource := ax25.APRSAddress{
		Callsign: "NW5W",
		SSID:     1,
	}

	pdest := ax25.APRSAddress{
		Callsign: "APZ001",
		SSID:     0,
	}

	path := []ax25.APRSAddress{
		{
			Callsign: "WIDE1",
			SSID:     1,
		},
		{
			Callsign: "WIDE2",
			SSID:     1,
		},
	}

	sender := ax25.APRSAddress{
		Callsign: "NW5W",
		SSID:     1,
	}

	recipient := ax25.APRSAddress{
		Callsign: "NW5W",
		SSID:     7,
	}

	m := aprs.Message{
		Sender:    sender,
		Recipient: recipient,
		ID:        "001",
		Text:      "Testing balloon coms",
	}

	ms, err := aprs.CreateMessage(m)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
	}

	if *sendit {

		a := ax25.APRSPacket{
			Source: psource,
			Dest:   pdest,
			Path:   path,
			Body:   ms,
		}

		packet, err := ax25.EncodeAX25Command(a)
		if err != nil {
			log.Fatalf("Unable to create packet: %v", err)
		}

		conn, err := net.Dial("tcp", *remote)
		if err != nil {
			log.Fatalf("Could not connect to %v.  Error: %v", *remote, err)
		}

		bw, err := conn.Write(packet)
		if err != nil {
			log.Fatalf("Could not write to remote.  Error: %v", err)
		} else {
			log.Printf("Wrote %v bytes to %v", bw, conn.RemoteAddr())
		}

		err = conn.Close()
		if err != nil {
			log.Fatalf("Error closing connection: %v", err)
		}

		// Let's decode our own packet to make sure tht it's bueno
		buf := bytes.NewReader(packet)
		d := ax25.NewDecoder(buf)
		msg, err := d.Next()
		fmt.Printf("%+v\n", msg)

	}

	fmt.Printf("Encoded message: %v\n", ms)

	dm, remains, err := aprs.DecodeMessage(ms)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
	}

	fmt.Printf("Decoded message: %+v\n", dm)
	fmt.Printf("Remains: %v\n", remains)

	dm, remains, err = aprs.DecodeMessage(":NW5W-7   :ACK707")

	fmt.Printf("Decoded message: %+v\n", dm)
	fmt.Printf("Remains: %v\n", remains)

}
Exemplo n.º 2
0
func ackMessage(m aprs.Message) {

	psource := ax25.APRSAddress{
		Callsign: "NW5W",
		SSID:     1,
	}

	pdest := ax25.APRSAddress{
		Callsign: "APZ001",
		SSID:     0,
	}

	path := []ax25.APRSAddress{
		{
			Callsign: "WIDE1",
			SSID:     1,
		},
		{
			Callsign: "WIDE2",
			SSID:     1,
		},
	}

	em, _ := aprs.CreateMessageACK(m)

	a := ax25.APRSPacket{
		Source: psource,
		Dest:   pdest,
		Path:   path,
		Body:   em,
	}

	packet, err := ax25.EncodeAX25Command(a)
	if err != nil {
		log.Fatalf("Unable to create packet: %v", err)
	}

	conn, err := net.Dial("tcp", "10.50.0.25:6700")
	if err != nil {
		log.Fatalf("Could not connect to %v.  Error: %v", "10.50.0.25:6700", err)
	}

	bw, err := conn.Write(packet)
	if err != nil {
		log.Fatalf("Could not write to remote.  Error: %v", err)
	} else {
		log.Printf("Wrote %v bytes to %v", bw, conn.RemoteAddr())
	}

	err = conn.Close()
	if err != nil {
		log.Fatalf("Error closing connection: %v", err)
	}

	// Let's decode our own packet to make sure tht it's bueno
	buf := bytes.NewReader(packet)
	d := ax25.NewDecoder(buf)
	msg, err := d.Next()
	fmt.Printf("%+v\n", msg)

}
Exemplo n.º 3
0
func main() {

	port := flag.String("port", "/dev/ttyUSB0", "Serial port device (defaults to /dev/ttyUSB0)")
	flag.Parse()

	c := &serial.Config{Name: *port, Baud: 4800}

	s, err := serial.OpenPort(c)
	if err != nil {
		log.Fatal(err)
	}

	psource := ax25.APRSAddress{
		Callsign: "NW5W",
		SSID:     7,
	}

	pdest := ax25.APRSAddress{
		Callsign: "APZ001",
		SSID:     0,
	}

	var path []ax25.APRSAddress

	path = append(path, ax25.APRSAddress{
		Callsign: "WIDE1",
		SSID:     1,
	})

	path = append(path, ax25.APRSAddress{
		Callsign: "WIDE2",
		SSID:     1,
	})

	point := geospatial.NewPoint()
	point.Lat = 47.262347
	point.Lon = -122.46988
	point.Alt = 1702

	position := aprs.CreateCompressedPosition(point, '/', 'O')
	body := fmt.Sprint(position, "GoBalloon Test http://nw5w.com")

	a := ax25.APRSPacket{
		Source: psource,
		Dest:   pdest,
		Path:   path,
		Body:   body,
	}

	packet, err := ax25.EncodeAX25Command(a)
	if err != nil {
		log.Fatalf("Unable to create packet: %v", err)
	}

	s.Write(packet)

	err = s.Close()
	if err != nil {
		log.Fatalf("Error closing port: %v", err)
	}

	// Let's decode our own packet to make sure tht it's bueno
	buf := bytes.NewReader(packet)
	d := ax25.NewDecoder(buf)
	msg, err := d.Next()
	fmt.Printf("%+v\n", msg)

}