2

On a freshly imaged stretch lite (it would be the same on a regular stretch or jessie) I've set-up wpa_supplicant.conf with 2 known wifi networks. After boot, the system selects one of the network specified in wpa_supplicant.conf, but how do I select the other one from the command line (without editing wpa_supplicant.conf of course!)?

2

It is not AFAIK possible to select by SSID, but you can manually select with something like the following.

wpa_cli select_network 1

It is quite a while since I used this, but networks are identified by position in wpa_supplicant.conf.

If you want to prefer one network setting priority is a better method.

  • So the index 1 in wpa_cli select_network 1 corresponds to the order of my networks in wpa_supplicant.conf? I'll try this soon. – calocedrus Jan 31 '18 at 0:07
  • Feedbacks on your answer: (1) wpa_cli select_network x with x = 0 or 1 returns the same Selected interface 'p2p-dev-wlan0' OK, and with both WiFi networks correctly broadcasting, my RPi still connects to only one of them, so this doesn't allow to switch between networks. (2) The position in wpa_supplicant.conf does not select the priority (setting my own hotspot in 2nd position in wpa_supplicant.conf will chose it even with the other WiFi turned on and set in 1st position). – calocedrus Jan 31 '18 at 1:14
  • And (3): I suppose that by setting priority you mean adding priority = x with x = 1, 2, ... inside network {...} in wpa_supplicant.conf? – calocedrus Jan 31 '18 at 1:16
  • As I said it has been some time since I used it (while testing with a number of AP). According to wpa_cli list_networks it works, I just switched from 1 PiNET any [CURRENT] to 1 PiNET any [DISABLED] but iwconfig shows wlan0 IEEE 802.11 ESSID:"PiNET" Maybe the wireless hook in dhcpcd gets in the way. – Milliways Jan 31 '18 at 1:37
  • Here's my experiment: (a) after reboot I'm connected to wifi_hotspot. (b) wpa_cli list_networks shows the 2 lines 0 other_wifi any and 1 myhostpot any (c) wpa_cli select_network 1 (d) wpa_cli list_networks then shows 0 other_wifi any [DISABLED] and 1 myhostpot any [CURRENT] (e) wpa_cli select_network 0 (f) wpa_cli list_networks shows 0 other_wifi any [CURRENT] 1 myhostpot any [DISABLED]. But I still see me as a connected user on my hotspot and still have the same IP address (ifconfig), and can do apt-get install (I didn't set the other wifi password so not connectd)! – calocedrus Jan 31 '18 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.