defmodule Towerops.Snmp.Profiles.Vendors.MoxaAwk do
  @moduledoc """
  Moxa AWK industrial wireless device-specific SNMP handling.

  Supports Moxa industrial wireless access points and clients.

  Supported devices:
  - AWK series (AWK-3131A, AWK-4131A, etc.)
  - AWK-1137C industrial wireless
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

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

  # Moxa Enterprise OID: 1.3.6.1.4.1.8691
  @model_oid "1.3.6.1.4.1.8691.15.34.1.1.0"

  @impl true
  def profile_names, do: ["moxa-awk"]

  @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
    [
      # Associated Clients
      %{
        oid: "1.3.6.1.4.1.8691.15.34.2.1.0",
        sensor_type: "clients",
        sensor_descr: "Associated Clients",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # CPU Utilization
      %{
        oid: "1.3.6.1.4.1.8691.15.34.3.1.0",
        sensor_type: "load",
        sensor_descr: "CPU Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # Memory Utilization
      %{
        oid: "1.3.6.1.4.1.8691.15.34.3.2.0",
        sensor_type: "load",
        sensor_descr: "Memory Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # Wireless Signal Strength
      %{
        oid: "1.3.6.1.4.1.8691.15.34.2.2.0",
        sensor_type: "rssi",
        sensor_descr: "Signal Strength",
        sensor_unit: "dBm",
        sensor_divisor: 1
      }
    ]
  end
end
