diff --git a/plinth/modules/networks/networks.py b/plinth/modules/networks/networks.py index db224e227..8bff13806 100644 --- a/plinth/modules/networks/networks.py +++ b/plinth/modules/networks/networks.py @@ -360,7 +360,9 @@ def add_wifi(request, ssid=None): form_data = None if ssid: + device = network.get_first_wifi_device() form_data = {'name': ssid, + 'interface': device, 'zone': 'external', 'ssid': ssid, 'mode': 'infrastructure', diff --git a/plinth/network.py b/plinth/network.py index 3e5a6bea8..2a5287900 100644 --- a/plinth/network.py +++ b/plinth/network.py @@ -76,6 +76,17 @@ def get_interface_list(device_type): return interfaces +def get_first_wifi_device(): + """Get a list of network interface available on the system.""" + interface = "empty" + for device in nm.Client.new(None).get_devices(): + if device.get_device_type() == nm.DeviceType.WIFI: + interface = device.get_iface() + return interface + + return interface + + def get_ip_from_device(devicename): """ Get the first ip address from the network interface.