From eee9e5047b411ca6fa3d876957917e8741453a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sat, 24 Sep 2016 00:41:30 +0200 Subject: [PATCH] Connman: enable wifi before scanning, and restart connman after generating the settings file --- wifi/drivers/connmanctl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wifi/drivers/connmanctl.c b/wifi/drivers/connmanctl.c index fcbc8318e4..9a70845b4a 100644 --- a/wifi/drivers/connmanctl.c +++ b/wifi/drivers/connmanctl.c @@ -55,6 +55,8 @@ static void connmanctl_scan(void) free(lines); lines = string_list_new(); + pclose(popen("connmanctl enable wifi", "r")); + pclose(popen("connmanctl scan wifi", "r")); runloop_msg_queue_push("Wi-Fi scan complete.", 1, 180, true); @@ -92,7 +94,7 @@ static bool connmanctl_ssid_is_online(unsigned i) const char *line = lines->elems[i].data; if (!line) return false; - return line[2] == 'O'; + return line[2] == 'O' || line[2] == 'R'; } static bool connmanctl_connect_ssid(unsigned i, const char* passphrase) @@ -105,6 +107,8 @@ static bool connmanctl_connect_ssid(unsigned i, const char* passphrase) char settings_path[PATH_MAX_LENGTH] = {0}; FILE *command_file = NULL; FILE *settings_file = NULL; + FILE *serv_file = NULL; + union string_list_elem_attr attr; const char *line = lines->elems[i].data; strlcpy(name, line+4, sizeof(name)); @@ -135,6 +139,8 @@ static bool connmanctl_connect_ssid(unsigned i, const char* passphrase) fprintf(settings_file, "IPv4.method=%s\n", "dhcp"); fclose(settings_file); + pclose(popen("systemctl restart connman", "r")); + strlcat(command, "connmanctl connect ", sizeof(command)); strlcat(command, service, sizeof(command)); strlcat(command, " 2>&1", sizeof(command));