Connman: enable wifi before scanning, and restart connman after generating the settings file

This commit is contained in:
Jean-André Santoni 2016-09-24 00:41:30 +02:00
parent d3878d5a92
commit eee9e5047b

View File

@ -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));