# `NervesDiscovery`
[🔗](https://github.com/nerves-networking/nerves_discovery/blob/v0.1.3/lib/nerves_discovery.ex#L5)

Discover Nerves devices on the local network using mDNS.

Supports macOS (dns-sd), Linux (avahi), and other platforms (generic OTP).

# `options`

```elixir
@type options() :: [
  timeout: non_neg_integer(),
  method: :auto | :macos | :avahi | :generic
]
```

Options for `discover/1`

# `result`

```elixir
@type result() :: %{
  name: String.t(),
  hostname: String.t(),
  addresses: [:inet.ip_address()],
  ip: String.t() | nil,
  serial: String.t() | nil,
  version: String.t() | nil,
  product: String.t() | nil,
  description: String.t() | nil,
  platform: String.t() | nil,
  architecture: String.t() | nil,
  author: String.t() | nil,
  uuid: String.t() | nil
}
```

Information about each found Nerves device

* `:name` - name of the Nerves device
* `:hostname` - hostname of the device (usually the name with `.local`)
* `:addresses` - list of IP addresses of the device in `t::inet.ip_address/0` tuples
* `:ip` - (DEPRECATED) the first IP address of the device as a string - use `:addresses` instead
* `:serial` - the device's serial number if included in the advertisement
* `:version` - the device's firmware version if included in the advertisement
* `:product` - the device's product if included in the advertisement
* `:description` - the device's description if included in the advertisement
* `:platform` - the device's platform if included in the advertisement
* `:architecture` - the device's CPU architecture if included in the advertisement
* `:author` - the device's firmware author if included in the advertisement
* `:uuid` - the device's firmware UUID if included in the advertisement

# `discover`

```elixir
@spec discover(options()) :: [result()]
```

Discover Nerves devices on the local network.

Options:
* `:timeout` - timeout in milliseconds to wait for replies (default 5000 ms)
* `:method` - method to use for querying mDNS (`:auto`, `:macos`, `:avahi`, `:generic`)

## Examples

    iex> NervesDiscovery.discover()
    [%{name: "nerves-1234", hostname: "nerves-1234.local", addresses: [{192, 168, 1, 100}]}]

---

*Consult [api-reference.md](api-reference.md) for complete listing*
