# `SSCMEx.Device`

Device singleton wrapper for SG2002 chip.

The Device provides access to system information, sensors (including cameras),
and model metadata. This is a singleton - only one device instance exists.

## Example

    {:ok, device} = SSCMEx.Device.get_instance()
    {:ok, info} = SSCMEx.Device.get_info(device)
    IO.puts("Device: #{info.name}")

    {:ok, sensors} = SSCMEx.Device.get_sensors(device)
    for sensor <- sensors do
      IO.puts("Sensor: #{sensor.id} (#{sensor.type})")
    end

# `device_info`

```elixir
@type device_info() :: %{
  name: String.t(),
  id: String.t(),
  version: String.t(),
  boot_count: non_neg_integer()
}
```

# `model_info`

```elixir
@type model_info() :: %{
  id: non_neg_integer(),
  name: String.t(),
  type: atom(),
  size: non_neg_integer(),
  addr: non_neg_integer()
}
```

# `resource`

```elixir
@type resource() :: reference()
```

# `sensor`

```elixir
@type sensor() :: %{
  id: non_neg_integer(),
  type: :camera | :microphone | :imu | :unknown
}
```

# `t`

```elixir
@type t() :: %SSCMEx.Device{resource: resource()}
```

# `get_info`

```elixir
@spec get_info(t()) :: {:ok, device_info()} | {:error, term()}
```

Get device information (name, id, version, boot count).

Returns a map with:
- `:name` - Device name
- `:id` - Device unique identifier
- `:version` - Firmware/software version
- `:boot_count` - Number of times the device has booted

## Examples

    {:ok, info} = SSCMEx.Device.get_info(device)
    # => %{name: "reCamera", id: "abc123", version: "1.0.0", boot_count: 42}

# `get_instance`

```elixir
@spec get_instance() :: {:ok, t()} | {:error, term()}
```

Get the Device singleton instance.

This returns the same device instance on every call.

## Examples

    {:ok, device} = SSCMEx.Device.get_instance()

# `get_models`

```elixir
@spec get_models(t()) :: {:ok, [model_info()]} | {:error, term()}
```

Get list of available model metadata.

This returns information about models stored on the device, not
currently loaded models. Use `SSCMEx.Engine` to load and run models.

Returns a list of model info maps, each with:
- `:id` - Model ID
- `:name` - Model name
- `:type` - Model type atom
- `:size` - Model size in bytes
- `:addr` - Memory address (for embedded models)

## Examples

    {:ok, models} = SSCMEx.Device.get_models(device)
    for model <- models do
      IO.puts("Model: #{model.name} (id=#{model.id})")
    end

# `get_sensors`

```elixir
@spec get_sensors(t()) :: {:ok, [sensor()]} | {:error, term()}
```

Get list of available sensors.

Returns a list of sensor maps, each with:
- `:id` - Sensor ID
- `:type` - Sensor type (`:camera`, `:microphone`, `:imu`, or `:unknown`)

## Examples

    {:ok, sensors} = SSCMEx.Device.get_sensors(device)
    # => [%{id: 0, type: :camera}, ...]

    # Find camera sensor
    camera = Enum.find(sensors, &(&1.type == :camera))

---

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