   def hci_bind_raw(dev_id) do
     GenServer.call(__MODULE__, {:hci_bind_raw, [dev_id]})
   end
-  
+
   @spec hci_send_command(binary) :: :ok
   def hci_send_command(message) when is_binary(message) do
     GenServer.call(__MODULE__, {:hci_send_command, [message]})
   end
-  def hci_send_command(ogf, ocf, params) 
+  def hci_send_command(ogf, ocf, params)
   when is_binary(params) and byte_size(params) < 256 and ogf < 64 and ocf < 1024 do
     package = create_command(ogf, ocf, params)
     hci_send_command(package)
-  end  
-  
-  def create_command(ogf, ocf, params) 
+  end
+
+  def create_command(ogf, ocf, params)
   when is_binary(params) and byte_size(params) < 256 and ogf < 64 and ocf < 1024 do
-    opcode_bin = << 
+    opcode_bin = <<
       ogf :: unsigned-integer-size(6),
       ocf :: unsigned-integer-size(10)
     >>

defmodule Bluetooth.HCI do
  @moduledoc """
  HCI interface implemented as a port. 

  ## Port Protocol

  The functions are encoded as a tuple with the function name as `atom` and the parameters as an
  (possibly empty) list. All Port functions are prefixed with `hci_`. The call of function `foo(x)`
  would thus transferred as `{:hci_foo, [x]}`. Since the port communication is asynchronous by 
  nature and to prevent locks inside the gen server, we use an asynchronous reply and remember 
  pending calls inside the gen server. To identify a pending call, a `reference` is created and 
  passed to the port. Every replying message must contain this reference. Therefore the message
  send to the port is `{ref, {:hci_foo, [x]}}` and the answer is `{ref, return_val}`.
  """

  def foo(x) do
    GenServer.call(__MODULE__, {:foo, [x]})
  end

  ###################################################################
  #
  # GenServer Callbacks
  #
  ###################################################################

  def stop() do
    GenServer.stop(__MODULE__, :normal)
