Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
RickCarlino committed Sep 18, 2020
2 parents 06f34c1 + 8688d32 commit 64eb092
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* Express v1.0 firmware updates.
* Fix bug where sequences would crash when a `coordinate` is passed as a variable (Thanks, @jsimmonds2).

# 11.0.1
# 11.1.0

* Bug fix related to usage of tools in MOVE block.
* Interim release to transition devices to new in-house OTA system

# 11.0.0

Expand Down
44 changes: 44 additions & 0 deletions farmbot_os/platform/target/sys_calls_check_update.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
defmodule FarmbotOS.SysCalls.CheckUpdate do
@moduledoc false
require FarmbotCore.Logger

alias FarmbotOS.{
UpdateSupport,
UpdateProgress
}

def check_update() do
if UpdateSupport.in_progress?() do
dont_check_update()
else
do_check_update()
end
end

def dont_check_update() do
{:error, "Installation already started. Please wait or reboot."}
end

def do_check_update() do
{:ok, progress_pid} = UpdateProgress.start_link([])
# Try to find the upgrade image URL (might be `nil`)
url_or_nil =
UpdateSupport.get_target()
|> UpdateSupport.download_meta_data()
|> Map.get("image_url", nil)

with :ok <- UpdateSupport.install_update(url_or_nil) do
UpdateProgress.set(progress_pid, 100)
FarmbotCeleryScript.SysCalls.reboot()
else
{:error, error} -> terminate(error, progress_pid)
error -> terminate(error, progress_pid)
end
end

def terminate(error, progress_pid) do
FarmbotCore.Logger.debug(3, "Upgrade halted: #{inspect(error)}")
UpdateProgress.set(progress_pid, 100)
{:error, error}
end
end

0 comments on commit 64eb092

Please sign in to comment.