defmodule Towerops.Snmp.Profiles.Vendors.Saf do
  @moduledoc """
  SAF Tehnika device-specific SNMP handling.

  Mirrors LibreNMS/OS/Saf.php for wireless sensor discovery.

  Supported devices:
  - SAF Tehnika Integra series
  - SAF Tehnika Lumina series
  - SAF Tehnika CFIP series
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

  alias Towerops.Snmp.Profiles.Vendors.Vendor

  @impl true
  def profile_names, do: ["saf"]

  @impl true
  def detect_hardware(_client_opts) do
    # SAF hardware detection is handled by YAML profile
    nil
  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
    [
      # Tx Frequency (in kHz, divide by 1000 for MHz)
      %{
        oid: "1.3.6.1.4.1.7571.100.1.1.5.1.1.1.10.1.9.1",
        sensor_type: "frequency",
        sensor_descr: "Tx Frequency",
        sensor_unit: "MHz",
        sensor_divisor: 1000
      },
      # Rx Frequency (in kHz, divide by 1000 for MHz)
      %{
        oid: "1.3.6.1.4.1.7571.100.1.1.5.1.1.1.10.1.10.1",
        sensor_type: "frequency",
        sensor_descr: "Rx Frequency",
        sensor_unit: "MHz",
        sensor_divisor: 1000
      },
      # Radial MSE (Mean Square Error, divide by 10 for dB)
      %{
        oid: "1.3.6.1.4.1.7571.100.1.1.5.1.1.1.12.1.10.1",
        sensor_type: "mse",
        sensor_descr: "Radial MSE",
        sensor_unit: "dB",
        sensor_divisor: 10
      },
      # Rx Power in dBm
      %{
        oid: "1.3.6.1.4.1.7571.100.1.1.5.1.1.1.10.1.5.1",
        sensor_type: "power",
        sensor_descr: "Rx Power",
        sensor_unit: "dBm",
        sensor_divisor: 1
      },
      # Tx Power in dBm
      %{
        oid: "1.3.6.1.4.1.7571.100.1.1.5.1.1.1.10.1.4.1",
        sensor_type: "power",
        sensor_descr: "Tx Power",
        sensor_unit: "dBm",
        sensor_divisor: 1
      },
      # ACM Capacity (in kbps)
      %{
        oid: "1.3.6.1.4.1.7571.100.1.1.5.1.1.1.12.1.18.1",
        sensor_type: "rate",
        sensor_descr: "ACM Capacity",
        sensor_unit: "kbps",
        sensor_divisor: 1
      },
      # Total Capacity (in kbps)
      %{
        oid: "1.3.6.1.4.1.7571.100.1.1.5.1.1.1.12.1.6.1",
        sensor_type: "rate",
        sensor_descr: "Total Capacity",
        sensor_unit: "kbps",
        sensor_divisor: 1
      }
    ]
  end
end
