# `Dala.Setup.Setup`
[🔗](https://github.com/manhvu/dala/blob/main/lib/dala/setup/setup.ex#L16)

Runtime setup helpers for Bluetooth and WiFi functionality.

This module provides functions that can be called from your app's startup
code to ensure Bluetooth and WiFi are properly configured and available.

## Usage

In your app's `Dala.App` module or in a screen's `mount/3`:

    def mount(_params, _session, socket) do
      # Check and request permissions at startup
      Dala.Setup.ensure_bluetooth_permissions(socket)
      Dala.Setup.ensure_wifi_permissions(socket)

      {:ok, socket}
    end

## Platform Notes

- **iOS**: Requires usage descriptions in Info.plist (see `mix dala.setup_bluetooth_wifi`)
- **Android**: Requires permissions in AndroidManifest.xml and runtime permission requests

# `check_bluetooth`

```elixir
@spec check_bluetooth() :: {:ok, Dala.Bluetooth.state()} | {:error, term()}
```

Check if Bluetooth is available and properly configured.

Returns:
    {:ok, state} - Bluetooth is available, returns current state
    {:error, reason} - Bluetooth is not available or not configured

# `check_wifi`

```elixir
@spec check_wifi() :: {:ok, map()} | {:error, term()}
```

Check if WiFi is available and properly configured.

Returns:
    {:ok, info} - WiFi is available, returns current network info
    {:error, reason} - WiFi is not available or not configured

# `diagnostic`

```elixir
@spec diagnostic() :: map()
```

Run a full diagnostic of Bluetooth and WiFi setup.

Returns a map with the status of each component.

Example:

    Dala.Setup.diagnostic()
    # => %{
    #      bluetooth: %{available: true, state: :powered_on, permission: :granted},
    #      wifi: %{available: true, connected: true, ssid: "MyNetwork"}
    #    }

# `ensure_bluetooth_permissions`

```elixir
@spec ensure_bluetooth_permissions(Dala.Socket.t()) :: Dala.Socket.t()
```

Ensure Bluetooth permissions are granted.

On Android, this will trigger a runtime permission request if needed.
On iOS, this checks if the permission is granted (must be configured in Info.plist).

Returns the updated socket.

# `ensure_wifi_permissions`

```elixir
@spec ensure_wifi_permissions(Dala.Socket.t()) :: Dala.Socket.t()
```

Ensure WiFi permissions are granted (Android only).

On Android, WiFi scanning requires location permission.
On iOS, WiFi info access is limited and may not require explicit permission.

Returns the updated socket.

# `print_diagnostic`

Print a human-readable diagnostic report to the console.

Useful for debugging during development.

---

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