// If this message has new position info, *and* we have good backfill, then craft a CompositeMsg. // Note, we don't wait for squawk info. func (s *ADSBSender) maybeCreateComposite(m *adsb.Msg) *adsb.CompositeMsg { if !m.HasPosition() { return nil } //if s.LastGroundSpeed == 0 || s.LastTrack == 0 || s.LastCallsign == "" { return nil } cm := adsb.CompositeMsg{Msg: *m} // Clone the input into the embedded struct // Overwrite with cached info (from previous packets), if we don't have it in this packet if cm.GroundSpeed == 0 { cm.GroundSpeed = s.LastGroundSpeed } if cm.VerticalRate == 0 { cm.VerticalRate = s.LastVerticalSpeed } if cm.Track == 0 { cm.Track = s.LastTrack } if cm.Callsign == "" { cm.Callsign = s.LastCallsign } if cm.Squawk == "" { cm.Squawk = s.LastSquawk } return &cm }