This repository has been archived by the owner on Jul 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7428d56
commit 39f73f4
Showing
23 changed files
with
671 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.5.0 | ||
0.6.0-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Used by "mix format" | ||
[ | ||
inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 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 3rd-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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Example | ||
|
||
`kiosk_system_rpi3` example app | ||
|
||
## Getting Started | ||
|
||
To start your Nerves app: | ||
|
||
Set the target | ||
```bash | ||
export MIX_TARGET=rpi3 | ||
``` | ||
|
||
Set the url to display | ||
```bash | ||
export KIOSK_URL=https://google.com | ||
``` | ||
|
||
Build and Burn firmware | ||
```bash | ||
mix do deps.get, firmware, firmware.burn | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# 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 | ||
|
||
# Customize the firmware. Uncomment all or parts of the following | ||
# to add files to the root filesystem or modify the firmware | ||
# archive. | ||
|
||
# config :nerves, :firmware, | ||
# rootfs_overlay: "rootfs_overlay", | ||
# fwup_conf: "config/fwup.conf" | ||
|
||
# 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] | ||
|
||
config :nerves, :firmware, | ||
rootfs_overlay: "rootfs_overlay" | ||
|
||
# Add the LoggerCircularBuffer backend. This removes the | ||
# default :console backend. | ||
config :logger, backends: [LoggerCircularBuffer] | ||
|
||
# Set the number of messages to hold in the circular buffer | ||
config :logger, LoggerCircularBuffer, buffer_size: 100 | ||
|
||
network_ssid = System.get_env("NERVES_NETWORK_SSID") | ||
network_psk = System.get_env("NERVES_NETWORK_PSK") | ||
|
||
network_iface = System.get_env("NERVES_NETWORK_IFACE") || "eth0" | ||
key_mgmt = System.get_env("NERVES_NETWORK_KEY_MGMT") || "WPA-PSK" | ||
|
||
wlan_conf = | ||
if network_iface == "wlan0" do | ||
config :nerves_network, :default, | ||
wlan0: [ssid: network_ssid, psk: network_psk, key_mgmt: key_mgmt] | ||
else | ||
config :nerves_network, :default, | ||
eth0: [ipv4_address_method: :dhcp] | ||
end | ||
|
||
config :nerves_network, | ||
iface: network_iface | ||
|
||
config :nerves_init_gadget, | ||
ifname: "eth0", | ||
address_method: :dhcp, | ||
mdns_domain: "kiosk.local", | ||
node_name: "kiosk", | ||
node_host: :mdns_domain | ||
|
||
config :nerves_firmware_ssh, | ||
authorized_keys: [ | ||
File.read!(Path.join(System.user_home!, ".ssh/id_rsa.pub")) | ||
] | ||
# 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.Project.config()[:target]}.exs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
defmodule Example do | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
defmodule Example.Application do | ||
use Application | ||
|
||
# See http://elixir-lang.org/docs/stable/elixir/Application.html | ||
# for more information on OTP Applications | ||
def start(_type, _args) do | ||
import Supervisor.Spec, warn: false | ||
iface = Application.get_env(:nerves_network, :iface) | ||
init0() | ||
# Define workers and child supervisors to be supervised | ||
children = [ | ||
worker(SystemRegistry.Task, [ | ||
[:state, :network_interface, iface, :ipv4_address], | ||
&init1/1]) | ||
] | ||
|
||
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html | ||
# for other strategies and supported options | ||
opts = [strategy: :one_for_one, name: Example.Supervisor] | ||
Supervisor.start_link(children, opts) | ||
end | ||
|
||
def init0 do | ||
# initial sound drivers | ||
### | ||
# Certain machines will have multiple sound cards. | ||
# Lets try to initialize 0, 1 and then check if card 1 | ||
# is present by listing them. | ||
# | ||
# aplay -l | ||
# card 1: THISCARD | ||
# | ||
# Then we need to export the env var with the value pulled from the card list | ||
# export ALSA_CARD THISCARD | ||
|
||
# Enum.each([0, 1], &:os.cmd('alsactl init #{&1}')) | ||
# {ret, 0} = System.cmd("aplay", ["-l"]) | ||
# case Regex.run ~r/card 1: (\w*)/, ret do | ||
# [_, card] -> | ||
# System.put_env("ALSA_CARD", card) | ||
# _ -> :noop | ||
# end | ||
|
||
# Initialize udev :( | ||
:os.cmd('udevd -d'); | ||
:os.cmd('udevadm trigger --type=subsystems --action=add'); | ||
:os.cmd('udevadm trigger --type=devices --action=add'); | ||
:os.cmd('udevadm settle --timeout=30'); | ||
|
||
end | ||
|
||
def init1(_delta) do | ||
# You will need to wait until the time is set if you point | ||
# to an ssl domain | ||
# :timer.sleep(200) | ||
# init_ntp("time.nist.gov") | ||
# :timer.sleep(200) | ||
init_ui() | ||
end | ||
|
||
def init_ui() do | ||
System.put_env("QTWEBENGINE_REMOTE_DEBUGGING", "9222") | ||
System.put_env("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-embedded-switches") | ||
System.cmd("qt-webengine-kiosk", ["-c", "/etc/qt-webengine-kiosk.ini", "--opengl", "NATIVE"]) | ||
end | ||
|
||
def init_ntp(ntp_server) do | ||
# ntpd in busybox is limited so this requires a two step dance. | ||
# Stop existing instances of ntpd first. | ||
System.cmd("killall", ["-q", "-SIGINT", "ntpd"]) | ||
# Run once and quit to block until clock is set. | ||
System.cmd("ntpd", ["-n", "-q", "-p", ntp_server]) | ||
# Then run as a daemon in the background to keep clock in sync. | ||
System.cmd("ntpd", ["-p", ntp_server]) | ||
end | ||
|
||
def start_remote_debugger() do | ||
System.cmd("socat", ["tcp-listen:9223,fork", "tcp:localhost:9222"]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
defmodule Example.MixProject do | ||
use Mix.Project | ||
|
||
@target System.get_env("MIX_TARGET") || "host" | ||
|
||
def project do | ||
[ | ||
app: :example, | ||
version: "0.1.0", | ||
elixir: "~> 1.4", | ||
target: @target, | ||
archives: [nerves_bootstrap: "~> 0.8"], | ||
deps_path: "deps/#{@target}", | ||
build_path: "_build/#{@target}", | ||
lockfile: "mix.lock.#{@target}", | ||
build_embedded: Mix.env == :prod, | ||
start_permanent: Mix.env == :prod, | ||
aliases: ["loadconfig": [&bootstrap/1]], | ||
deps: deps() | ||
] | ||
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: application(@target) | ||
|
||
# Specify target specific application configurations | ||
# It is common that the application start function will start and supervise | ||
# applications which could cause the host to fail. Because of this, we only | ||
# invoke Example.start/2 when running on a target. | ||
def application("host") do | ||
[extra_applications: [:logger]] | ||
end | ||
|
||
def application(_target) do | ||
[mod: {Example.Application, []}, extra_applications: [:logger]] | ||
end | ||
|
||
# Run "mix help deps" to learn about dependencies. | ||
defp deps do | ||
[ | ||
{:nerves, "~> 0.10", runtime: false}, | ||
{:logger_circular_buffer, "~> 0.2"} | ||
] ++ deps(@target) | ||
end | ||
|
||
# Specify target specific dependencies | ||
defp deps("host"), do: [] | ||
|
||
defp deps(target) do | ||
[ | ||
{:shoehorn, "~> 0.2"}, | ||
{:nerves_runtime, "~> 0.4"}, | ||
{:nerves_network, "~> 0.3"}, | ||
{:nerves_init_gadget, "~> 0.1"}, | ||
] ++ system(target) | ||
end | ||
|
||
defp system("x86_64"), do: [{:kiosk_system_x86_64, path: "../", runtime: false}] | ||
defp system(target), do: Mix.raise "Unknown MIX_TARGET: #{target}" | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
%{ | ||
"distillery": {:hex, :distillery, "1.5.2", "eec18b2d37b55b0bcb670cf2bcf64228ed38ce8b046bb30a9b636a6f5a4c0080", [:mix], [], "hexpm"}, | ||
"nerves": {:hex, :nerves, "0.9.4", "6ff8b5bbe5a8a08c49b598248aada91ad13e71fcd1937c045f2fc0759a228212", [:mix], [{:distillery, "~> 1.4", [hex: :distillery, repo: "hexpm", optional: false]}], "hexpm"}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
%{ | ||
"distillery": {:hex, :distillery, "1.5.2", "eec18b2d37b55b0bcb670cf2bcf64228ed38ce8b046bb30a9b636a6f5a4c0080", [:mix], [], "hexpm"}, | ||
"dns": {:hex, :dns, "1.0.1", "1d88187fdf564d937cee202949141090707fd0c9d7fcae903a6878ef24ef5d1e", [:mix], [{:socket, "~> 0.3.12", [hex: :socket, repo: "hexpm", optional: false]}], "hexpm"}, | ||
"elixir_make": {:hex, :elixir_make, "0.4.0", "992f38fabe705bb45821a728f20914c554b276838433349d4f2341f7a687cddf", [:mix], [], "hexpm"}, | ||
"logger_circular_buffer": {:hex, :logger_circular_buffer, "0.2.0", "fd3dfd4720ef9e26a20e1d405d4bfbd6b88507e2fb0cccbe00a1fff38862e5ca", [:mix], [], "hexpm"}, | ||
"mdns": {:hex, :mdns, "0.1.7", "7b949773ff5809bb720256171767db1c9bf21eea477128b361a92b0c5e6af220", [:mix], [{:dns, "~> 1.0", [hex: :dns, repo: "hexpm", optional: false]}], "hexpm"}, | ||
"nerves": {:hex, :nerves, "0.10.0", "8558b661f92acb1c01689bb1b750362c58733ac4305aa305ce418b2ed2af3f20", [:mix], [{:distillery, "~> 1.4", [hex: :distillery, repo: "hexpm", optional: false]}], "hexpm"}, | ||
"nerves_firmware_ssh": {:hex, :nerves_firmware_ssh, "0.3.1", "e8b1967fa0aff255230be539c68ec868d33884193a385caff957ebad7d6aa8af", [:mix], [{:nerves_runtime, "~> 0.4", [hex: :nerves_runtime, repo: "hexpm", optional: false]}], "hexpm"}, | ||
"nerves_init_gadget": {:hex, :nerves_init_gadget, "0.2.1", "20f36dd062fb00e2be8817ddff1b9ced9762877cfe23f6ec1d5936a37e3fc2c8", [:mix], [{:mdns, "~> 0.1", [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]}], "hexpm"}, | ||
"nerves_network": {:hex, :nerves_network, "0.3.6", "c95779283ace071e9d12882d6a80e31edc8c476012adc61aba2ff6c306ef97b3", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:nerves_network_interface, "~> 0.4.0", [hex: :nerves_network_interface, repo: "hexpm", optional: false]}, {:nerves_wpa_supplicant, "~> 0.3.0", [hex: :nerves_wpa_supplicant, repo: "hexpm", optional: false]}, {:system_registry, "~> 0.4", [hex: :system_registry, repo: "hexpm", optional: false]}], "hexpm"}, | ||
"nerves_network_interface": {:hex, :nerves_network_interface, "0.4.4", "200b1a84bc1a7fdeaf3a1e0e2d4e9b33e240b034e73f39372768d43f8690bae0", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm"}, | ||
"nerves_runtime": {:hex, :nerves_runtime, "0.5.3", "7447a3e718762f3901046f72cc824e528f8d0565a581b8ae58f4f5b6436bca7f", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:system_registry, "~> 0.5", [hex: :system_registry, repo: "hexpm", optional: false]}], "hexpm"}, | ||
"nerves_system_br": {:hex, :nerves_system_br, "0.17.0", "f7c0d1b6b11e9a1c187b17f2401a00956bebd5c45946bfe2a332ad26ecbf18f9", [:mix], [], "hexpm"}, | ||
"nerves_system_linter": {:hex, :nerves_system_linter, "0.3.0", "84e0f63c8ac196b16b77608bbe7df66dcf352845c4e4fb394bffd2b572025413", [:mix], [], "hexpm"}, | ||
"nerves_toolchain_ctng": {:hex, :nerves_toolchain_ctng, "1.3.1", "add96a4b12da4b50fdc5cf18517989de37cf3b329d7edf258ec794878ba06e89", [:mix], [{:nerves, "~> 0.9", [hex: :nerves, repo: "hexpm", optional: false]}], "hexpm"}, | ||
"nerves_toolchain_x86_64_unknown_linux_gnu": {:hex, :nerves_toolchain_x86_64_unknown_linux_gnu, "0.13.1", "41979823c60bbc6808f40ab61048ccab48a432b5ff268f1c87f9e1edd9621fd9", [:mix], [{:nerves, "~> 0.9", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_toolchain_ctng, "~> 1.3", [hex: :nerves_toolchain_ctng, repo: "hexpm", optional: false]}], "hexpm"}, | ||
"nerves_wpa_supplicant": {:hex, :nerves_wpa_supplicant, "0.3.2", "19dc7e1248336e7f542b11b2b857ceb5b088d3eb41a6ca75b7b76628dcf67aad", [:make, :mix], [{:elixir_make, "~> 0.3", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm"}, | ||
"shoehorn": {:hex, :shoehorn, "0.2.0", "6aa80804145c545c59af01980d255209483b14826f53411b4a8797b24c323c20", [:mix], [{:distillery, "~> 1.0", [hex: :distillery, repo: "hexpm", optional: false]}], "hexpm"}, | ||
"socket": {:hex, :socket, "0.3.13", "98a2ab20ce17f95fb512c5cadddba32b57273e0d2dba2d2e5f976c5969d0c632", [:mix], [], "hexpm"}, | ||
"system_registry": {:hex, :system_registry, "0.7.0", "cd3aaf2c15392fa60f93869dde49f536fcf60e54f3b15db737e7d4ebcac108f4", [:mix], [], "hexpm"}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use Mix.Releases.Config, | ||
# This sets the default release built by `mix release` | ||
default_release: :default, | ||
# This sets the default environment used by `mix release` | ||
default_environment: :dev | ||
|
||
# For a full list of config options for both releases | ||
# and environments, visit https://hexdocs.pm/distillery/configuration.html | ||
|
||
|
||
# You may define one or more environments in this file, | ||
# an environment's settings will override those of a release | ||
# when building in that environment, this combination of release | ||
# and environment configuration is called a profile | ||
|
||
environment :dev do | ||
set cookie: :"gVk/XkX*[email protected];hB&hZ3<eRzO@%2!aF_|q:|w3wI%21>Lm7=*H" | ||
end | ||
|
||
environment :prod do | ||
set cookie: :"gVk/XkX*[email protected];hB&hZ3<eRzO@%2!aF_|q:|w3wI%21>Lm7=*H" | ||
end | ||
|
||
# You may define one or more releases in this file. | ||
# If you have not set a default release, or selected one | ||
# when running `mix release`, the first release in the file | ||
# will be used by default | ||
|
||
release :example do | ||
set version: current_version(:example) | ||
plugin Shoehorn | ||
if System.get_env("NERVES_SYSTEM") do | ||
set dev_mode: false | ||
set include_src: false | ||
set include_erts: System.get_env("ERL_LIB_DIR") | ||
set include_system_libs: System.get_env("ERL_SYSTEM_LIB_DIR") | ||
set vm_args: "rel/vm.args" | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## Add custom options here | ||
|
||
## Distributed Erlang Options | ||
## The cookie needs to be configured prior to vm boot for | ||
## for read only filesystem. | ||
|
||
# -name [email protected] | ||
-setcookie /Jnde0Hr143FzUp/uzr/9i8eKQ2lbtQwRqotbkWFZf8yzABEdbRtqwGB+0TOZfwB | ||
|
||
## Use Ctrl-C to interrupt the current shell rather than invoking the emulator's | ||
## break handler and possibly exiting the VM. | ||
+Bc | ||
|
||
## Save the shell history between reboots | ||
## See http://erlang.org/doc/man/kernel_app.html for additional options | ||
-kernel shell_history enabled | ||
|
||
## Start the Elixir shell | ||
|
||
-noshell | ||
-user Elixir.IEx.CLI | ||
|
||
## Enable colors in the shell | ||
-elixir ansi_enabled true | ||
|
||
## Options added after -extra are interpreted as plain arguments and | ||
## can be retrieved using :init.get_plain_arguments(). | ||
-extra --no-halt |
Oops, something went wrong.