From: saerome kim Date: Tue, 22 Aug 2017 10:26:27 +0000 (+0900) Subject: Add new CAPI to get softAP config options X-Git-Tag: submit/tizen/20170828.225740~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d1b35ac81b0d699444374188deedb36ff11e997;p=platform%2Fcore%2Fapi%2Fwifi-mesh.git Add new CAPI to get softAP config options Change-Id: If1f867b0e1bf32f34da123b8ab0690870513a8fd Signed-off-by: Saurav Babu --- diff --git a/include/wifi-mesh.h b/include/wifi-mesh.h index 7c73c5b..9ea778c 100644 --- a/include/wifi-mesh.h +++ b/include/wifi-mesh.h @@ -972,6 +972,35 @@ int wifi_mesh_get_joined_network(wifi_mesh_h handle, wifi_mesh_network_h* networ int wifi_mesh_set_softap(wifi_mesh_h handle, const char* ssid, const char* key, int channel, bool visibility, int max_stations, int security); +/** + * @brief Gets softap options + * @details This function gets softap options. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[out] ssid The SSID + * @param[out] channel The operating channel number + * @param[out] visibility The broadcast option (1:Broadcast SSID, 2:Hidden) + * @param[out] max_stations The maximum allowable number of stations (default:10) + * @param[out] security Security option (1:WPA1, 2:WPA2) + * @param[out] key The pre-shared key + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_set_softap() + * @see wifi_mesh_enable_softap() + * @see wifi_mesh_disable_softap() + * + */ +int wifi_mesh_get_softap(wifi_mesh_h handle, char **ssid, int *channel, + bool *visibility, int *max_stations, + int *security, char **key); + /** * @brief Enables softap * @details This function enables softap. diff --git a/include/wifi-mesh_dbus.h b/include/wifi-mesh_dbus.h index 16dc20d..73d1faa 100644 --- a/include/wifi-mesh_dbus.h +++ b/include/wifi-mesh_dbus.h @@ -58,6 +58,8 @@ int _wifi_mesh_set_gate(wifi_mesh_h handle, bool gate_announce, int hwmp_root_mo int _wifi_mesh_unset_gate(wifi_mesh_h handle); int _wifi_mesh_set_softap(wifi_mesh_h handle, const char* ssid, const char* key, const char* mode, int channel, int visibility, int max_stations, int security); +int _wifi_mesh_get_softap(wifi_mesh_h handle, char **ssid, int *channel, + bool *visibility, int *max_stations, int *security, char **key); int _wifi_mesh_enable_softap(wifi_mesh_h handle); int _wifi_mesh_disable_softap(wifi_mesh_h handle); int _mesh_create_network(wifi_mesh_h handle, wifi_mesh_network_h _network); diff --git a/src/wifi-mesh-dbus.c b/src/wifi-mesh-dbus.c index d3674db..29c1654 100644 --- a/src/wifi-mesh-dbus.c +++ b/src/wifi-mesh-dbus.c @@ -1318,6 +1318,59 @@ int _wifi_mesh_set_softap(wifi_mesh_h handle, const char* ssid, return result; } +int _wifi_mesh_get_softap(wifi_mesh_h handle, char **ssid, int *channel, + bool *visibility, int *max_stations, int *security, char **key) +{ + GVariant *variant = NULL; + int result = WIFI_MESH_ERROR_NONE; + GError *error = NULL; + struct mesh_handle *h = handle; + + if (NULL == h) { + /* LCOV_EXCL_START */ + LOGE("Invaild parameter"); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + if (NULL == h->dbus_connection || NULL == _gproxy_mesh_service) { + /* LCOV_EXCL_START */ + LOGE("I/O error"); + return WIFI_MESH_ERROR_IO_ERROR; + /* LCOV_EXCL_STOP */ + } + + variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_softap", NULL, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); + if (variant) { + char *_ssid = NULL, *_mode = NULL, *_key = NULL; + int _channel = -1, _visibility = -1, _max_sta = -1, _security = -1; + g_variant_get(variant, "(ssiiiisi)", &_ssid, &_mode, &_channel, + &_visibility, &_max_sta, &_security, &_key, &result); + LOGD("get_softap status 0x%x", result); + result = __convert_service_error_type(result); + + if (result == WIFI_MESH_ERROR_NONE) { + *ssid = g_strdup(_ssid); + *channel = _channel; + *visibility = _visibility == 1 ? 1 : 0; + *max_stations = _max_sta; + *security = _security; + if (_security == 1) + *key = g_strdup(_key); + } + + } else if (error) { + /* LCOV_EXCL_START */ + LOGE("Failed DBus call [%s]", error->message); + g_error_free(error); + return WIFI_MESH_ERROR_IO_ERROR; + /* LCOV_EXCL_STOP */ + } + + return result; +} + int _wifi_mesh_enable_softap(wifi_mesh_h handle) { GVariant *variant = NULL; diff --git a/src/wifi-mesh.c b/src/wifi-mesh.c index c7658bc..a9ae35a 100644 --- a/src/wifi-mesh.c +++ b/src/wifi-mesh.c @@ -717,6 +717,28 @@ EXPORT_API int wifi_mesh_set_softap(wifi_mesh_h handle, const char* ssid, return rv; } +EXPORT_API int wifi_mesh_get_softap(wifi_mesh_h handle, char **ssid, + int *channel, bool *visibility, int *max_stations, + int *security, char **key) +{ + int rv = 0; + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + if (NULL == handle || ssid == NULL || channel == NULL || + visibility == NULL || max_stations == NULL || + security == NULL || key == NULL) { + /* LCOV_EXCL_START */ + LOGE("Invalid parameter"); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + rv = _wifi_mesh_get_softap(handle, ssid, channel, visibility, max_stations, + security, key); + + return rv; +} + EXPORT_API int wifi_mesh_enable_softap(wifi_mesh_h handle) { int rv = 0; diff --git a/test/wifi-mesh-network.c b/test/wifi-mesh-network.c index fa8b708..fb601ab 100644 --- a/test/wifi-mesh-network.c +++ b/test/wifi-mesh-network.c @@ -605,6 +605,28 @@ static int run_set_softap(MManager *mm, struct menu_data *menu) } msg(" - wifi_mesh_set_softap() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); + msg("Get SoftAp Option"); + char *g_ssid, *g_key; + int g_channel, g_max_stations, g_security; + bool g_visibility; + ret = wifi_mesh_get_softap(mesh, &g_ssid, &g_channel, &g_visibility, + &g_max_stations, &g_security, &g_key); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to get softap options: [%s(0x%X)]", + wifi_mesh_error_to_string(ret), ret); + return RET_FAILURE; + } + + msg("SSID: %s", g_ssid); + msg("Channel: %d", g_channel); + msg("Visibility: %d", g_visibility); + msg("Max Stations: %d", g_max_stations); + msg("Security: %d", g_security); + msg("Key: %s", g_security ? g_key : "NULL"); + + g_free(g_ssid); + g_free(g_key); + return RET_SUCCESS; }