defmodule Towerops.Snmp.Profiles.Vendors.Ciscowlc do
  @moduledoc """
  Cisco Wireless LAN Controller (WLC) device-specific SNMP handling.

  Supports Cisco WLC series controllers.

  Supported devices:
  - Cisco 2500 Series WLC
  - Cisco 3500 Series WLC
  - Cisco 5500 Series WLC
  - Cisco 8500 Series WLC
  - Cisco Virtual WLC
  - Cisco Catalyst 9800 Series
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

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

  # Cisco AIRESPACE MIB
  # Enterprise OID: 1.3.6.1.4.1.14179
  @model_oid "1.3.6.1.4.1.14179.1.1.1.3.0"

  @impl true
  def profile_names do
    ["ciscowlc"]
  end

  @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
    [
      # Total Associated Mobile Stations (Clients)
      %{
        oid: "1.3.6.1.4.1.14179.2.1.1.1.38.0",
        sensor_type: "clients",
        sensor_descr: "Associated Clients",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # Total Number of APs
      %{
        oid: "1.3.6.1.4.1.14179.2.1.1.1.12.0",
        sensor_type: "ap-count",
        sensor_descr: "Total APs",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # Active 802.11a Clients
      %{
        oid: "1.3.6.1.4.1.14179.2.1.1.1.2.0",
        sensor_type: "clients",
        sensor_descr: "5GHz Clients",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # Active 802.11b/g Clients
      %{
        oid: "1.3.6.1.4.1.14179.2.1.1.1.3.0",
        sensor_type: "clients",
        sensor_descr: "2.4GHz Clients",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # Total Rogue APs
      %{
        oid: "1.3.6.1.4.1.14179.2.1.1.1.14.0",
        sensor_type: "count",
        sensor_descr: "Rogue APs",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # Total Rogue Clients
      %{
        oid: "1.3.6.1.4.1.14179.2.1.1.1.15.0",
        sensor_type: "count",
        sensor_descr: "Rogue Clients",
        sensor_unit: "",
        sensor_divisor: 1
      }
    ]
  end
end
