Skip to content
Permalink
Browse files

Misc app cleanup and updates

* Add helpful Makefile task for fetching deps
* Remove dead nerves_hub code
* Update deps
  • Loading branch information...
ConnorRigby committed Jan 8, 2019
1 parent b62acb8 commit 86d18345382f7e8c51b6a5f8a4cfac1396d3e067
@@ -47,3 +47,9 @@ format:
echo formatting $$project ; \
cd $$project && mix format && cd .. ; \
done

deps:
@for project in $(PROJECTS) ; do \
echo Fetching deps: $$project ; \
cd $$project && mix deps.get && cd .. ; \
done
@@ -277,6 +277,11 @@ defmodule Farmbot.Firmware do
{:noreply, goto(state, :no_config)}
end

def handle_report({:report_no_config, []}, %{status: :boot} = state) do
Logger.info("ARDUINO STARTUP COMPLETE")
{:noreply, goto(state, :no_config)}
end

def handle_report({:report_debug_message, msg}, state) do
side_effects(state, :handle_debug_message, [msg])
{:noreply, state}
@@ -148,11 +148,16 @@ defmodule Farmbot.System.NervesHub do
}

change = DeviceCert.changeset(old, params)

case Repo.insert_or_update(change) do
{:ok, _} ->
:ok

{:error, reason} ->
Logger.error 1, "Failed to configure nerveshub due to database error: #{inspect(reason)}"
Farmbot.Logger.error(
1,
"Failed to configure nerveshub due to database error: #{inspect(reason)}"
)
end
end

@@ -1,6 +1,7 @@
defmodule Farmbot.TTYDetector do
use GenServer
require Logger
require Farmbot.Logger
alias Circuits.UART

import Farmbot.Config, only: [get_config_value: 3, update_config_value: 4]
@@ -62,10 +63,12 @@ defmodule Farmbot.TTYDetector do

def handle_continue([{name, _} | _rest], %{device: nil} = state)
when name in @expected_names do
Farmbot.Logger.debug(3, "Found tty: #{name}")
{:noreply, %{state | device: name}, 0}
end

def handle_continue([_ | rest], %{device: nil} = state) do
def handle_continue([{name, _} | rest], %{device: nil} = state) do
Farmbot.Logger.debug(3, "#{name} not a valid Farmbot tty")
{:noreply, state, {:continue, rest}}
end

@@ -72,16 +72,16 @@ defmodule Farmbot.OS.MixProject do
{:ranch, "~> 1.5", override: true},
{:cors_plug, "~> 2.0"},
{:phoenix_html, "~> 2.12"},
{:nerves_runtime, "~> 0.8"},
{:nerves_network, "~> 0.3"},
{:nerves_runtime, "~> 0.9"},
{:nerves_network, "~> 0.5"},
{:nerves_wpa_supplicant, "~> 0.3"},
{:nerves_time, "~> 0.2"},
{:nerves_hub, "~> 0.2"},
{:dhcp_server, "~> 0.6"},
{:mdns, "~> 1.0"},
{:nerves_firmware_ssh, "~> 0.3"},
{:nerves_init_gadget, "~> 0.5", only: :dev},
{:circuits_gpio, github: "elixir-circuits/circuits_gpio"},
{:circuits_gpio, "~> 0.1.0"},
{:toolshed, "~> 0.2"}
] ++ system(target)
end

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -51,7 +51,7 @@ defmodule Farmbot.System.NervesHubClient do

# Start the connection again.
{:ok, _pid} = Supervisor.start_child(supervisor, NervesHub.Supervisor)
Logger.debug(3, "OTA Service started")
Farmbot.Logger.debug(3, "OTA Service started")
:ok
end

@@ -97,7 +97,7 @@ defmodule Farmbot.System.NervesHubClient do

case NervesHub.HTTPClient.update() do
{:ok, %{"data" => %{"update_available" => false}}} ->
do_backup_strats()
nil

_ ->
Farmbot.Logger.info(1, "Applying OTA update")
@@ -106,19 +106,6 @@ defmodule Farmbot.System.NervesHubClient do
end
end

defp do_backup_strats do
case Farmbot.System.Updates.check_updates() do
{version, url} ->
Logger.busy(1, "Downloading fallback OTA")
Farmbot.System.Updates.download_and_apply_update({version, url})
:ok

_ ->
Logger.success(1, "Farmbot is up to date!")
nil
end
end

# Callback for NervesHub.Client
def update_available(args) do
GenServer.call(__MODULE__, {:update_available, args}, :infinity)
@@ -217,11 +204,11 @@ defmodule Farmbot.System.NervesHubClient do
:ok

{:ok, old_version} ->
Logger.info(1, "Updating FarmbotOS from #{old_version} to #{@current_version}")
Farmbot.Logger.info(1, "Updating FarmbotOS from #{old_version} to #{@current_version}")
do_post_update()

{:error, :enoent} ->
Logger.info(1, "Setting up FarmbotOS #{@current_version}")
Farmbot.Logger.info(1, "Setting up FarmbotOS #{@current_version}")

{:error, err} ->
raise err
@@ -236,7 +223,7 @@ defmodule Farmbot.System.NervesHubClient do
is_beta? = Farmbot.Project.branch() in ["beta", "staging"]

if is_beta? do
Logger.debug(1, "Forcing beta image arduino firmware flash.")
Farmbot.Logger.debug(1, "Forcing beta image arduino firmware flash.")
Update.force_update_firmware(hw)
else
Update.maybe_update_firmware(hw)

0 comments on commit 86d1834

Please sign in to comment.
You can’t perform that action at this time.