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

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

  Supported devices:
  - Radwin WinLink series
  - Radwin JET series
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

  alias Towerops.Snmp.Profiles.Vendors.Vendor

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

  @impl true
  def detect_hardware(_client_opts) do
    # Radwin 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
    [
      # Link Distance (in meters, divide by 1000 for km)
      %{
        oid: "1.3.6.1.4.1.4458.1000.1.5.29.0",
        sensor_type: "distance",
        sensor_descr: "Link Distance",
        sensor_unit: "km",
        sensor_divisor: 1000
      },
      # Tx Power in dBm
      %{
        oid: "1.3.6.1.4.1.4458.1000.1.5.4.0",
        sensor_type: "power",
        sensor_descr: "Tx Power",
        sensor_unit: "dBm",
        sensor_divisor: 1
      },
      # Rx Power in dBm
      %{
        oid: "1.3.6.1.4.1.4458.1000.1.5.9.1.0",
        sensor_type: "power",
        sensor_descr: "Rx Power",
        sensor_unit: "dBm",
        sensor_divisor: 1
      },
      # RSSI in dBm
      %{
        oid: "1.3.6.1.4.1.4458.1000.1.1.51.7.0",
        sensor_type: "rssi",
        sensor_descr: "RSSI",
        sensor_unit: "dBm",
        sensor_divisor: 1
      }
    ]
  end
end
