From: nshero.lee Date: Wed, 20 Dec 2017 10:08:02 +0000 (+0900) Subject: Update implementaion X-Git-Tag: submit/tizen_4.0/20180104.080035~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da454ca80ee85a6b3ac66a8e52f1a2b23c0adf13;p=platform%2Fcore%2Fsystem%2Fsetup-adaptor.git Update implementaion Signed-off-by: nshero.lee --- diff --git a/include/sa_types.h b/include/sa_types.h index a5fdb7d..b891dc7 100644 --- a/include/sa_types.h +++ b/include/sa_types.h @@ -37,31 +37,6 @@ #define SA_CONFIG_NETWORKDATA_HTTPPROXYHOST "httpProxyHost" #define SA_CONFIG_NETWORKDATA_HTTPPROXYPORT "httpProxyPort" -#define SA_MESSAGE_QID 0x00000001 - -/** - * @brief This enum contains docker interface command type - * - * The sa_msgq_cmd_type_e indicates what command is set - * - */ -typedef enum { - SA_FILE_CHANGE = 0x10, - SA_WIFI_CALLBACK = 0x11, -} sa_msgq_cmd_type_e; - -/** - * @struct sa_msgq_buf_s - * @brief This struct contains message queue information - * - * The sa_msgq_buf_s encapsulate the mtype, *event_data, cmd in the one data - * - */ -typedef struct { - long mtype; - char *event_data; - sa_msgq_cmd_type_e cmd; -} sa_msgq_buf_s; /** * @brief This enum contains setup-adaptor error information diff --git a/include/setup_network.h b/include/setup_network.h index 2b432c9..169e74c 100644 --- a/include/setup_network.h +++ b/include/setup_network.h @@ -16,6 +16,16 @@ #ifndef __SETUP_NETWORK_H__ #define __SETUP_NETWORK_H__ +typedef enum { + NETWORK_WIFI_STATE_DEACTIVATED = 0, + NETWORK_WIFI_STATE_ACTIVATING, + NETWORK_WIFI_STATE_ACTIVATED, + NETWORK_WIFI_STATE_SCANNING, + NETWORK_WIFI_STATE_SCANNED, + NETWORK_WIFI_STATE_CONNECTING, + NETWORK_WIFI_STATE_CONNECTED, +} network_wifi_state_e; + /** * @fn int sa_network_get_state(int conn_state) * @brief This function to get connection state @@ -29,23 +39,23 @@ int sa_network_get_state(sa_network_state_e *conn_state, sa_network_type_e *conn * @fn int sa_network_set_connection(sa_network_s *info) * @brief This function to set connection with info @param conn_type [in] type of connection - * @return int return of function + * @return sa_error_e return of function */ -int sa_network_set_connection(sa_network_s *info); +sa_error_e sa_network_set_connection(sa_network_s *info); /** * @fn int sa_network_get_connection(sa_network_s *info) * @brief This function to get connection with info * @param conn_type [out] connection info - * @return int return of function + * @return sa_error_e return of function */ -int sa_network_get_connection(sa_network_s *info); +sa_error_e sa_network_get_connection(sa_network_s *info); /** * @fn int sa_network_deactivate(void) * @brief This function to deactivate current connection - * @return int return of function + * @return sa_error_e return of function */ -int sa_network_deactivate(void); +sa_error_e sa_network_deactivate(void); #endif/* __SETUP_NETWORK_H__ */ diff --git a/include/setup_system.h b/include/setup_system.h index 8d0834d..4d72df0 100644 --- a/include/setup_system.h +++ b/include/setup_system.h @@ -20,16 +20,16 @@ * @fn int sa_system_set_proxy(sa_network_s *info) * @brief This function to set connection with info @param conn_type [in] proxy info to set - * @return int return of function + * @return sa_error_e return of function */ -int sa_system_set_proxy(sa_proxy_s *info); +sa_error_e sa_system_set_proxy(sa_proxy_s *info); /** * @fn int sa_system_get_proxy(sa_network_s *info) * @brief This function to get connection with info * @param conn_type [out] proxy info to get - * @return int return of function + * @return sa_error_e return of function */ -int sa_system_get_proxy(sa_proxy_s *info); +sa_error_e sa_system_get_proxy(sa_proxy_s *info); #endif/* __SETUP_SYSTEMDATA_H__ */ diff --git a/packaging/setup-adaptor.service b/packaging/setup-adaptor.service index 0e73224..fb3dd24 100644 --- a/packaging/setup-adaptor.service +++ b/packaging/setup-adaptor.service @@ -7,7 +7,7 @@ Requires=connman.service SmackProcessLabel=System Type=notify ExecStart=/usr/bin/setup-adaptor -Restart=always +Restart=on-failure RestartSec=0 [Install] diff --git a/packaging/setup-adaptor.spec b/packaging/setup-adaptor.spec index 20a5d01..3d8e2c4 100644 --- a/packaging/setup-adaptor.spec +++ b/packaging/setup-adaptor.spec @@ -1,8 +1,9 @@ Name: setup-adaptor Summary: Provide network and system data setting daemon -Version: 0.1.0 +Version: 0.2.0 Release: 0 -Group: System & Docker Framework +Group: System & System Tools +ExclusiveArch: armv7l License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1: %{name}.manifest diff --git a/src/adaptor.c b/src/adaptor.c index 45f3d00..1a9aa91 100644 --- a/src/adaptor.c +++ b/src/adaptor.c @@ -171,36 +171,117 @@ static int __parsing_config(sa_config_s *config) return ret; } -static int __activate_network(sa_network_s *network) +static int __compare_network_info(sa_network_s *devNetwork, sa_network_s *newNetwork) { + int needChange = FALSE; + + if (devNetwork == NULL || newNetwork == NULL) { + return -1; + } + + // compare wifi + // wifi has higher priority to compare. + // If wifi info is changed, it doesn't have to compare ethernet info + if (devNetwork->wifi != NULL && newNetwork->wifi != NULL) { + if (newNetwork->wifi->enabled == TRUE) { + // check ssid/password only + if (strcmp(devNetwork->wifi->ssid, newNetwork->wifi->ssid)) { + needChange = TRUE; + } + + if (needChange == FALSE && strcmp(devNetwork->wifi->password, newNetwork->wifi->password)) { + needChange = TRUE; + } + // TBD for checking other members such as, ipaddress, dns, gateway.... + } + } + + + if (needChange == FALSE && (devNetwork->eth != NULL && newNetwork->eth != NULL)) { + if (newNetwork->eth->enabled == TRUE) { + // check ip address only + if (devNetwork->eth->staticInfo != NULL && newNetwork->eth->staticInfo != NULL) { + if (strcmp(devNetwork->eth->staticInfo->ipAddress, newNetwork->eth->staticInfo->ipAddress)) { + needChange = TRUE; + } + } + } + } + + + return needChange; +} + +static int __set_network(sa_network_s *network) +{ + sa_network_s *currentNetwork = NULL; sa_error_e ret = SA_ERROR_NONE; sa_network_type_e conn_type; sa_network_state_e conn_state; int index = 0; + if (network != NULL) { + return -1; + } + // 1. check network state + // 2. if it is connected, read detail info + ret = sa_network_get_state(&conn_state, &conn_type); if (ret == SA_ERROR_NONE) { - for (index = 0; index < NETWORK_CHECK_RETRY_MAX; index++) { - ret = sa_network_get_state(&conn_state, &conn_type); - if (ret == SA_ERROR_NONE) { - if (conn_state == SA_NETWORK_STATE_CONNECTED) { - _D("Network is connected : Type[%d][%s]", conn_type, __print_connection_type(conn_type)); - break; - } else { - _D("conn_state [%d][%s]", conn_state, __print_connection_state(conn_state)); + _D("Device Network : Type[%d][%s] State[%d][%s]", conn_type, __print_connection_type(conn_type), conn_state, __print_connection_state(conn_state)); + if (conn_state == SA_NETWORK_STATE_CONNECTED) { + // read current network info + ret = sa_network_get_connection(currentNetwork); + if (ret == SA_ERROR_NONE && currentNetwork != NULL) { + // compare network info + if (__compare_network_info(currentNetwork, network)) { + // set network connection + ret = sa_network_set_connection(network); } } else { - _E("sa_network_get_state return error [%d]", ret); - break; + _E("__get_current_network_info return error [%d]", ret); + } + } else { + // in case of disconnect state + ret = sa_network_set_connection(network); + } + } + + return ret; +} + +static int compare_proxy_info(sa_proxy_s *devProxy, sa_proxy_s *newProxy) +{ + // comapre proxy + if (devProxy != NULL && newProxy != NULL) { + if (strlen(devProxy->httpProxyHost) > 0) { + if (strcmp(devProxy->httpProxyHost, newProxy->httpProxyHost)) { + // proxy info is different + return 1; + } else { + // Host address is the same, but port is different + if (devProxy->httpProxyPort != newProxy->httpProxyPort) { + return 1; + } } - sleep(1); } } - if (ret == SA_ERROR_NONE && conn_state != SA_NETWORK_STATE_CONNECTED) { - if (network != NULL) { - ret = sa_network_set_connection(network); + return 0; +} + +static int __set_system(sa_system_s *system) +{ + sa_proxy_s *devProxy = NULL; + sa_error_e ret = SA_ERROR_NONE; + + if (system != NULL) { + if (system->proxy != NULL) { + ret = sa_system_get_proxy(devProxy); + if (ret == SA_ERROR_NONE && compare_proxy_info(devProxy, system->proxy)) { + // set proxy + ret = sa_system_set_proxy(system->proxy); + } } - } return ret; @@ -217,7 +298,13 @@ void __monitor_file_state_cb(sa_file_state_e state, void *param1, void *param2) if (SA_ERROR_NONE == __parsing_config(config)) { // activate network if (config != NULL) { - __activate_network(config->networkData); + if (config->systemData != NULL) { + __set_system(config->systemData); + } + + if (config->networkData != NULL) { + __set_network(config->networkData); + } } __release_config_resource(config); } diff --git a/src/setup_network.c b/src/setup_network.c index 8aea5cc..c7d8106 100644 --- a/src/setup_network.c +++ b/src/setup_network.c @@ -22,6 +22,42 @@ #include "net_connection.h" #include "wifi-manager.h" +static int initialize_setup_network_flag; +static sa_network_state_e setup_network_wifi_state; +static char wifi_password[99+1]; +static connection_h connection_handle = NULL; +static wifi_manager_h *wifi_handle = NULL; + +static int __get_setup_network_initialized(void) +{ + return initialize_setup_network_flag; +} + +static void __set_setup_network_wifi_state(sa_network_state_e val) +{ + if (val != __get_setup_network_initialized()) { + setup_network_wifi_state = val; + } +} + +static int __get_setup_network_wifi_state(void) +{ + return setup_network_wifi_state; +} + +static void __set_setup_network_wifi_password(char *password) +{ + if (strcmp(wifi_password, password)) { + memcpy(wifi_password, password, MIN(strlen(password), sizeof(wifi_password)-1)); + } +} + +static char *__get_setup_network_wifi_password(void) +{ + return wifi_password; +} + + static const char *__print_wifi_state(connection_wifi_state_e state) { switch (state) { @@ -175,18 +211,25 @@ static int __check_wifi_state(connection_h connection, connection_wifi_state_e w static void __activated_callback(wifi_manager_error_e result, void *user_data) { - if (result == WIFI_MANAGER_ERROR_NONE) + if (result == WIFI_MANAGER_ERROR_NONE) { + __set_setup_network_wifi_state(NETWORK_WIFI_STATE_ACTIVATED); _D("Wi-Fi Activation Succeeded"); + } else _D("Wi-Fi Activation Failed! error : %s", __print_wifi_error(result)); } static void __scan_request_callback(wifi_manager_error_e error_code, void* user_data) { - if (user_data != NULL) - _D("user_data : %s", (char *)user_data); + __set_setup_network_wifi_state(NETWORK_WIFI_STATE_ACTIVATED); - _D("Scan Completed from scan request, error code : %s", __print_wifi_error(error_code)); + if (error_code == WIFI_MANAGER_ERROR_NONE) { + __set_setup_network_wifi_state(NETWORK_WIFI_STATE_SCANNED); + _D("Scan Completed from scan request"); + } + else + _D("Wi-Fi Scan Failed! error : %s", __print_wifi_error(error_code)); + } static int __compare_ap_name(const char *ap_name, const char *ap_name_part) @@ -209,7 +252,7 @@ static void __connected_callback(wifi_manager_error_e result, void *user_data) _D("Wi-Fi Connection Failed! error : %s", __print_wifi_error(result)); } -static int __found_connect_ap_callback(wifi_manager_ap_h ap, void *user_data) +static void __found_connect_ap_callback(wifi_manager_ap_h ap, void *user_data) { int rv = 0; char *ap_name = NULL; @@ -218,7 +261,7 @@ static int __found_connect_ap_callback(wifi_manager_ap_h ap, void *user_data) rv = wifi_manager_ap_get_essid(ap, &ap_name); if (rv != WIFI_MANAGER_ERROR_NONE) { _D("Fail to get AP name [%s]\n", __print_wifi_error(rv)); - return -1; + return; } if (__compare_ap_name(ap_name, ap_name_part)) { @@ -228,86 +271,90 @@ static int __found_connect_ap_callback(wifi_manager_ap_h ap, void *user_data) if (rv == WIFI_MANAGER_ERROR_NONE) { if (required) { - char passphrase[100]; - _D("Input passphrase for %s : ", ap_name); - rv = scanf("%99s", passphrase); - + char *passphrase = __get_setup_network_wifi_password(); + _D("password : [%s]", passphrase); rv = wifi_manager_ap_set_passphrase(ap, passphrase); if (rv != WIFI_MANAGER_ERROR_NONE) { _D("Fail to set passphrase : %s", __print_wifi_error(rv)); if (ap_name != NULL) free(ap_name);; - return false; + return ; } } //rv = wifi_manager_connect(wifi, ap, __connected_callback, NULL); if (rv != WIFI_MANAGER_ERROR_NONE) _D("Fail to connection request [%s] : %s", ap_name, __print_wifi_error(rv)); - else + else { _D("Success to connection request [%s]", ap_name); + __set_setup_network_wifi_state(NETWORK_WIFI_STATE_CONNECTED); + } } } if (ap_name != NULL) free(ap_name); - return true; -} + return; +} static int __connect_wifi(sa_wifi_s *info) { int rv = 0; - wifi_manager_h wifi = NULL; bool state = false; + int ret = 0; + sa_network_state_e wifi_state = SA_NETWORK_STATE_DISCONNECTED; if (info == NULL) { return -1; } - - rv = wifi_manager_initialize(&wifi); - - if (rv == WIFI_MANAGER_ERROR_NONE) { - // check wifi - rv = wifi_manager_is_activated(wifi, &state); - if (rv != WIFI_MANAGER_ERROR_NONE) { - printf("Fail to get Wi-Fi device state [%s]", __print_wifi_error(rv)); - return -1; - } - - // if wifi is not activated - if (state == FALSE) { - rv = wifi_manager_activate(wifi, __activated_callback, NULL); + + // if wifi is already connected, it would be diconnected + while(NETWORK_WIFI_STATE_CONNECTED != __get_setup_network_wifi_state()) { + // check wifi state whether it is activated or not + if (NETWORK_WIFI_STATE_DEACTIVATED == __get_setup_network_wifi_state()) { + rv = wifi_manager_is_activated(wifi_handle, &state); + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("Fail to get Wi-Fi device state [%s]", __print_wifi_error(rv)); + break; + } + __set_setup_network_wifi_state(NETWORK_WIFI_STATE_ACTIVATING); + rv = wifi_manager_activate(wifi_handle, __activated_callback, NULL); if (rv != WIFI_MANAGER_ERROR_NONE) { printf("Fail to activate Wi-Fi device [%s]", __print_wifi_error(rv)); - return -1; + break; } - } + } - // scan ap - rv = wifi_manager_scan(wifi, __scan_request_callback, NULL); + if (NETWORK_WIFI_STATE_ACTIVATED == __get_setup_network_wifi_state()) { + // scan ap + __set_setup_network_wifi_state(NETWORK_WIFI_STATE_SCANNING); + rv = wifi_manager_scan(wifi_handle, __scan_request_callback, NULL); - if (rv != WIFI_MANAGER_ERROR_NONE) { - _D("Scan request failed [%s]", __print_wifi_error(rv)); - return -1; + if (rv != WIFI_MANAGER_ERROR_NONE) { + _D("Scan request failed [%s]", __print_wifi_error(rv)); + break; + } } + + if (NETWORK_WIFI_STATE_SCANNED == __get_setup_network_wifi_state()) { + // connecting + __set_setup_network_wifi_state(NETWORK_WIFI_STATE_CONNECTING); + __set_setup_network_wifi_password(info->password); + rv = wifi_manager_foreach_found_ap(wifi_handle, __found_connect_ap_callback, info->ssid); - // connect ap - _D("AP : [%s]", info->ssid); - - rv = wifi_manager_foreach_found_ap(wifi, __found_connect_ap_callback, info->ssid); - if (rv != WIFI_MANAGER_ERROR_NONE) { - _D("Fail to connect (can't get AP list) [%s]", __print_wifi_error(rv)); - return -1; - } + if (rv != WIFI_MANAGER_ERROR_NONE) { + _D("Fail to connect (can't get AP list) [%s]", __print_wifi_error(rv)); + break; + } + } - } else { - _E("fail creation wifi-manager handler [%s]", __print_wifi_error(rv)); + sleep(1); } - return 0; + return rv; } static int __connect_ethernet(sa_eth_s *info) @@ -339,60 +386,114 @@ static int __connect_ethernet(sa_eth_s *info) return 0; } +static int __start_setup_network(void) +{ + int ret = 0; + int err_code = 0; + + err_code = wifi_manager_initialize(wifi_handle); + if (err_code == WIFI_MANAGER_ERROR_NONE) { + err_code = connection_create(&connection_handle); + if (err_code != CONNECTION_ERROR_NONE) + return -1; + } else { + return -1; + } + + return 0; +} + +static int __get_wifi_info(sa_wifi_s *info) +{ + int rv = 0; + char *ap_name = NULL; + wifi_manager_ap_h ap_h; + + rv = wifi_manager_get_connected_ap(wifi_handle, &ap_h); + if (rv != WIFI_MANAGER_ERROR_NONE) { + _D("Fail to get connected AP [%s]", __print_wifi_error(rv)); + return -1; + } + + rv = wifi_manager_ap_get_essid(ap_h, &ap_name); + if (rv != WIFI_MANAGER_ERROR_NONE) { + _D("Fail to get essid [%s]", __print_wifi_error(rv)); + wifi_manager_ap_destroy(ap_h); + return -1; + } + + _D("Connected AP : %s\n", ap_name); + memcpy(info->ssid, ap_name, MIN(strlen(ap_name), sizeof(info->ssid)-1)); + free(ap_name); + wifi_manager_ap_destroy(ap_h); + + return rv; +} + +static int __get_ethernet_info(sa_eth_s *info) { + char *ip_addr = NULL; + int input; + int rv; + + if (info != NULL) { + // only for ipv4 + rv = connection_get_ip_address(connection_handle, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + if (ip_addr == NULL) { + _D("IPv4 address does not exist"); + return -1; + } + _D("IPv4 address : %s", ip_addr); + memcpy(info->staticInfo->ipAddress, ip_addr, MIN(strlen(ip_addr), sizeof(info->staticInfo->ipAddress)-1)); + free(ip_addr); + } + + return rv; +} + int sa_network_get_state(sa_network_state_e *conn_state, sa_network_type_e *conn_type) { sa_error_e ret = SA_ERROR_UNKNOWN; - connection_h connection = NULL; connection_type_e net_state; connection_wifi_state_e wifi_state; int rv = 0; - int err = connection_create(&connection); - + if (!__get_setup_network_initialized()) { + if(__start_setup_network()) { + _E("not ready to use network api due to async reply from network api"); + } + } // check network state(eth/wifi) - if (CONNECTION_ERROR_NONE == err) { - rv = connection_get_type(connection, &net_state); - if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get network state [%s]\n", __print_error(rv)); - } else { - ret = SA_ERROR_NONE; - _D("Retval = [%s] network connection state [%s]\n", __print_error(rv), __print_connection_type(net_state)); - if (CONNECTION_TYPE_DISCONNECTED == net_state) { - *conn_state = SA_NETWORK_STATE_DISCONNECTED; - }else if (CONNECTION_TYPE_WIFI == net_state) { - *conn_type = SA_NETWORK_TYPE_WIFI; - // check wifi state - if (!__check_wifi_state(connection, wifi_state)) { - if (wifi_state == CONNECTION_WIFI_STATE_CONNECTED) { - *conn_state = SA_NETWORK_STATE_CONNECTED; - } else { - *conn_state = SA_NETWORK_STATE_DISCONNECTED; - } + rv = connection_get_type(connection_handle, &net_state); + if (rv != CONNECTION_ERROR_NONE) { + printf("Fail to get network state [%s]\n", __print_error(rv)); + } else { + ret = SA_ERROR_NONE; + _D("Retval = [%s] network connection state [%s]\n", __print_error(rv), __print_connection_type(net_state)); + if (CONNECTION_TYPE_DISCONNECTED == net_state) { + *conn_state = SA_NETWORK_STATE_DISCONNECTED; + } else if (CONNECTION_TYPE_WIFI == net_state) { + *conn_type = SA_NETWORK_TYPE_WIFI; + // check wifi state + if (!__check_wifi_state(connection_handle, wifi_state)) { + if (wifi_state == CONNECTION_WIFI_STATE_CONNECTED) { + *conn_state = SA_NETWORK_STATE_CONNECTED; + } else { + *conn_state = SA_NETWORK_STATE_DISCONNECTED; } - } else if (CONNECTION_TYPE_ETHERNET == net_state) { - *conn_type = SA_NETWORK_TYPE_ETH; - *conn_state = SA_NETWORK_STATE_CONNECTED; - } else { - *conn_state = SA_NETWORK_STATE_UNKNOWN; - *conn_type = SA_NETWORK_TYPE_NONE; } + } else if (CONNECTION_TYPE_ETHERNET == net_state) { + *conn_type = SA_NETWORK_TYPE_ETH; + *conn_state = SA_NETWORK_STATE_CONNECTED; + } else { + *conn_state = SA_NETWORK_STATE_UNKNOWN; + *conn_type = SA_NETWORK_TYPE_NONE; } - - // destroy connection - rv = connection_destroy(connection); - if (rv != CONNECTION_ERROR_NONE) { - ret = SA_ERROR_UNKNOWN; - printf("Fail to get network state [%s]\n", __print_error(rv)); - } - - } else { - _E("fail creation connection handler [%s]\n", __print_error(err)); - } + } return ret; } -int sa_network_activate(sa_network_s *info) +sa_error_e sa_network_set_connection(sa_network_s *info) { sa_error_e ret = SA_ERROR_NONE; connection_wifi_state_e wifi_state; @@ -403,27 +504,74 @@ int sa_network_activate(sa_network_s *info) return SA_ERROR_INVALID_PARAMETER; } - // first priority is wifi - if (info->wifi->enabled == TRUE) { - // wifi setting and waiting to get response - retWifi = __connect_wifi(info->wifi); + if (!__get_setup_network_initialized()) { + if(__start_setup_network()) { + _E("not ready to use network api due to async reply from network api"); + } + } - // or if wifi is enabled but fail to connect, try to connect eth - if (wifi_state != CONNECTION_WIFI_STATE_CONNECTED && info->eth->enabled == TRUE) { - retEth = __connect_ethernet(info->eth); + // first priority is wifi + if (info->wifi != NULL) { + if (info->wifi->enabled == TRUE) { + // wifi setting and waiting to get response + retWifi = __connect_wifi(info->wifi); + _D("return wifi [%d]", retWifi); + // or if wifi is enabled but fail to connect, try to connect eth + + /* + if (info->eth != NULL) { + if (wifi_state != CONNECTION_WIFI_STATE_CONNECTED && info->eth->enabled == TRUE) { + retEth = __connect_ethernet(info->eth); + } + }*/ } + } + + return 0; +} - } else { - // second priority is eth - if (info->eth->enabled == TRUE) { - retEth = __connect_ethernet(info->eth); +sa_error_e sa_network_get_connection(sa_network_s *info) +{ + sa_error_e ret; + connection_type_e net_state; + connection_wifi_state_e wifi_state; + sa_network_state_e conn_state; + sa_network_type_e conn_type; + int rv = 0; + + if (!__get_setup_network_initialized()) { + if(__start_setup_network()) { + _E("not ready to use network api due to async reply from network api"); } - } + } + // get network state + rv = connection_get_type(connection_handle, &net_state); + if (rv != CONNECTION_ERROR_NONE) { + // get detail information + if (CONNECTION_TYPE_WIFI == net_state) { + // check wifi state + if (!__check_wifi_state(connection_handle, wifi_state)) { + if (wifi_state == CONNECTION_WIFI_STATE_CONNECTED) { + // detail info for wifi + info->wifi = (sa_wifi_s *)malloc(sizeof(sa_wifi_s)); + if (info->wifi != NULL) { + ret = __get_wifi_info(info->wifi); + } + } + } + } else if (CONNECTION_TYPE_ETHERNET == net_state) { + // detail info for ethernet + info->eth = (sa_eth_s *)malloc(sizeof(sa_eth_s)); + if (info->eth != NULL) { + ret = __get_ethernet_info(info->eth); + } + } + } - return 0; + return ret; } -int sa_network_deactivate(void) +sa_error_e sa_network_deactivate(void) { sa_error_e ret = SA_ERROR_NONE; diff --git a/src/setup_system.c b/src/setup_system.c index e6e7f5d..c98d768 100644 --- a/src/setup_system.c +++ b/src/setup_system.c @@ -18,3 +18,12 @@ #include "sa_types.h" #include "setup_system.h" +sa_error_e sa_system_set_proxy(sa_proxy_s *info) +{ + return SA_ERROR_NONE; +} + +sa_error_e sa_system_get_proxy(sa_proxy_s *info) +{ + return SA_ERROR_NONE; +} \ No newline at end of file