Need help with assigning priority to wifi network

Hello Community,

I’m trying to configure multiple wifi networks to my wlan0 using vintage_net.
I want understand more about assigning priority to the networks. I was able to set priority and observed that network with higher priority is selected. Sharing an example i used

VintageNet.configure("wlan0", %{
  type: VintageNetWiFi,
  vintage_net_wifi: %{
    networks: [
      
      %{
        ssid: "TestWifi1",
        psk: "Test1234567",
        key_mgmt: :wpa_psk,
        priority: 2
      },
      %{
        ssid: "TestWifi2",
        psk: "Test1234567@sor",
        key_mgmt: :wpa_psk,
        priority: 1
      }
    ]
  },
  ipv4: %{method: :dhcp}
})

Referring to above example, I observed wlan0 get connected to TestWifi1
I do have few question related to this

  1. Is there any limit to priority
  2. Is there any other method to assign priority
  3. priority should always be integer? or it can be string?
  4. I was not able to find any documentation related to this, if someone can point me to any documentation

Thanks & Regards

VintageNetWiFi’s parameters translate pretty much verbatim to those used by wpa_supplicant, so the example wpa_supplicant.conf usually has the best information.

Here’s the relevant section about priority:

# priority: priority group (integer)
# By default, all networks will get same priority group (0). If some of the
# networks are more desirable, this field can be used to change the order in
# which wpa_supplicant goes through the networks when selecting a BSS. The
# priority groups will be iterated in decreasing priority (i.e., the larger the
# priority value, the sooner the network is matched against the scan results).
# Within each priority group, networks will be selected based on security
# policy, signal strength, etc.
# Please note that AP scanning with scan_ssid=1 and ap_scan=2 mode are not
# using this priority to select the order for scanning. Instead, they try the
# networks in the order that used in the configuration file.
1 Like