SLP improvement: multiple wifi networks configured

S.L.P. image questions, stereoscopic video livestream and recording, stereoscopic photo capture etc.
Post Reply
stereomaton
Posts: 215
Joined: Tue May 21, 2019 12:33 pm
Location: France

SLP improvement: multiple wifi networks configured

Post by stereomaton »

Observed in version 0.2.3 of SLP

I usually connect my stereopi to home WiFi network (to easily work on it with the computer) and mobile-phone WiFi network (for in-field control). However, SLP allows to store the ids of only one of these networks at a time.
By modifying the scripts, it is possible to have multiple access points registered (the first seen will be used). That way, I do not have to change the configuration of the stereopi anymore.

In /opt/StereoPi/scripts/wlan.lib.php
Add

Code: Select all

        shell_exec('cat /etc/wifi.conf >> /run/' . $iface . '.conf');
just after the line 174

Code: Select all

        file_put_contents("/run/$iface.conf", "country=00\n");
Now, the file /etc/wifi.conf is added in the configuration of WiFi manager (takes precedence because before stereopi configuration). When trying to connect to a wifi network, it first tries the networks listed in this file from the first to the last and then the network written in the stereopi.conf file.

It is possible to make the stereopi.conf more important by adding the aforementioned added line one line after.

To construct /etc/wifi.conf, you can (with the filesystem unlocked) do

Code: Select all

wpa_passphrase "SSID" "password" >> /etc/wifi.conf
Example of /etc/wifi.conf file:

Code: Select all

network={
        ssid="MyPhone"
        #psk="SuperPassword"
        psk=479ad0624653e3b28b8da0fa355692603071a29f8613217f087eaec1b126ba4e
}
network={
        ssid="MyHome"
        #psk="SuperPassword"
        psk=83f244c0e1f4079b262ce69d1c7075ddaaff397e1c63cf397ebe8fb27b0d43d5
}
network={
        ssid="MyHome2"
        psk=d1b4719a8788e370f0c03f5018422a2eb8bf11c557b6d21656087fd79dcd2f40
}
Note: the #psk line is optional and can be removed like here for the MyHome2 network
Stereophotographer and hacker
Despite my quite active participation in the forum, I am not in the StereoPi team
StereoPi (v1) Standard Edition + CM3Lite module + a few cameras

User avatar
stereomii
Posts: 37
Joined: Mon May 13, 2019 3:11 pm
Location: Apeldoorn, The Netherlands
Contact:

Re: SLP improvement: multiple wifi networks configured

Post by stereomii »

Thanks for this hack :D
Works like a charm. Btw I put wifi.conf in /boot. Readable by Windows.
Jan a.k.a. stereomii
StereoPi with Waveshare 160deg cams

Post Reply