defmodule Towerops.Snmp.Profiles.Vendors.ZyxelWlc do
  @moduledoc """
  ZyXEL Wireless LAN Controller device-specific SNMP handling.

  Supports ZyXEL NXC series wireless controllers and NWA access points.

  Supported devices:
  - NXC2500/5500 Wireless Controllers
  - NWA series Access Points
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

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

  # ZyXEL Enterprise OID: 1.3.6.1.4.1.890
  @model_oid "1.3.6.1.4.1.890.1.6.1.1.2.0"

  @impl true
  def profile_names, do: ["zyxelwlc", "zyxelnwa"]

  @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 Wireless Clients
      %{
        oid: "1.3.6.1.4.1.890.1.6.22.1.3.1.0",
        sensor_type: "clients",
        sensor_descr: "Wireless Clients",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # Connected APs
      %{
        oid: "1.3.6.1.4.1.890.1.6.22.1.3.2.0",
        sensor_type: "ap-count",
        sensor_descr: "Connected APs",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # Active Sessions
      %{
        oid: "1.3.6.1.4.1.890.1.6.22.1.3.3.0",
        sensor_type: "count",
        sensor_descr: "Active Sessions",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # CPU Utilization
      %{
        oid: "1.3.6.1.4.1.890.1.6.22.1.4.1.0",
        sensor_type: "load",
        sensor_descr: "CPU Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # Memory Utilization
      %{
        oid: "1.3.6.1.4.1.890.1.6.22.1.4.2.0",
        sensor_type: "load",
        sensor_descr: "Memory Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      }
    ]
  end
end
