defmodule Towerops.Snmp.Profiles.Vendors.Cnpilot do
  @moduledoc """
  Cambium cnPilot device-specific SNMP handling.

  Mirrors LibreNMS/OS/Cnpilote.php for wireless sensor discovery.

  Supported devices:
  - cnPilot E-series (E400, E410, E425, E430, E500, E501, E502, E505, E510, E600, E601)
  - cnPilot R-series (R190, R195, R200, R201)
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

  alias Towerops.Snmp.Profiles.Vendors.Vendor

  @impl true
  def profile_names, do: ["cnpilot", "cnpilote", "cnpilotr"]

  @impl true
  def detect_hardware(_client_opts) do
    # cnPilot hardware detection is handled by YAML profile
    nil
  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 Clients (AP mode)
      %{
        oid: "1.3.6.1.4.1.17713.22.1.1.1.14.0",
        sensor_type: "clients",
        sensor_descr: "Clients",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # SNR (SM mode)
      %{
        oid: "1.3.6.1.4.1.17713.22.1.3.1.11.0",
        sensor_type: "snr",
        sensor_descr: "SNR",
        sensor_unit: "dB",
        sensor_divisor: 1
      },
      # Transmit Power
      %{
        oid: "1.3.6.1.4.1.17713.22.1.2.1.8.0",
        sensor_type: "power",
        sensor_descr: "Transmit Power",
        sensor_unit: "dBm",
        sensor_divisor: 1
      },
      # Noise Floor
      %{
        oid: "1.3.6.1.4.1.17713.22.1.2.1.16.0",
        sensor_type: "noise-floor",
        sensor_descr: "Radio Noise Floor",
        sensor_unit: "dBm",
        sensor_divisor: 1
      }
    ]
  end
end
