     GenServer.call(ble, :controllers)
   end
 
-  defstruct [:driver, :monitor_ref, :controllers]
+  defstruct [:driver, :monitor_ref, controllers: %{}, devices: %{}]
 
   defmodule Controller do
     @moduledoc """

      discoverable: false]
  end

  def init([driver]) do
    ref = Process.monitor(driver)
    Driver.attach(driver, self())
    {:ok, %__MODULE__{driver: driver, monitor_ref: ref, controllers: %{}}}
  end

  def handle_call(:controllers, _from, state = %__MODULE__{controllers: cs}) do

    end)
    {:noreply, final_state}
  end
  def handle_info({:new, {:device, id, name}}, state = %__MODULE__{devices: ds}) do
    d = %Device{id: id, name: name}
    Logger.info "New controller: #{inspect d}"
    {:noreply, %__MODULE__{state | devices: Map.put(ds, id, d)}}
  end
  def handle_info({:change, {:device, id, attributes}}, state = %__MODULE__{devices: ds}) do
    case Map.get(ds, id) do
      nil -> Logger.error("Unknown device #{id}")
      d ->
        new_d = struct!(d, attributes)
        {:noreply,  %__MODULE__{state | devices: Map.put(ds, id, new_d)}}
    end
  end
  def handle_info({:new, {:controller, id, name}}, state = %__MODULE__{controllers: cs}) do
    c = %Controller{id: id, name: name}
    Logger.info "New controller: #{inspect c}"
    {:noreply, %__MODULE__{state | controllers: Map.put(cs, id, c)}}
  end
  def handle_info({:change, {:controller, id, attributes}}, state = %__MODULE__{controllers: cs}) do
    case Map.get(cs, id) do
      nil -> Logger.error("Unknown controller #{id}")
      c ->
        new_c = struct!(c, attributes)
        {:noreply,  %__MODULE__{state | controllers: Map.put(cs, id, new_c)}}
    end
  end
