diff --git a/firmware/mix.lock b/firmware/mix.lock index bfd2a0b..872ef09 100644 --- a/firmware/mix.lock +++ b/firmware/mix.lock @@ -39,6 +39,7 @@ "phoenix_ecto": {:hex, :phoenix_ecto, "4.0.0", "c43117a136e7399ea04ecaac73f8f23ee0ffe3e07acfcb8062fe5f4c9f0f6531", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_html": {:hex, :phoenix_html, "2.13.3", "850e292ff6e204257f5f9c4c54a8cb1f6fbc16ed53d360c2b780a3d0ba333867", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.2.1", "274a4b07c4adbdd7785d45a8b0bb57634d0b4f45b18d2c508b26c0344bd59b8f", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"}, + "phoenix_live_view": {:hex, :phoenix_live_view, "0.3.1", "5474c9e70db4e5bb23c1d1200d9a119ee76b927f3352554d31f5f31eaa1ea568", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.4.9", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.13.2", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm"}, "plug": {:hex, :plug, "1.8.2", "0bcce1daa420f189a6491f3940cc77ea7fb1919761175c9c3b59800d897440fc", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"}, "plug_cowboy": {:hex, :plug_cowboy, "2.1.0", "b75768153c3a8a9e8039d4b25bb9b14efbc58e9c4a6e6a270abff1cd30cbe320", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, diff --git a/morse/lib/morse/worker.ex b/morse/lib/morse/worker.ex index 467a200..c7b8831 100644 --- a/morse/lib/morse/worker.ex +++ b/morse/lib/morse/worker.ex @@ -3,6 +3,8 @@ defmodule Morse.Worker do Functions to control the signal lamp connected with GPIO. """ + @esrom_node :"esrom@esrom.lan" + @sleep_short 200 @sleep_delay 400 @sleep_long 700 @@ -60,10 +62,14 @@ defmodule Morse.Worker do |> String.to_charlist() end + # Communicate with a deployed esrom node, if running on a host. case Application.get_env(:ui, :target) do :host -> def toggle_lamp(state) do - :rpc.call(:"esrom@esrom.lan", Morse.Worker, :toggle_lamp, [state]) + # Check if the deployed esrom node is online. + if :pong == Node.ping(@esrom_node) do + :rpc.call(@esrom_node, Morse.Worker, :toggle_lamp, [state]) + end end _ -> diff --git a/ui/lib/ui/application.ex b/ui/lib/ui/application.ex index 9d75bba..cdef571 100644 --- a/ui/lib/ui/application.ex +++ b/ui/lib/ui/application.ex @@ -23,7 +23,7 @@ defmodule Ui.Application do def children(:host) do {:ok, _} = Node.start(:"host@0.0.0.0") Node.set_cookie(:tastycookie) - true = Node.connect(:"esrom@esrom.lan") + Node.connect(:"esrom@esrom.lan") [] end