Refactor the code that implicitely called __connman_service_connect()
for ethernet and gadget services and __connman_service_autoconnect()
for a non-NFC provisioned wifi service to do this explicitely.

Ethernet and gadget services are to be connected immediately when
provisioned as the services only exist while a cable is attached. For
a non-NFC provisioned wifi service autoconnect is used, as the
provisioned wifi might not be the best one in range. An NFC
provisioned wifi, i.e. the only category that currently has a virtual
config,  will be connected explicitely after the exiting to the main
loop.
---
 src/config.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/config.c b/src/config.c
index 276e06b..9d1759f 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1296,9 +1296,7 @@ static int try_provision_service(struct 
connman_config_service *config,
        if (type == CONNMAN_SERVICE_TYPE_WIFI) {
                provision_service_wifi(config, service, network,
                                                        ssid, ssid_len);
-       } else
-               __connman_service_connect(service,
-                                       CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+       }
 
        __connman_service_mark_dirty();
 
@@ -1312,8 +1310,19 @@ static int try_provision_service(struct 
connman_config_service *config,
                virtual->vfile = config->virtual_file;
 
                g_timeout_add(0, remove_virtual_config, virtual);
-       } else
-               
__connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+
+               return 0;
+       }
+
+       if (type == CONNMAN_SERVICE_TYPE_ETHERNET ||
+                       type == CONNMAN_SERVICE_TYPE_GADGET) {
+               __connman_service_connect(service,
+                               CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+
+               return 0;
+       }
+
+       __connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
 
        return 0;
 }
-- 
1.9.1

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to