defmodule Towerops.Snmp.Profiles.Vendors.Cnwave60 do
  @moduledoc """
  Cambium cnWave 60GHz device-specific SNMP handling.

  Supports Cambium cnWave 60GHz fixed wireless equipment.

  Supported devices:
  - cnWave V1000
  - cnWave V3000
  - cnWave V5000
  - cnWave E500/E600
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

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

  # Cambium cnWave 60 Enterprise OID: 1.3.6.1.4.1.17713.60
  @model_oid "1.3.6.1.4.1.17713.60.1.1.1.0"

  @impl true
  def profile_names do
    ["cnwave60"]
  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 (RSL)
      %{
        oid: "1.3.6.1.4.1.17713.60.12.1.0",
        sensor_type: "rssi",
        sensor_descr: "Receive Signal Level",
        sensor_unit: "dBm",
        sensor_divisor: 10
      },
      # Transmit Power
      %{
        oid: "1.3.6.1.4.1.17713.60.12.2.0",
        sensor_type: "power",
        sensor_descr: "Transmit Power",
        sensor_unit: "dBm",
        sensor_divisor: 10
      },
      # Signal to Noise Ratio
      %{
        oid: "1.3.6.1.4.1.17713.60.12.3.0",
        sensor_type: "snr",
        sensor_descr: "Signal to Noise Ratio",
        sensor_unit: "dB",
        sensor_divisor: 10
      },
      # Link Capacity
      %{
        oid: "1.3.6.1.4.1.17713.60.12.4.0",
        sensor_type: "capacity",
        sensor_descr: "Link Capacity",
        sensor_unit: "Mbps",
        sensor_divisor: 1
      },
      # System Temperature
      %{
        oid: "1.3.6.1.4.1.17713.60.13.1.0",
        sensor_type: "temperature",
        sensor_descr: "System Temperature",
        sensor_unit: "C",
        sensor_divisor: 1
      }
    ]
  end
end
