       {:event, event_bin} when is_binary(event_bin) ->
         event = interprete_event(event_bin)
         Logger.debug "Received event #{inspect event}"
-        Logger.error "Do not know what to do with the event!"
+        if state.receiver == nil do
+          # enqueue the event
+          new_q = :queue.in(state.messages, event)
+          %__MODULE__{state | messages: new_q}
+        else
+          # send the event directly to the waiting process
+          Process.cancel_timer(state.timer)
+          GenServer.reply(state.receiver, {:ok, event})
+          %__MODULE__{state | timer: nil, receiver: nil}
+        end
       # _ -> state
     end
     {:noreply, new_state}
+  end
+  def handle_info({:receive_timeout, from}, state) do
+    # write a handle_info for the timeout
+    GenServer.reply(from, {:error, :timeout})
+    {:noreply, %__MODULE__{state | receiver: nil, timer: nil}}
   end
   def handle_info({:EXIT, port, :normal}, state) do
     {:stop, :normal, %__MODULE__{state | port: nil}}


  @type t :: %__MODULE__{
    port: nil | port,
    calls: %{required(reference) => any}
  }
  defstruct [port: nil, calls: %{}]

  def init([]) do
    Process.flag(:trap_exit, true)

  @doc "Sets the package type to EVENT and allows all event types"
  def default_filter() do
    <<@hci_event_package_type :: size(32)-unsigned-integer,
      0xff, 0xff, 0xff, 0xff,
      0xff, 0xff, 0xff, 0xff,
      0x00, 0x00, 0x00, 0x00>>
  end

  def hci_receive(timeout \\ 5_000) do
    GenServer.call(__MODULE__, {:hci_recieve, [timeout]})
  end


  @spec hci_send_command(binary) :: :ok
  def hci_send_command(message) when is_binary(message) do
