defmodule Towerops.Snmp.Profiles.Vendors.Deliberant do
  @moduledoc """
  Deliberant (LigoWave) device-specific SNMP handling.

  Supports Deliberant/LigoWave wireless equipment.

  Supported devices:
  - DLB APC Series
  - DLB APC 5M
  - DLB APC 2M
  - LigoPTP RapidFire
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

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

  # Deliberant/LigoWave Enterprise OID: 1.3.6.1.4.1.32761
  @model_oid "1.3.6.1.4.1.32761.1.1.1.0"

  @impl true
  def profile_names do
    ["deliberant"]
  end

  @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
    [
      # Receive Signal Level
      %{
        oid: "1.3.6.1.4.1.32761.3.5.1.2.1.6.1",
        sensor_type: "rssi",
        sensor_descr: "Signal Level",
        sensor_unit: "dBm",
        sensor_divisor: 1
      },
      # Noise Floor
      %{
        oid: "1.3.6.1.4.1.32761.3.5.1.2.1.7.1",
        sensor_type: "noise",
        sensor_descr: "Noise Floor",
        sensor_unit: "dBm",
        sensor_divisor: 1
      },
      # Transmit CCQ
      %{
        oid: "1.3.6.1.4.1.32761.3.5.1.2.1.8.1",
        sensor_type: "quality",
        sensor_descr: "Transmit CCQ",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # Connected Clients
      %{
        oid: "1.3.6.1.4.1.32761.3.5.1.2.1.9.1",
        sensor_type: "clients",
        sensor_descr: "Connected Clients",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # CPU Temperature
      %{
        oid: "1.3.6.1.4.1.32761.3.1.1.2.0",
        sensor_type: "temperature",
        sensor_descr: "CPU Temperature",
        sensor_unit: "C",
        sensor_divisor: 1
      }
    ]
  end
end
