   alias Farmbot.System.ConfigStorage
   alias Nerves.Network
   alias Farmbot.Target.Network.Ntp
-  import Farmbot.Target.Network, only: [test_dns: 0]
+  import Farmbot.Target.Network, only: [test_dns: 0, test_dns: 1]
 
   def get_ip_addr(interface) do
     GenServer.call(:"#{__MODULE__}-#{interface}", :ip)

    {:ok, _} = Registry.register(Nerves.Udhcpc, interface, [])
    {:ok, _} = Registry.register(Nerves.WpaSupplicant, interface, [])
    Network.setup(interface, opts)
    {:ok, %{interface: interface, ip_address: nil, connected: false, not_found_timer: nil, ntp_timer: nil}}
  end

  def handle_call(:ip, _, state) do


    connected = match?({:ok, {:hostent, 'nerves-project.org', [], :inet, 4, _}}, test_dns())
    if connected do
      not_found_timer = cancel_timer(state.not_found_timer)
      dns_timer = restart_dns_timer(state.dns_timer, 45_000)
      {:noreply, %{state | dns_timer: dns_timer, ip_address: ip, connected: true, not_found_timer: not_found_timer, ntp_timer: ntp_timer}}
    else
      {:noreply, %{state | connected: false, ntp_timer: ntp_timer, ip_address: ip}}
    end
