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

  Supports Xirrus wireless arrays (now part of Cambium Networks).

  Supported devices:
  - XR Series (XR-520, XR-620, XR-2000, etc.)
  - XD Series
  - XN Series
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

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

  # Xirrus Enterprise OID: 1.3.6.1.4.1.21013
  @model_oid "1.3.6.1.4.1.21013.1.2.12.0"

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

  @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 Stations
      %{
        oid: "1.3.6.1.4.1.21013.1.2.24.1.0",
        sensor_type: "clients",
        sensor_descr: "Associated Stations",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # System CPU Usage
      %{
        oid: "1.3.6.1.4.1.21013.1.2.12.6.0",
        sensor_type: "load",
        sensor_descr: "CPU Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # System Memory Usage
      %{
        oid: "1.3.6.1.4.1.21013.1.2.12.7.0",
        sensor_type: "load",
        sensor_descr: "Memory Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # Radio Count
      %{
        oid: "1.3.6.1.4.1.21013.1.2.24.2.0",
        sensor_type: "count",
        sensor_descr: "Active Radios",
        sensor_unit: "",
        sensor_divisor: 1
      }
    ]
  end
end
