nymea / berrylan

Raspberry Pi WiFi setup
http://berrylan.org
GNU General Public License v3.0
333 stars 55 forks source link

Re-setup Wi-Fi #65

Open Ra-Light opened 2 years ago

Ra-Light commented 2 years ago

Would be nice to have possibility to setup Wi-Fi again and connect to another Wi-Fi network after initial Wi-Fi setup. Possibility to view IP address on connected network also would be nice to have.

osarhan commented 2 years ago

Would love functionality around seeing existing rpi wifi information and the ability to disconnect and reconnect to a wifi.

mzanetti commented 2 years ago

So, connecting to a different wifi after the initial setup is not really the problem. You can connect to the Pi again and configure a different WiFi. However, the actual issue here is the fact that the Bluetooth server shuts down once the RPi is connected to a WiFi. For security reasons that's probably the most sensible thing to do given the Bluetooth server does not require any authentication. Having the Bluetooth server active all the time would allow anyone within the Bluetooth signal range to "take over" your RPi.

That said, there might be use cases where this is not a concern. If that's the case for you, you can edit /etc/nymea/nymea-networkmanager.conf on the RPi and change the Mode to "always". This will keep the Bluetooth server active all the time and allow reconfiguration to a different WiFi at any time.

The best solution would be to add a push button to the RPi GPIO and set the Mode to "pushbutton" (Also configuring the GPIO pin for the button). This will require to have physical access to the RPi in order to press the button and will then open the Bluetooth server for a minute to allow reconfiguration.

As for obtaining IP information on an existing connection or disconnect it, I suppose that could be added to the app. However, note that it is affected to the same issue with the Bluetooth server not running (unless configured to always or pushbutton).

jonhassall commented 2 years ago

Perhaps setting a Bluetooth PIN after the first setup of WiFi would be a solution. The user could note it down if it was a situation where they may wish to change the connection later.

mzanetti commented 2 years ago

Given this works via Bluetooth LE (4.x) which an entirely different thing than classic Bluetooth, there is no pin based pairing available at Bluetooth level. This could be added on application level in a custom manner - in theory, but don't hold your breath for it happening anytime soon :)

Side note, for the push button approach as described above, everything is in place: Set the Mode to "button" and connect a push button between 3.3V and GPIO 14 (for some odd reason it's hardcoded to active-low currently). If you don't have a push button at hand, it would even suffice to connect GPIO 14 to the 3.3V with a dupont wire. To start the Bluetooth server, remove the wire for a second (simulating a 1 second button button press). That should start the Bluetooth server. Then plug the wire back in to not start the server endlessly.