Ifone.USB (Ifone v1.0.0)

View Source

USB interface discovery for iOS devices.

Provides functions to:

  • List NCM data interfaces for a device by serial number or USB location
  • Look up the USB serial number for a network interface

Summary

Functions

Gets the USB serial number for a network interface.

Lists all connected iOS devices and their NCM interfaces.

Lists NCM data interfaces for a USB device.

Types

interfaces_result()

@type interfaces_result() :: %{
  configuration: non_neg_integer(),
  interfaces: %{required(non_neg_integer()) => String.t() | nil}
}

Functions

get_serial_for_interface(interface_name)

@spec get_serial_for_interface(String.t()) :: {:ok, String.t()} | {:error, atom()}

Gets the USB serial number for a network interface.

Arguments

  • interface_name - Network interface name (e.g., "en16")

Returns

  • {:ok, serial} - The USB serial number
  • {:error, :not_found} - Interface not found or not a USB NCM interface

Examples

iex> Ifone.USB.get_serial_for_interface("en16")
{:ok, "00008101000000000000001E"}

list_devices()

@spec list_devices() ::
  {:ok, %{required(String.t()) => interfaces_result()}} | {:error, atom()}

Lists all connected iOS devices and their NCM interfaces.

Returns

  • {:ok, %{serial => %{configuration: N, interfaces: %{...}}}} - Map of every connected iOS device keyed by USB serial number
  • {:error, reason} - Other error

Examples

iex> Ifone.USB.list_devices()
{:ok, %{"00008101000000000000001E" => %{configuration: 5, interfaces: %{3 => "en16", 5 => "en17"}}}}

list_ncm_data_interfaces(identifier)

@spec list_ncm_data_interfaces(String.t() | non_neg_integer()) ::
  {:ok, interfaces_result()} | {:error, atom()}

Lists NCM data interfaces for a USB device.

Arguments

  • identifier - Either a USB serial number (string) or USB location ID (integer)

Returns

  • {:ok, %{configuration: N, interfaces: %{...}}} - Map with configuration and interfaces map
  • {:error, :not_found} - Device not found
  • {:error, reason} - Other error

Examples

iex> Ifone.USB.list_ncm_data_interfaces("00008101000000000000001E")
{:ok, %{configuration: 5, interfaces: %{3 => "en16", 5 => "en17"}}}

iex> Ifone.USB.list_ncm_data_interfaces(34603008)
{:ok, %{configuration: 5, interfaces: %{3 => "en16", 5 => "en17"}}}