defmodule Towerops.Snmp.Profiles.Vendors.Mimosa do
  @moduledoc """
  Mimosa Networks device-specific SNMP handling.

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

  Supported devices:
  - Mimosa B5/B5c (PTP)
  - Mimosa A5/A5c (PTMP)
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

  alias Towerops.Snmp.Profiles.Vendors.Vendor

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

  @impl true
  def detect_hardware(_client_opts) do
    # Mimosa 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 Packet Error Ratio (divide by 100 for %)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.7.3.0",
        sensor_type: "error-ratio",
        sensor_descr: "Tx Packet Error Ratio",
        sensor_unit: "%",
        sensor_divisor: 100
      },
      # Rx Packet Error Ratio (divide by 100 for %)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.7.4.0",
        sensor_type: "error-ratio",
        sensor_descr: "Rx Packet Error Ratio",
        sensor_unit: "%",
        sensor_divisor: 100
      },
      # Center Frequency Chain 1 (in MHz)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.1.1.6.1",
        sensor_type: "frequency",
        sensor_descr: "Frequency Chain 1",
        sensor_unit: "MHz",
        sensor_divisor: 1
      },
      # Center Frequency Chain 2 (in MHz)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.1.1.6.2",
        sensor_type: "frequency",
        sensor_descr: "Frequency Chain 2",
        sensor_unit: "MHz",
        sensor_divisor: 1
      },
      # Tx Power Chain 1 (divide by 10 for dBm)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.1.1.2.1",
        sensor_type: "power",
        sensor_descr: "Tx Power Chain 1",
        sensor_unit: "dBm",
        sensor_divisor: 10
      },
      # Tx Power Chain 2 (divide by 10 for dBm)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.1.1.2.2",
        sensor_type: "power",
        sensor_descr: "Tx Power Chain 2",
        sensor_unit: "dBm",
        sensor_divisor: 10
      },
      # Rx Power Chain 1 (divide by 10 for dBm)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.1.1.3.1",
        sensor_type: "power",
        sensor_descr: "Rx Power Chain 1",
        sensor_unit: "dBm",
        sensor_divisor: 10
      },
      # Rx Power Chain 2 (divide by 10 for dBm)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.1.1.3.2",
        sensor_type: "power",
        sensor_descr: "Rx Power Chain 2",
        sensor_unit: "dBm",
        sensor_divisor: 10
      },
      # Rx Noise Chain 1 (divide by 10 for dBm)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.1.1.4.1",
        sensor_type: "noise-floor",
        sensor_descr: "Rx Noise Chain 1",
        sensor_unit: "dBm",
        sensor_divisor: 10
      },
      # Rx Noise Chain 2 (divide by 10 for dBm)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.1.1.4.2",
        sensor_type: "noise-floor",
        sensor_descr: "Rx Noise Chain 2",
        sensor_unit: "dBm",
        sensor_divisor: 10
      },
      # SNR Chain 1 (divide by 10 for dB)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.1.1.5.1",
        sensor_type: "snr",
        sensor_descr: "SNR Chain 1",
        sensor_unit: "dB",
        sensor_divisor: 10
      },
      # SNR Chain 2 (divide by 10 for dB)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.1.1.5.2",
        sensor_type: "snr",
        sensor_descr: "SNR Chain 2",
        sensor_unit: "dB",
        sensor_divisor: 10
      },
      # Tx PHY Rate Stream 1 (in Mbps)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.2.1.2.1",
        sensor_type: "rate",
        sensor_descr: "Tx Rate Stream 1",
        sensor_unit: "Mbps",
        sensor_divisor: 1
      },
      # Rx PHY Rate Stream 1 (in Mbps)
      %{
        oid: "1.3.6.1.4.1.43356.2.1.2.6.2.1.5.1",
        sensor_type: "rate",
        sensor_descr: "Rx Rate Stream 1",
        sensor_unit: "Mbps",
        sensor_divisor: 1
      }
    ]
  end
end
