defmodule Towerops.Snmp.Profiles.Vendors.Pepwave do
  @moduledoc """
  Peplink/Pepwave device-specific SNMP handling.

  Supports Pepwave cellular routers and bonding devices.

  Supported devices:
  - Pepwave MAX series (HD2, HD4, Transit, etc.)
  - Pepwave Balance series
  - Peplink SpeedFusion appliances
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

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

  # Peplink Enterprise OID: 1.3.6.1.4.1.27662
  @model_oid "1.3.6.1.4.1.27662.1.1.1.0"

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

  @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
    [
      # WAN1 Signal Strength
      %{
        oid: "1.3.6.1.4.1.27662.3.1.1.1.0",
        sensor_type: "rssi",
        sensor_descr: "WAN1 Signal Strength",
        sensor_unit: "dBm",
        sensor_divisor: 1
      },
      # WAN1 Connection Status (1=connected)
      %{
        oid: "1.3.6.1.4.1.27662.3.1.2.1.0",
        sensor_type: "state",
        sensor_descr: "WAN1 Status",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # CPU Utilization
      %{
        oid: "1.3.6.1.4.1.27662.2.1.1.0",
        sensor_type: "load",
        sensor_descr: "CPU Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # Memory Utilization
      %{
        oid: "1.3.6.1.4.1.27662.2.1.2.0",
        sensor_type: "load",
        sensor_descr: "Memory Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      }
    ]
  end
end
