defmodule Microwaveprop.Propagation.ModeThresholds do
  @moduledoc """
  Required-SNR thresholds (dB) for the modes the rover planner supports.

  The rover predicts a per-link SNR margin; subtracting the mode's required
  SNR yields "dB above decode threshold". Numbers come from the rover spec —
  SSB needs full quieting, CW pulls signals well below the noise floor, and
  Q65 modes go deeper still.
  """

  @thresholds %{
    ssb: 0.0,
    cw: -18.0,
    q65_60a: -24.0,
    q65_120b: -26.0
  }

  @modes [
    {:ssb, "SSB"},
    {:cw, "CW"},
    {:q65_60a, "Q65-60A"},
    {:q65_120b, "Q65-120B"}
  ]

  @type mode :: :ssb | :cw | :q65_60a | :q65_120b

  @spec required_snr_db(mode()) :: float()
  def required_snr_db(mode) when is_map_key(@thresholds, mode), do: Map.fetch!(@thresholds, mode)

  @spec modes() :: [{mode(), String.t()}]
  def modes, do: @modes

  @spec default_mode() :: mode()
  def default_mode, do: :ssb
end
