MobDev.Device (mob_dev v0.5.3)

Copy Markdown View Source

Represents a connected or available device (physical or emulator/simulator).

Summary

Functions

Returns the short ID shown in mix mob.devices and accepted by --device.

Returns true if input identifies this device.

Returns the Erlang node name atom for a device.

True for devices that aren't a development emulator/simulator.

Derives a short identifier from a serial for use in node names.

Human-readable one-line summary.

Types

t()

@type t() :: %MobDev.Device{
  abi: term(),
  dist_port: term(),
  error: term(),
  host_ip: term(),
  name: term(),
  node: term(),
  platform: term(),
  sdk_level: term(),
  serial: term(),
  status: term(),
  type: term(),
  version: term()
}

Functions

display_id(device)

@spec display_id(t()) :: String.t()

Returns the short ID shown in mix mob.devices and accepted by --device.

  • Android: the serial as-is (emulator-5554, R5CW3089HVB)
  • iOS simulator: first 8 hex chars of the UDID, lowercased (78354490) — same prefix used in the node name
  • iOS physical: full UDID

match_id?(device, input)

@spec match_id?(t(), String.t()) :: boolean()

Returns true if input identifies this device.

Matches display_id/1 or the full serial, case-insensitively. Used by mix mob.deploy --device <id> to target a specific device.

node_name(device)

@spec node_name(t()) :: atom()

Returns the Erlang node name atom for a device.

  • Android (emulator/physical): <app>_android_<serial-stub>@127.0.0.1 (unique per device — Mac's EPMD is shared via adb-reverse so the suffix is required to avoid collisions when two phones run the same app)
  • iOS simulator: <app>_ios_<8-char-udid>@127.0.0.1 (unique per simulator, matches the name mob_beam.m builds using SIMULATOR_UDID)
  • iOS physical: <app>_ios@<device-ip> (mob_beam.m finds IP: USB > WiFi/LAN > Tailscale)

physical?(device)

@spec physical?(t()) :: boolean()

True for devices that aren't a development emulator/simulator.

Used as a safety predicate by destructive Mix tasks (mix mob.uninstall --all-devices) so that the broad-sweep flags only hit dev-disposable targets by default. Sweeping a personal iPhone or shared physical Android is opt-in via --all-physical or --device <id>.

iex> MobDev.Device.physical?(%MobDev.Device{type: :physical})
true

iex> MobDev.Device.physical?(%MobDev.Device{type: :emulator})
false

iex> MobDev.Device.physical?(%MobDev.Device{type: :simulator})
false

short_id(serial)

@spec short_id(String.t()) :: String.t()

Derives a short identifier from a serial for use in node names.

iex> MobDev.Device.short_id("emulator-5554") "5554"

iex> MobDev.Device.short_id("R5CW3089HVB") "HVBA" # last 4 chars, uppercased

iex> MobDev.Device.short_id("78354490-EF38-44D7-A437-DD941C20524D") "524D"

summary(d)

@spec summary(t()) :: String.t()

Human-readable one-line summary.