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

  Supports Proxim wireless bridges and access points.

  Supported devices:
  - Tsunami MP series
  - Tsunami QB series
  - ORiNOCO series
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

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

  # Proxim Enterprise OID: 1.3.6.1.4.1.11898
  @model_oid "1.3.6.1.4.1.11898.2.1.1.1.0"

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

  @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
    [
      # Receive Signal Level
      %{
        oid: "1.3.6.1.4.1.11898.2.1.18.1.2.0",
        sensor_type: "rssi",
        sensor_descr: "RSSI",
        sensor_unit: "dBm",
        sensor_divisor: 1
      },
      # Signal to Noise Ratio
      %{
        oid: "1.3.6.1.4.1.11898.2.1.18.1.3.0",
        sensor_type: "snr",
        sensor_descr: "SNR",
        sensor_unit: "dB",
        sensor_divisor: 1
      },
      # Link Quality
      %{
        oid: "1.3.6.1.4.1.11898.2.1.18.1.4.0",
        sensor_type: "quality",
        sensor_descr: "Link Quality",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # Associated Stations
      %{
        oid: "1.3.6.1.4.1.11898.2.1.18.2.1.0",
        sensor_type: "clients",
        sensor_descr: "Associated Stations",
        sensor_unit: "",
        sensor_divisor: 1
      }
    ]
  end
end
