Hi there! I have asked some slightly related questions on the Nerves Slack channel already, but that is of course not a medium to treat an in-depth question in much detail.
Here is my use case: For a pilot, I am building/programming a raspberry pi, which at its core reads data from a smart electicity meter, and forwards this data to a server.
Since each of these devices ends up in the home of another person, with another WiFi network, it is important to be able to easily set up the correct WiFi connection settings (and also be able to change them later).
So the current idea was to let the Nerves device switch between AP mode and WiFi mode every minute or so, until a successful connection can be made with the configured WiFi settings. As soon as someone visits the Phoenix web-interface where you can configure these settings, the device will stop switching mode until you leave it, to not drop the connection at an inappropriate time.
From the pointers other people already gave me in the Nerves slack channel, I know that the VintageNetWizard exists, which theoretically does more or less this. However, it is currently still missing some features that the system I am building would require:
- mDNS support.
nerves_init_gadgetsupports this (although until now I have only been able to make
nerves_init_gadget's mDNS work over an external WiFi and not over Rpi-as-AP) but it conflicts with VintageNet. Another possibility would be a ‘Captive Portal’ (the kind of “log in to wifi” portal that you also see on public WiFi networks) but I have no idea how those are set up (and findinf information about them online proved rather difficult).
- Because of the confict with
nerves_init_gadget, VintageNet also does not allow e.g. updating firmware over SSH and other quality-of-life improvements to the development phase that I really appreciatae.
So then it seems like I should just use NervesNetwork and build my own simple abstraction for persistence of settings and a web-UI on top of that. However, I have not been able to configure
Nerves.InitGadget properly to switch at runtime between Rpi-as-AP and Rpi-connected-to-remote-WiFi modes.
It would be really appreciated if someone can help me with the way these libraries ought to be configured for this use case. Especially
Nerves.InitGadget seems to mostly be built to be configured in the Mix config files only. However, looking in the code it does seem like its configuration is only applied once a connection is (re)starteed so maybe
Application.put_env should be used?
And if you have information on how to solve this problem in any other way, then that would of course also be very welcome!