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

  Supports Alvarion/Breezecom wireless equipment.

  Supported devices:
  - BreezeMAX series
  - BreezeNET series
  - BreezeACCESS series
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

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

  # Alvarion Enterprise OID: 1.3.6.1.4.1.12394
  @model_oid "1.3.6.1.4.1.12394.4.1.1.1.0"

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

  @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 Strength
      %{
        oid: "1.3.6.1.4.1.12394.4.1.3.1.0",
        sensor_type: "rssi",
        sensor_descr: "RSSI",
        sensor_unit: "dBm",
        sensor_divisor: 1
      },
      # Signal to Noise Ratio
      %{
        oid: "1.3.6.1.4.1.12394.4.1.3.2.0",
        sensor_type: "snr",
        sensor_descr: "SNR",
        sensor_unit: "dB",
        sensor_divisor: 1
      },
      # Associated Subscribers
      %{
        oid: "1.3.6.1.4.1.12394.4.1.5.1.0",
        sensor_type: "clients",
        sensor_descr: "Associated Subscribers",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # Transmit Power
      %{
        oid: "1.3.6.1.4.1.12394.4.1.2.3.0",
        sensor_type: "power",
        sensor_descr: "Tx Power",
        sensor_unit: "dBm",
        sensor_divisor: 1
      }
    ]
  end
end
