This is the sample repository of Zenohex on Nerves.
To start your Nerves app:
export MIX_TARGET=my_target
or prefix every command withMIX_TARGET=my_target
. For example,MIX_TARGET=rpi4
- Install dependencies with
mix deps.get
- Create firmware with
mix firmware
- Burn to an SD card with
mix burn
Zenohex itself doesn't include Zenohex.Examples
.
We copied the examples from Zenohex to demonstrate.
On Nerves iex shell,
iex> RingLogger.attach
iex> Zenohex.Examples.Subscriber.start_link
{:ok, #PID<>}
Nerves project can also run on PC(host), make sure MIX_TARGET is unset before starting iex
On PC iex shell,
iex> Zenohex.Examples.Publisher.start_link
{:ok, #PID<>}
iex(2)> Zenohex.Examples.Publisher.put("hello")
:ok
Back to Nerves iex shell to confirm receiving.
23:11:34.054 [debug] %Zenohex.Sample{key_expr: "zenohex/examples/pub", value: "hello", kind: :put, reference: #Reference<0.2097591244.707657743.258773>}
Yay!!
Of course, we can do the opposite, starting Subscriber on your PC and Publisher on Nerves. Please try it!
(RingLogger.attach
is not necessary on this case.)
- Official docs: https://hexdocs.pm/nerves/getting-started.html
- Official website: https://nerves-project.org/
- Forum: https://elixirforum.com/c/nerves-forum
- Discussion Slack elixir-lang #nerves (Invite)
- Source: https://github.com/nerves-project/nerves