diff --git a/plinth/modules/networks/networks.py b/plinth/modules/networks/networks.py index 8bff13806..c4a368242 100644 --- a/plinth/modules/networks/networks.py +++ b/plinth/modules/networks/networks.py @@ -354,15 +354,15 @@ def add_pppoe(request): 'form': form}) -def add_wifi(request, ssid=None): +def add_wifi(request, ssid=None, interface_name=None): """Serve wifi connection create form.""" form = None form_data = None if ssid: - device = network.get_first_wifi_device() + device = network.get_device_by_interface_name(interface_name) form_data = {'name': ssid, - 'interface': device, + 'interface': interface_name if device else None, 'zone': 'external', 'ssid': ssid, 'mode': 'infrastructure', diff --git a/plinth/modules/networks/templates/wifi_scan.html b/plinth/modules/networks/templates/wifi_scan.html index 54a7a38e8..092c287aa 100644 --- a/plinth/modules/networks/templates/wifi_scan.html +++ b/plinth/modules/networks/templates/wifi_scan.html @@ -29,7 +29,7 @@
{% if access_point.ssid %} + href="{% url 'networks:add_wifi' access_point.ssid access_point.interface_name %}"> {{ access_point.ssid }} {% else %} diff --git a/plinth/modules/networks/urls.py b/plinth/modules/networks/urls.py index ad483a737..d07739551 100644 --- a/plinth/modules/networks/urls.py +++ b/plinth/modules/networks/urls.py @@ -37,7 +37,7 @@ urlpatterns = patterns( url(r'^sys/networks/add/$', 'add', name='add'), url(r'^sys/networks/add/ethernet/$', 'add_ethernet', name='add_ethernet'), url(r'^sys/networks/add/pppoe/$', 'add_pppoe', name='add_pppoe'), - url(r'^sys/networks/add/wifi/(?:(?P[^/]+)/)?$', 'add_wifi', + url(r'^sys/networks/add/wifi/(?:(?P[^/]+)/(?P[^/]+)/)?$', 'add_wifi', name='add_wifi'), url(r'^sys/networks/(?P[\w.@+-]+)/delete/$', 'delete', name='delete'), diff --git a/plinth/network.py b/plinth/network.py index 2a5287900..fb2794ef8 100644 --- a/plinth/network.py +++ b/plinth/network.py @@ -624,6 +624,7 @@ def wifi_scan(): ssid = access_point.get_ssid() ssid_string = ssid.get_data() if ssid else '' access_points.append({ + 'interface_name': device.get_iface(), 'ssid': ssid_string, 'strength': access_point.get_strength()})