Hi, I’m relatively new to the Elixir/OTP world and I’m wondering how to structure a Phoenix/Nerves application
I’m building a project to control IKEA lights on a Raspberry Pi, and I currently have a phoenix application alongside a nerves one in a ‘Poncho’ project.
I’m currently using Phoenix Pub/Sub to communicate between the two, which works well. However, I want to be able to keep track of the state of the lights which seems difficult. It makes sense to me to have the light state in the firmware part of the application where the lights are controlled, but I’m not sure how to access this state on demand from Phoenix.
I can’t depend on the Nerves application from the web one as this would create a circular dependency, and I don’t want to roll my own request/response system over PubSub.
What would be the best way to create a single source of truth for my application that both parts can depend on?
For those interested, the project is here: https://github.com/th0mas/Fancy-Lights.
Relevant files are in fancy_lights_firmware/lib/fancy_lights_firmware/light_manager.ex and fancy_lights_ui/lib/fancy_lights_ui_web/channels/light_channel.ex