Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: How to connect to specific WiFi BSSID?
#1
Hi,

Been using Moode for my RPi / LMS system via Squeezelite for some years now and its great
I have just installed the latest Moode 6.4.0 version


I have a new Wifi Access point upstairs now and keep it with the same SSID as the router downstairs so that the mobile phones automatically switch between them without getting stuck on one or the other until the signal is zero
However, some of the RPi Moode Squeezelite boxes keep connecting to the upstairs wifi access point and then they are not visible to LMS

So, what I need is to be able to force these boxes to WiFi connect to the Router and not the upstairs access point - which both have the same SSID but different BSSID's.

I can do this on my Xubuntu on the laptop, by specifying BSSID

Is there any way to do this on Moode?

I hope I made sense  Smile

Leigh
Reply
#2
The link references an old post but it suggests that specifying bssid instead of ssid in wpa_supplicant.conf could work.
https://superuser.com/questions/1075776/...about-ssid

If it does work then just be aware that anytime you save the Network Config screen it will overwrite wpa_supplicant.conf.

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
@Leigh

I've been trying to wrap my head around what you said

Quote:I have a new Wifi Access point upstairs now and keep it with the same SSID as the router downstairs so that the mobile phones automatically switch between them without getting stuck on one or the other until the signal is zero

However, some of the RPi Moode Squeezelite boxes keep connecting to the upstairs wifi access point and then they are not visible to LMS

Tim's suggestion certainly works to ensure a connection only to a chosen AP [1], but it sounds like you may have an underlying issue with your home network configuration if there are visibility problems.

Regards,
Kent

[1] for those who like techie details: 

I have only a single AP running at the moment, but it was easy to edit the already configured wpa_supplicant.conf file on one of my moOde players and reboot. Using the BSSID worked a treat. 

As the discussion in the referenced link points out, this only works if the PSK is used and not the plaintext passphrase. Tim changed moOde to use the PSK beginning at version 6.0.0 so this is not an issue. However (!), the PSK depends on the SSID, the passphrase, and the specific client host, so it has to be pre-computed on each moOde player which is to use the BSSID.
Reply
#4
Thanks!
Yes, there is a problem with the home network, but it is beyond me to try to even understand it.


Upstairs is via an ethernet cable from the router, through an ethernet switch, then through another ethernet cable to an access point to give upstairs WiFi

Both the access point and the Router have the same SSID
I did this because otherwise the phones seemed to 'hang on' to the downstairs wifi when I went upstairs even when upstairs was much much stronger

However, when an RPi Moode box connected to upstairs Wifi, the LMS RPi (connected to downstairs Wifi) couldn't see it (Although I could see it via the web interface on the Laptop when connected to downstair WiFi)

Perhaps I should be trying to see why the visibility problem is there, or is it inevitable with the setup I have?

w.r.t Tim's solution, do I have to first boot up the RPi close to the router or with the access point switched off to ensure connection to the router to generate the PSK and then just change the SSID=xxxx to BSID=XXXXXXXXXXX in /etc/wpa_supplicant/wpa_supplicant.conf via ssh?
I am a bit wary of this as if I mess up the wifi connection, how do I get back in to reset it?

I have cheated for now - it was the Moode RPi in the Lounge that was the problem, so I just moved it closer to the router so that it didnt connect to the upstairs Access point   Blush

However, it would be nice to have music upstairs too ....

Leigh
Reply
#5
@Leigh

Yeah, it's frustrating but it shouldn't be "inevitable." 

However, I think it's beyond the scope of this forum to get into the details of multi-AP network configuration. I expect your upstairs access point is actually a combination access point/router which will have to be configured to be a bridge back to your primary router. Here's one step-by-step example I found in a quickie search: https://smallbusiness.chron.com/setting-...68675.html

These days folks seem to be migrating to mesh network gear to get around some of the setup hassles. I don't have any and can't comment on any possible gotchas (I always expect my toast to fall jelly-side down!).

