defmodule Towerops.Snmp.Profiles.Vendors.Stellar do
  @moduledoc """
  Alcatel-Lucent Enterprise Stellar Wireless device-specific SNMP handling.

  Supports ALE OmniAccess Stellar wireless access points.

  Supported devices:
  - OmniAccess Stellar AP series
  - AP1101/AP1201/AP1220/AP1230/AP1251
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

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

  # ALE Enterprise OID: 1.3.6.1.4.1.6486
  @model_oid "1.3.6.1.4.1.6486.802.1.1.1.1.1.0"

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

  @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 Clients
      %{
        oid: "1.3.6.1.4.1.6486.802.1.1.2.1.1.1.0",
        sensor_type: "clients",
        sensor_descr: "Associated Clients",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # CPU Utilization
      %{
        oid: "1.3.6.1.4.1.6486.802.1.1.1.2.1.0",
        sensor_type: "load",
        sensor_descr: "CPU Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # Memory Utilization
      %{
        oid: "1.3.6.1.4.1.6486.802.1.1.1.2.2.0",
        sensor_type: "load",
        sensor_descr: "Memory Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # 2.4GHz Radio Clients
      %{
        oid: "1.3.6.1.4.1.6486.802.1.1.2.1.2.1.0",
        sensor_type: "clients",
        sensor_descr: "2.4GHz Clients",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # 5GHz Radio Clients
      %{
        oid: "1.3.6.1.4.1.6486.802.1.1.2.1.2.2.0",
        sensor_type: "clients",
        sensor_descr: "5GHz Clients",
        sensor_unit: "",
        sensor_divisor: 1
      }
    ]
  end
end
