 
     %{settings | count: new_count}
   end
-
-  defp set_up(port, log_path, sample_rate) do
-    with {:ok, settings} <- generate_settings(log_path, sample_rate),
-         :ok <- UART.open(uart_pid(), port, @open_options),
-         :ok <- UART.flush(uart_pid()),
-         :ok <- UART.write(uart_pid(), @on),
-         :ok <- UART.drain(uart_pid()),
-         :ok <- add_backend(log_path),
-         do: {:ok, settings}
-  end
-
-  defp teardown(settings) do
-    with :ok <- UART.write(uart_pid(), @off),
-         :ok <- UART.drain(uart_pid()),
-         :ok <- UART.close(uart_pid()),
-         do: remove_backend(settings.log_path)
-  end
 end

      {:reply, {:error, :eagain}, state}
    else
      log_path = Path.expand(Keyword.get(opts, :log_path, @default_log_path))
      sample_rate = Keyword.get(opts, :sample_rate, @default_sample_rate)

      case set_up(port, log_path, sample_rate) do
        {:ok, settings} ->
          new_state = Map.put(state, port, settings)
          {:reply, :ok, new_state}

  alias Nerves.UART

  @uart_pid UART

  @default_log_path Path.join([".", "log", "temperature_logger.log"])

  # 10 seconds
  @default_period 10

  # Texas Instruments
  @vendor_id 1105

  # MSP430G2 Rev.1.4
  @product_id 62514

  @baud 9600

  # 1 seconds
  @min_period 1

  @on "O"

  @off "F"

  @open_options [
    speed: @baud,
    active: true,
