protocol/aprs: extract position and symbol to frame
Some checks failed
Run tests / test (1.25) (push) Failing after 1m36s
Run tests / test (stable) (push) Failing after 1m36s

This commit is contained in:
2026-03-02 22:33:15 +01:00
parent 63040a44b3
commit d4a693365d
3 changed files with 33 additions and 12 deletions

View File

@@ -79,31 +79,36 @@ func (d micEDecoder) Decode(frame *Frame) (data Data, err error) {
}
var (
r = new(MicE)
report = new(MicE)
north, west bool
dest = frame.Destination.Call
info = []byte(frame.Raw[1:])
)
if r.Latitude, r.Type, r.Ambiguity, north, err = r.decodeLatitude(dest); err != nil {
if report.Latitude, report.Type, report.Ambiguity, north, err = report.decodeLatitude(dest); err != nil {
return
}
if r.Longitude, west, r.Velocity, r.Symbol, err = r.decodeMicELongitudeAndMotion(dest, info); err != nil {
if report.Longitude, west, report.Velocity, report.Symbol, err = report.decodeMicELongitudeAndMotion(dest, info); err != nil {
return
}
if !north {
r.Latitude = -r.Latitude
report.Latitude = -report.Latitude
}
if west {
r.Longitude = -r.Longitude
report.Longitude = -report.Longitude
}
r.parseExtensions(info[8:])
report.parseExtensions(info[8:])
return r, nil
frame.Latitude = report.Latitude
frame.Longitude = report.Longitude
frame.Altitude = report.Altitude
frame.Symbol = report.Symbol
return report, nil
}
func (r *MicE) decodeLatitude(dest string) (
func (report *MicE) decodeLatitude(dest string) (
lat float64,
msg MessageType,
ambiguity int,
@@ -161,7 +166,7 @@ func (r *MicE) decodeLatitude(dest string) (
lat = -lat
}
return lat, r.interpretMessage(msgBits), ambiguity, north, nil
return lat, report.interpretMessage(msgBits), ambiguity, north, nil
}
func decodeDestChar(c byte) (
@@ -196,7 +201,7 @@ func maskAmbiguity(digits []int, ambiguity int) {
}
}
func (r *MicE) decodeMicELongitudeAndMotion(dest string, info []byte) (lon float64, west bool, velocity *Velocity, symbol string, err error) {
func (report *MicE) decodeMicELongitudeAndMotion(dest string, info []byte) (lon float64, west bool, velocity *Velocity, symbol string, err error) {
if len(info) < 3 {
err = errors.New("info too short for longitude")
return