This commit is contained in:
Pim Kunis 2022-10-09 08:09:42 +02:00
parent ba8f072d23
commit 2c935df494
110 changed files with 1350 additions and 8011 deletions

View file

@ -1,2 +0,0 @@
erlang 22.0.4
elixir 1.10.0-otp-22

View file

@ -1,38 +0,0 @@
# esrom
Source code for [the esrom geocache](https://www.geocaching.com/geocache/GC7C642_esrom).
If you have found the source code before finding the geocache, consider it a hint :)
![built with nerves](https://nerves-project.org/images/badge/nerves-badge_100x52_black.png)
## Setup (for future me)
- elixir 1.9.0-otp-22
- erlang 22.0.4
- nodejs 12.6.0
- [Nerves](https://hexdocs.pm/nerves/installation.html)
- [Phoenix](https://hexdocs.pm/phoenix/installation.html)
## dev
- Run `epmd` in the background so it can function as a distributed system with the pi.
- Run `cd ui && mix deps.get` to install Elixir dependencies.
- Run `cd assets && npm install && cd ..` to install npm dependencies.
- Run `mix phx.server` to start the server.
## Building
```bash
cd ui/ && export SECRET_KEY_BASE="$(mix phx.gen.secret | tail -1)"
export MIX_ENV=prod && export MIX_TARGET=<device>
cd assets && npm install && node node_modules/webpack/bin/webpack.js --mode production
cd ../ && mix phx.digest
cd ../firmware && mix deps.get
mix firmware
mix firmware.burn # After inserting SD card
```
## Setting morse code
To set the morse code, create a new file under firmware/config, called secrets.exs:
```elixir
use Mix.Config
config :morse, :morse_message, "...---..."
```

View file

@ -0,0 +1,8 @@
# Used by "mix format"
[
inputs: [
"{mix,.formatter}.exs",
"{config,lib,test}/**/*.{ex,exs}",
"rootfs_overlay/etc/iex.exs"
]
]

View file

@ -7,7 +7,7 @@
# The directory Mix downloads your dependencies sources to. # The directory Mix downloads your dependencies sources to.
/deps/ /deps/
# Where 3rd-party dependencies like ExDoc output generated docs. # Where third-party dependencies like ExDoc output generated docs.
/doc/ /doc/
# Ignore .fetch files in case you like to edit your project deps locally. # Ignore .fetch files in case you like to edit your project deps locally.

View file

@ -1,4 +1,4 @@
# Firmware # EisromFirmware
**TODO: Add description** **TODO: Add description**
@ -21,7 +21,7 @@ To start your Nerves app:
`MIX_TARGET=my_target`. For example, `MIX_TARGET=rpi3` `MIX_TARGET=my_target`. For example, `MIX_TARGET=rpi3`
* Install dependencies with `mix deps.get` * Install dependencies with `mix deps.get`
* Create firmware with `mix firmware` * Create firmware with `mix firmware`
* Burn to an SD card with `mix firmware.burn` * Burn to an SD card with `mix burn`
## Learn more ## Learn more

View file

@ -0,0 +1,35 @@
# This file is responsible for configuring your application and its
# dependencies.
#
# This configuration file is loaded before any dependency and is restricted to
# this project.
import Config
# Enable the Nerves integration with Mix
Application.start(:nerves_bootstrap)
config :eisrom_firmware, target: Mix.target()
# Customize non-Elixir parts of the firmware. See
# https://hexdocs.pm/nerves/advanced-configuration.html for details.
config :nerves, :firmware, rootfs_overlay: "rootfs_overlay"
# Set the SOURCE_DATE_EPOCH date for reproducible builds.
# See https://reproducible-builds.org/docs/source-date-epoch/ for more information
config :nerves, source_date_epoch: "1665154132"
# Use Ringlogger as the logger backend and remove :console.
# See https://hexdocs.pm/ring_logger/readme.html for more information on
# configuring ring_logger.
config :logger, backends: [RingLogger]
if Mix.target() == :host do
import_config "host.exs"
else
import_config "target.exs"
end
import_config "secrets.exs"

View file

@ -0,0 +1,4 @@
import Config
# Add configuration that is only needed when running on the host here.
import_config "../../eisrom_ui/config/dev.exs"

View file

@ -0,0 +1,93 @@
import Config
# Use shoehorn to start the main application. See the shoehorn
# library documentation for more control in ordering how OTP
# applications are started and handling failures.
config :shoehorn, init: [:nerves_runtime, :nerves_pack]
# Erlinit can be configured without a rootfs_overlay. See
# https://github.com/nerves-project/erlinit/ for more information on
# configuring erlinit.
config :nerves,
erlinit: [
hostname_pattern: "nerves-%s"
]
# Configure the device for SSH IEx prompt access and firmware updates
#
# * See https://hexdocs.pm/nerves_ssh/readme.html for general SSH configuration
# * See https://hexdocs.pm/ssh_subsystem_fwup/readme.html for firmware updates
keys =
[
Path.join([System.user_home!(), ".ssh", "id_rsa.pub"]),
Path.join([System.user_home!(), ".ssh", "id_ecdsa.pub"]),
Path.join([System.user_home!(), ".ssh", "id_ed25519.pub"])
]
|> Enum.filter(&File.exists?/1)
if keys == [],
do:
Mix.raise("""
No SSH public keys found in ~/.ssh. An ssh authorized key is needed to
log into the Nerves device and update firmware on it using ssh.
See your project's config.exs for this error message.
""")
config :nerves_ssh,
authorized_keys: Enum.map(keys, &File.read!/1)
# Configure the network using vintage_net
# See https://github.com/nerves-networking/vintage_net for more information
config :vintage_net,
regulatory_domain: "US",
config: [
{"usb0", %{type: VintageNetDirect}},
{"eth0",
%{
type: VintageNetEthernet,
ipv4: %{method: :dhcp}
}},
{"wlan0", %{type: VintageNetWiFi}}
]
config :mdns_lite,
# The `hosts` key specifies what hostnames mdns_lite advertises. `:hostname`
# advertises the device's hostname.local. For the official Nerves systems, this
# is "nerves-<4 digit serial#>.local". The `"nerves"` host causes mdns_lite
# to advertise "nerves.local" for convenience. If more than one Nerves device
# is on the network, it is recommended to delete "nerves" from the list
# because otherwise any of the devices may respond to nerves.local leading to
# unpredictable behavior.
hosts: [:hostname, "nerves"],
ttl: 120,
# Advertise the following services over mDNS.
services: [
%{
protocol: "ssh",
transport: "tcp",
port: 22
},
%{
protocol: "sftp-ssh",
transport: "tcp",
port: 22
},
%{
protocol: "epmd",
transport: "tcp",
port: 4369
}
]
# 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
# import_config "#{Mix.target()}.exs"
import_config "../../eisrom_ui/config/prod.exs"

View file

@ -1,6 +1,6 @@
defmodule Firmware do defmodule EisromFirmware do
@moduledoc """ @moduledoc """
Documentation for Firmware. Documentation for EisromFirmware.
""" """
@doc """ @doc """
@ -8,7 +8,7 @@ defmodule Firmware do
## Examples ## Examples
iex> Firmware.hello iex> EisromFirmware.hello
:world :world
""" """

View file

@ -0,0 +1,44 @@
defmodule EisromFirmware.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: EisromFirmware.Supervisor]
children =
[
# Children for all targets
# Starts a worker by calling: EisromFirmware.Worker.start_link(arg)
# {EisromFirmware.Worker, arg},
] ++ children(target())
Supervisor.start_link(children, opts)
end
# List all child processes to be supervised
def children(:host) do
[
# Children that only run on the host
# Starts a worker by calling: EisromFirmware.Worker.start_link(arg)
# {EisromFirmware.Worker, arg},
]
end
def children(_target) do
[
# Children for all targets except host
# Starts a worker by calling: EisromFirmware.Worker.start_link(arg)
# {EisromFirmware.Worker, arg},
]
end
def target() do
Application.get_env(:eisrom_firmware, :target)
end
end

72
eisrom_firmware/mix.exs Normal file
View file

@ -0,0 +1,72 @@
defmodule EisromFirmware.MixProject do
use Mix.Project
@app :eisrom_firmware
@version "0.1.0"
@all_targets [:rpi, :rpi0, :rpi2, :rpi3, :rpi3a, :rpi4, :bbb, :osd32mp1, :x86_64, :grisp2]
def project do
[
app: @app,
version: @version,
elixir: "~> 1.11",
archives: [nerves_bootstrap: "~> 1.11"],
start_permanent: Mix.env() == :prod,
deps: deps(),
releases: [{@app, release()}],
preferred_cli_target: [run: :host, test: :host]
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
mod: {EisromFirmware.Application, []},
extra_applications: [:logger, :runtime_tools]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
# Dependencies for all targets
{:nerves, "~> 1.7.16 or ~> 1.8.0", runtime: false},
{:shoehorn, "~> 0.9.1"},
{:ring_logger, "~> 0.8.5"},
{:toolshed, "~> 0.2.26"},
# Dependencies for all targets except :host
{:nerves_runtime, "~> 0.13.0", targets: @all_targets},
{:nerves_pack, "~> 0.7.0", targets: @all_targets},
{:eisrom_ui, path: "../eisrom_ui", targets: @all_targets, env: Mix.env()},
# Dependencies for specific targets
# NOTE: It's generally low risk and recommended to follow minor version
# bumps to Nerves systems. Since these include Linux kernel and Erlang
# version updates, please review their release notes in case
# changes to your application are needed.
{:nerves_system_rpi, "~> 1.19", runtime: false, targets: :rpi},
{:nerves_system_rpi0, "~> 1.19", runtime: false, targets: :rpi0},
{:nerves_system_rpi2, "~> 1.19", runtime: false, targets: :rpi2},
{:nerves_system_rpi3, "~> 1.19", runtime: false, targets: :rpi3},
{:nerves_system_rpi3a, "~> 1.19", runtime: false, targets: :rpi3a},
{:nerves_system_rpi4, "~> 1.19", runtime: false, targets: :rpi4},
{:nerves_system_bbb, "~> 2.14", runtime: false, targets: :bbb},
{:nerves_system_osd32mp1, "~> 0.10", runtime: false, targets: :osd32mp1},
{:nerves_system_x86_64, "~> 1.19", runtime: false, targets: :x86_64},
{:nerves_system_grisp2, "~> 0.3", runtime: false, targets: :grisp2}
]
end
def release do
[
overwrite: true,
# Erlang distribution is not started automatically.
# See https://hexdocs.pm/nerves_pack/readme.html#erlang-distribution
cookie: "#{@app}_cookie",
include_erts: &Nerves.Release.erts/0,
steps: [&Nerves.Release.init/1, :assemble],
strip_beams: Mix.env() == :prod or [keep: ["Docs"]]
]
end
end

65
eisrom_firmware/mix.lock Normal file
View file

@ -0,0 +1,65 @@
%{
"beam_notify": {:hex, :beam_notify, "1.0.0", "5b8dceed76f8ac4acadf4d2915ac85b98c42bb17d7dd58253c7593d2a0deedbd", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "a80331f6c3596918affa408d91ed634106b7ae71b3fc589432363aca68378362"},
"castore": {:hex, :castore, "0.1.18", "deb5b9ab02400561b6f5708f3e7660fc35ca2d51bfc6a940d2f513f89c2975fc", [:mix], [], "hexpm", "61bbaf6452b782ef80b33cdb45701afbcf0a918a45ebe7e73f1130d661e66a06"},
"circular_buffer": {:hex, :circular_buffer, "0.4.1", "477f370fd8cfe1787b0a1bade6208bbd274b34f1610e41f1180ba756a7679839", [:mix], [], "hexpm", "633ef2e059dde0d7b89bbab13b1da9d04c6685e80e68fbdf41282d4fae746b72"},
"cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
"cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
"elixir_make": {:hex, :elixir_make, "0.6.3", "bc07d53221216838d79e03a8019d0839786703129599e9619f4ab74c8c096eac", [:mix], [], "hexpm", "f5cbd651c5678bcaabdbb7857658ee106b12509cd976c2c2fca99688e1daf716"},
"esbuild": {:hex, :esbuild, "0.5.0", "d5bb08ff049d7880ee3609ed5c4b864bd2f46445ea40b16b4acead724fb4c4a3", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "f183a0b332d963c4cfaf585477695ea59eef9a6f2204fdd0efa00e099694ffe5"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"gen_state_machine": {:hex, :gen_state_machine, "3.0.0", "1e57f86a494e5c6b14137ebef26a7eb342b3b0070c7135f2d6768ed3f6b6cdff", [:mix], [], "hexpm", "0a59652574bebceb7309f6b749d2a41b45fdeda8dbb4da0791e355dd19f0ed15"},
"jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"},
"mdns_lite": {:hex, :mdns_lite, "0.8.6", "cafdcde5be222d151342629637ec3178619090e4668a57c8cfdc67d970d0b268", [:mix], [{:vintage_net, "~> 0.7", [hex: :vintage_net, repo: "hexpm", optional: true]}], "hexpm", "7b6fcf2d45be8823492b77380f69510327d3a98f6b17d403f355daf31e1ac961"},
"mime": {:hex, :mime, "2.0.3", "3676436d3d1f7b81b5a2d2bd8405f412c677558c81b1c92be58c00562bb59095", [:mix], [], "hexpm", "27a30bf0db44d25eecba73755acf4068cbfe26a4372f9eb3e4ea3a45956bff6b"},
"muontrap": {:hex, :muontrap, "1.0.0", "53a05c37f71cc5070aaa0858a774ae1f500160b7186a70565521a14ef7843c5a", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "0d3cd6e335986f9c2af1b61f583375b0f0d91cea95b7ec7bc720f330b4dc9b49"},
"nerves": {:hex, :nerves, "1.8.0", "2735cda2037985411ede03c59937e9cb222f8990d5540e1a0e1ec77db96618cc", [:make, :mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "878c82ec079cf75ea48229ce802d2c2edf24bee60c17c33e477b18f83f7a49e1"},
"nerves_logging": {:hex, :nerves_logging, "0.2.0", "4099b860f41a0171ff49fbc1e86ee0ce4576c24c1cf318a0fd0bf227355e8c12", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "07cfb9fe9d21b908da51b81a1ced858288c68519204aca7aa2c1fcd531d5e059"},
"nerves_motd": {:hex, :nerves_motd, "0.1.7", "33d7818767a2065ad793e30d9508c8c7076e17746baf89778f637a0e47ca291b", [:mix], [{:nerves_runtime, "~> 0.8", [hex: :nerves_runtime, repo: "hexpm", optional: false]}, {:nerves_time_zones, "~> 0.1", [hex: :nerves_time_zones, repo: "hexpm", optional: true]}], "hexpm", "8d631eb9407ca206d5d6d8e68dfba88aea635a25c150e5a00a2fa78791349bb7"},
"nerves_pack": {:hex, :nerves_pack, "0.7.0", "bc93834edbb9321b180dc104440070279eb02159359715f68f770e74ed86a582", [:mix], [{:mdns_lite, "~> 0.8", [hex: :mdns_lite, repo: "hexpm", optional: false]}, {:nerves_motd, "~> 0.1", [hex: :nerves_motd, repo: "hexpm", optional: false]}, {:nerves_runtime, "~> 0.6", [hex: :nerves_runtime, repo: "hexpm", optional: false]}, {:nerves_ssh, "~> 0.3", [hex: :nerves_ssh, repo: "hexpm", optional: false]}, {:nerves_time, "~> 0.3", [hex: :nerves_time, repo: "hexpm", optional: false]}, {:ring_logger, "~> 0.8", [hex: :ring_logger, repo: "hexpm", optional: false]}, {:vintage_net, "~> 0.10", [hex: :vintage_net, repo: "hexpm", optional: false]}, {:vintage_net_direct, "~> 0.10", [hex: :vintage_net_direct, repo: "hexpm", optional: false]}, {:vintage_net_ethernet, "~> 0.10", [hex: :vintage_net_ethernet, repo: "hexpm", optional: false]}, {:vintage_net_wifi, "~> 0.10", [hex: :vintage_net_wifi, repo: "hexpm", optional: false]}], "hexpm", "65a43ea78c10938c87c72d6d42a82c05e831e9a95a0ea26fe8f9d848c009cc57"},
"nerves_runtime": {:hex, :nerves_runtime, "0.13.1", "b5f87675d8e07a4e5f29c2fe2f7d026467a84f604962dc0f4fb381f3928438f7", [:mix], [{:nerves_logging, "~> 0.2.0", [hex: :nerves_logging, repo: "hexpm", optional: false]}, {:nerves_uevent, "~> 0.1.0", [hex: :nerves_uevent, repo: "hexpm", optional: false]}, {:uboot_env, "~> 1.0 or ~> 0.3.0", [hex: :uboot_env, repo: "hexpm", optional: false]}], "hexpm", "bd7f41fb43d29bbfa32c164ac3cead3da04244a84108c2bcc70bbd130a5839ae"},
"nerves_ssh": {:hex, :nerves_ssh, "0.4.1", "d20ee21b0b4b3624051cb24af11dac08879ae24bccb9f7ba845b6877666bfb6e", [:mix], [{:nerves_runtime, "~> 0.11", [hex: :nerves_runtime, repo: "hexpm", optional: false]}, {:ssh_subsystem_fwup, "~> 0.5", [hex: :ssh_subsystem_fwup, repo: "hexpm", optional: false]}], "hexpm", "45105baad45d576459c8caf1057d1fbc4c2fd119e989368e7a43fda52eb7e900"},
"nerves_system_bbb": {:hex, :nerves_system_bbb, "2.15.3", "aa6ffbaaaab8e59882cc29e0fea6a3660b50efe352d0510d5e1cc14f93a3e8a4", [:mix], [{:nerves, "~> 1.6.0 or ~> 1.7.15 or ~> 1.8", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.20.6", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_toolchain_armv7_nerves_linux_gnueabihf, "~> 1.6.0", [hex: :nerves_toolchain_armv7_nerves_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "d5ef86ac4a507b97cb64cdc1a5f9157bfe10a102abcc884b4d8b98127cf99486"},
"nerves_system_br": {:hex, :nerves_system_br, "1.20.6", "6622ee4230e968a95716105518bbd7ef569ac82b44e9114cf6a78a1ddca65455", [:mix], [], "hexpm", "ca187a129288156a1e5fb4f34d393aeddb7580091f41aefb82dbed6a4e378748"},
"nerves_system_grisp2": {:hex, :nerves_system_grisp2, "0.4.2", "8723f94e941c618e460076726cf6c4144567b84afc930301fa4b03f9bda8aebd", [:mix], [{:nerves, "~> 1.6.0 or ~> 1.7.15 or ~> 1.8", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.20.6", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_toolchain_armv7_nerves_linux_gnueabihf, "~> 1.6.0", [hex: :nerves_toolchain_armv7_nerves_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "cc139f6e6cb14b04de856f5e728e19d60a1a02a71b3820a42f899bf618a1157e"},
"nerves_system_osd32mp1": {:hex, :nerves_system_osd32mp1, "0.11.2", "d88457fa56340e2d7f9af22d4941bbc5de95a3d13099156fd6910b42bc14c735", [:mix], [{:nerves, "~> 1.6.0 or ~> 1.7.15 or ~> 1.8", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.20.6", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_toolchain_armv7_nerves_linux_gnueabihf, "~> 1.6.0", [hex: :nerves_toolchain_armv7_nerves_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "7805c00a100cf9423f64a3538ee56a2a82ef5632858dc3c0d1bdc3ab5c1fe2ac"},
"nerves_system_rpi": {:hex, :nerves_system_rpi, "1.20.2", "e131f874a477121ceb5ce3793d2a14121a5e9dfff6472d4165001b526fc18637", [:mix], [{:nerves, "~> 1.6.0 or ~> 1.7.15 or ~> 1.8", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.20.6", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_toolchain_armv6_nerves_linux_gnueabihf, "~> 1.6.0", [hex: :nerves_toolchain_armv6_nerves_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "328df7f460524fa674ac1714f381cbf3688c1e2f4fc0f0aa8202673a10695dc9"},
"nerves_system_rpi0": {:hex, :nerves_system_rpi0, "1.20.2", "0b98ef4099ddbb9cf548bae388f30226e97d342799daa65ffe4af4cf256ecbde", [:mix], [{:nerves, "~> 1.6.0 or ~> 1.7.15 or ~> 1.8", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.20.6", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_toolchain_armv6_nerves_linux_gnueabihf, "~> 1.6.0", [hex: :nerves_toolchain_armv6_nerves_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "ce6732d352f1d3ff4b4e23fe203a6ecfb4855a6a501a37557a8b79ae85cb385d"},
"nerves_system_rpi2": {:hex, :nerves_system_rpi2, "1.20.2", "fde25fa9667779787a74f543404fc09fa4b610894f0b0debc22fed8ad92eeba6", [:mix], [{:nerves, "~> 1.5.4 or ~> 1.6.0 or ~> 1.7.15 or ~> 1.8", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.20.6", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_toolchain_armv7_nerves_linux_gnueabihf, "~> 1.6.0", [hex: :nerves_toolchain_armv7_nerves_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "dbeca8737e159d9263bc420f16b660b0ea20795ae012c8ecc825cabf965971ab"},
"nerves_system_rpi3": {:hex, :nerves_system_rpi3, "1.20.2", "3a43b8333b733e7a9f19b2eaa984bd0f33aa1fca6b8595f4a439eb32482c5ed0", [:mix], [{:nerves, "~> 1.5.4 or ~> 1.6.0 or ~> 1.7.15 or ~> 1.8", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.20.6", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_toolchain_armv7_nerves_linux_gnueabihf, "~> 1.6.0", [hex: :nerves_toolchain_armv7_nerves_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "0c3b1526e99e84ed05ddaadab629aeed172f40ed06ef59960a3f199a1f9deb8f"},
"nerves_system_rpi3a": {:hex, :nerves_system_rpi3a, "1.20.2", "cb66ac8be1d0d79c52a78606ca140ef245244068fe98a5e9fd3dbfb9dc252465", [:mix], [{:nerves, "~> 1.5.4 or ~> 1.6.0 or ~> 1.7.15 or ~> 1.8", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.20.6", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_toolchain_armv7_nerves_linux_gnueabihf, "~> 1.6.0", [hex: :nerves_toolchain_armv7_nerves_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "257074d7eae6109dff6f6a7b2e484c46863cd58321ace790b4564b0ee19dcc07"},
"nerves_system_rpi4": {:hex, :nerves_system_rpi4, "1.20.2", "db83189a20bbdb439311308c0a344587ddc9b8f295041b458a558bda0922a694", [:mix], [{:nerves, "~> 1.5.4 or ~> 1.6.0 or ~> 1.7.15 or ~> 1.8", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.20.6", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_toolchain_aarch64_nerves_linux_gnu, "~> 1.6.0", [hex: :nerves_toolchain_aarch64_nerves_linux_gnu, repo: "hexpm", optional: false]}], "hexpm", "942333f7754d9b9a34372cf0f1c92a195cb6fae120770569da64dc65f52ebf68"},
"nerves_system_x86_64": {:hex, :nerves_system_x86_64, "1.20.3", "c011857f01d8659f9aef2f3ef344651f115347fd07a260ff9f5e280a52017155", [:mix], [{:nerves, "~> 1.5.4 or ~> 1.6.0 or ~> 1.7.15 or ~> 1.8", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.20.6", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_toolchain_x86_64_nerves_linux_musl, "~> 1.6.0", [hex: :nerves_toolchain_x86_64_nerves_linux_musl, repo: "hexpm", optional: false]}], "hexpm", "2fc00a72c0f1c61b858c20e006caa32cbc1e26a769f20aabb1444817819251c2"},
"nerves_time": {:hex, :nerves_time, "0.4.5", "038d6754421b20f21eff8918f006d26a2c3e7440dc6954c4164030427e9228d8", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:muontrap, "~> 1.0 or ~> 0.5", [hex: :muontrap, repo: "hexpm", optional: false]}], "hexpm", "cbe4593bb63ba6fd66f09c321f558037ca9de6ad8b93bc0dc77c4209c4734a88"},
"nerves_toolchain_aarch64_nerves_linux_gnu": {:hex, :nerves_toolchain_aarch64_nerves_linux_gnu, "1.6.0", "70817bd3c1d30d8948265f67d371bd4f02be69def0fbfcdffdd5181508e4c6f5", [:mix], [{:nerves, "~> 1.4", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_toolchain_ctng, "~> 1.9.0", [hex: :nerves_toolchain_ctng, repo: "hexpm", optional: false]}], "hexpm", "4a6fc659031148fb46f9eaf020515078963f01cfba0f8881a4eeb6cd036254a5"},
"nerves_toolchain_armv6_nerves_linux_gnueabihf": {:hex, :nerves_toolchain_armv6_nerves_linux_gnueabihf, "1.6.0", "626364370f2016b8d9137187ab48fbeb611e0d1677a44b4e7af5a02b42d4dd05", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_toolchain_ctng, "~> 1.9.0", [hex: :nerves_toolchain_ctng, repo: "hexpm", optional: false]}], "hexpm", "b8d27844ca4b1cb70c5989a150287f5a0fea33dee8e5ddff716ff7883efee0c4"},
"nerves_toolchain_armv7_nerves_linux_gnueabihf": {:hex, :nerves_toolchain_armv7_nerves_linux_gnueabihf, "1.6.0", "ed30bc7cb1853ef306a185cf2b24f9e8fb296dbc2839bf303302b46288c2cbd3", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_toolchain_ctng, "~> 1.9.0", [hex: :nerves_toolchain_ctng, repo: "hexpm", optional: false]}], "hexpm", "ed68e12550f9b5ed4eda1b291a3ef2368a99a3fd89690a207b8f9cd576861109"},
"nerves_toolchain_ctng": {:hex, :nerves_toolchain_ctng, "1.9.0", "fe53615624763eeb5db6a5022a4fb5de8622405f314dba089b17fbf35d502529", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}], "hexpm", "80b0225108960a8433a81c0fbb5df1508b4015c222077361895e1b3a2f7c42d1"},
"nerves_toolchain_x86_64_nerves_linux_musl": {:hex, :nerves_toolchain_x86_64_nerves_linux_musl, "1.6.0", "b4993f4dd639b70eb4b5fedf2165cfd4647053781aa45de97008a173e9f36cb3", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_toolchain_ctng, "~> 1.9.0", [hex: :nerves_toolchain_ctng, repo: "hexpm", optional: false]}], "hexpm", "289711847c1b0ff5ab64e8be38840f60a6e527bb2c3213a5e2bb9a973a570532"},
"nerves_uevent": {:hex, :nerves_uevent, "0.1.0", "651111a46be9a238560cbf7946989fc500e5f33d7035fd9ea7194d07a281bc19", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:property_table, "~> 0.2.0", [hex: :property_table, repo: "hexpm", optional: false]}], "hexpm", "cb0b1993c3ed3cefadbcdb534e910af0661f95c3445796ce8a7c8be3519a4e5f"},
"one_dhcpd": {:hex, :one_dhcpd, "2.0.1", "d2d24dcb29f84072f3666580e4fb297ce8533c61667f78c94643ad37d586f7b8", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "1558faedeb560bb358827864bec3e862eadfcbaa589f9c2d457f49c833db704c"},
"phoenix": {:hex, :phoenix, "1.6.13", "5b3152907afdb8d3a6cdafb4b149e8aa7aabbf1422fd9f7ef4c2a67ead57d24a", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "13d8806c31176e2066da4df2d7443c144211305c506ed110ad4044335b90171d"},
"phoenix_html": {:hex, :phoenix_html, "3.2.0", "1c1219d4b6cb22ac72f12f73dc5fad6c7563104d083f711c3fcd8551a1f4ae11", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "36ec97ba56d25c0136ef1992c37957e4246b649d620958a1f9fa86165f8bc54f"},
"phoenix_live_dashboard": {:hex, :phoenix_live_dashboard, "0.6.5", "1495bb014be12c9a9252eca04b9af54246f6b5c1e4cd1f30210cd00ec540cf8e", [:mix], [{:ecto, "~> 3.6.2 or ~> 3.7", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_mysql_extras, "~> 0.3", [hex: :ecto_mysql_extras, repo: "hexpm", optional: true]}, {:ecto_psql_extras, "~> 0.7", [hex: :ecto_psql_extras, repo: "hexpm", optional: true]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.17.7", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "ef4fa50dd78364409039c99cf6f98ab5209b4c5f8796c17f4db118324f0db852"},
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.3", "3a53772a6118d5679bf50fc1670505a290e32a1d195df9e069d8c53ab040c054", [: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", "766796676e5f558dbae5d1bdb066849673e956005e3730dfd5affd7a6da4abac"},
"phoenix_live_view": {:hex, :phoenix_live_view, "0.17.12", "74f4c0ad02d7deac2d04f50b52827a5efdc5c6e7fac5cede145f5f0e4183aedc", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.0 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.1", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "af6dd5e0aac16ff43571f527a8e0616d62cb80b10eb87aac82170243e50d99c8"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.1", "ba04e489ef03763bf28a17eb2eaddc2c20c6d217e2150a61e3298b0f4c2012b5", [:mix], [], "hexpm", "81367c6d1eea5878ad726be80808eb5a787a23dee699f96e72b1109c57cdd8d9"},
"phoenix_view": {:hex, :phoenix_view, "1.1.2", "1b82764a065fb41051637872c7bd07ed2fdb6f5c3bd89684d4dca6e10115c95a", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "7ae90ad27b09091266f6adbb61e1d2516a7c3d7062c6789d46a7554ec40f3a56"},
"plug": {:hex, :plug, "1.13.6", "187beb6b67c6cec50503e940f0434ea4692b19384d47e5fdfd701e93cadb4cc2", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "02b9c6b9955bce92c829f31d6284bf53c591ca63c4fb9ff81dfd0418667a34ff"},
"plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"},
"plug_crypto": {:hex, :plug_crypto, "1.2.3", "8f77d13aeb32bfd9e654cb68f0af517b371fb34c56c9f2b58fe3df1235c1251a", [:mix], [], "hexpm", "b5672099c6ad5c202c45f5a403f21a3411247f164e4a8fab056e5cd8a290f4a2"},
"property_table": {:hex, :property_table, "0.2.1", "88ab40972036d150eb8b09c4f1aea7834e5970225afbd787fa5533a80399ef8f", [:mix], [], "hexpm", "eb67da5228c649bdc19647a3bbff721d1d1df893e8d342be7255a6819813164b"},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"ring_logger": {:hex, :ring_logger, "0.8.5", "e807c5b29993cb5e64afbcff41a5a7c44c44f3293ee17dd6601439b408f48903", [:mix], [{:circular_buffer, "~> 0.4.0", [hex: :circular_buffer, repo: "hexpm", optional: false]}], "hexpm", "1a29ec270ed9961b1b999a378bce5ea47d4ea9f3a3b8c53c67c05562b897e31b"},
"shoehorn": {:hex, :shoehorn, "0.9.1", "8e12670024c2942e3c2fdd27cd5a034ee0337ee7c25c37b3ebc2ad482de67199", [:mix], [], "hexpm", "fccd040ac22de9b3cc111bbf78a363832c7210010a3fff4a550fbb2f10de0692"},
"ssh_subsystem_fwup": {:hex, :ssh_subsystem_fwup, "0.6.1", "628f8e3795de5f1d0e7b3b55de4248ab0a77ab4c47e3cd282f1dda89d6354a9f", [:mix], [], "hexpm", "babdae337f2dc011ab5478662b4ec850650d7acfb165662ae47f6f0ce8892499"},
"telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"},
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"},
"telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"},
"toolshed": {:hex, :toolshed, "0.2.26", "1e50c8ff6da61d304dd59598667c403ff0873319afb73f40efda775a49e00c93", [:mix], [{:nerves_runtime, "~> 0.8", [hex: :nerves_runtime, repo: "hexpm", optional: true]}], "hexpm", "7e92e03731ed39c1261d5baf58576a771d116e2e3461db35cdd45c78a6b999b2"},
"uboot_env": {:hex, :uboot_env, "1.0.1", "b0e136cf1a561412ff7db23ed2b6df18d7c7ce2fc59941afd851006788a67f3d", [:mix], [], "hexpm", "b6d4fe7c24123be57ed946c48116d23173e37944bc945b8b76fccc437909c60b"},
"vintage_net": {:hex, :vintage_net, "0.12.2", "2e6b858f0f4000476758a20ac72aefff899ec25adeb0233f284547b59f287dc4", [:make, :mix], [{:beam_notify, "~> 1.0 or ~> 0.2.0", [hex: :beam_notify, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:gen_state_machine, "~> 2.0.0 or ~> 2.1.0 or ~> 3.0.0", [hex: :gen_state_machine, repo: "hexpm", optional: false]}, {:muontrap, "~> 1.0 or ~> 0.5.1 or ~> 0.6.0", [hex: :muontrap, repo: "hexpm", optional: false]}, {:property_table, "~> 0.2.0", [hex: :property_table, repo: "hexpm", optional: false]}], "hexpm", "8a3a55a5797d89daae591ede297e99883b29ce3e148d605f0e61fbb58203569b"},
"vintage_net_direct": {:hex, :vintage_net_direct, "0.10.6", "a5e9ba836a6e384a3beebb65b3ed9d977d3487e1bd8889851bfe301b3a300393", [:mix], [{:one_dhcpd, "~> 2.0 or ~> 1.0 or ~> 0.2.3", [hex: :one_dhcpd, repo: "hexpm", optional: false]}, {:vintage_net, "~> 0.9.1 or ~> 0.10.0 or ~> 0.11.0 or ~> 0.12.0", [hex: :vintage_net, repo: "hexpm", optional: false]}], "hexpm", "f3927a0c1aea864eb70beb6267c7f2fa404985305ad3919cca737038920c9d35"},
"vintage_net_ethernet": {:hex, :vintage_net_ethernet, "0.11.0", "3610e7961f0b595043b196e80e0eed86acf38098b65bfcb7fad1d30911bd2313", [:mix], [{:vintage_net, "~> 0.12.0", [hex: :vintage_net, repo: "hexpm", optional: false]}], "hexpm", "7720c70dee5955610a82ef9c4f6a57ae93f0fb717f29547c6a709a1baec8ac23"},
"vintage_net_wifi": {:hex, :vintage_net_wifi, "0.11.1", "efbcc0eff75acfd0982044028dd6c8a73fc89a06fea9db6d64f10ae7dff8441c", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:vintage_net, "~> 0.12.0", [hex: :vintage_net, repo: "hexpm", optional: false]}], "hexpm", "7a40fd6d8a23eda1b866e14a2c5442f9a02ad5c02a2ee4f5ce08d86c7ce2632b"},
}

View file

@ -1,10 +1,16 @@
## Add custom options here ## Customize flags given to the VM: http://erlang.org/doc/man/erl.html
## Distributed Erlang Options ## Do not set -name or -sname here. Prefer configuring them at runtime
## The cookie needs to be configured prior to vm boot for ## Configure -setcookie in the mix.exs release section or at runtime
## for read only filesystem.
-setcookie <%= @release.options[:cookie] %> ## Number of dirty schedulers doing IO work (file, sockets, and others)
##+SDio 5
## Increase number of concurrent ports/sockets
##+Q 65536
## Tweak GC to run more often
##-env ERL_FULLSWEEP_AFTER 10
## Use Ctrl-C to interrupt the current shell rather than invoking the emulator's ## Use Ctrl-C to interrupt the current shell rather than invoking the emulator's
## break handler and possibly exiting the VM. ## break handler and possibly exiting the VM.
@ -18,6 +24,12 @@
## See http://erlang.org/doc/system_principles/system_principles.html#code-loading-strategy ## See http://erlang.org/doc/system_principles/system_principles.html#code-loading-strategy
-mode embedded -mode embedded
## Disable scheduler busy wait to reduce idle CPU usage and avoid delaying
## other OS processes. See http://erlang.org/doc/man/erl.html#+sbwt
+sbwt none
+sbwtdcpu none
+sbwtdio none
## Save the shell history between reboots ## Save the shell history between reboots
## See http://erlang.org/doc/man/kernel_app.html for additional options ## See http://erlang.org/doc/man/kernel_app.html for additional options
-kernel shell_history enabled -kernel shell_history enabled

View file

@ -0,0 +1,4 @@
NervesMOTD.print()
# Add Toolshed helpers to the IEx session
use Toolshed

View file

@ -0,0 +1,8 @@
defmodule EisromFirmwareTest do
use ExUnit.Case
doctest EisromFirmware
test "greets the world" do
assert EisromFirmware.hello() == :world
end
end

View file

@ -20,17 +20,16 @@ erl_crash.dump
*.ez *.ez
# Ignore package tarball (built via "mix hex.build"). # Ignore package tarball (built via "mix hex.build").
ui-*.tar eisrom_ui-*.tar
# If NPM crashes, it generates a log, let's ignore it too. # Ignore assets that are produced by build tools.
/priv/static/assets/
# Ignore digested assets cache.
/priv/static/cache_manifest.json
# In case you use Node.js/npm, you want to ignore these.
npm-debug.log npm-debug.log
# The directory NPM downloads your dependencies sources to.
/assets/node_modules/ /assets/node_modules/
# Since we are building assets from assets/,
# we ignore priv/static. You may want to comment
# this depending on your deployment strategy.
/priv/static/
config/secrets.exs config/secrets.exs

View file

@ -1,10 +1,9 @@
# Ui # EisromUi
To start your Phoenix server: To start your Phoenix server:
* Install dependencies with `mix deps.get` * Install dependencies with `mix deps.get`
* Install Node.js dependencies with `cd assets && npm install` * Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server`
* Start Phoenix endpoint with `mix phx.server`
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
@ -12,8 +11,8 @@ Ready to run in production? Please [check our deployment guides](https://hexdocs
## Learn more ## Learn more
* Official website: http://www.phoenixframework.org/ * Official website: https://www.phoenixframework.org/
* Guides: https://hexdocs.pm/phoenix/overview.html * Guides: https://hexdocs.pm/phoenix/overview.html
* Docs: https://hexdocs.pm/phoenix * Docs: https://hexdocs.pm/phoenix
* Mailing list: http://groups.google.com/group/phoenix-talk * Forum: https://elixirforum.com/c/phoenix-forum
* Source: https://github.com/phoenixframework/phoenix * Source: https://github.com/phoenixframework/phoenix

View file

@ -0,0 +1,45 @@
// We import the CSS which is extracted to its own file by esbuild.
// Remove this line if you add a your own CSS build pipeline (e.g postcss).
import "../css/app.css"
// If you want to use Phoenix channels, run `mix help phx.gen.channel`
// to get started and then uncomment the line below.
// import "./user_socket.js"
// You can include dependencies in two ways.
//
// The simplest option is to put them in assets/vendor and
// import them using relative paths:
//
// import "../vendor/some-package.js"
//
// Alternatively, you can `npm install some-package --prefix assets` and import
// them using a path starting with the package name:
//
// import "some-package"
//
// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
import "phoenix_html"
// Establish Phoenix Socket and LiveView configuration.
import {Socket} from "phoenix"
import {LiveSocket} from "phoenix_live_view"
import topbar from "../vendor/topbar"
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}})
// Show progress bar on live navigation and form submits
topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"})
window.addEventListener("phx:page-loading-start", info => topbar.show())
window.addEventListener("phx:page-loading-stop", info => topbar.hide())
// connect if there are any LiveViews on the page
liveSocket.connect()
// expose liveSocket on window for web console debug logs and latency simulation:
// >> liveSocket.enableDebug()
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
// >> liveSocket.disableLatencySim()
window.liveSocket = liveSocket

157
eisrom_ui/assets/vendor/topbar.js vendored Normal file
View file

@ -0,0 +1,157 @@
/**
* @license MIT
* topbar 1.0.0, 2021-01-06
* https://buunguyen.github.io/topbar
* Copyright (c) 2021 Buu Nguyen
*/
(function (window, document) {
"use strict";
// https://gist.github.com/paulirish/1579671
(function () {
var lastTime = 0;
var vendors = ["ms", "moz", "webkit", "o"];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame =
window[vendors[x] + "RequestAnimationFrame"];
window.cancelAnimationFrame =
window[vendors[x] + "CancelAnimationFrame"] ||
window[vendors[x] + "CancelRequestAnimationFrame"];
}
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function (callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function () {
callback(currTime + timeToCall);
}, timeToCall);
lastTime = currTime + timeToCall;
return id;
};
if (!window.cancelAnimationFrame)
window.cancelAnimationFrame = function (id) {
clearTimeout(id);
};
})();
var canvas,
progressTimerId,
fadeTimerId,
currentProgress,
showing,
addEvent = function (elem, type, handler) {
if (elem.addEventListener) elem.addEventListener(type, handler, false);
else if (elem.attachEvent) elem.attachEvent("on" + type, handler);
else elem["on" + type] = handler;
},
options = {
autoRun: true,
barThickness: 3,
barColors: {
0: "rgba(26, 188, 156, .9)",
".25": "rgba(52, 152, 219, .9)",
".50": "rgba(241, 196, 15, .9)",
".75": "rgba(230, 126, 34, .9)",
"1.0": "rgba(211, 84, 0, .9)",
},
shadowBlur: 10,
shadowColor: "rgba(0, 0, 0, .6)",
className: null,
},
repaint = function () {
canvas.width = window.innerWidth;
canvas.height = options.barThickness * 5; // need space for shadow
var ctx = canvas.getContext("2d");
ctx.shadowBlur = options.shadowBlur;
ctx.shadowColor = options.shadowColor;
var lineGradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
for (var stop in options.barColors)
lineGradient.addColorStop(stop, options.barColors[stop]);
ctx.lineWidth = options.barThickness;
ctx.beginPath();
ctx.moveTo(0, options.barThickness / 2);
ctx.lineTo(
Math.ceil(currentProgress * canvas.width),
options.barThickness / 2
);
ctx.strokeStyle = lineGradient;
ctx.stroke();
},
createCanvas = function () {
canvas = document.createElement("canvas");
var style = canvas.style;
style.position = "fixed";
style.top = style.left = style.right = style.margin = style.padding = 0;
style.zIndex = 100001;
style.display = "none";
if (options.className) canvas.classList.add(options.className);
document.body.appendChild(canvas);
addEvent(window, "resize", repaint);
},
topbar = {
config: function (opts) {
for (var key in opts)
if (options.hasOwnProperty(key)) options[key] = opts[key];
},
show: function () {
if (showing) return;
showing = true;
if (fadeTimerId !== null) window.cancelAnimationFrame(fadeTimerId);
if (!canvas) createCanvas();
canvas.style.opacity = 1;
canvas.style.display = "block";
topbar.progress(0);
if (options.autoRun) {
(function loop() {
progressTimerId = window.requestAnimationFrame(loop);
topbar.progress(
"+" + 0.05 * Math.pow(1 - Math.sqrt(currentProgress), 2)
);
})();
}
},
progress: function (to) {
if (typeof to === "undefined") return currentProgress;
if (typeof to === "string") {
to =
(to.indexOf("+") >= 0 || to.indexOf("-") >= 0
? currentProgress
: 0) + parseFloat(to);
}
currentProgress = to > 1 ? 1 : to;
repaint();
return currentProgress;
},
hide: function () {
if (!showing) return;
showing = false;
if (progressTimerId != null) {
window.cancelAnimationFrame(progressTimerId);
progressTimerId = null;
}
(function loop() {
if (topbar.progress("+.1") >= 1) {
canvas.style.opacity -= 0.05;
if (canvas.style.opacity <= 0.05) {
canvas.style.display = "none";
fadeTimerId = null;
return;
}
}
fadeTimerId = window.requestAnimationFrame(loop);
})();
},
};
if (typeof module === "object" && typeof module.exports === "object") {
module.exports = topbar;
} else if (typeof define === "function" && define.amd) {
define(function () {
return topbar;
});
} else {
this.topbar = topbar;
}
}.call(this, window, document));

View file

@ -0,0 +1,38 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
# General application configuration
import Config
# Configures the endpoint
config :eisrom_ui, EisromUiWeb.Endpoint,
url: [host: "localhost"],
render_errors: [view: EisromUiWeb.ErrorView, accepts: ~w(html json), layout: false],
pubsub_server: EisromUi.PubSub,
live_view: [signing_salt: "v9/5caL4"]
# Configure esbuild (the version is required)
config :esbuild,
version: "0.14.29",
default: [
args:
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]
# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"
import_config "secrets.exs"

64
eisrom_ui/config/dev.exs Normal file
View file

@ -0,0 +1,64 @@
import Config
# For development, we disable any cache and enable
# debugging and code reloading.
#
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with esbuild to bundle .js and .css sources.
config :eisrom_ui, EisromUiWeb.Endpoint,
# Binding to loopback ipv4 address prevents access from other machines.
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
http: [ip: {127, 0, 0, 1}, port: 4000],
check_origin: false,
code_reloader: true,
debug_errors: true,
secret_key_base: "LD6C7sMtLQTWwvx6BkMEGME1K0xZvBSK7t3LQJzBPLLgma1URsBwK37I+gooshlu",
watchers: [
# Start the esbuild watcher by calling Esbuild.install_and_run(:default, args)
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]}
]
# ## SSL Support
#
# In order to use HTTPS in development, a self-signed
# certificate can be generated by running the following
# Mix task:
#
# mix phx.gen.cert
#
# Note that this task requires Erlang/OTP 20 or later.
# Run `mix help phx.gen.cert` for more information.
#
# The `http:` config above can be replaced with:
#
# https: [
# port: 4001,
# cipher_suite: :strong,
# keyfile: "priv/cert/selfsigned_key.pem",
# certfile: "priv/cert/selfsigned.pem"
# ],
#
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.
# Watch static and templates for browser reloading.
config :eisrom_ui, EisromUiWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"lib/eisrom_ui_web/(live|views)/.*(ex)$",
~r"lib/eisrom_ui_web/templates/.*(eex)$"
]
]
# Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n"
# Set a higher stacktrace during development. Avoid configuring such
# in production as building large stacktraces may be expensive.
config :phoenix, :stacktrace_depth, 20
# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime

62
eisrom_ui/config/prod.exs Normal file
View file

@ -0,0 +1,62 @@
import Config
# For production, don't forget to configure the url host
# to something meaningful, Phoenix uses this information
# when generating URLs.
#
# Note we also include the path to a cache manifest
# containing the digested version of static files. This manifest is generated by the `mix phx.digest` task,
# which you should run after static files are built and
# before starting your production server.
#config :eisrom_ui, EisromUiWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
# Do not print debug messages in production
config :logger, level: :info
# ## SSL Support
#
# To get SSL working, you will need to add the `https` key
# to the previous section and set your `:url` port to 443:
#
# config :eisrom_ui, EisromUiWeb.Endpoint,
# ...,
# url: [host: "example.com", port: 443],
# https: [
# ...,
# port: 443,
# cipher_suite: :strong,
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
# ]
#
# The `cipher_suite` is set to `:strong` to support only the
# latest and more secure SSL ciphers. This means old browsers
# and clients may not be supported. You can set it to
# `:compatible` for wider support.
#
# `:keyfile` and `:certfile` expect an absolute path to the key
# and cert in disk or a relative path inside priv, for example
# "priv/ssl/server.key". For all supported SSL configuration
# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
#
# We also recommend setting `force_ssl` in your endpoint, ensuring
# no data is ever sent via http, always redirecting to https:
#
# config :eisrom_ui, EisromUiWeb.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.
config :eisrom_ui, EisromUiWeb.Endpoint,
url: [host: "geokunis2.nl"],
http: [port: 80],
cache_static_manifest: "priv/static/cache_manifest.json", # needed?
secret_key_base: "ains9m4Gu88kI1PO13704I+MkKUNaiap/+ppJa80NotAs62bA62/9cQI/eeH2TNf",
live_view: [signing_salt: "v9/5caL4"],
check_origin: false,
render_errors: [view: EisromUiWeb.ErrorView, accepts: ~w(html json), layout: false],
pubsub_server: EisromUi.PubSub,
server: true,
code_reloader: false
config :phoenix, :json_library, Jason

View file

@ -0,0 +1,50 @@
import Config
# config/runtime.exs is executed for all environments, including
# during releases. It is executed after compilation and before the
# system starts, so it is typically used to load production configuration
# and secrets from environment variables or elsewhere. Do not define
# any compile-time configuration in here, as it won't be applied.
# The block below contains prod specific runtime configuration.
# ## Using releases
#
# If you use `mix release`, you need to explicitly enable the server
# by passing the PHX_SERVER=true when you start it:
#
# PHX_SERVER=true bin/eisrom_ui start
#
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
# script that automatically sets the env var above.
if System.get_env("PHX_SERVER") do
config :eisrom_ui, EisromUiWeb.Endpoint, server: true
end
if config_env() == :prod do
# The secret key base is used to sign/encrypt cookies and other secrets.
# A default value is used in config/dev.exs and config/test.exs but you
# want to use a different value for prod and you most likely don't want
# to check this value into version control, so we use an environment
# variable instead.
secret_key_base =
System.get_env("SECRET_KEY_BASE") ||
raise """
environment variable SECRET_KEY_BASE is missing.
You can generate one by calling: mix phx.gen.secret
"""
host = System.get_env("PHX_HOST") || "example.com"
port = String.to_integer(System.get_env("PORT") || "4000")
config :eisrom_ui, EisromUiWeb.Endpoint,
url: [host: host, port: 443, scheme: "https"],
http: [
# Enable IPv6 and bind on all interfaces.
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
# See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: port
],
secret_key_base: secret_key_base
end

14
eisrom_ui/config/test.exs Normal file
View file

@ -0,0 +1,14 @@
import Config
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :eisrom_ui, EisromUiWeb.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 4002],
secret_key_base: "dfppXvxP1vXJhlk0z7H3jC/wqrQw/SUXVXG9RmTPIHPHSqBh/L8KllPViDdiEfay",
server: false
# Print only warnings and errors during test
config :logger, level: :warn
# Initialize plugs at runtime for faster test compilation
config :phoenix, :plug_init_mode, :runtime

View file

@ -1,6 +1,6 @@
defmodule Ui do defmodule EisromUi do
@moduledoc """ @moduledoc """
Ui keeps the contexts that define your domain EisromUi keeps the contexts that define your domain
and business logic. and business logic.
Contexts are also responsible for managing your data, regardless Contexts are also responsible for managing your data, regardless

View file

@ -0,0 +1,33 @@
defmodule EisromUi.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
children = [
# Start the Telemetry supervisor
EisromUiWeb.Telemetry,
# Start the PubSub system
{Phoenix.PubSub, name: EisromUi.PubSub},
# Start the Endpoint (http/https)
EisromUiWeb.Endpoint,
{Eisrom.Morse.Server, nil}
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: EisromUi.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
@impl true
def config_change(changed, _new, removed) do
EisromUiWeb.Endpoint.config_change(changed, removed)
:ok
end
end

View file

@ -1,4 +1,4 @@
defmodule Morse.Server do defmodule Eisrom.Morse.Server do
use GenServer use GenServer
def start_link(_) do def start_link(_) do
@ -29,11 +29,12 @@ defmodule Morse.Server do
@impl true @impl true
def handle_call(:toggle, _from, {pid, _progress}) do def handle_call(:toggle, _from, {pid, _progress}) do
if worker_alive?(pid) do if worker_alive?(pid) do
Morse.Worker.kill(pid) EisromUi.Morse.Worker.kill(pid)
apply(pubsub(), :broadcast, [Ui.PubSub, "morse_progress", 0]) Phoenix.PubSub.broadcast(EisromUi.PubSub, "morse_progress", 0)
# apply(pubsub(), :broadcast, [EisromUi.PubSub, "morse_progress", 0])
{:reply, :ok, {nil, 0}} {:reply, :ok, {nil, 0}}
else else
pid = spawn(&Morse.Worker.signal/0) pid = spawn(&Eisrom.Morse.Worker.signal/0)
{:reply, :ok, {pid, 0}} {:reply, :ok, {pid, 0}}
end end
end end
@ -48,12 +49,13 @@ defmodule Morse.Server do
@impl true @impl true
def handle_cast({:progress, new_progress}, {pid, _progress}) do def handle_cast({:progress, new_progress}, {pid, _progress}) do
apply(pubsub(), :broadcast, [Ui.PubSub, "morse_progress", new_progress]) Phoenix.PubSub.broadcast(EiromUi.PubSub, "morse_progress", new_progress)
# apply(pubsub(), :broadcast, [EisromUi.PubSub, "morse_progress", new_progress])
{:noreply, {pid, new_progress}} {:noreply, {pid, new_progress}}
end end
defp pubsub do defp pubsub do
Application.fetch_env!(:morse, :pubsub) Application.fetch_env!(:eisrom_ui, :pubsub)
end end
defp worker_alive?(pid) do defp worker_alive?(pid) do

View file

@ -1,4 +1,4 @@
defmodule Morse.Worker do defmodule Eisrom.Morse.Worker do
@moduledoc """ @moduledoc """
Functions to control the signal lamp connected with GPIO. Functions to control the signal lamp connected with GPIO.
""" """
@ -57,23 +57,23 @@ defmodule Morse.Worker do
end end
defp update_progress(index, length) do defp update_progress(index, length) do
Morse.Server.update_progress(index / length * 100) Eisrom.Morse.Server.update_progress(index / length * 100)
end end
defp secret_code do defp secret_code do
Application.fetch_env!(:morse, :morse_message) Application.fetch_env!(:eisrom_ui, :morse_message)
|> String.to_charlist() |> String.to_charlist()
end end
# Communicate with a deployed esrom node, if running on a host. # Communicate with a deployed esrom node, if running on a host.
case Application.get_env(:ui, :target) do case Application.get_env(:eisrom_ui, :target) do
:host -> :host ->
@esrom_node :"esrom@esrom.lan" @esrom_node :"esrom@esrom.lan"
def toggle_lamp(state) do def toggle_lamp(state) do
# Check if the deployed esrom node is online. # Check if the deployed esrom node is online.
if :pong == Node.ping(@esrom_node) do if :pong == Node.ping(@esrom_node) do
:rpc.call(@esrom_node, Morse.Worker, :toggle_lamp, [state]) :rpc.call(@esrom_node, Eisrom.Morse.Worker, :toggle_lamp, [state])
end end
end end
@ -84,7 +84,7 @@ defmodule Morse.Worker do
end end
defp relay_pin() do defp relay_pin() do
Application.fetch_env!(:morse, :relay_pin) Application.fetch_env!(:eisrom_ui, :relay_pin)
end end
end end
end end

View file

@ -0,0 +1,107 @@
defmodule EisromUiWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, views, channels and so on.
This can be used in your application as:
use EisromUiWeb, :controller
use EisromUiWeb, :view
The definitions below will be executed for every view,
controller, etc, so keep them short and clean, focused
on imports, uses and aliases.
Do NOT define functions inside the quoted expressions
below. Instead, define any helper function in modules
and import those modules here.
"""
def controller do
quote do
use Phoenix.Controller, namespace: EisromUiWeb
import Plug.Conn
alias EisromUiWeb.Router.Helpers, as: Routes
end
end
def view do
quote do
use Phoenix.View,
root: "lib/eisrom_ui_web/templates",
namespace: EisromUiWeb
# Import convenience functions from controllers
import Phoenix.Controller,
only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]
# Include shared imports and aliases for views
unquote(view_helpers())
end
end
def live_view do
quote do
use Phoenix.LiveView,
layout: {EisromUiWeb.LayoutView, "live.html"}
unquote(view_helpers())
end
end
def live_component do
quote do
use Phoenix.LiveComponent
unquote(view_helpers())
end
end
def component do
quote do
use Phoenix.Component
unquote(view_helpers())
end
end
def router do
quote do
use Phoenix.Router
import Plug.Conn
import Phoenix.Controller
import Phoenix.LiveView.Router
end
end
def channel do
quote do
use Phoenix.Channel
end
end
defp view_helpers do
quote do
# Use all HTML functionality (forms, tags, etc)
use Phoenix.HTML
# Import LiveView and .heex helpers (live_render, live_patch, <.form>, etc)
import Phoenix.LiveView.Helpers
# Import basic rendering functionality (render, render_layout, etc)
import Phoenix.View
import EisromUiWeb.ErrorHelpers
alias EisromUiWeb.Router.Helpers, as: Routes
end
end
@doc """
When used, dispatch to the appropriate controller/view/etc.
"""
defmacro __using__(which) when is_atom(which) do
apply(__MODULE__, which, [])
end
end

View file

@ -0,0 +1,15 @@
defmodule EisromUiWeb.PageController do
use EisromUiWeb, :controller
def index(conn, _params) do
send_resp(conn, 204, "")
end
def instructions(conn, _params) do
render(conn, :instructions)
end
def morse(conn, _params) do
Phoenix.LiveView.Controller.live_render(conn, EisromUiWeb.MorseLive)
end
end

View file

@ -1,7 +1,16 @@
defmodule UiWeb.Endpoint do defmodule EisromUiWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :ui use Phoenix.Endpoint, otp_app: :eisrom_ui
socket "/live", Phoenix.LiveView.Socket # The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
@session_options [
store: :cookie,
key: "_eisrom_ui_key",
signing_salt: "lolEkmxx"
]
socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]]
# Serve at "/" the static files from "priv/static" directory. # Serve at "/" the static files from "priv/static" directory.
# #
@ -9,9 +18,9 @@ defmodule UiWeb.Endpoint do
# when deploying your static files in production. # when deploying your static files in production.
plug Plug.Static, plug Plug.Static,
at: "/", at: "/",
from: :ui, from: :eisrom_ui,
gzip: false, gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt berenbos.jpg lamp.png) only: ~w(assets fonts images favicon.ico robots.txt)
# Code reloading can be explicitly enabled under the # Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint. # :code_reloader configuration of your endpoint.
@ -21,6 +30,10 @@ defmodule UiWeb.Endpoint do
plug Phoenix.CodeReloader plug Phoenix.CodeReloader
end end
plug Phoenix.LiveDashboard.RequestLogger,
param_key: "request_logger",
cookie_key: "request_logger"
plug Plug.RequestId plug Plug.RequestId
plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint] plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
@ -31,14 +44,6 @@ defmodule UiWeb.Endpoint do
plug Plug.MethodOverride plug Plug.MethodOverride
plug Plug.Head plug Plug.Head
plug Plug.Session, @session_options
# The session will be stored in the cookie and signed, plug EisromUiWeb.Router
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
plug Plug.Session,
store: :cookie,
key: "_ui_key",
signing_salt: "N1da3BnS"
plug UiWeb.Router
end end

View file

@ -0,0 +1,39 @@
defmodule EisromUiWeb.MorseLive do
use Phoenix.LiveView
require Logger
@topic "morse_progress"
def render(assigns) do
EisromUiWeb.PageView.render("morse.html", assigns)
end
def mount(_params, _session, socket) do
EisromUiWeb.Endpoint.subscribe(@topic)
{:ok, assign(socket, default_assigns())}
end
def handle_event("toggle_morse", _value, socket) do
Logger.info("Button pressed!")
Eisrom.Morse.Server.toggle_morse()
{:noreply, socket}
end
def handle_event("toggle_hint", _value, socket) do
{:noreply, update(socket, :hints_visible, &(not &1))}
end
def handle_info(progress, socket) do
{:noreply, assign(socket, progress: progress, in_progress?: Eisrom.Morse.Server.in_progress?())}
end
defp default_assigns do
[
progress: Eisrom.Morse.Server.progress(),
in_progress?: Eisrom.Morse.Server.in_progress?(),
hints_visible: false
]
end
end

View file

@ -0,0 +1,52 @@
defmodule EisromUiWeb.Router do
use EisromUiWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {EisromUiWeb.LayoutView, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", EisromUiWeb do
pipe_through :browser
get "/", PageController, :index
get "/ZZZZ", PageController, :instructions
get "/morse", PageController, :instructions
get "/esrom", PageController, :instructions
get "/0B13", PageController, :morse
get "/OB13", PageController, :morse
get "/seinlamp", PageController, :morse
end
# Other scopes may use custom stacks.
# scope "/api", EisromUiWeb do
# pipe_through :api
# end
# Enables LiveDashboard only for development
#
# If you want to use the LiveDashboard in production, you should put
# it behind authentication and allow only admins to access it.
# If your application does not have an admins-only section yet,
# you can use Plug.BasicAuth to set up some basic authentication
# as long as you are also using SSL (which you should anyway).
if Mix.env() in [:dev, :test] do
import Phoenix.LiveDashboard.Router
scope "/" do
pipe_through :browser
live_dashboard "/dashboard", metrics: EisromUiWeb.Telemetry
end
end
end

View file

@ -0,0 +1,48 @@
defmodule EisromUiWeb.Telemetry do
use Supervisor
import Telemetry.Metrics
def start_link(arg) do
Supervisor.start_link(__MODULE__, arg, name: __MODULE__)
end
@impl true
def init(_arg) do
children = [
# Telemetry poller will execute the given period measurements
# every 10_000ms. Learn more here: https://hexdocs.pm/telemetry_metrics
{:telemetry_poller, measurements: periodic_measurements(), period: 10_000}
# Add reporters as children of your supervision tree.
# {Telemetry.Metrics.ConsoleReporter, metrics: metrics()}
]
Supervisor.init(children, strategy: :one_for_one)
end
def metrics do
[
# Phoenix Metrics
summary("phoenix.endpoint.stop.duration",
unit: {:native, :millisecond}
),
summary("phoenix.router_dispatch.stop.duration",
tags: [:route],
unit: {:native, :millisecond}
),
# VM Metrics
summary("vm.memory.total", unit: {:byte, :kilobyte}),
summary("vm.total_run_queue_lengths.total"),
summary("vm.total_run_queue_lengths.cpu"),
summary("vm.total_run_queue_lengths.io")
]
end
defp periodic_measurements do
[
# A module, function and arguments to be invoked periodically.
# This function must call :telemetry.execute/3 and a metric must be added above.
# {EisromUiWeb, :count_users, []}
]
end
end

View file

@ -0,0 +1,5 @@
<main role="main" class="container">
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<%= @inner_content %>
</main>

View file

@ -0,0 +1,11 @@
<main role="main" class="container">
<p class="alert alert-info" role="alert"
phx-click="lv:clear-flash"
phx-value-key="info"><%= live_flash(@flash, :info) %></p>
<p class="alert alert-danger" role="alert"
phx-click="lv:clear-flash"
phx-value-key="error"><%= live_flash(@flash, :error) %></p>
<%= @inner_content %>
</main>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="csrf-token" content={csrf_token_value()}>
<title>Esrom Geocache</title>
<link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/assets/app.css")}/>
<script defer phx-track-static type="text/javascript" src={Routes.static_path(@conn, "/assets/app.js")}></script>
</head>
<body>
<%= @inner_content %>
</body>
</html>

View file

@ -10,7 +10,9 @@
<% end %> <% end %>
<div id="response-block"> <div id="response-block">
<h2>Progress:</h2> <h2>Progress:</h2>
<progress max="100" value="<%= @progress %>"><%= @progress %>%</progress> <progress max="100" value={@progress}>
<%= @progress %>%
</progress>
</div> </div>
</div> </div>
@ -18,11 +20,7 @@
<br> <br>
<br> <br>
<button phx-click="toggle_hint" id="hintButton">Click here for a hint!</button> <button phx-click="toggle_hint" id="hintButton">Click here for a hint!</button>
<%= if @hints_visible do %> <div id="givehint" style={"visibility:" <> (if @hints_visible, do: "visible", else: "hidden")}>
<div id="givehint">
<% else %>
<div id="givehint" style="visibility: hidden">
<% end %>
<p>en: Position yourself on the bridge. Watch carefully around to windows of houses, remember this is a nightly geocache. During daytime it is quite hard to see, but not impossible. After pushing the button, it takes 3 <p>en: Position yourself on the bridge. Watch carefully around to windows of houses, remember this is a nightly geocache. During daytime it is quite hard to see, but not impossible. After pushing the button, it takes 3
seconds to start. The whole process takes about 35 sec. You can start it all over again as much as you like. In case you are really stuck, you could try to contact me via WhatsApp on number +31 6 41633689. Best of luck to you!</p> seconds to start. The whole process takes about 35 sec. You can start it all over again as much as you like. In case you are really stuck, you could try to contact me via WhatsApp on number +31 6 41633689. Best of luck to you!</p>
<p>nl: Ga op de brug staan. Kijk goed om je heen naar ramen van woningen en realiseer je dat dit een een nachtcache is. Overdag is het slecht te zien, maar niet onmogelijk. Na het indrukken van de knop duurt het 3 seconden <p>nl: Ga op de brug staan. Kijk goed om je heen naar ramen van woningen en realiseer je dat dit een een nachtcache is. Overdag is het slecht te zien, maar niet onmogelijk. Na het indrukken van de knop duurt het 3 seconden

View file

@ -0,0 +1,30 @@
defmodule EisromUiWeb.ErrorHelpers do
@moduledoc """
Conveniences for translating and building error messages.
"""
use Phoenix.HTML
@doc """
Generates tag for inlined form input errors.
"""
def error_tag(form, field) do
Enum.map(Keyword.get_values(form.errors, field), fn error ->
content_tag(:span, translate_error(error),
class: "invalid-feedback",
phx_feedback_for: input_name(form, field)
)
end)
end
@doc """
Translates an error message.
"""
def translate_error({msg, opts}) do
# Because the error messages we show in our forms and APIs
# are defined inside Ecto, we need to translate them dynamically.
Enum.reduce(opts, msg, fn {key, value}, acc ->
String.replace(acc, "%{#{key}}", fn _ -> to_string(value) end)
end)
end
end

View file

@ -1,5 +1,5 @@
defmodule UiWeb.ErrorView do defmodule EisromUiWeb.ErrorView do
use UiWeb, :view use EisromUiWeb, :view
# If you want to customize a particular status code # If you want to customize a particular status code
# for a certain format, you may uncomment below. # for a certain format, you may uncomment below.

View file

@ -0,0 +1,7 @@
defmodule EisromUiWeb.LayoutView do
use EisromUiWeb, :view
# Phoenix LiveDashboard is available only in development by default,
# so we instruct Elixir to not warn if the dashboard route is missing.
@compile {:no_warn_undefined, {Routes, :live_dashboard_path, 2}}
end

View file

@ -0,0 +1,3 @@
defmodule EisromUiWeb.PageView do
use EisromUiWeb, :view
end

64
eisrom_ui/mix.exs Normal file
View file

@ -0,0 +1,64 @@
defmodule EisromUi.MixProject do
use Mix.Project
def project do
[
app: :eisrom_ui,
version: "0.1.0",
elixir: "~> 1.12",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()
]
end
# Configuration for the OTP application.
#
# Type `mix help compile.app` for more information.
def application do
[
env: [morse_message: "... --- ...", relay_pin: 17],
mod: {EisromUi.Application, []},
extra_applications: [:logger, :runtime_tools]
]
end
# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
# Specifies your project dependencies.
#
# Type `mix help deps` for examples and options.
defp deps do
[
{:phoenix, "~> 1.6.13"},
{:phoenix_html, "~> 3.0"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_view, "~> 0.17.5"},
{:floki, ">= 0.30.0", only: :test},
{:phoenix_live_dashboard, "~> 0.6"},
{:esbuild, "~> 0.4", runtime: Mix.env() == :dev && Mix.target() == :host},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:jason, "~> 1.2"},
{:plug_cowboy, "~> 2.5"},
{:circuits_gpio, "~> 1.0"}
]
end
# Aliases are shortcuts or tasks specific to the current project.
# For example, to install project dependencies and perform other setup tasks, run:
#
# $ mix setup
#
# See the documentation for `Mix` for more info on aliases.
defp aliases do
[
setup: ["deps.get"],
"assets.deploy": ["esbuild default --minify", "phx.digest"]
]
end
end

28
eisrom_ui/mix.lock Normal file
View file

@ -0,0 +1,28 @@
%{
"castore": {:hex, :castore, "0.1.18", "deb5b9ab02400561b6f5708f3e7660fc35ca2d51bfc6a940d2f513f89c2975fc", [:mix], [], "hexpm", "61bbaf6452b782ef80b33cdb45701afbcf0a918a45ebe7e73f1130d661e66a06"},
"circuits_gpio": {:hex, :circuits_gpio, "1.0.1", "53e0aefebc0eedc1326f7f28cc53831bed84654767eb3c613934c6ec8ca77caa", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "d8e918fdfada785b24a071edc7e4dbd334b3b42c6a0298fc0d13e7f1fc5b3e0a"},
"cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
"cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
"elixir_make": {:hex, :elixir_make, "0.6.3", "bc07d53221216838d79e03a8019d0839786703129599e9619f4ab74c8c096eac", [:mix], [], "hexpm", "f5cbd651c5678bcaabdbb7857658ee106b12509cd976c2c2fca99688e1daf716"},
"esbuild": {:hex, :esbuild, "0.5.0", "d5bb08ff049d7880ee3609ed5c4b864bd2f46445ea40b16b4acead724fb4c4a3", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "f183a0b332d963c4cfaf585477695ea59eef9a6f2204fdd0efa00e099694ffe5"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"floki": {:hex, :floki, "0.33.1", "f20f1eb471e726342b45ccb68edb9486729e7df94da403936ea94a794f072781", [:mix], [{:html_entities, "~> 0.5.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm", "461035fd125f13fdf30f243c85a0b1e50afbec876cbf1ceefe6fddd2e6d712c6"},
"html_entities": {:hex, :html_entities, "0.5.2", "9e47e70598da7de2a9ff6af8758399251db6dbb7eebe2b013f2bbd2515895c3c", [:mix], [], "hexpm", "c53ba390403485615623b9531e97696f076ed415e8d8058b1dbaa28181f4fdcc"},
"jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"},
"mime": {:hex, :mime, "2.0.3", "3676436d3d1f7b81b5a2d2bd8405f412c677558c81b1c92be58c00562bb59095", [:mix], [], "hexpm", "27a30bf0db44d25eecba73755acf4068cbfe26a4372f9eb3e4ea3a45956bff6b"},
"phoenix": {:hex, :phoenix, "1.6.13", "5b3152907afdb8d3a6cdafb4b149e8aa7aabbf1422fd9f7ef4c2a67ead57d24a", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "13d8806c31176e2066da4df2d7443c144211305c506ed110ad4044335b90171d"},
"phoenix_html": {:hex, :phoenix_html, "3.2.0", "1c1219d4b6cb22ac72f12f73dc5fad6c7563104d083f711c3fcd8551a1f4ae11", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "36ec97ba56d25c0136ef1992c37957e4246b649d620958a1f9fa86165f8bc54f"},
"phoenix_live_dashboard": {:hex, :phoenix_live_dashboard, "0.6.5", "1495bb014be12c9a9252eca04b9af54246f6b5c1e4cd1f30210cd00ec540cf8e", [:mix], [{:ecto, "~> 3.6.2 or ~> 3.7", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_mysql_extras, "~> 0.3", [hex: :ecto_mysql_extras, repo: "hexpm", optional: true]}, {:ecto_psql_extras, "~> 0.7", [hex: :ecto_psql_extras, repo: "hexpm", optional: true]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.17.7", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "ef4fa50dd78364409039c99cf6f98ab5209b4c5f8796c17f4db118324f0db852"},
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.3", "3a53772a6118d5679bf50fc1670505a290e32a1d195df9e069d8c53ab040c054", [: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", "766796676e5f558dbae5d1bdb066849673e956005e3730dfd5affd7a6da4abac"},
"phoenix_live_view": {:hex, :phoenix_live_view, "0.17.12", "74f4c0ad02d7deac2d04f50b52827a5efdc5c6e7fac5cede145f5f0e4183aedc", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.0 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.1", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "af6dd5e0aac16ff43571f527a8e0616d62cb80b10eb87aac82170243e50d99c8"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.1", "ba04e489ef03763bf28a17eb2eaddc2c20c6d217e2150a61e3298b0f4c2012b5", [:mix], [], "hexpm", "81367c6d1eea5878ad726be80808eb5a787a23dee699f96e72b1109c57cdd8d9"},
"phoenix_view": {:hex, :phoenix_view, "1.1.2", "1b82764a065fb41051637872c7bd07ed2fdb6f5c3bd89684d4dca6e10115c95a", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "7ae90ad27b09091266f6adbb61e1d2516a7c3d7062c6789d46a7554ec40f3a56"},
"plug": {:hex, :plug, "1.13.6", "187beb6b67c6cec50503e940f0434ea4692b19384d47e5fdfd701e93cadb4cc2", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "02b9c6b9955bce92c829f31d6284bf53c591ca63c4fb9ff81dfd0418667a34ff"},
"plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"},
"plug_crypto": {:hex, :plug_crypto, "1.2.3", "8f77d13aeb32bfd9e654cb68f0af517b371fb34c56c9f2b58fe3df1235c1251a", [:mix], [], "hexpm", "b5672099c6ad5c202c45f5a403f21a3411247f164e4a8fab056e5cd8a290f4a2"},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"},
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"},
"telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"},
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -0,0 +1,5 @@
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /

View file

@ -1,4 +1,4 @@
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
# #
# To ban all spiders from the entire site uncomment the next two lines: # To ban all spiders from the entire site uncomment the next two lines:
# User-agent: * # User-agent: *

Binary file not shown.

View file

@ -0,0 +1,8 @@
defmodule EisromUiWeb.PageControllerTest do
use EisromUiWeb.ConnCase
test "GET /", %{conn: conn} do
conn = get(conn, "/")
assert html_response(conn, 200) =~ "Welcome to Phoenix!"
end
end

View file

@ -0,0 +1,14 @@
defmodule EisromUiWeb.ErrorViewTest do
use EisromUiWeb.ConnCase, async: true
# Bring render/3 and render_to_string/3 for testing custom views
import Phoenix.View
test "renders 404.html" do
assert render_to_string(EisromUiWeb.ErrorView, "404.html", []) == "Not Found"
end
test "renders 500.html" do
assert render_to_string(EisromUiWeb.ErrorView, "500.html", []) == "Internal Server Error"
end
end

View file

@ -0,0 +1,8 @@
defmodule EisromUiWeb.LayoutViewTest do
use EisromUiWeb.ConnCase, async: true
# When testing helpers, you may want to import Phoenix.HTML and
# use functions such as safe_to_string() to convert the helper
# result into an HTML string.
# import Phoenix.HTML
end

View file

@ -0,0 +1,3 @@
defmodule EisromUiWeb.PageViewTest do
use EisromUiWeb.ConnCase, async: true
end

View file

@ -1,4 +1,4 @@
defmodule UiWeb.ConnCase do defmodule EisromUiWeb.ConnCase do
@moduledoc """ @moduledoc """
This module defines the test case to be used by This module defines the test case to be used by
tests that require setting up a connection. tests that require setting up a connection.
@ -8,9 +8,11 @@ defmodule UiWeb.ConnCase do
to build common data structures and query the data layer. to build common data structures and query the data layer.
Finally, if the test case interacts with the database, Finally, if the test case interacts with the database,
it cannot be async. For this reason, every test runs we enable the SQL sandbox, so changes done to the database
inside a transaction which is reset at the beginning are reverted at the end of every test. If you are using
of the test unless the test case is marked as async. PostgreSQL, you can even run database tests asynchronously
by setting `use EisromUiWeb.ConnCase, async: true`, although
this option is not recommended for other databases.
""" """
use ExUnit.CaseTemplate use ExUnit.CaseTemplate
@ -18,11 +20,14 @@ defmodule UiWeb.ConnCase do
using do using do
quote do quote do
# Import conveniences for testing with connections # Import conveniences for testing with connections
use Phoenix.ConnTest import Plug.Conn
alias UiWeb.Router.Helpers, as: Routes import Phoenix.ConnTest
import EisromUiWeb.ConnCase
alias EisromUiWeb.Router.Helpers, as: Routes
# The default endpoint for testing # The default endpoint for testing
@endpoint UiWeb.Endpoint @endpoint EisromUiWeb.Endpoint
end end
end end

View file

@ -1,4 +0,0 @@
# Used by "mix format"
[
inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"]
]

View file

@ -1,31 +0,0 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
use Mix.Config
config :firmware, target: Mix.target()
# Customize non-Elixir parts of the firmware. See
# https://hexdocs.pm/nerves/advanced-configuration.html for details.
config :nerves, :firmware, rootfs_overlay: "rootfs_overlay"
# Use shoehorn to start the main application. See the shoehorn
# docs for separating out critical OTP applications such as those
# involved with firmware updates.
config :shoehorn,
init: [:nerves_runtime, :nerves_init_gadget],
app: Mix.Project.config()[:app]
# Use Ringlogger as the logger backend and remove :console.
# See https://hexdocs.pm/ring_logger/readme.html for more information on
# configuring ring_logger.
config :logger, backends: [RingLogger]
import_config("target.exs")
import_config("../../ui/config/config.exs")

View file

@ -1,48 +0,0 @@
use Mix.Config
# Authorize the device to receive firmware using your public key.
# See https://hexdocs.pm/nerves_firmware_ssh/readme.html for more information
# on configuring nerves_firmware_ssh.
keys =
[
Path.join([System.user_home!(), ".ssh", "id_rsa.pub"]),
Path.join([System.user_home!(), ".ssh", "id_ecdsa.pub"]),
Path.join([System.user_home!(), ".ssh", "id_ed25519.pub"])
]
|> Enum.filter(&File.exists?/1)
if keys == [],
do:
Mix.raise("""
No SSH public keys found in ~/.ssh. An ssh authorized key is needed to
log into the Nerves device and update firmware on it using ssh.
See your project's config.exs for this error message.
""")
config :nerves_firmware_ssh,
authorized_keys: Enum.map(keys, &File.read!/1)
# Configure nerves_init_gadget.
# See https://hexdocs.pm/nerves_init_gadget/readme.html for more information.
# Setting the node_name will enable Erlang Distribution.
# Only enable this for prod if you understand the risks.
node_name = "esrom"
config :nerves_init_gadget,
ifname: "eth0",
address_method: :dhcp,
mdns_domain: "esrom.lan",
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
# import_config "#{Mix.target()}.exs"

View file

@ -1,16 +0,0 @@
defmodule Firmware.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
def start(_type, _args) do
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Firmware.Supervisor]
children = []
Supervisor.start_link(children, opts)
end
end

View file

@ -1,72 +0,0 @@
defmodule Firmware.MixProject do
use Mix.Project
@app :firmware
@version "0.1.0"
@all_targets [:rpi, :rpi0, :rpi2, :rpi3, :rpi3a, :bbb, :x86_64]
def project do
[
app: @app,
version: @version,
elixir: "~> 1.9",
archives: [nerves_bootstrap: "~> 1.6"],
start_permanent: Mix.env() == :prod,
build_embedded: true,
aliases: [loadconfig: [&bootstrap/1]],
deps: deps(),
releases: [{@app, release()}],
preferred_cli_target: [run: :host, test: :host]
]
end
# Starting nerves_bootstrap adds the required aliases to Mix.Project.config()
# Aliases are only added if MIX_TARGET is set.
def bootstrap(args) do
Application.start(:nerves_bootstrap)
Mix.Task.run("loadconfig", args)
end
# Run "mix help compile.app" to learn about applications.
def application do
[
mod: {Firmware.Application, []},
extra_applications: [:logger, :runtime_tools]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
# Dependencies for all targets
{:nerves, "~> 1.7", runtime: false},
{:shoehorn, "~> 0.6"},
{:ring_logger, "~> 0.6"},
{:toolshed, "~> 0.2"},
{:ui, path: "../ui"},
# Dependencies for all targets except :host
{:nerves_runtime, "~> 0.6", targets: @all_targets},
{:nerves_init_gadget, "~> 0.4", targets: @all_targets},
# Dependencies for specific targets
{:nerves_system_rpi, "~> 1.8", runtime: false, targets: :rpi},
{:nerves_system_rpi0, "~> 1.8", runtime: false, targets: :rpi0},
{:nerves_system_rpi2, "~> 1.8", runtime: false, targets: :rpi2},
{:nerves_system_rpi3, "~> 1.8", runtime: false, targets: :rpi3},
{:nerves_system_rpi3a, "~> 1.8", runtime: false, targets: :rpi3a},
{:nerves_system_bbb, "~> 2.3", runtime: false, targets: :bbb},
{:nerves_system_x86_64, "~> 1.8", runtime: false, targets: :x86_64},
{:nerves_time, "~> 0.3.0"}
]
end
def release do
[
overwrite: true,
cookie: "tastycookie",
include_erts: &Nerves.Release.erts/0,
steps: [&Nerves.Release.init/1, :assemble]
]
end
end

View file

@ -1,68 +0,0 @@
%{
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"},
"circuits_gpio": {:hex, :circuits_gpio, "0.4.1", "344dd34f2517687fd28723e5552571babff5469db05b697181cab860fe7eff23", [:make, :mix], [{:elixir_make, "~> 0.5", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "8031c53c1813f52ccd2926c5e806d192ec5625cb12c3a2bf6b63fecd34999010"},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"},
"cowboy": {:hex, :cowboy, "2.6.3", "99aa50e94e685557cad82e704457336a453d4abcb77839ad22dbe71f311fcc06", [:rebar3], [{:cowlib, "~> 2.7.3", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "e5580029080f3f1ad17436fb97b0d5ed2ed4e4815a96bac36b5a992e20f58db6"},
"cowlib": {:hex, :cowlib, "2.7.3", "a7ffcd0917e6d50b4d5fb28e9e2085a0ceb3c97dea310505f7460ff5ed764ce9", [:rebar3], [], "hexpm", "1e1a3d176d52daebbecbbcdfd27c27726076567905c2a9d7398c54da9d225761"},
"db_connection": {:hex, :db_connection, "2.1.0", "122e2f62c4906bf2e49554f1e64db5030c19229aa40935f33088e7d543aa79d0", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"},
"decimal": {:hex, :decimal, "1.8.0", "ca462e0d885f09a1c5a342dbd7c1dcf27ea63548c65a65e67334f4b61803822e", [:mix], [], "hexpm"},
"dns": {:hex, :dns, "2.1.2", "81c46d39f7934f0e73368355126e4266762cf227ba61d5889635d83b2d64a493", [:mix], [{:socket, "~> 0.3.13", [hex: :socket, repo: "hexpm", optional: false]}], "hexpm", "6818589d8e59c03a2c73001e5cd7a957f99c30a796021aa32445ea14d0f3356b"},
"ecto": {:hex, :ecto, "3.1.7", "fa21d06ef56cdc2fdaa62574e8c3ba34a2751d44ea34c30bc65f0728421043e5", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
"ecto_sql": {:hex, :ecto_sql, "3.1.6", "1e80e30d16138a729c717f73dcb938590bcdb3a4502f3012414d0cbb261045d8", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.1.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.9.1", [hex: :mariaex, repo: "hexpm", optional: true]}, {:myxql, "~> 0.2.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.14.0 or ~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
"elixir_make": {:hex, :elixir_make, "0.6.0", "38349f3e29aff4864352084fc736fa7fa0f2995a819a737554f7ebd28b85aaab", [:mix], [], "hexpm", "d522695b93b7f0b4c0fcb2dfe73a6b905b1c301226a5a55cb42e5b14d509e050"},
"file_system": {:hex, :file_system, "0.2.7", "e6f7f155970975789f26e77b8b8d8ab084c59844d8ecfaf58cbda31c494d14aa", [:mix], [], "hexpm"},
"gettext": {:hex, :gettext, "0.17.0", "abe21542c831887a2b16f4c94556db9c421ab301aee417b7c4fbde7fbdbe01ec", [:mix], [], "hexpm", "e0b8598e802676c81e66b061a2148c37c03886b24a3ca86a1f98ed40693b94b3"},
"hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "e0100f8ef7d1124222c11ad362c857d3df7cb5f4204054f9f0f4a728666591fc"},
"idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"},
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
"mdns": {:hex, :mdns, "1.0.3", "f08414daf5636bf5cd364611e838818e9250c91a3282a817ad9174b03e757401", [:mix], [{:dns, "~> 2.0", [hex: :dns, repo: "hexpm", optional: false]}], "hexpm", "6cb44eac9d1d71d0c5b400a383ccdc2b474d2e89a49a1e049e496637a6bab4c1"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
"mime": {:hex, :mime, "1.6.0", "dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2", [:mix], [], "hexpm", "31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"muontrap": {:hex, :muontrap, "0.5.0", "0b885a4095e990000d519441bccb8f037a9c4c35908720e7814a516a606be278", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "09d6c4edbd83024c6de1035a5629708df21a60d011d06d5aa66fe8ac9baaa3ae"},
"nerves": {:hex, :nerves, "1.7.6", "daf2d44ad821e2af1b243bea25805227557b424f5961c98f35bea3dae25df812", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "33a2509965a4650a5e685867e23048d5cd661826b40c094f4c71f58b1be42651"},
"nerves_firmware_ssh": {:hex, :nerves_firmware_ssh, "0.4.4", "12b0d9c84ec9f79c1b0ac0de1c575372ef972d0c58ce21c36bf354062c6222d9", [:mix], [{:nerves_runtime, "~> 0.6", [hex: :nerves_runtime, repo: "hexpm", optional: false]}], "hexpm", "98c40104d0d2c6e6e8cce22f8c8fd8ad5b4b97f8694e42a9101ca44befac38f0"},
"nerves_init_gadget": {:hex, :nerves_init_gadget, "0.6.0", "64eb8877b438678aed6d421737326a8cac3810b425e00abd5c7a3a0e95054988", [:mix], [{:mdns, "~> 1.0", [hex: :mdns, repo: "hexpm", optional: false]}, {:nerves_firmware_ssh, "~> 0.2", [hex: :nerves_firmware_ssh, repo: "hexpm", optional: false]}, {:nerves_network, "~> 0.3", [hex: :nerves_network, repo: "hexpm", optional: false]}, {:nerves_runtime, "~> 0.3", [hex: :nerves_runtime, repo: "hexpm", optional: false]}, {:one_dhcpd, "~> 0.1", [hex: :one_dhcpd, repo: "hexpm", optional: false]}, {:ring_logger, "~> 0.4", [hex: :ring_logger, repo: "hexpm", optional: false]}], "hexpm", "725ec14004240f82b07fad8605ffa442a275d2ef76af6e007d5dc073695d11c0"},
"nerves_network": {:hex, :nerves_network, "0.5.5", "4690c362707f76c4072810bd9639b2ae8eb7dd9c21119656308b462a087230aa", [:make, :mix], [{:elixir_make, "~> 0.5", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:nerves_network_interface, "~> 0.4.4", [hex: :nerves_network_interface, repo: "hexpm", optional: false]}, {:nerves_wpa_supplicant, "~> 0.5", [hex: :nerves_wpa_supplicant, repo: "hexpm", optional: false]}, {:one_dhcpd, "~> 0.2.0", [hex: :one_dhcpd, repo: "hexpm", optional: false]}, {:system_registry, "~> 0.7", [hex: :system_registry, repo: "hexpm", optional: false]}], "hexpm", "5e63529c6e128d147f5a6df82bd7daffd211057b8ac0c8ba625939a7fde9ccff"},
"nerves_network_interface": {:hex, :nerves_network_interface, "0.4.6", "d50e57daca8154f0f780fd98eb5ae94a005579e0d72d69840e80e228375d88ad", [:make, :mix], [{:elixir_make, "~> 0.5", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "94eb89db67ceb17a7f3465d55c05b00e8d8cf10aa812556745ce0c06868768d3"},
"nerves_runtime": {:hex, :nerves_runtime, "0.10.1", "4cefcfbcb99f237def5346e1dc881bda523811ede26adfd3a2204e6f26530146", [:make, :mix], [{:elixir_make, "~> 0.5", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:system_registry, "~> 0.5", [hex: :system_registry, repo: "hexpm", optional: false]}, {:uboot_env, "~> 0.1", [hex: :uboot_env, repo: "hexpm", optional: false]}], "hexpm", "739a56203412cf58fd888de264471a210ae56f488af1ef184d6c9e7705ced01a"},
"nerves_system_bbb": {:hex, :nerves_system_bbb, "2.3.0", "887b7aafe036ad832bb285c0622cc1d136861857b8d949f1c957c74e1f4efc20", [:mix], [{:nerves, "~> 1.4", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.8.2", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_system_linter, "~> 0.3.0", [hex: :nerves_system_linter, repo: "hexpm", optional: false]}, {:nerves_toolchain_arm_unknown_linux_gnueabihf, "1.2.0", [hex: :nerves_toolchain_arm_unknown_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "caac7bea3ea0e0f2dd9a546cf78019b09d64eeb73b8e14bd772df69c8b1055f8"},
"nerves_system_br": {:hex, :nerves_system_br, "1.8.2", "bd1639c9aadbeb104c1d1080554048eeed28352841bf5621a7cbeaca53e99404", [:mix], [], "hexpm", "2deb3f3a0f952f227569840f56cc023be599470f2e9fd7c3d162200e390f8460"},
"nerves_system_linter": {:hex, :nerves_system_linter, "0.3.0", "84e0f63c8ac196b16b77608bbe7df66dcf352845c4e4fb394bffd2b572025413", [:mix], [], "hexpm", "bffbdfb116bc72cde6e408c34c0670b199846e9a8f0953cc1c9f1eea693821a1"},
"nerves_system_rpi": {:hex, :nerves_system_rpi, "1.8.0", "c8e0df198a2e9923a94583a1f7cfaeeb0d6057aca0a2e02ecd34dd24b51e6ebc", [:mix], [{:nerves, "~> 1.4", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.8.2", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_system_linter, "~> 0.3.0", [hex: :nerves_system_linter, repo: "hexpm", optional: false]}, {:nerves_toolchain_armv6_rpi_linux_gnueabi, "1.2.0", [hex: :nerves_toolchain_armv6_rpi_linux_gnueabi, repo: "hexpm", optional: false]}], "hexpm", "239661ee996fa342dcc768cfb5e93818507080740a6bec32f300a113836e198c"},
"nerves_system_rpi0": {:hex, :nerves_system_rpi0, "1.8.0", "332f1bc0a19243690bb88c62d8dd40bf0e97af6e6ac8c6e0e90a90d0c52d3990", [:mix], [{:nerves, "~> 1.4", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.8.2", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_system_linter, "~> 0.3.0", [hex: :nerves_system_linter, repo: "hexpm", optional: false]}, {:nerves_toolchain_armv6_rpi_linux_gnueabi, "1.2.0", [hex: :nerves_toolchain_armv6_rpi_linux_gnueabi, repo: "hexpm", optional: false]}], "hexpm", "974e1b5bdfa987ba824591e05b170b634c157048007d97bda6c8203abb9c1f75"},
"nerves_system_rpi2": {:hex, :nerves_system_rpi2, "1.8.0", "a81a2720fc5d4f28f586272833ae71ab200101cf41d0fe7ed1c560703993dd31", [:mix], [{:nerves, "~> 1.4", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.8.2", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_system_linter, "~> 0.3.0", [hex: :nerves_system_linter, repo: "hexpm", optional: false]}, {:nerves_toolchain_arm_unknown_linux_gnueabihf, "1.2.0", [hex: :nerves_toolchain_arm_unknown_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "6dc9a232555aa8f8fbc504c8e07ad0979d971f590816abc13f1ffce846f7a822"},
"nerves_system_rpi3": {:hex, :nerves_system_rpi3, "1.8.0", "64cc1e669613a64b29fba8c8ad7ee2686600956a056aeb5833753ed6cf939812", [:mix], [{:nerves, "~> 1.4", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.8.2", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_system_linter, "~> 0.3.0", [hex: :nerves_system_linter, repo: "hexpm", optional: false]}, {:nerves_toolchain_arm_unknown_linux_gnueabihf, "1.2.0", [hex: :nerves_toolchain_arm_unknown_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "99cd78dead980247758bf8bc63814c93e07d180f2d3167192402feae67af4240"},
"nerves_system_rpi3a": {:hex, :nerves_system_rpi3a, "1.8.0", "466af465517a46bc3f96a58a2f8abfd1298f60ff659b1cf636dc21eee5bd8d9b", [:mix], [{:nerves, "~> 1.4", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.8.2", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_system_linter, "~> 0.3.0", [hex: :nerves_system_linter, repo: "hexpm", optional: false]}, {:nerves_toolchain_arm_unknown_linux_gnueabihf, "1.2.0", [hex: :nerves_toolchain_arm_unknown_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm", "f4169c0843e783d506c4f792d5f976dac8709f46c3a418af308db47a3a44988d"},
"nerves_system_x86_64": {:hex, :nerves_system_x86_64, "1.8.0", "f58a9043dede98666249d2ab53ba81fbae51ecfefec21eb9e034772eb327b77d", [:mix], [{:nerves, "~> 1.4", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.8.2", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_system_linter, "~> 0.3.0", [hex: :nerves_system_linter, repo: "hexpm", optional: false]}, {:nerves_toolchain_x86_64_unknown_linux_musl, "1.2.0", [hex: :nerves_toolchain_x86_64_unknown_linux_musl, repo: "hexpm", optional: false]}], "hexpm", "327de1c3c2bbc55e2b74de48a23bec2315fd578504c545dc930c6d9831a7e763"},
"nerves_time": {:hex, :nerves_time, "0.3.2", "cbd1048701a756695cda6ec5835419e47505a7fe437f97088c9475dc6f8ab625", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:muontrap, "~> 0.5", [hex: :muontrap, repo: "hexpm", optional: false]}], "hexpm", "b2da78b6d98775c29a7bd296d4b293a89a849a0fed2a685774892b50b2b63444"},
"nerves_toolchain_arm_unknown_linux_gnueabihf": {:hex, :nerves_toolchain_arm_unknown_linux_gnueabihf, "1.2.0", "ba48ce7c846ee12dfca8148dc7240988d96a3f2eb9c234bf08bffe4f0f7a3c62", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_toolchain_ctng, "~> 1.6.0", [hex: :nerves_toolchain_ctng, repo: "hexpm", optional: false]}], "hexpm", "18df425fee48a9088bf941d3615c677b818b537310123c4b4c90b710e4a34180"},
"nerves_toolchain_armv6_rpi_linux_gnueabi": {:hex, :nerves_toolchain_armv6_rpi_linux_gnueabi, "1.2.0", "007668c7ad1f73bad8fd54ad1a27a3b0fb91bca51b4af6bb3bbdac968ccae0ba", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_toolchain_ctng, "~> 1.6.0", [hex: :nerves_toolchain_ctng, repo: "hexpm", optional: false]}], "hexpm", "4e843f405d4b8e6137419f94e5b8f491bff5a87b02ac2223e126182e8cec4256"},
"nerves_toolchain_ctng": {:hex, :nerves_toolchain_ctng, "1.6.0", "452f8589c1a58ac787477caab20a8cfc6671e345837ccc19beefe49ae35ba983", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}], "hexpm", "7ee5744dc606c6debf3e459ef122e77c13d6a1be9e093f7e29af3759896f9dbb"},
"nerves_toolchain_x86_64_unknown_linux_musl": {:hex, :nerves_toolchain_x86_64_unknown_linux_musl, "1.2.0", "fbe688fa561b03190765e269d4336333c4961a48d2acd3f6cb283443a058e138", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_toolchain_ctng, "~> 1.6.0", [hex: :nerves_toolchain_ctng, repo: "hexpm", optional: false]}], "hexpm", "9cb676b7fb7a4564b18e1e16f72bc64f06f77346a477033fde6e4c2d1cc2ecff"},
"nerves_wpa_supplicant": {:hex, :nerves_wpa_supplicant, "0.5.2", "4ec392fc08faf35f50d1070446c2e5019f6b85bd53f5716f904e3f75716d9596", [:make, :mix], [{:elixir_make, "~> 0.5", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "c286ed5397fa185ab986226596eeb72d8f5f9f1b1156103418193f85905da713"},
"one_dhcpd": {:hex, :one_dhcpd, "0.2.2", "2dfdcad61ed7c6d9f652bc1a06f14924a497de2c2aa2d4f48ee3b1aa13be0f33", [:make, :mix], [{:elixir_make, "~> 0.5", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "9aa7d429e85b80e971aed74d01c122d699ac9863e85dd53c170c95e90ec1fd27"},
"parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"},
"phoenix": {:hex, :phoenix, "1.4.9", "746d098e10741c334d88143d3c94cab1756435f94387a63441792e66ec0ee974", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.8.1 or ~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a40833266f1f55750d784fb780d8d5945f9f048be4d474b5b6197aec9db0a22e"},
"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", "8b01b3d6d39731ab18aa548d928b5796166d2500755f553725cfe967bafba7d9"},
"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", "faeda10c544f0ca6a805f2e03a7742bfeb90b1be7e1ac73e185b6fc2873f366b"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm", "1f13f9f0f3e769a667a6b6828d29dec37497a082d195cc52dbef401a9b69bf38"},
"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", "54c8bbd5062cb32880aa1afc9894a823b1c18a47a1821a552887310b561cd418"},
"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", "6cd8ddd1bd1fbfa54d3fc61d4719c2057dae67615395d58d40437a919a46f132"},
"plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm", "73c1682f0e414cfb5d9b95c8e8cd6ffcfdae699e3b05e1db744e58b7be857759"},
"postgrex": {:hex, :postgrex, "0.14.3", "5754dee2fdf6e9e508cbf49ab138df964278700b764177e8f3871e658b345a1e", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm", "451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"},
"ring_logger": {:hex, :ring_logger, "0.8.0", "b1baddc269099b2afe2ea3a87b8e2b71e57331c0000038ae55090068aac679db", [:mix], [], "hexpm", "9b2f482e4346c13c11ef555f898202d0ddbfda6e2354e5c6e0559d2b4e0cf781"},
"shoehorn": {:hex, :shoehorn, "0.6.0", "f9a1b7d6212cf18ba91c4f71c26076059df33cea4db2eb3c098bfa6673349412", [:mix], [{:distillery, "~> 2.1", [hex: :distillery, repo: "hexpm", optional: true]}], "hexpm", "e54a1f58a121caf8f0f3a355686b2661258b1bc0d4fffef8923bd7b11c2f9d79"},
"socket": {:hex, :socket, "0.3.13", "98a2ab20ce17f95fb512c5cadddba32b57273e0d2dba2d2e5f976c5969d0c632", [:mix], [], "hexpm", "f82ea9833ef49dde272e6568ab8aac657a636acb4cf44a7de8a935acb8957c2e"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm", "13104d7897e38ed7f044c4de953a6c28597d1c952075eb2e328bc6d6f2bfc496"},
"system_registry": {:hex, :system_registry, "0.8.2", "df791dc276652fcfb53be4dab823e05f8269b96ac57c26f86a67838dbc0eefe7", [:mix], [], "hexpm", "f7acdede22c73ab0b3735eead7f2095efb2a7a6198366564205274db2ca2a8f8"},
"telegram": {:git, "https://github.com/visciang/telegram.git", "548cfb192e92e7e810be026121b0c77672d0ca8d", [tag: "master"]},
"telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"},
"tesla": {:hex, :tesla, "1.4.1", "ff855f1cac121e0d16281b49e8f066c4a0d89965f98864515713878cca849ac8", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.3", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "~> 4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "95f5de35922c8c4b3945bee7406f66eb680b0955232f78f5fb7e853aa1ce201a"},
"toolshed": {:hex, :toolshed, "0.2.10", "31e33f3bfbd88085a5f34844930a75e579940417873eb8a5c25b9525ad1a1372", [:mix], [{:nerves_runtime, "~> 0.8", [hex: :nerves_runtime, repo: "hexpm", optional: true]}], "hexpm", "14610e55afa20441209c9e2d3198f8f6f3347b3d2f2969c161fc5c7d9f31ee94"},
"uboot_env": {:hex, :uboot_env, "0.1.1", "b01e3ec0973e99473234f27839e29e63b5b81eba6a136a18a78d049d4813d6c5", [:mix], [], "hexpm", "f7b82da0cb40c8db9c9fb1fc977780ab0c28d961ec1f3c7ab265c4352e4141ae"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"},
}

View file

@ -1,18 +0,0 @@
# Add Toolshed helpers to the IEx session
use Toolshed
if RingLogger in Application.get_env(:logger, :backends, []) do
IO.puts """
RingLogger is collecting log messages from Elixir and Linux. To see the
messages, either attach the current IEx session to the logger:
RingLogger.attach
or print the next messages in the log:
RingLogger.next
"""
end
# Be careful when adding to this file. Nearly any error can crash the VM and
# cause a reboot.

View file

@ -1,8 +0,0 @@
defmodule FirmwareTest do
use ExUnit.Case
doctest Firmware
test "greets the world" do
assert Firmware.hello() == :world
end
end

View file

@ -1,4 +0,0 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]

23
morse/.gitignore vendored
View file

@ -1,23 +0,0 @@
# The directory Mix will write compiled artifacts to.
/_build/
# If you run "mix test --cover", coverage assets end up here.
/cover/
# The directory Mix downloads your dependencies sources to.
/deps/
# Where third-party dependencies like ExDoc output generated docs.
/doc/
# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch
# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump
# Also ignore archive artifacts (built via "mix archive.build").
*.ez
# Ignore package tarball (built via "mix hex.build").
morse-*.tar

View file

@ -1,21 +0,0 @@
# Morse
**TODO: Add description**
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `morse` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:morse, "~> 0.1.0"}
]
end
```
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/morse](https://hexdocs.pm/morse).

View file

@ -1,12 +0,0 @@
defmodule Morse.Application do
use Application
def start(_type, _args) do
children = [
{Morse.Server, nil}
]
opts = [strategy: :one_for_one, name: Morse.Supervisor]
Supervisor.start_link(children, opts)
end
end

View file

@ -1,29 +0,0 @@
defmodule Morse.MixProject do
use Mix.Project
def project do
[
app: :morse,
version: "0.1.0",
elixir: "~> 1.9",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger],
env: [morse_message: "... --- ...", relay_pin: 17],
mod: {Morse.Application, []}
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:circuits_gpio, "~> 0.4.1"}
]
end
end

View file

@ -1,4 +0,0 @@
%{
"circuits_gpio": {:hex, :circuits_gpio, "0.4.1", "344dd34f2517687fd28723e5552571babff5469db05b697181cab860fe7eff23", [:make, :mix], [{:elixir_make, "~> 0.5", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm"},
"elixir_make": {:hex, :elixir_make, "0.6.0", "38349f3e29aff4864352084fc736fa7fa0f2995a819a737554f7ebd28b85aaab", [:mix], [], "hexpm"},
}

View file

@ -1,4 +0,0 @@
defmodule MorseTest do
use ExUnit.Case
doctest Morse
end

View file

@ -1,5 +0,0 @@
{
"presets": [
"@babel/preset-env"
]
}

View file

@ -1,3 +0,0 @@
/* This file is for your main application css. */
@import "./ruby.css";

View file

@ -1,18 +0,0 @@
// We need to import the CSS so that webpack will load it.
// The MiniCssExtractPlugin is used to separate it out into
// its own CSS file.
import css from "../css/app.css"
// webpack automatically bundles all modules in your
// entry points. Those entry points can be configured
// in "webpack.config.js".
//
// Import dependencies
//
import "phoenix_html"
import {Socket} from "phoenix"
import LiveSocket from "phoenix_live_view"
let liveSocket = new LiveSocket("/live", Socket)
liveSocket.connect()

File diff suppressed because it is too large Load diff

View file

@ -1,25 +0,0 @@
{
"repository": {},
"license": "MIT",
"scripts": {
"deploy": "webpack --mode production",
"watch": "webpack --mode development --watch"
},
"dependencies": {
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
"phoenix_live_view": "file:../deps/phoenix_live_view"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-loader": "^8.0.0",
"copy-webpack-plugin": "^5.1.1",
"css-loader": "^2.1.1",
"mini-css-extract-plugin": "^0.4.0",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"uglifyjs-webpack-plugin": "^1.2.4",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.6"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 KiB

View file

@ -1,41 +0,0 @@
const path = require('path');
const glob = require('glob');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = (env, options) => ({
optimization: {
minimizer: [
new UglifyJsPlugin({ cache: true, parallel: true, sourceMap: false }),
new OptimizeCSSAssetsPlugin({})
]
},
entry: {
'./js/app.js': glob.sync('./vendor/**/*.js').concat(['./js/app.js'])
},
output: {
filename: 'app.js',
path: path.resolve(__dirname, '../priv/static/js')
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
}
]
},
plugins: [
new MiniCssExtractPlugin({ filename: '../css/app.css' }),
new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
]
});

View file

@ -1,21 +0,0 @@
use Mix.Config
config :ui, target: Mix.target()
config :ui, UiWeb.Endpoint,
live_view: [signing_salt: "h4niP0Ovx/wDHjKRBJelcKHsbBUzptcagimD/iSDHMg5r535/A1ad5uAKJjY9ktI"],
pubsub: [name: Ui.PubSub, adapter: Phoenix.PubSub.PG2]
config :phoenix, :json_library, Jason
config :phoenix, template_engines: [leex: Phoenix.LiveView.Engine]
config :morse, :pubsub, Phoenix.PubSub
if Mix.target() != :host do
"target.exs"
else
"host.exs"
end
|> import_config()
import_config "secrets.exs"

View file

@ -1,36 +0,0 @@
use Mix.Config
config :ui, UiWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "FkfuB09FEncz4aAi6hS6w5bsNast+D1P12MckXr5dlRdhtFJrKqgEhvhpTU3qzgh",
render_errors: [view: UiWeb.ErrorView, accepts: ~w(html json)],
http: [port: 4000],
server: true,
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../assets", __DIR__)
]
],
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/ui_web/{live,views}/.*(ex)$",
~r"lib/ui_web/templates/.*(eex)$",
~r{lib/ui_web/live/.*(ex)$}
]
]
# Set a higher stacktrace during development. Avoid configuring such
# in production as building large stacktraces may be expensive.
config :phoenix, :stacktrace_depth, 20
# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime

View file

@ -1,12 +0,0 @@
use Mix.Config
config :ui, UiWeb.Endpoint,
url: [host: "www.geokunis2.nl"],
http: [port: 80],
secret_key_base: "HEY05EB1dFVSu6KykKHuS4rQPQzSHv4F7mGVB/gnDLrIu75wE/ytBXy2TaL3A6RA",
root: Path.dirname(__DIR__),
server: true,
render_errors: [view: UiWeb.ErrorView, accepts: ~w(html json)],
code_reloader: false
config :morse, :relay_pin, 17

View file

@ -1,42 +0,0 @@
defmodule Ui.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
def start(_type, _args) do
# List all child processes to be supervised
children = [
# Start the endpoint when the application starts
UiWeb.Endpoint
# Starts a worker by calling: Ui.Worker.start_link(arg)
# {Ui.Worker, arg},
] ++ children(target())
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Ui.Supervisor]
Supervisor.start_link(children, opts)
end
def children(:host) do
{:ok, _} = Node.start(:"host@0.0.0.0")
Node.set_cookie(:tastycookie)
Node.connect(:"esrom@esrom.lan")
[]
end
def children(_target), do: []
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
def config_change(changed, _new, removed) do
UiWeb.Endpoint.config_change(changed, removed)
:ok
end
def target() do
Application.get_env(:ui, :target)
end
end

View file

@ -1,43 +0,0 @@
defmodule Ui.MessageBot do
def message(msg) do
{:ok, _result} = Tesla.put(client(), "/_matrix/client/r0/rooms/" <> room() <> "/send/m.room.message/" <> transaction_id(), construct_message(msg))
end
def client do
middleware = [
{Tesla.Middleware.BaseUrl, matrix_ip()},
Tesla.Middleware.JSON,
{Tesla.Middleware.Headers, [{"Host", matrix_host()}, {"Authorization", "Bearer " <> token()}]}
]
Tesla.client(middleware)
end
def token do
Application.fetch_env!(:ui, :matrix_token)
end
def matrix_ip do
Application.fetch_env!(:ui, :matrix_ip)
end
def matrix_host do
Application.fetch_env!(:ui, :matrix_host)
end
def room do
Application.fetch_env!(:ui, :matrix_room)
end
def transaction_id do
id = DateTime.utc_now()
|> DateTime.to_unix()
|> Integer.to_string()
"esrom-" <> id
end
def construct_message(msg) do
%{msgtype: "m.text", body: msg}
end
end

View file

@ -1,72 +0,0 @@
defmodule UiWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, views, channels and so on.
This can be used in your application as:
use UiWeb, :controller
use UiWeb, :view
The definitions below will be executed for every view,
controller, etc, so keep them short and clean, focused
on imports, uses and aliases.
Do NOT define functions inside the quoted expressions
below. Instead, define any helper function in modules
and import those modules here.
"""
def controller do
quote do
use Phoenix.Controller, namespace: UiWeb
import Plug.Conn
import UiWeb.Gettext
alias UiWeb.Router.Helpers, as: Routes
end
end
def view do
quote do
use Phoenix.View,
root: "lib/ui_web/templates",
namespace: UiWeb
# Import convenience functions from controllers
import Phoenix.Controller, only: [get_flash: 1, get_flash: 2, view_module: 1]
# Use all HTML functionality (forms, tags, etc)
use Phoenix.HTML
import UiWeb.ErrorHelpers
import UiWeb.Gettext
alias UiWeb.Router.Helpers, as: Routes
import Phoenix.LiveView, only: [live_render: 2, live_render: 3]
end
end
def router do
quote do
use Phoenix.Router
import Plug.Conn
import Phoenix.Controller
import Phoenix.LiveView.Router
end
end
def channel do
quote do
use Phoenix.Channel
import UiWeb.Gettext
end
end
@doc """
When used, dispatch to the appropriate controller/view/etc.
"""
defmacro __using__(which) when is_atom(which) do
apply(__MODULE__, which, [])
end
end

View file

@ -1,20 +0,0 @@
defmodule UiWeb.PageController do
use UiWeb, :controller
alias Phoenix.LiveView
def index(conn, _params) do
send_resp(conn, 204, "")
end
def instructions(conn, _params) do
render(conn, :instructions)
end
def morse(conn, _params) do
ip = case Plug.Conn.get_req_header(conn, "x-real-ip") do
[h|_tl] -> h
_ -> "0.0.0.0"
end
LiveView.Controller.live_render(conn, UiWeb.MorseLive, session: %{ip: ip})
end
end

View file

@ -1,24 +0,0 @@
defmodule UiWeb.Gettext do
@moduledoc """
A module providing Internationalization with a gettext-based API.
By using [Gettext](https://hexdocs.pm/gettext),
your module gains a set of macros for translations, for example:
import UiWeb.Gettext
# Simple translation
gettext("Here is the string to translate")
# Plural translation
ngettext("Here is the string to translate",
"Here are the strings to translate",
3)
# Domain-based translation
dgettext("errors", "Here is the error message to translate")
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
"""
use Gettext, otp_app: :ui
end

View file

@ -1,50 +0,0 @@
defmodule UiWeb.MorseLive do
use Phoenix.LiveView
require Logger
@topic "morse_progress"
def render(assigns) do
UiWeb.PageView.render("morse.html", assigns)
end
def mount(%{ip: ip}, socket) do
UiWeb.Endpoint.subscribe(@topic)
{:ok, assign(socket, default_assigns(ip))}
end
def handle_event("toggle_morse", _value, %{assigns: %{ip: ip}} = socket) do
Logger.info("#{ip} pressed the button!")
if not Morse.Server.in_progress?() and ip_send_message?(ip) do
Logger.info("Sending message.")
spawn(fn -> Ui.MessageBot.message("#{ip} pressed the button!") end)
end
Morse.Server.toggle_morse()
{:noreply, socket}
end
def handle_event("toggle_hint", _value, socket) do
{:noreply, update(socket, :hints_visible, &(not &1))}
end
def handle_info(progress, socket) do
{:noreply, assign(socket, progress: progress, in_progress?: Morse.Server.in_progress?())}
end
defp default_assigns(ip) do
[
progress: Morse.Server.progress(),
in_progress?: Morse.Server.in_progress?(),
hints_visible: false,
ip: ip
]
end
defp ip_send_message?(ip) do
not (String.starts_with?(ip, "192.168.") or String.starts_with?(ip, "10.")
or ip == "127.0.0.1" or ip == "localhost" or ip == "0.0.0.0")
end
end

View file

@ -1,32 +0,0 @@
defmodule UiWeb.Router do
use UiWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug Phoenix.LiveView.Flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", UiWeb do
pipe_through :browser
get "/", PageController, :index
get "/ZZZZ", PageController, :instructions
get "/morse", PageController, :instructions
get "/esrom", PageController, :instructions
get "/0B13", PageController, :morse
get "/OB13", PageController, :morse
get "/seinlamp", PageController, :morse
# get "/start", PageController, :start
end
end

View file

@ -1,19 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Esrom Geocache</title>
<link rel="shortcut icon" type="image/x-icon" href="<%= Routes.static_path(@conn, "/favicon.ico") %>"/>
<link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/>
</head>
<body>
<main role="main" class="container">
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<%= render @view_module, @view_template, assigns %>
</main>
<script type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>
</body>
</html>

View file

@ -1,44 +0,0 @@
defmodule UiWeb.ErrorHelpers do
@moduledoc """
Conveniences for translating and building error messages.
"""
use Phoenix.HTML
@doc """
Generates tag for inlined form input errors.
"""
def error_tag(form, field) do
Enum.map(Keyword.get_values(form.errors, field), fn error ->
content_tag(:span, translate_error(error), class: "help-block")
end)
end
@doc """
Translates an error message using gettext.
"""
def translate_error({msg, opts}) do
# When using gettext, we typically pass the strings we want
# to translate as a static argument:
#
# # Translate "is invalid" in the "errors" domain
# dgettext("errors", "is invalid")
#
# # Translate the number of files with plural rules
# dngettext("errors", "1 file", "%{count} files", count)
#
# Because the error messages we show in our forms and APIs
# are defined inside Ecto, we need to translate them dynamically.
# This requires us to call the Gettext module passing our gettext
# backend as first argument.
#
# Note we use the "errors" domain, which means translations
# should be written to the errors.po file. The :count option is
# set by Ecto and indicates we should also apply plural rules.
if count = opts[:count] do
Gettext.dngettext(UiWeb.Gettext, "errors", msg, msg, count, opts)
else
Gettext.dgettext(UiWeb.Gettext, "errors", msg, opts)
end
end
end

View file

@ -1,3 +0,0 @@
defmodule UiWeb.LayoutView do
use UiWeb, :view
end

View file

@ -1,3 +0,0 @@
defmodule UiWeb.PageView do
use UiWeb, :view
end

Some files were not shown because too many files have changed in this diff Show more