Nicd
I have an app structuring question regarding Nerves. First I’ll generally describe my app on a high level.
I’m making a game where RFID readers will play an integral part. The game consists of many devices (different kinds of Raspberry Pi) acting as a network and synchronising game state together. There are initially three types of devices:
- Player device: This is worn by the player and contains an RFID reader. Each player also has an RFID tag in their hand. The player device connects to the others with WiFi. If the RFID reader detects another player’s code, that player has tagged the wearing player and the wearing player’s tag will be disabled from affecting other players (by communicating this to all other players). Then that player must go to read their tag at a respawn station to reactivate their tag.
- Respawn device: This is stationary somewhere and will connect via Ethernet most likely. When the respawn station’s RFID reader detects a tag, it should communicate to all the devices that that player’s tag is active again.
- “Judge” that coordinates the whole game. This device should also offer a web page probably with Phoenix that can be used to set up and follow the game. Another feature could be permanent storage of game info to PostgreSQL/SQLite for example.
Now my issue is, how should I structure my code? The two first devices are similar enough, but the third would also have Phoenix and maybe other stuff, but it still needs the game coordination code that is common to all three. I know of umbrella applications but I thought they are not the solution if you only want to start part of the applications in some environments, or am I wrong?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
I’ve followed the Phoenix LiveView file upload code here Uploads — Phoenix LiveView v1.0.0-rc.7 and so far everything works just fine wit...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
Latest Nerves Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #ai
- #iex
- #graphql
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
outlog
1 & 2 could(should?) be simple clients that have a socket connection open to 3 (perhaps with GitHub - J0/phoenix_gen_socket_client: Socket client behaviour for phoenix channels · GitHub).. so they could share code and configs would decide if it was respawn for gameX or playerX for gameX..
you will face and be fighting latency issues - player A tags B, and then B tags A - however wifi latency etc. can change the order of those messages. so you will need to timestamp the event messages on the device.. (you might need a device with RTC or add it to the board Breakout Boards, Clocks Products Category on Adafruit Industries - so clocks don’t drift)..
and even then you still need logic on the ‘judge’ if a tag event comes in it should wait x ms to see if another and contrary event comes in - and then decide based on the timestamps if A gets the tag or not.
mnesia doesn’t solve this logic so I would not venture there. start with ets and then you can always lazily persist things to sqlite etc.
also you will face rfid latency.. you might have to use battery assisted tags..
Nicd
As long as the latency is at acceptable levels (<50ms?) I don’t see this as an issue, can just act like they both tagged each other. This is mostly for fun (it’s preparation for a company 24 hour hackfest) so it doesn’t need serious sports timing.
I was hoping I could avoid implementing HTTP/WebSocket APIs by networking the devices together and just using BEAM cross-node calls, is that unfeasible?
outlog
ok, maybe go with this Add simple Erlang Distribution example to `hello_network` by GregMefford · Pull Request #71 · nerves-project/nerves_examples · GitHub
hardcode the ‘judge’ node in a config
and then after the :net_kernel.start([node_name]) you can do the node.connect to judge
and then a single genserver, and the judge can dynamic config that a device should be a ‘respawn’ or ‘player_x’ (kept in genserver state) - and the devices then does remote calls to the judge according to their state and events..
Nicd
Thanks for that link, it will surely help.