   @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,
       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

      {: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!"
      # _ -> state
    end
    {:noreply, new_state}
  end
  def handle_info({:EXIT, port, :normal}, state) do
    {:stop, :normal, %__MODULE__{state | port: nil}}

    {:ok, state}
  end

  def handle_call({:hci_receive, [timeout]}, from, s = %__MODULE__{messages: q, receiver: nil}) do
    case :queue.out(q) do
      {:empty, ^q} ->
        # set a timer to timeout to wait for a reply
        ref = Process.send_after(self, {:receive_timeout, from}, timeout)
        # return a noreply message
        {:noreply, %__MODULE__{s | receiver: from, timer: ref}}
        # if a package arrives and a timer is running, abort the timer
        # and send a reply
      {message, new_q} ->
        {:reply, message, %__MODULE__{s | messages: new_q}}
    end
  end
  # define a generic encoding and handling, it is not required to
  # differentiate between number of params here!
  def handle_call({func, args} = msg, from, s = %__MODULE__{port: port, calls: c})
