manager_object = g_new0(wlan_manager_object, 1);
manager_object->message_func = NULL;
manager_object->refresh_func = NULL;
+ manager_object->active_wifi_index = 0;
}
return manager_object;
int wlan_manager_update_ap(wifi_manager_ap_h ap)
{
- int rv = wifi_manager_update_ap(manager_object->wifi, ap);
+ int rv = wifi_manager_update_ap(manager_object->wifi[manager_object->active_wifi_index], ap);
if (rv != WIFI_MANAGER_ERROR_NONE)
ERROR_LOG(COMMON_NAME_ERR, "Unable to update ap handle");
return rv;
int wlan_manager_is_activated(bool *activated)
{
- return wifi_manager_is_activated(manager_object->wifi, activated);
+ return wifi_manager_is_activated(manager_object->wifi[manager_object->active_wifi_index], activated);
}
int wlan_manager_destroy(void)
return ret;
}
- wifi_manager_unset_device_state_changed_cb(manager_object->wifi);
+ wifi_manager_unset_device_state_changed_cb(manager_object->wifi[manager_object->active_wifi_index]);
wlan_manager_deregister_cbs();
connection_manager_destroy();
- ret = wifi_manager_deinitialize(manager_object->wifi);
+ ret = wifi_manager_deinitialize(manager_object->wifi[manager_object->active_wifi_index]);
if (manager_object != NULL) {
g_free(manager_object);
int ret = WLAN_MANAGER_ERR_NONE;
- switch (wlan_initialize(&(manager_object->wifi))) {
+ if (!manager_object->ifname[manager_object->active_wifi_index]) {
+ ret = wlan_initialize(&(manager_object->wifi[manager_object->active_wifi_index]), NULL);
+ if (ret == WIFI_MANAGER_ERROR_NONE)
+ INFO_LOG(UG_NAME_NORMAL, "Initialize success and return");
+ return ret;
+ }
+
+ switch (wlan_initialize(&(manager_object->wifi[manager_object->active_wifi_index]), manager_object->ifname[manager_object->active_wifi_index])) {
case WIFI_MANAGER_ERROR_NONE:
/* Register the callbacks */
wlan_manager_register_cbs();
int wlan_manager_forget(wifi_manager_ap_h ap)
{
- return wifi_manager_forget_ap(manager_object->wifi, ap);
+ return wifi_manager_forget_ap(manager_object->wifi[manager_object->active_wifi_index], ap);
}
static void wlan_manager_network_event_cb(
{
__COMMON_FUNC_ENTER__;
- wifi_manager_set_device_state_changed_cb(manager_object->wifi, wlan_manager_device_state_changed_cb, NULL);
- wifi_manager_set_connection_state_changed_cb(manager_object->wifi, wlan_manager_connection_state_changed_cb, NULL);
- wifi_manager_set_rssi_level_changed_cb(manager_object->wifi, wlan_manager_rssi_level_changed_cb, NULL);
+ wifi_manager_set_device_state_changed_cb(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_device_state_changed_cb, NULL);
+ wifi_manager_set_connection_state_changed_cb(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_connection_state_changed_cb, NULL);
+ wifi_manager_set_rssi_level_changed_cb(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_rssi_level_changed_cb, NULL);
memset(&scan_req_data, 0, sizeof(scan_req_data));
scan_req_data.req_type = WLAN_MANAGER_REQ_TYPE_SCAN_RESULT;
- wifi_manager_set_background_scan_cb(manager_object->wifi, wlan_manager_network_event_cb, &scan_req_data);
+ wifi_manager_set_background_scan_cb(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_network_event_cb, &scan_req_data);
__COMMON_FUNC_EXIT__;
}
* detsroy.
*/
- wifi_manager_unset_background_scan_cb(manager_object->wifi);
- wifi_manager_unset_connection_state_changed_cb(manager_object->wifi);
- wifi_manager_unset_rssi_level_changed_cb(manager_object->wifi);
+ wifi_manager_unset_background_scan_cb(manager_object->wifi[manager_object->active_wifi_index]);
+ wifi_manager_unset_connection_state_changed_cb(manager_object->wifi[manager_object->active_wifi_index]);
+ wifi_manager_unset_rssi_level_changed_cb(manager_object->wifi[manager_object->active_wifi_index]);
__COMMON_FUNC_EXIT__;
}
ap_state_info.state = ap_state;
ap_state_info.ap = ≈
- ret_val = wifi_manager_foreach_found_ap(manager_object->wifi, wifi_found_ap_with_state_cb, &ap_state_info);
+ ret_val = wifi_manager_foreach_found_ap(manager_object->wifi[manager_object->active_wifi_index], wifi_found_ap_with_state_cb, &ap_state_info);
if (ret_val != WIFI_MANAGER_ERROR_NONE)
return NULL;
int wlan_manager_get_connected_ap(wifi_manager_ap_h *ap)
{
- return wifi_manager_get_connected_ap(manager_object->wifi, ap);
+ return wifi_manager_get_connected_ap(manager_object->wifi[manager_object->active_wifi_index], ap);
}
int wlan_manager_state_get(void)
wifi_manager_connection_state_e connection_state;
bool activated;
- if (WIFI_MANAGER_ERROR_NONE != wifi_manager_is_activated(manager_object->wifi, &activated)) {
+ if (WIFI_MANAGER_ERROR_NONE != wifi_manager_is_activated(manager_object->wifi[manager_object->active_wifi_index], &activated)) {
return WLAN_MANAGER_ERROR;
} else if (false == activated) {
INFO_LOG(COMMON_NAME_LIB, "STATE: WIFI_OFF");
return WLAN_MANAGER_OFF;
}
- ret_val = wifi_manager_get_connection_state(manager_object->wifi, &connection_state);
+ ret_val = wifi_manager_get_connection_state(manager_object->wifi[manager_object->active_wifi_index], &connection_state);
if (WIFI_MANAGER_ERROR_NONE != ret_val)
return WLAN_MANAGER_ERROR;
int ret = 0;
wlan_mgr_req_data_t *req_data = g_new0(wlan_mgr_req_data_t, 1);
req_data->req_type = WLAN_MANAGER_REQ_TYPE_ACTIVATE;
- ret = wifi_manager_activate(manager_object->wifi, wlan_manager_network_event_cb, req_data);
+ ret = wifi_manager_activate(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_network_event_cb, req_data);
if (WIFI_MANAGER_ERROR_NONE != ret && WIFI_MANAGER_ERROR_ALREADY_EXISTS != ret) {
ERROR_LOG(UG_NAME_REQ, "Power on request. Error Reason [%d]", ret);
g_free(req_data);
wlan_mgr_req_data_t *req_data = g_new0(wlan_mgr_req_data_t, 1);
req_data->req_type = WLAN_MANAGER_REQ_TYPE_DEACTIVATE;
- int ret = wifi_manager_deactivate(manager_object->wifi, wlan_manager_network_event_cb, req_data);
+ int ret = wifi_manager_deactivate(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_network_event_cb, req_data);
if (WIFI_MANAGER_ERROR_NONE != ret && WIFI_MANAGER_ERROR_ALREADY_EXISTS != ret) {
ERROR_LOG(UG_NAME_REQ, "Power off request. Error Reason [%d]", ret);
{
__COMMON_FUNC_ENTER__;
- wifi_manager_ap_hidden_create(manager_object->wifi, ssid, hidden_ap);
+ wifi_manager_ap_hidden_create(manager_object->wifi[manager_object->active_wifi_index], ssid, hidden_ap);
__COMMON_FUNC_EXIT__;
return;
{
__COMMON_FUNC_ENTER__;
- return wifi_manager_ap_create(manager_object->wifi, essid, ap);
+ return wifi_manager_ap_create(manager_object->wifi[manager_object->active_wifi_index], essid, ap);
__COMMON_FUNC_EXIT__;
}
{
__COMMON_FUNC_ENTER__;
- return wifi_manager_foreach_found_ap(manager_object->wifi, callback, profiles_list_size);
+ return wifi_manager_foreach_found_ap(manager_object->wifi[manager_object->active_wifi_index], callback, profiles_list_size);
__COMMON_FUNC_EXIT__;
}
req_data->req_type = WLAN_MANAGER_REQ_TYPE_SCAN;
manager_object->b_scan_blocked = TRUE;
- int ret = wifi_manager_scan(manager_object->wifi, wlan_manager_network_event_cb, req_data);
+ int ret = wifi_manager_scan(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_network_event_cb, req_data);
if (ret != WLAN_MANAGER_ERR_NONE) {
ERROR_LOG(UG_NAME_REQ, "Scan failed. Ret: %d", ret);
{
__COMMON_FUNC_ENTER__;
- int ret = wifi_manager_scan_specific_ap(manager_object->wifi,
+ int ret = wifi_manager_scan_specific_ap(manager_object->wifi[manager_object->active_wifi_index],
ssid, wlan_manager_specific_scan_finished_cb, user_data);
if (ret != WIFI_MANAGER_ERROR_NONE) {
ERROR_LOG(UG_NAME_REQ, "Specific Scan failed. Ret: %d", ret);
{
__COMMON_FUNC_ENTER__;
- return wifi_manager_get_connection_state(manager_object->wifi, state);
+ return wifi_manager_get_connection_state(manager_object->wifi[manager_object->active_wifi_index], state);
__COMMON_FUNC_EXIT__;
}
case WIFI_MANAGER_CONNECTION_STATE_FAILURE:
case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
- wlan_connect_next(manager_object->wifi);
+ wlan_connect_next(manager_object->wifi[manager_object->active_wifi_index]);
break;
case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
- wlan_go_fast_next(manager_object->wifi);
+ wlan_go_fast_next(manager_object->wifi[manager_object->active_wifi_index]);
break;
default:
break;
int wlan_manager_set_autoscan_mode(wlan_manager_autoscan_mode_e mode)
{
- int ret = wifi_manager_set_autoscan_mode(manager_object->wifi, mode);
+ int ret = wifi_manager_set_autoscan_mode(manager_object->wifi[manager_object->active_wifi_index], mode);
if (ret == WIFI_MANAGER_ERROR_NONE)
return WLAN_MANAGER_ERR_NONE;
else
return WLAN_MANAGER_ERR_OPERATION_FAILED;
}
+
+void wlan_manager_set_active_wifi_index(wlan_manager_wifi_iface_index_e index)
+{
+ manager_object->active_wifi_index = index;
+}
+
+int wlan_mgr_get_index_from_ifname(const char *ifname)
+{
+ if (!ifname)
+ return WLAN_MANAGER_WIFI_IFACE_MAX;
+ if (strncmp(ifname, WLAN_MANAGER_WIFI_WLAN0, strlen(ifname)) == 0)
+ return WLAN_MANAGER_WIFI_IFACE_WLAN0;
+ else if (strncmp(ifname, WLAN_MANAGER_WIFI_WLAN1, strlen(ifname)) == 0)
+ return WLAN_MANAGER_WIFI_IFACE_WLAN1;
+ else if (strncmp(ifname, WLAN_MANAGER_WIFI_WLAN2, strlen(ifname)) == 0)
+ return WLAN_MANAGER_WIFI_IFACE_WLAN2;
+ else if (strncmp(ifname, WLAN_MANAGER_WIFI_WLAN3, strlen(ifname)) == 0)
+ return WLAN_MANAGER_WIFI_IFACE_WLAN3;
+ return WLAN_MANAGER_WIFI_IFACE_MAX;
+}
+
+bool wlan_manager_interface_cb(char *ifname, void *user_data)
+{
+ int index = wlan_mgr_get_index_from_ifname(ifname);
+ if(index >= WLAN_MANAGER_WIFI_IFACE_MAX)
+ return TRUE;
+ manager_object->ifname[index] = g_strdup((char*)ifname);
+ INFO_LOG(UG_NAME_NORMAL, "Avalable ifname[%s] index[%d]", manager_object->ifname[manager_object->interface_count], index);
+ manager_object->interface_count++;
+ return TRUE;
+}
+
+int wlan_manager_get_available_interface(void)
+{
+ __COMMON_FUNC_ENTER__;
+ int ret = WLAN_MANAGER_ERR_NONE;
+
+ switch (wlan_manager_start()) {
+ case WLAN_MANAGER_ERR_NONE:
+ break;
+
+ case WLAN_MANAGER_ERR_ALREADY_REGISTERED:
+ break;
+
+ default:
+ ERROR_LOG(UG_NAME_NORMAL, "Cannot start wlan_manager");
+ return WLAN_MANAGER_ERR_UNKNOWN;
+ }
+ ret = wifi_manager_foreach_available_interface(manager_object->wifi[manager_object->active_wifi_index], wlan_manager_interface_cb, NULL );
+ wifi_manager_deinitialize(manager_object->wifi[manager_object->active_wifi_index]);
+ manager_object->wifi[manager_object->active_wifi_index] = NULL;
+ __COMMON_FUNC_EXIT__;
+ return ret;
+}
#include <wifi-manager-extension.h>
typedef enum {
+ WLAN_MANAGER_WIFI_IFACE_WLAN0,
+ WLAN_MANAGER_WIFI_IFACE_WLAN1,
+ WLAN_MANAGER_WIFI_IFACE_WLAN2,
+ WLAN_MANAGER_WIFI_IFACE_WLAN3,
+ WLAN_MANAGER_WIFI_IFACE_MAX
+} wlan_manager_wifi_iface_index_e;
+
+typedef enum {
WLAN_MANAGER_ERR_NONE = 0x00,
WLAN_MANAGER_ERR_UNKNOWN,
WLAN_MANAGER_ERR_INVALID_PARAM,
WLAN_MANAGER_RESPONSE_TYPE_UPDATE_WIFI_RSSI = 0x1C,
WLAN_MANAGER_RESPONSE_TYPE_CONFIGURATION = 0x1D,
WLAN_MANAGER_RESPONSE_TYPE_DHCP_FAILED = 0x1E,
- WLAN_MANAGER_RESPONSE_TYPE_MAX = 0x1F,
+ WLAN_MANAGER_RESPONSE_TYPE_MAX = 0x1F,
} WLAN_MANAGER_RESPONSE_TYPES;
typedef enum {
typedef void (*wlan_event_handler)(wlan_mgr_event_info_t *event_info, void *user_data);
+#define WLAN_IFACE_MAX_LEN 16
+#define WLAN_MANAGER_WIFI_WLAN0 "wlan0"
+#define WLAN_MANAGER_WIFI_WLAN1 "wlan1"
+#define WLAN_MANAGER_WIFI_WLAN2 "wlan2"
+#define WLAN_MANAGER_WIFI_WLAN3 "wlan3"
+
/** It should be hide to others */
typedef struct wlan_manager_object {
wlan_event_handler message_func;
wlan_manager_ui_refresh_func_t refresh_func;
gboolean b_scan_blocked;
gboolean b_ui_refresh;
- wifi_manager_h wifi;
+ unsigned int active_wifi_index;
+ wifi_manager_h wifi[WLAN_MANAGER_WIFI_IFACE_MAX];
+ char *ifname[WLAN_IFACE_MAX_LEN];
+ int interface_count;
} wlan_manager_object;
/////////////////////////////////////////////////////////////////
gboolean wlan_manager_is_same_network(wifi_manager_ap_h ap1, wifi_manager_ap_h ap2);
STRENGTH_TYPES wlan_manager_get_signal_strength(int rssi);
int wlan_manager_set_autoscan_mode(wlan_manager_autoscan_mode_e mode);
+void wlan_manager_set_active_wifi_index(wlan_manager_wifi_iface_index_e index);
+int wlan_manager_get_available_interface(void);
+bool wlan_manager_interface_cb(char *ifname, void *user_data);
+int wlan_mgr_get_index_from_ifname(const char *ifname);
//// profile refresh /////////////////////////////////////////////
void wlan_manager_scanned_profile_refresh(void);