diff --git a/README.md b/README.md index c543059..6dc882f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ If you have found the source code before finding the geocache, consider it a hin Building: ```bash +export MIX_ENV=prod && export MIX_TARGET= cd ui/assets && npm install cd ../ && mix phx.digest cd ../firmware && mix deps.get @@ -20,12 +21,9 @@ mix firmware.burn # After inserting SD card ``` ## Setting morse code -Still have to find out how to correctly set secrets... so I have to do it manually now. - -```bash -ssh nerves.local -``` - +To set the morse code, create a new file under firmware/config, called secrets.exs: ```elixir -System.set_env("MORSE_MESSAGE", "...---...") +use Mix.Config + +config :morse, :morse_message, "...---..." ``` diff --git a/firmware/config/secrets.exs b/firmware/config/secrets.exs new file mode 100644 index 0000000..3c4c754 --- /dev/null +++ b/firmware/config/secrets.exs @@ -0,0 +1,3 @@ +use Mix.Config + +config :morse, :morse_message, "................" diff --git a/firmware/config/target.exs b/firmware/config/target.exs index d0b2ab0..f5c8fda 100644 --- a/firmware/config/target.exs +++ b/firmware/config/target.exs @@ -37,6 +37,10 @@ config :nerves_init_gadget, node_name: node_name, node_host: :mdns_domain +if File.exists?("config/secrets.exs") do + import_config "secrets.exs" +end + # Import target specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. # Uncomment to use target specific configurations diff --git a/morse/.gitignore b/morse/.gitignore index 2f07eac..d2ca612 100644 --- a/morse/.gitignore +++ b/morse/.gitignore @@ -21,4 +21,3 @@ erl_crash.dump # Ignore package tarball (built via "mix hex.build"). morse-*.tar - diff --git a/morse/lib/morse.ex b/morse/lib/morse.ex index e921788..3131b2c 100644 --- a/morse/lib/morse.ex +++ b/morse/lib/morse.ex @@ -21,12 +21,7 @@ defmodule Morse do """ def signal do - case System.get_env("MORSE_MESSAGE") do - nil -> - # Signal for SOS if the env variable wasn't found :) - signal("...---...") - message -> signal(message) - end + signal(Application.fetch_env!(:morse, :morse_message)) end def signal(symbols) do diff --git a/morse/mix.exs b/morse/mix.exs index 9232c4c..a4345bf 100644 --- a/morse/mix.exs +++ b/morse/mix.exs @@ -14,7 +14,8 @@ defmodule Morse.MixProject do # Run "mix help compile.app" to learn about applications. def application do [ - extra_applications: [:logger] + extra_applications: [:logger], + env: [morse_message: "...---..."] ] end diff --git a/ui/.gitignore b/ui/.gitignore index a52507c..2a3a776 100644 --- a/ui/.gitignore +++ b/ui/.gitignore @@ -32,3 +32,5 @@ npm-debug.log # we ignore priv/static. You may want to comment # this depending on your deployment strategy. /priv/static/ + +config/secrets.exs