Skip to content

Commit

Permalink
Add method for sending UI frames
Browse files Browse the repository at this point in the history
For beaconing etc.
  • Loading branch information
martinhpedersen committed Jan 28, 2023
1 parent bbfd3eb commit 1af7ec2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions transport/ax25/agwpe/frame_kinds.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
kindDisconnect kind = 'd'
kindConnectedData kind = 'D'
kindOutstandingFramesForConn kind = 'Y' // Direwolf >= 1.4
kindUnprotoInformation kind = 'M'
)

func versionNumberFrame() frame {
Expand Down Expand Up @@ -112,6 +113,15 @@ func connectViaFrame(from, to string, port uint8, digis []string) frame {
return frame{header: h, Data: buf.Bytes()}
}

func unprotoInformationFrame(from, to string, port uint8, data []byte) frame {
h := header{
DataKind: kindUnprotoInformation,
From: callsignFromString(from),
To: callsignFromString(to),
}
return frame{header: h, Data: data}
}

func disconnectFrame(from, to string, port uint8) frame {
h := header{DataKind: kindDisconnect}
copy(h.From[:], from)
Expand Down
8 changes: 8 additions & 0 deletions transport/ax25/agwpe/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ func (p *Port) Listen() (net.Listener, error) {
return newListener(p), nil
}

func (p *Port) SendUI(data []byte, dst string) error {
if p.demux.isClosed() {
return ErrPortClosed
}
f := unprotoInformationFrame(p.mycall, dst, p.port, data)
return p.tnc.write(f)
}

func (p *Port) numOutstandingFrames() (int, error) {
resp := p.demux.NextFrame(kindOutstandingFramesForPort)
f := outstandingFramesForPortFrame(p.port)
Expand Down

0 comments on commit 1af7ec2

Please sign in to comment.