From: saerome kim Date: Tue, 22 Aug 2017 10:30:06 +0000 (+0900) Subject: Added new CAPI to check is softap enabled X-Git-Tag: submit/tizen/20170828.225740^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be3655a2ef457720cea6f275db5440ae74a6e38d;p=platform%2Fcore%2Fapi%2Fwifi-mesh.git Added new CAPI to check is softap enabled Change-Id: Ib0b7a1d4e5e2c8ae5e319da2f112c08c3f79ddd6 Signed-off-by: Saurav Babu --- diff --git a/include/wifi-mesh.h b/include/wifi-mesh.h index 9ea778c..99b7783 100644 --- a/include/wifi-mesh.h +++ b/include/wifi-mesh.h @@ -1037,10 +1037,32 @@ int wifi_mesh_enable_softap(wifi_mesh_h handle); * * @see wifi_mesh_set_softap() * @see wifi_mesh_enable_softap() + * @see wifi_mesh_is_softap_started() * */ int wifi_mesh_disable_softap(wifi_mesh_h handle); +/** + * @brief Check softap status + * @details This function checks softap status + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[out] status Status of SoftAP + * + * + * @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() + * + */ +int wifi_mesh_is_softap_started(wifi_mesh_h handle, bool *status); + /** * @brief Creates new Wi-Fi mesh network configuration * @details This function creates new mesh network. diff --git a/include/wifi-mesh_dbus.h b/include/wifi-mesh_dbus.h index 73d1faa..8e878d2 100644 --- a/include/wifi-mesh_dbus.h +++ b/include/wifi-mesh_dbus.h @@ -62,6 +62,7 @@ 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 _wifi_mesh_is_softap_started(wifi_mesh_h handle, bool *result); int _mesh_create_network(wifi_mesh_h handle, wifi_mesh_network_h _network); int _mesh_connect_network(wifi_mesh_h handle, wifi_mesh_network_h _network); int _mesh_disconnect_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 29c1654..3cdddd5 100644 --- a/src/wifi-mesh-dbus.c +++ b/src/wifi-mesh-dbus.c @@ -1453,6 +1453,43 @@ int _wifi_mesh_disable_softap(wifi_mesh_h handle) return result; } +int _wifi_mesh_is_softap_started(wifi_mesh_h handle, bool *result) +{ + GVariant *variant = NULL; + 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, + "is_softap_enabled", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, + &error); + if (variant) { + g_variant_get(variant, "(b)", result); + LOGD("check_softap_status status %d", *result); + } 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 WIFI_MESH_ERROR_NONE; +} + int _mesh_create_network(wifi_mesh_h handle, wifi_mesh_network_h _network) { GVariant *variant = NULL; diff --git a/src/wifi-mesh.c b/src/wifi-mesh.c index a9ae35a..f59da7e 100644 --- a/src/wifi-mesh.c +++ b/src/wifi-mesh.c @@ -771,6 +771,22 @@ EXPORT_API int wifi_mesh_disable_softap(wifi_mesh_h handle) return rv; } +EXPORT_API int wifi_mesh_is_softap_started(wifi_mesh_h handle, bool *status) +{ + int rv = 0; + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + if (NULL == handle || NULL == status) { + /* LCOV_EXCL_START */ + LOGE("Invalid parameter"); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + rv = _wifi_mesh_is_softap_started(handle, status); + return rv; +} + EXPORT_API int wifi_mesh_create_network(wifi_mesh_h handle, wifi_mesh_network_h network) { int rv = 0; diff --git a/test/wifi-mesh-network.c b/test/wifi-mesh-network.c index fb601ab..e8ecf54 100644 --- a/test/wifi-mesh-network.c +++ b/test/wifi-mesh-network.c @@ -650,6 +650,21 @@ static int run_enable_softap(MManager *mm, struct menu_data *menu) static int run_disable_softap(MManager *mm, struct menu_data *menu) { int ret; + bool status; + msg("Check SoftAp status"); + + ret = wifi_mesh_is_softap_started(mesh, &status); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to check soft ap status: [%s(0x%X)]", + wifi_mesh_error_to_string(ret), ret); + return RET_FAILURE; + } + + if (status == false) { + msg("SoftAP is already disabled"); + return RET_SUCCESS; + } + msg("Disable SoftAp"); ret = wifi_mesh_disable_softap(mesh);