# 09. Feeds: Smart Ports and MLAT

# Feeds: Smart Ports and MLAT

## 1. Feed basics

In `Feeds`, define raw data sources (`Mode-S Raw`, `BaseStation`).

`Mode-S Raw` covers both:
1. Beast family binary (`30005`, `30006`, `30105`, `31005`, `31006`)
2. AVR / raw text (`30002`, `*8D...;`)

For each feed, configure:
1. `Address` and `Port`
2. `Format`
3. `ConnectionType`
4. `Enabled`
5. `Visible in Radar Dropdown`
6. optional `Receiver Location`

After save:
1. verify connection status,
2. verify message counters increase,
3. verify `AircraftList.json` is non-empty.

## 2. Smart profile ports

Known smart profiles:
1. `30002` -> `[ADS-B] AVR/Raw Text`
2. `30003` -> `[ADS-B] BaseStation/SBS Text`
3. `30005` -> `[ADS-B] Beast/Binary`
4. `30006` -> `[ADS-B] BeastReduce`
5. `30105` -> `[MLAT] Beast/Binary`
6. `30106` -> `[MLAT] BaseStation/SBS Text`
7. `31005` -> `[MLAT Hub] Beast/Binary`
8. `31006` -> `[MLAT Hub] BeastReduce`

When one of these ports is entered, feed editor pre-applies matching format/MLAT defaults.

## 3. Quick Add: Feed Set

Use `/admin/feeds` -> `Add Feed Set` when one feeder exposes several related ports on the same IP.

The dialog asks for:
1. `Base Name` - auto-filled as the first unused `FEEDxx` family, for example `FEED01`,
2. `Address / IP` - shared by all generated feeds,
3. `Primary Feed` - required ADS-B source, `30003` or `30005`,
4. `Dedicated MLAT Feed` - optional `30105` or `30106`,
5. `MLAT Hub Feed` - optional `31005` or `31006`,
6. `Receiver Location` - copied to every generated feed,
7. optional `Add created feeds to merged feed`.

The UI saves ordinary feeds underneath, for example:
1. `FEED01_ADSB`
2. `FEED01_MLAT`
3. `FEED01_MLATHUB`

`FEED01_MLATHUB` is still stored as an MLAT feed internally (`IsMlatFeed = true`).

This keeps backward compatibility with existing configuration while making multi-port feeders faster to add.

Generated feed behavior:
1. every created feed is a normal TCP active feed,
2. smart port profiles still set parser/MLAT defaults,
3. duplicate endpoints with the same normalized address and port are skipped,
4. if all requested endpoints already exist, nothing is created,
5. if no merged feed is selected, primary ADS-B feeds stay visible in the radar dropdown and MLAT-only feeds stay hidden by default,
6. if a merged feed is selected, all newly created feed IDs are appended to that merged feed and the visibility checkbox is applied to created feeds.

Use normal `Add Feed` instead when the source needs:
1. a custom port outside the smart profile list,
2. passive TCP mode,
3. serial receiver configuration,
4. unusual format settings.

Known `readsb` ports without a feed profile:
1. `30047` -> JSON position stream, not a raw feed input
2. `30152` -> HTTP API JSON, not a raw feed input

## 4. MLAT options

Feed-level MLAT controls:
1. `MLAT Feed` forces all positions from feed to be treated as MLAT-derived.
2. Use `MLAT Feed` only for dedicated MLAT streams without reliable MLAT marker tagging.
3. For mixed ADS-B + MLAT streams, keep `MLAT Feed` disabled and rely on per-message MLAT detection.
4. `Assume DF18 CF1 = ICAO` is experimental and should be enabled only for known-compatible sources.

## 5. BeastReduce and MLAT Hub

`BeastReduce` is still Beast on the wire.
1. Use the same `Mode-S Raw` parser as for normal Beast.
2. The difference is reduced rate / lower bandwidth, not a different binary format.

`MLAT Hub` is a consolidated MLAT-results output, not a primary ADS-B receiver feed.
1. `31005` and `31006` are usually advanced, MLAT-only sources.
2. They should not be presented as a normal full-traffic ADS-B feed.
3. Default `MLAT Feed = on` is appropriate for these dedicated MLAT outputs.

## 6. Quick verification

1. open aircraft detail panel,
2. check `Position Source` (`MLAT position` or `ADS-B position`),
3. compare behavior before and after MLAT option changes.

## 7. UI visibility note

`Visible in Radar Dropdown` controls whether a feed appears in frontend `All feeds / feed selector`.