 
   @type t :: %__MODULE__{
     port: nil | port,
-    calls: %{required(reference) => any}
+    calls: %{required(reference) => any},
+    messages: :: :queue.t,
+    receiver: :: nil | pid,
+    timer: :: nil | ref
   }
-  defstruct [port: nil, calls: %{}]
+  defstruct [port: nil, calls: %{}, messages: :queue.new(), receiver: nil, timer: nil]
 
   def init([]) do
     Process.flag(:trap_exit, true)

    else
      {hci, []}
    end
      
    port = case Port.open({:spawn_executable, exec}, [{:args, args}, {:packet, 2}, :use_stdio, :binary]) do
      p when is_port(p) -> p
    end

  @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
