nerves-project / nerves_examples

Small example programs using Nerves
386 stars 113 forks source link

Simplify and make WiFi configuration consistent between examples #193

Open fhunleth opened 3 years ago

fhunleth commented 3 years ago

Currently some examples allow you to hardcode WiFi credentials in firmware by setting environment variables. This isn't supported by all examples and its implementation is inconsistent. I would be nice if there were common instructions for setting up WiFi and that every example that could use WiFi would be done the same way.

mnishiguchi commented 3 years ago

@fhunleth Is it doable to standardize on nerves_livebook's firmware provision options? https://github.com/livebook-dev/nerves_livebook#firmware-provisioning-options

fhunleth commented 3 years ago

The Nerves Livebook firmware provisioning is needed since you download images rather than build firmware yourself. All of the Nerves examples are built, so there are more options available and hardcoding network options may arguably be the most instructive to people learning Nerves. I lean towards less code in the examples if possible so that the key thing they show isn't obscured.

I'm also hesitant to promote the Nerves Livebook route. It was convenient, but there's work for every key/value that you export. What I'd really like is a generic way to update the application environment. Perhaps a ConfigProvider that reads from Nerves.Runtime.KV so any application environment key can be overridden. I think there are edge cases that need to be thought through on this especially on how to recover from bad settings.

mnishiguchi commented 3 years ago

Ah I see. Thanks for your explanation!

mnishiguchi commented 3 years ago

Maybe we can just use this pattern for all the examples, until we have plans for the ConfigProvider thing? https://github.com/nerves-project/nerves_examples/blob/main/hello_phoenix/firmware/config/target.exs#L75-L88

And if it is OK to be the default, maybe we could let the hex nerves.new generates that?