return true;
}
+struct _ap_data {
+ char ap_name[33];
+ bool is_found;
+};
+
static bool __test_found_connect_ap_callback(wifi_manager_ap_h ap, void *user_data)
{
int rv = 0;
char *ap_name = NULL;
- char *ap_name_part = (char*)user_data;
+ struct _ap_data *data = (struct _ap_data*)user_data;
rv = wifi_manager_ap_get_essid(ap, &ap_name);
if (rv != WIFI_MANAGER_ERROR_NONE) {
return false;
}
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ if (__test_compare_ap_name(ap_name, data->ap_name)) {
bool required = false;
+ data->is_found = true;
if (wifi_manager_ap_is_passphrase_required(ap, &required) == WIFI_MANAGER_ERROR_NONE)
printf("Passphrase required : %s\n", required ? "TRUE" : "FALSE");
int test_wifi_manager_connect(void)
{
int rv = 0;
- char ap_name[33];
+ struct _ap_data data;
bool state = false;
wifi_manager_is_activated(wifi, &state);
return -1;
printf("Input a part of AP name to connect : ");
- rv = scanf("%32s", ap_name);
+ rv = scanf("%32s", data.ap_name);
+ data.is_found = false;
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_ap_callback, ap_name);
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_ap_callback, (void*)&data);
if (rv != WIFI_MANAGER_ERROR_NONE) {
printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
return -1;
}
+ if (!data.is_found) {
+ printf("%s is not found\n", data.ap_name);
+ return -1;
+ }
printf("Connection step finished\n");
return 1;
}