2 * Copyright (c) 2013, Intel Corporation.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
9 var connmanScanInProgress = false;
11 function connmanPanelInit() {
13 /* Connman Settings Panel */
14 $('#page_connman').on('pageshow', function(event, data) {
15 if (data.prevPage.attr('id') === 'page_connman_service') return;
17 wsAPI.subscribeEvents(connmanEventReceived);
19 console.log('Get all the available technologies');
20 $('#connman_technologies').html('');
21 settings.connman.getTechnologies(function(technologies) {
22 for (var i = 0; i < technologies.length; i++) {
23 var technology = technologies[i];
24 console.log('Connman technology found: ' + technology.prop.Type);
25 if (technology.prop.Type === 'bluetooth') {
26 /* Do not show bluetooth */
29 if (technology.prop.Powered === undefined) {
31 t.getPowered(function(is_powered) {
32 t.prop.Powered = is_powered;
33 connmanConstructTechnologyElement(t);
35 t.prop.Powered = false;
36 connmanConstructTechnologyElement(t);
40 connmanConstructTechnologyElement(technology);
48 $('#button_connman_refresh').on('click', function() {
49 /* connman only supports wifi scan */
50 if ($('#toggle_connman_wifi').val() === 'on') {
51 connmanScan('/net/connman/technology/wifi');
53 connmanSync(null, function(e) {
59 $('#button_connman_wifi_add').on('click', function() {
60 if (connmanScanInProgress) return;
62 console.log('Enter add WiFi page');
63 $.mobile.changePage('#page_wifi_add');
66 /* Connman tethering page */
67 $('#page_connman_tethering').on('pageshow', function(event, data) {
68 connmanTetheringPageReload();
71 /* Connman service detail page */
72 $('#page_connman_service').on('pageshow', function(event, data) {
73 var service_id = localStorage.getItem('connman_service_id');
74 if (service_id == undefined) return;
75 var service = $(jqId(service_id)).data('service-object');
76 connmanConstructServicePanel(service);
79 /* WiFi add new network page */
80 $('#page_wifi_add').on('pagebeforeshow', function(event, data) {
81 $('#input_wifi_add_ssid').val('');
82 $('#input_wifi_add_password').val('');
83 $('#radio_wifi_none').prop('checked', true);
84 $('input[name=radio_wifi_security]').checkboxradio('refresh');
85 $('#input_wifi_add_password').textinput('disable');
88 $('#button_wifi_add').on('click', function() {
89 var name = $('#input_wifi_add_ssid').val();
90 var security = $('input[name=radio_wifi_security]:checked').val();
91 var passcode = $('#input_wifi_add_password').val();
94 showMsg('Error', 'Enter SSID');
98 if (security !== 'none' && passcode === '') {
99 showMsg('Error', 'Enter passphrase');
103 showSpinner(false, 'Adding...');
104 connmanGetHiddenServicePath(security, function(service_path) {
105 var service = new settings.connman.ConnmanService('', {
107 'EncryptionMode': security
109 service.connect(passcode, function() {
111 connmanSync(function() {
113 console.log('Go back to Connman page');
114 $.mobile.changePage('#page_connman');
121 showMsg('Error', 'Failed to add network: ' + e);
129 $('[name="radio_wifi_security"]').on('change', function(event, data) {
130 var security = $('input[name=radio_wifi_security]:checked').val();
132 if (security === 'none') {
133 $('#input_wifi_add_password').textinput('disable');
134 $('#input_wifi_add_password').val('');
136 $('#input_wifi_add_password').textinput('enable');
140 $('#button_wifi_connect').on('click', function() {
141 var service_id = localStorage.getItem('connman_service_id');
142 if (service_id == undefined) return;
143 var service = $(jqId(service_id)).data('service-object');
144 var passcode = $('#input_wifi_connect_passphrase').val();
145 connmanConnectToService(service, passcode, function() {
146 console.log('Successfully connected to service: ' + service.prop.Name);
147 if ($.mobile.activePage.attr('id') !== 'page_connman') {
148 console.log('Go back to Connman page');
149 $.mobile.changePage('#page_connman');
152 showMsg('Error', 'Connect service failed: ' + e);
157 function connmanEventReceived(event) {
158 if (event.type === WS_EVENT_TYPE.CONNMAN) {
159 if ($.mobile.activePage.attr('id') !== 'page_connman' && $.mobile.activePage.attr('id') !== 'page_connman_service') {
163 if (event.name === 'ServicesChanged') {
164 connmanHandleServicesChanged(event.id, event.value);
165 } else if (event.name === 'PropertyChanged') {
166 connmanHandlePropertyChanged(event.id, event.value);
168 console.log('Unsupported event received: ' + event.name);
173 function connmanHandleServicesChanged(object_path, services) {
174 var servicesChanged = services[0];
175 var servicesRemoved = services[1];
177 console.log(servicesChanged.length + ' services changed');
178 for (var i = 0; i < servicesChanged.length; i++) {
179 if (servicesChanged[i][0] === undefined) {
180 console.log('Invalid parameters, missing object path');
184 var service = $(jqId(servicesChanged[i][0])).data('service-object');
186 if (service == null) {
187 console.log('could not find service object ' + servicesChanged[i][0]);
191 for (var prop in servicesChanged[i][1]) {
192 if (servicesChanged[i][1].hasOwnProperty(prop)) {
193 service.prop.prop = servicesChanged[i][1].prop;
194 connmanUpdateService(service);
195 console.log('Service ' + service.prop.Name + ' updated: ' + prop);
200 console.log(servicesRemoved.length + ' services removed');
201 for (var i = 0; i < servicesRemoved.length; i++) {
202 if (servicesRemoved[i] === undefined) {
203 console.log('Invalid parameters, missing object path');
207 connmanRemoveFromAvailableList(servicesRemoved[i]);
211 function connmanHandlePropertyChanged(id, property) {
212 if (property[0] === 'Powered') {
213 var index = id.lastIndexOf('/');
214 var technology = id.substring(index + 1);
215 if (property[1] === true) {
216 connmanToggleOn(technology);
217 if (technology === 'wifi') {
218 setTimeout(function() {
219 /* add a 1 sec delay */
224 connmanToggleOff(technology);
228 if (property[0] === 'State') {
229 /* specific service has changed */
230 var service = $(jqId(id)).data('service-object');
231 if (service == null) {
232 console.error('Connman service not found ' + id);
236 service.prop.State = property[1];
237 connmanUpdateService(service);
238 } else if (property[0] === 'Connected') {
239 /* unknown service has changed, sync Connman */
240 console.log('Unknown service connected property changed');
241 connmanSync(null, function(e) {
247 function connmanClearAvailableList() {
248 $('#listview_services_available').html('');
251 function connmanScan(technology) {
252 if (technology !== '/net/connman/technology/wifi') {
253 /* Connman only supports wifi scan */
257 if (connmanScanInProgress) {
258 console.log('Connman scan in progress...');
262 console.log('Start connman scan');
263 connmanScanInProgress = true;
265 /* clear the services list with new scan */
266 connmanClearAvailableList();
268 showSpinner(false, 'Scanning...');
269 $('#toggle_connman_wifi').slider('disable');
270 $('#toggle_connman_wifi').slider('refresh');
271 settings.connman.scan(technology, function(services) {
273 connmanScanInProgress = false;
274 $('#toggle_connman_wifi').slider('enable');
275 $('#toggle_connman_wifi').slider('refresh');
276 console.log('found ' + services.length + ' connman services');
277 for (var i = 0; i < services.length; i++) {
278 var service = services[i];
279 if (service.prop.Type === undefined || service.prop.Type === 'bluetooth') {
280 console.log('Ignore bluetooth or unknown services');
283 if (service.prop.Name === undefined) {
284 console.log('Ignore hidden service - ' + service.id);
288 connmanUpdateService(service);
292 connmanScanInProgress = false;
293 $('#toggle_connman_wifi').slider('enable');
294 $('#toggle_connman_wifi').slider('refresh');
295 showMsg('Error', 'Cannot scan: ' + e);
299 function connmanSync(success_cb, error_cb) {
300 if (connmanScanInProgress) {
301 console.log('Connman scan in progress...');
305 console.log('Start connman sync');
306 /* clear the services list with new scan */
307 connmanClearAvailableList();
309 wifiScanInProgress = true;
310 $('#toggle_connman_wifi').slider('disable');
311 $('#toggle_connman_wifi').slider('refresh');
312 settings.connman.getServices(function(services) {
313 connmanScanInProgress = false;
314 $('#toggle_connman_wifi').slider('enable');
315 $('#toggle_connman_wifi').slider('refresh');
316 console.log('found ' + services.length + ' connman services');
317 for (var i = 0; i < services.length; i++) {
318 var service = services[i];
319 if (service.prop.Type === undefined || service.prop.Type === 'bluetooth') {
320 console.log('Ignore bluetooth or unknown services');
323 if (service.prop.Name === undefined) {
324 console.log('Ignore hidden service - ' + service.id);
328 connmanUpdateService(service);
334 connmanScanInProgress = false;
335 $('#toggle_connman_wifi').slider('enable');
336 $('#toggle_connman_wifi').slider('refresh');
343 function connmanRefreshServicesList() {
344 $('#listview_services_available').listview('refresh');
347 function connmanAppendToAvailableList(service) {
348 if ($('#listview_services_available').find(jqId(service.id)).length != 0) return;
350 var parent = '#listview_services_available';
351 connmanConstructServiceElement(parent, service);
352 connmanUpdateServiceButton(service);
353 connmanRefreshServicesList();
356 function connmanRemoveFromAvailableList(service_id) {
357 var removeThis = $('#listview_services_available li').filter(function() {
358 return $(this).find(jqId(service_id)).length === 1;
361 if (removeThis.length !== 0) {
363 connmanRefreshServicesList();
367 function getSignalStrengthStr(strength) {
368 var signal_strength = 'unknown';
369 if (strength > 0 && strength <= 20) {
370 strength = 'very poor';
371 } else if (strength > 20 && strength <= 40) {
372 signal_strength = 'poor';
373 } else if (strength > 40 && strength <= 70) {
374 signal_strength = 'average';
375 } else if (strength > 70 && strength <= 90) {
376 signal_strength = 'good';
377 } else if (strength > 90 && strength <= 100) {
378 signal_strength = 'excellent';
380 return signal_strength;
383 function connmanConstructTechnologyElement(technology) {
384 if (technology.prop.Type === undefined || technology.prop.Name == undefined) {
385 console.error('technology type or name missing ' + technology);
389 var html = '<ul data-role="listview" data-inset="true" class="ui-listview ui-listview-inset">';
390 html += '<li data-role="fieldcontain">';
391 html += '<label for="toggle_connman_' + technology.prop.Type + '" class="ui-slider">' + technology.prop.Name + '</label>';
392 html += '<select data-role="slider" name="toggle_connman_' + technology.prop.Type + '" ';
393 html += 'id="toggle_connman_' + technology.prop.Type + '" class="ui-slider-switch">';
394 html += '<option value="off">Off</option>';
395 html += '<option value="on">On</option>';
396 html += '</select></li></ul>';
397 $('#connman_technologies').append(html).trigger('create');
399 console.log('Connman technology ' + technology.prop.Type + ' is powered: ' + technology.prop.Powered);
400 if (technology.prop.Powered) {
401 connmanToggleOn(technology.prop.Type);
402 if ($('ul#listview_services_available li').length === 0) {
403 /* connman only supports wifi scan */
404 if (technology.prop.Type === 'wifi') {
405 connmanScan(technology.id);
407 connmanSync(null, function(e) {
413 connmanToggleOff(technology.prop.Type);
416 $('#toggle_connman_' + technology.prop.Type).change(function() {
417 console.log('toggle ' + technology.prop.Type + ' changed');
419 if (connmanScanInProgress) {
420 console.log('Connman scan in progress...');
424 $('#toggle_connman_' + technology.prop.Type).slider('disable');
425 $('#toggle_connman_' + technology.prop.Type).slider('refresh');
426 if ($('#toggle_connman_' + technology.prop.Type).val() === 'off') {
427 technology.setPowered(false, function() {
429 $('#toggle_connman_' + technology.prop.Type).slider('enable');
430 $('#toggle_connman_' + technology.prop.Type).slider('refresh');
431 console.log('Successfully disabled connman technology ' + technology.prop.Type);
435 $('#toggle_connman_' + technology.prop.Type).slider('enable');
436 $('#toggle_connman_' + technology.prop.Type).val('on').slider('refresh');
437 showMsg('Error', 'Cannot disable ' + technology.prop.Type);
440 technology.setPowered(true, function() {
442 $('#toggle_connman_' + technology.prop.Type).slider('enable');
443 $('#toggle_connman_' + technology.prop.Type).slider('refresh');
444 if (technology.prop.Type === 'wifi') {
445 setTimeout(function() {
446 /* add a 1 sec delay */
447 connmanScan(technology.id);
450 console.log('Successfully enabled connman technology ' + technology.prop.Type);
454 $('#toggle_connman_' + technology.prop.Type).slider('enable');
455 $('#toggle_connman_' + technology.prop.Type).val('off').slider('refresh');
456 showMsg('Error', 'Cannot enable ' + technology.prop.Type);
462 function connmanConstructServiceElement(parent, service) {
463 if (service.id === undefined || service.prop.Type === undefined) {
464 console.error('service id or type missing ' + service);
468 var html = '<li data-icon="false"><a href="#" id="' + jqId(service.id).replace('#', '') + '">';
469 html += '<div class="service-ssid">' + service.prop.Name + '</div>';
471 if (service.prop.Type === 'wifi') {
472 html += '<div class="service-encryption">Encryption: ' + service.prop.EncryptionMode + '</div>';
473 html += '<div class="service-strength">Signal: ' + getSignalStrengthStr(service.prop.Strength) + '</div>';
475 html += '<div class="service-status"></div>';
476 html += '<div data-role="button" class="service-action-button ui-li-aside" data-inline="true"></div>';
478 $(parent).append(html).trigger('create');
480 /* store service object in the element so we can reference it later */
481 $(jqId(service.id)).data('service-object', service);
483 $(jqId(service.id)).on('click', function() {
484 /* BUG in webruntime that cause click event when another page is rendered */
485 if ($.mobile.activePage.attr('id') === 'page_connman') {
486 localStorage.setItem('connman_service_id', service.id);
487 console.log('Enter Connman service page');
488 $.mobile.changePage('#page_connman_service');
492 $(jqId(service.id)).find('div.service-action-button').on('click', function(e) {
493 var parent = $(this).parent().attr('id');
496 * prevent the click event to propagate up
498 e.stopImmediatePropagation();
501 /* retrieve the service object from element */
502 var service = $(jqId(parent)).data('service-object');
503 if (service == null) {
504 console.error('Connman service object not found');
508 if (service.prop.State === 'idle') {
509 if (service.prop.EncryptionMode === 'none') {
510 connmanConnectToService(service, null);
512 connmanConnectToService(service, null, null, function(e) {
513 console.log('Connect failed, will ask for passphrase');
514 localStorage.setItem('connman_service_id', service.id);
515 console.log('Enter connect WiFi page');
516 $.mobile.changePage('#page_wifi_connect');
519 } else if (service.prop.State === 'ready') {
520 console.log('Disconnecting from service: ' + service.prop.Name);
521 showSpinner(false, 'Disconnecting...');
522 service.disconnect(function() {
524 connmanSync(function() {
532 showMsg('Error', 'Disconnect service failed: ' + e);
538 function connmanTetheringPageReload() {
539 $('#connman_tethering_technologies').html('');
540 settings.connman.getTechnologies(function(technologies) {
541 for (var i = 0; i < technologies.length; i++) {
542 var technology = technologies[i];
543 console.log('Connman technology available for tethering: ' + technology.prop.Name);
544 connmanConstructTetheringElement(technology);
551 function connmanConstructTetheringElement(technology) {
552 if (technology.prop.Type === undefined || technology.prop.Name == undefined) {
553 console.error('technology type or name missing ' + technology);
557 var html = '<ul data-role="listview" data-inset="true" class="ui-listview ui-listview-inset">';
558 html += '<li data-role="fieldcontain">';
559 html += '<label for="toggle_tethering_' + technology.prop.Type + '" class="ui-slider">Tether ' + technology.prop.Name + '</label>';
560 html += '<select data-role="slider" name="toggle_tethering_' + technology.prop.Type + '" ';
561 html += 'id="toggle_tethering_' + technology.prop.Type + '" class="ui-slider-switch">';
562 html += '<option value="off">Off</option>';
563 html += '<option value="on">On</option>';
564 html += '</select></li></ul>';
565 $('#connman_tethering_technologies').append(html).trigger('create');
567 console.log('Connman technology ' + technology.prop.Type + ' is tethered: ' + technology.prop.Tethering);
569 if (technology.prop.Powered === true && technology.prop.Connected === true) {
570 if (technology.prop.Tethering === true) {
571 $('#toggle_tethering_' + technology.prop.Type).val('on').slider('refresh');
572 $('#input_wifi_tethering_id').textinput('disable');
573 $('#input_wifi_tethering_passphrase').textinput('disable');
574 /* WiFi-only options */
575 if (technology.prop.Type === 'wifi') {
576 $('#connman_wifi_tethering_options').show();
577 if (technology.prop.TetheringIdentifier) {
578 $('#input_wifi_tethering_id').val(technology.prop.TetheringIdentifier);
580 if (technology.prop.TetheringPassphrase) {
581 $('#input_wifi_tethering_passphrase').val(technology.prop.TetheringPassphrase);
585 $('#toggle_tethering_' + technology.prop.Type).val('off').slider('refresh');
588 if (technology.prop.Type === 'wifi') {
589 $('#input_wifi_tethering_id').textinput('disable');
590 $('#input_wifi_tethering_passphrase').textinput('disable');
592 $('#toggle_tethering_' + technology.prop.Type).slider('disable');
593 $('#toggle_tethering_' + technology.prop.Type).slider('refresh');
596 $('#toggle_tethering_' + technology.prop.Type).change(function() {
597 if ($('#toggle_tethering_' + technology.prop.Type).val() === 'on') {
598 if (technology.prop.Type === 'wifi') {
599 var tethering_id = $('#input_wifi_tethering_id').val();
600 var tethering_passphrase = $('#input_wifi_tethering_passphrase').val();
601 if (tethering_id === '' || tethering_passphrase === '') {
602 connmanTetheringPageReload();
603 showMsg('Error', 'Please provide identifier and passphrase');
607 technology.setTethering(true, tethering_id, tethering_passphrase, function() {
609 console.log('Successfully tethered connman technology ' + technology.prop.Type);
610 connmanTetheringPageReload();
613 connmanTetheringPageReload();
614 showMsg('Error', 'Cannot tether ' + technology.prop.Type + ': ' + e);
617 technology.setTethering(true, '', '', function() {
619 console.log('Successfully tethered connman technology ' + technology.prop.Type);
620 connmanTetheringPageReload();
623 connmanTetheringPageReload();
624 showMsg('Error', 'Cannot tether ' + technology.prop.Type + ': ' + e);
628 technology.setTethering(false, '', '', function() {
630 console.log('Successfully untethered connman technology ' + technology.prop.Type);
631 connmanTetheringPageReload();
634 connmanTetheringPageReload();
635 showMsg('Error', 'Cannot untether ' + technology.prop.Type + ': ' + e);
641 function connmanUpdateService(service) {
642 connmanAppendToAvailableList(service);
644 /* update service button for allowed action */
645 connmanUpdateServiceButton(service);
647 /* update service connection status */
648 connmanUpdateConnectionStatus(service);
650 /* update service detail panel */
651 if ($.mobile.activePage.attr('id') === 'page_connman_service') {
652 var service_id = localStorage.getItem('connman_service_id');
653 if (service_id == undefined) return;
654 var service_object = $(jqId(service_id)).data('service-object');
655 if (service.id === service_object.id) {
656 connmanConstructServicePanel(service);
661 function connmanUpdateServiceButton(service) {
662 if (service.prop.State === 'ready') {
663 $(jqId(service.id)).find('div.service-action-button').find('span').text('Disconnect');
664 } else if (service.prop.State === 'idle' || service.prop.State === 'online') {
665 $(jqId(service.id)).find('div.service-action-button').find('span').text('Connect');
669 function connmanUpdateConnectionStatus(service) {
670 var status = 'disconnected';
671 if (service.prop.State === 'ready') {
672 $(jqId(service.id)).addClass('service-connected');
673 status = 'connected';
674 } else if (service.prop.State === 'idle' || service.prop.State === 'online') {
675 status = 'disconnected';
676 $(jqId(service.id)).removeClass('service-connected');
679 connmanUpdateConnectionStatusText(service, status);
682 function connmanUpdateConnectionStatusText(service, status) {
683 $(jqId(service.id)).find('div.service-status').text(status);
686 function connmanConstructServicePanel(service) {
687 var status_connected = 'No';
689 if (service == null) return;
690 if (service.prop.State === 'ready') status_connected = 'Yes';
692 $('#page_connman_service_content').html('');
693 var html = '<ul data-role="listview" id="listview_connman_service" data-inset="true" ' + 'class="service-list ui-listview">';
694 html += '<li id="connman_service_name"><h2>Name: ' + service.prop.Name + '</h2></li>';
695 html += '<li id="connman_service_type"><h2>Type: ' + service.prop.Type + '</h2></li>';
696 html += '<li id="connman_service_type"><h2>State: ' + service.prop.State + '</h2></li>';
697 if (service.prop.Type === 'ethernet' || service.prop.Type === 'wifi') {
698 if (service.prop.Type === 'wifi') {
699 html += '<li id="connman_service_bssid"><h2>SSID: ' + service.prop.BSSID + '</h2></li>';
700 html += '<li id="connman_service_encryption"><h2>Encryption: ' + service.prop.EncryptionMode + '</h2></li>';
701 html += '<li id="connman_service_strength"><h2>Signal Strength: ' + service.prop.Strength + '</h2></li>';
703 if (service.prop.State === 'ready') {
704 html += '<li id="connman_service_ip_address"><h2>IP Address: ' + service.prop.IPv4.Address + '</h2></li>';
705 html += '<li id="connman_servicel_gateway"><h2>Gateway: ' + service.prop.IPv4.Gateway + '</h2></li>';
706 html += '<li id="connman_service_netmask"><h2>Netmask: ' + service.prop.IPv4.Netmask + '</h2></li>';
709 html += '<li id="connman_service_connected"><h2>Connected: ' + status_connected + '</h2></li>';
711 $('#page_connman_service_content').append(html).trigger('create');
712 $('#listview_connman_services').listview('refresh');
714 var html = '<ul data-role="listview" data-inset="true" class="ui-listview ui-listview-inset">';
715 html += '<li data-role="fieldcontain">';
716 html += '<label for="toggle_autoconnect" class="ui-slider">Auto Connect</label>';
717 html += '<select data-role="slider" name="toggle_autoconnect" ';
718 html += 'id="toggle_autoconnect" class="ui-slider-switch">';
719 html += '<option value="off">Off</option>';
720 html += '<option value="on">On</option>';
721 html += '</select></li></ul>';
722 $('#page_connman_service_content').append(html).trigger('create');
724 if (service.prop.AutoConnect) {
725 $('#toggle_autoconnect').val('on').slider('refresh');
727 $('#toggle_autoconnect').val('off').slider('refresh');
730 $('#toggle_autoconnect').change(function() {
731 if ($('#toggle_autoconnect').val() === 'on') {
732 service.setAutoConnect(true, function() {
734 console.log('Successfully enabled autoconnect for ' + service.prop.Name);
737 console.log('Cannot enable autoconnect: ' + e);
740 service.setAutoConnect(false, function() {
742 console.log('Successfully disabled autoconnect for ' + service.prop.Name);
745 console.log('Cannot disable autoconnect: ' + e);
751 function connmanUpdateServicePanel(service) {
752 var status_connected = 'No';
754 if (service == null) return;
755 if (service.prop.State === 'ready') status_connected = 'Yes';
756 $('#connman_service_connected').text(status_connected);
757 $('#listview_connman_service').listview('refresh');
760 function connmanToggleOn(technology_type) {
761 setTimeout(function() {
762 $('#toggle_connman_' + technology_type).val('on').slider('refresh');
763 console.log('Turn on toggle #toggle_connman_' + technology_type);
767 function connmanToggleOff(technology_type) {
768 setTimeout(function() {
769 $('#toggle_connman_' + technology_type).val('off').slider('refresh');
770 console.log('Turn off toggle #toggle_connman_' + technology_type);
774 function connmanConnectToService(service, passphrase, success_cb, error_cb) {
775 console.log('Connect to service: ' + service.prop.Name);
776 showSpinner(false, 'Connecting...');
777 service.connect(passphrase, function() {
779 connmanSync(function() {
799 function connmanGetHiddenServicePath(security_type, success_cb, error_cb) {
800 if (security_type === undefined || success_cb === undefined || error_cb === undefined) return;
801 settings.connman.scan(function(services) {
802 connmanScanInProgress = false;
803 console.log('found ' + services.length + ' connman services');
804 for (var i = 0; i < services.length; i++) {
805 var service = services[i];
806 if (service.prop.Name === undefined && service.prop.Type === 'wifi') {
807 console.log('Hidden network matched - ' + service.id);
808 success_cb(service.id);
812 error_cb('No hidden network with security: ' + security_type);
814 connmanScanInProgress = false;