As for the BSSID trick, yes, first configure moOde to be a client in your WiFi network. Before moOde can connect to your AP, it has to calculate the PSK, writing it into the /etc/wpa_supplicant/wpa_supplicant.conf file. You can then save a copy of this file---just in case!---and edit the original to use bssid= instead of ssid= and reboot. Note that you have to do the copying and editing as root (e.g., using sudo). Here's an example

Code:
pi@moode0w:/etc/wpa_supplicant $ sudo cat wpa_supplicant.conf
#########################################
# This file is automatically generated by
# the player Network configuration page.
#########################################

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
#ssid="XXXXXX"
bssid=XX:XX:XX:XX:XX:XX
scan_ssid=1
psk=x823x3x01x273761xx6x8x5x4xx7xx6x3x4x5xx4x20742xx5xx8x8xxx7xxxx56
}

where I have obfuscated various entries. The bssid value is published by the access point (a little Web searching will turn up how to get it various ways such as using the 'iwlist scan' command in Linux), and the psk value was calculated by moOde using wpa_passphrase. 

You can do this editing via moOde's Web SSH Terminal or by ssh'ing into moOde from another host.

I can think of two ways to recover if this borks something. One is to plug your moOde player into an Ethernet port on your router, ssh into it, and undo the edit. The other, if you have a Linux or MacOS host, is to remove the uSD card from the RPi, plug it into the host, and, again undo the edit.

Regards,
Kent
Reply
#6
Thanks Kent,
Just a simple repeater/AP plug in to mains thingy (D-Link DAP 1365), and that networking stuff is beyond me
Thanks for the info about the BSSID though.
No ethernet on my RPi Zero's but I can take the card out and edit the file
For now, though I am going to be lazy and leave the thing where it picks up the downstairs router!
Thanks again´
Leigh
Reply
#7
(12-11-2019, 05:44 PM)Leigh Wrote: Thanks Kent,
Just a simple repeater/AP plug in to mains thingy (D-Link DAP 1365), and that networking stuff is beyond me
Thanks for the info about the BSSID though.
No ethernet on my RPi Zero's but I can take the card out and edit the file
For now, though I am going to be lazy and leave the thing where it picks up the downstairs router!
Thanks again´
Leigh

That's not being lazy. It's prioritizing your efforts Smile

I have no experience with any vendor's WiFi range extenders. I have always assumed that using them wouldn't be much different from my using a full-function access point in bridge mode but you know what they say about *assume*!

Here's a line from the generic WiFi range extender explanation on the Linksys site which I think may be alluding to the BSSID issue but I could be wrong.

Quote:Pay attention to your device settings when using a range extender, though. You might not think it, but your home WiFi device will remain connected to your router until you manually switch over to your range extender network, even if your range extender is in closer proximity to your device than your router. Advances in range extender technology ... are underway to automate this process so that the switching happens “behind the scenes” without the user having to do any work.

Regards,
Kent
Reply
#8
I finally got round to trying it and it worked  Big Grin 
Thanks Tim & Kent!

I first connected the Rpi to the downstairs router by placing it nearby so that it calculated the PSK value

Then I shut it down and took out the SD card and put it in my Laptop, and did the below from there, (but I guess I could have used SSH to directly do it on the RPi?)


Then I found the correct bssid  using:
Code:
sudo iwlist wlp3s0 scan | egrep 'Cell |Quality|ESSID|Frequency'


Then I edited the /etc/wpa_supplicant/wpa_supplicant.conf file (via terminal with 'sudo nano') to comment out the ssid line and put in a new bssid line, thus

Code:
#ssid "MySSID" # old line
bssid 01:23:45:67:89:ab # new line


Finally, I reinserted the SD card in the RPi and booted it up in the place in the lounge where it used to connect to the upstairs access point and it instead connected to the downstairs router, just as I wanted!

Thanks again for your great help 

Leigh
Reply


Forum Jump: