And voíla you can connect the regular Livebook app to your device as an attached node and you can run and re-run entire experiments over and over again.
The fact that you keep your livebook can make this a fair bit more practical than the IEx session I use so much during Nerves development.
Need to try it with some sensors and graphs as well.
When I mentioned this on Slack Frank brought up the need for port forwarding on NervesHub so you can connect to you devices. That would be quite rad and I need to read more about wireguard
I imagine this would allow having runbooks for checking the status of a device. Fixes for known problems. That kind of stuff. And of course working with a specific troubled device over time. Without pasting stuff over and over.
For completeness, depending on the use case, you can also use the “Remote execution” smart cell. This should remove restriction on Elixir version compatibility between Livebook and the Nerves device. Also, this way you can offload some computation to the local machine, and you can bring extra dependencies for charting data and whatnot. Finally, it has a lower footprint, because attaching Livebook temporarily loads some Livebook-specific modules into the node, whereas the cell only does an :erpc call : )
NervesHub provides IEx terminal in the browser over WebSocket without needing a direct network path from you to the device. Device connects to NervesHub over WebSocket. You connect to NervesHub via browser. Meaning free NAT traversal and so on but no general networking.
Makes sense, a pretty optimal solution that is easy to manage.
I was investigating a few years ago about potential solutions to overcome restricted networks and I am positive SSH can set a reverse tunnel, the only thing you need to do is monitor the connection and restart it from time to time, otherwise it should behave in the same manner as the websocket connection you are currently establishing from client devices.
Yes. SSH can establish a tunnel for any traffic you like pretty much. We would need the device to connect to a NervesHub service and your device to connect as well and then make those sockets have a chat.
Wireguard can do the same. But to my understanding Wireguard is way less overhead and operates more like a VPN giving you a flat network. You would be able to treat it as if your Nerves device was on the local network. SSH is only port forwarding.
Wireguard would enable you to access a web UI, SSH and so on.
SSH remote tunnels were a blessing for me on restricted networks in my teens. I could expose any port I liked if could SSH to my home server and my home server ran SSH on port 443.
Not ehat I would do for a good dev flow with Livebook and Nerves though. Maybe some nice MNDP (mndp | Hex) for discovery which I guess could work over Wireguard. (Edit: seems like Wireguard does not support broadcast/multicast so no discovery)
On this topic, there are also commercial solutions like cloudflare that offer a generous free tier. Their service is battery included, however their service is not protocol agnostic and you have to select one from the list when creating a tunnel.
The only big concern with the tunnel they provide is that you need to use their client, there is cloudflared that is most probably too resource heavy for an IOT device, it’s more oriented to be deployed on a proxy server, and warp that they market as the lightweight replacement, but the one I never managed to get working on linux.