defmodule Towerops.Snmp.Profiles.Vendors.Dragonwave do
  @moduledoc """
  DragonWave Horizon device-specific SNMP handling.

  Supports Horizon Compact, CompactPlus, Duo, and Quantum series.

  Supported devices:
  - Horizon Compact
  - Horizon Compact Plus
  - Horizon Duo
  - Horizon Quantum
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

  alias Towerops.Snmp.Client
  alias Towerops.Snmp.Profiles.Vendors.Vendor

  # Horizon ODU MIB - hardware info
  @hardware_oid "1.3.6.1.4.1.7262.2.2.1.1.8.0"

  @impl true
  def profile_names do
    ["horizon-compact", "horizon-compactplus", "horizon-duo", "horizon-quantum"]
  end

  @impl true
  def detect_hardware(client_opts) do
    case Client.get(client_opts, @hardware_oid) do
      {:ok, hardware} when is_binary(hardware) -> hardware
      _ -> nil
    end
  end

  @impl true
  def discover_wireless_sensors(client_opts) do
    Vendor.fetch_sensors(wireless_oid_defs(), client_opts)
  end

  @impl true
  def wireless_oid_defs do
    [
      # Radio Temperature (divide by 10)
      %{
        oid: "1.3.6.1.4.1.7262.2.2.5.1.3.6.0",
        sensor_type: "temperature",
        sensor_descr: "Radio Temperature",
        sensor_unit: "C",
        sensor_divisor: 10
      },
      # Modem SNR (divide by 10)
      %{
        oid: "1.3.6.1.4.1.7262.2.2.5.1.2.3.0",
        sensor_type: "snr",
        sensor_descr: "Modem SNR",
        sensor_unit: "dB",
        sensor_divisor: 10
      },
      # RSL (Receive Signal Level)
      %{
        oid: "1.3.6.1.4.1.7262.2.2.5.1.2.2.0",
        sensor_type: "rssi",
        sensor_descr: "RSL",
        sensor_unit: "dBm",
        sensor_divisor: 10
      },
      # Transmit Power
      %{
        oid: "1.3.6.1.4.1.7262.2.2.5.1.3.2.0",
        sensor_type: "power",
        sensor_descr: "Tx Power",
        sensor_unit: "dBm",
        sensor_divisor: 10
      }
    ]
  end
end
