예제 #1
0
static wifi_device_info_t *view_main_item_device_info_create(wifi_ap_h ap)
{
	wifi_device_info_t *wifi_device = g_try_new0(wifi_device_info_t, 1);
	wifi_security_type_e sec_type;

	if (WIFI_ERROR_NONE != wifi_ap_clone(&(wifi_device->ap), ap)) {
		g_free(wifi_device);
		return NULL;
	} else if (WIFI_ERROR_NONE != wifi_ap_get_essid(ap, &(wifi_device->ssid))) {
		g_free(wifi_device);
		return NULL;
	} else if (WIFI_ERROR_NONE != wifi_ap_get_rssi(ap, &(wifi_device->rssi))) {
		g_free(wifi_device->ssid);
		g_free(wifi_device);
		return NULL;
	} else if (WIFI_ERROR_NONE != wifi_ap_get_security_type(ap, &sec_type)) {
		g_free(wifi_device->ssid);
		g_free(wifi_device);
		return NULL;
	} else if (WIFI_ERROR_NONE != wifi_ap_is_wps_supported(ap, &(wifi_device->wps_mode))) {
		g_free(wifi_device->ssid);
		g_free(wifi_device);
		return NULL;
	}

	wifi_device->security_mode = common_utils_get_sec_mode(sec_type);
	/*MINI*/
	wifi_device->ap_status_txt = common_utils_get_ap_security_type_info_txt(PACKAGE,
	wifi_device, true);
	wifi_device->is_bt_tethered_device = false;
	common_utils_get_device_icon(wifi_device, &wifi_device->ap_image_path);

	return wifi_device;
}
예제 #2
0
void view_main_item_state_set(wifi_ap_h ap, ITEM_CONNECTION_MODES state)
{
	__COMMON_FUNC_ENTER__;

	char *item_ssid = NULL;
	wifi_security_type_e sec_type;
	wlan_security_mode_type_t item_sec_mode;
	Elm_Object_Item* it = NULL;

	it = elm_genlist_first_item_get(list);
	if (!it ||
		!ap ||
		(WIFI_ERROR_NONE != wifi_ap_get_essid(ap, &item_ssid)) ||
		(WIFI_ERROR_NONE != wifi_ap_get_security_type(ap, &sec_type))) {
		ERROR_LOG(SP_NAME_NORMAL, "Invalid params");
		if(item_ssid != NULL) {
			g_free(item_ssid);
			item_ssid = NULL;
		}
		__COMMON_FUNC_EXIT__;
		return;
	}
	item_sec_mode = common_utils_get_sec_mode(sec_type);
	SECURE_INFO_LOG(SP_NAME_NORMAL, "item state set for AP[%s] with sec mode[%d]", item_ssid, item_sec_mode);
	while (it) {
		devpkr_gl_data_t *gdata = (devpkr_gl_data_t *)elm_object_item_data_get(it);
		if (gdata != NULL) {
			SECURE_INFO_LOG(SP_NAME_NORMAL, "gdata AP[%s] with sec mode[%d]",
					gdata->dev_info->ssid, gdata->dev_info->security_mode);
		}

		if (gdata && gdata->dev_info->security_mode == item_sec_mode &&
			!g_strcmp0(gdata->dev_info->ssid, item_ssid)) {
			if (gdata->connection_mode != state) {
				gdata->connection_mode = state;
				INFO_LOG(SP_NAME_NORMAL, "State transition from [%d] --> [%d]", view_main_state_get(), state);
				view_main_state_set(state);
				elm_genlist_item_update(it);
			}
			break;
		}

		it = elm_genlist_item_next_get(it);
	}
	g_free(item_ssid);
	__COMMON_FUNC_EXIT__;
	return;
}
예제 #3
0
Elm_Object_Item *view_main_item_get_for_ap(wifi_ap_h ap)
{
	__COMMON_FUNC_ENTER__;
	if (!ap || !list) {
		__COMMON_FUNC_EXIT__;
		return NULL;
	}

	char *essid = NULL;
	wifi_security_type_e type = WIFI_SECURITY_TYPE_NONE;

	if (WIFI_ERROR_NONE != wifi_ap_get_essid(ap, &essid)) {
		__COMMON_FUNC_EXIT__;
		return NULL;
	}
	if (WIFI_ERROR_NONE != wifi_ap_get_security_type(ap, &type)) {
		g_free(essid);
		__COMMON_FUNC_EXIT__;
		return NULL;
	}

	Elm_Object_Item *it = elm_genlist_first_item_get(list);
	wlan_security_mode_type_t sec_mode = common_utils_get_sec_mode(type);
	while (it) {
		devpkr_gl_data_t* gdata = elm_object_item_data_get(it);
		wifi_device_info_t *device_info = NULL;
		if (gdata && (device_info = gdata->dev_info)) {
			if (!g_strcmp0(device_info->ssid, essid) && device_info->security_mode == sec_mode) {
				break;
			}
		}

		it = elm_genlist_item_next_get(it);
	}

	g_free(essid);
	__COMMON_FUNC_EXIT__;
	return it;
}
예제 #4
0
bool __wifi_found_ap_cb(wifi_ap_h ap, void *user_data)
{
    OIC_LOG(INFO,LOG_TAG,"#### __wifi_found_ap_cb received ");

    int error_code = 0;
    char *ap_name = NULL;
    wifi_connection_state_e state;

    error_code = wifi_ap_get_essid(ap, &ap_name);
    if (error_code != WIFI_ERROR_NONE)
    {
        OIC_LOG(ERROR,LOG_TAG,"#### Fail to get AP name.");

        return false;
    }
    error_code = wifi_ap_get_connection_state(ap, &state);
    if (error_code != WIFI_ERROR_NONE)
    {
        OIC_LOG(ERROR,LOG_TAG,"#### Fail to get state.");
        free(ap_name);

        return false;
    }
    OIC_LOG_V(INFO,LOG_TAG,"#### AP name : %s, state : %s", ap_name, print_state(state));

    if (strcmp(ap_name, gSsid) == 0)
    {
        OIC_LOG(INFO,LOG_TAG,"#### network found");
        wifi_ap_set_passphrase(ap, gPass);
        connectedWifi = ap;
        error_code = wifi_connect(ap, __wifi_connected_cb, NULL);
        OIC_LOG_V(INFO,LOG_TAG,"Code=%d", error_code);
    }
    OIC_LOG(INFO,LOG_TAG,"#### __wifi_found_ap_cb received ");
    free(ap_name);
    return true;
}