defmodule Towerops.Snmp.Profiles.Vendors.Sub10 do
  @moduledoc """
  Sub10 Systems device-specific SNMP handling.

  Supports Sub10 millimeter wave (E-band) backhaul radios.

  Supported devices:
  - Liberator-E Series (80 GHz)
  - Liberator-V Series (60 GHz)
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

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

  # Sub10 Enterprise OID: 1.3.6.1.4.1.39003
  @model_oid "1.3.6.1.4.1.39003.1.1.1.0"

  @impl true
  def profile_names do
    ["sub10"]
  end

  @impl true
  def detect_hardware(client_opts) do
    case Client.get(client_opts, @model_oid) do
      {:ok, model} when is_binary(model) -> model
      _ -> 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
      %{
        oid: "1.3.6.1.4.1.39003.1.2.1.3.0",
        sensor_type: "temperature",
        sensor_descr: "Radio Temperature",
        sensor_unit: "C",
        sensor_divisor: 1
      },
      # Receive Signal Level (RSL)
      %{
        oid: "1.3.6.1.4.1.39003.1.3.1.2.0",
        sensor_type: "rssi",
        sensor_descr: "RSL",
        sensor_unit: "dBm",
        sensor_divisor: 10
      },
      # Transmit Power
      %{
        oid: "1.3.6.1.4.1.39003.1.3.1.1.0",
        sensor_type: "power",
        sensor_descr: "Tx Power",
        sensor_unit: "dBm",
        sensor_divisor: 10
      },
      # Link SNR
      %{
        oid: "1.3.6.1.4.1.39003.1.3.1.5.0",
        sensor_type: "snr",
        sensor_descr: "SNR",
        sensor_unit: "dB",
        sensor_divisor: 10
      },
      # Link Capacity (Mbps)
      %{
        oid: "1.3.6.1.4.1.39003.1.3.1.10.0",
        sensor_type: "capacity",
        sensor_descr: "Link Capacity",
        sensor_unit: "Mbps",
        sensor_divisor: 1
      }
    ]
  end
end
