Added new CAPI to check is softap enabled 69/145469/1 submit/tizen/20170828.225740
authorsaerome kim <saerome.kim@samsung.com>
Tue, 22 Aug 2017 10:30:06 +0000 (19:30 +0900)
committersaerome kim <saerome.kim@samsung.com>
Tue, 22 Aug 2017 10:30:06 +0000 (19:30 +0900)
Change-Id: Ib0b7a1d4e5e2c8ae5e319da2f112c08c3f79ddd6
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
include/wifi-mesh.h
include/wifi-mesh_dbus.h
src/wifi-mesh-dbus.c
src/wifi-mesh.c
test/wifi-mesh-network.c

index 9ea778cc09899e7528095cdf31e84aa26214389f..99b778382456a1630a713779f4f644a0fee97c3f 100644 (file)
@@ -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.
index 73d1faa554b8d4f9b71e67756fd964b7e2775fc2..8e878d2d33a76bd8fb3f44586e771c4540b5f311 100644 (file)
@@ -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);
index 29c1654582370ba1fe0ae457d3994db27fa68a2c..3cdddd55aff3f40816af57402ebbeb1a178f1edb 100644 (file)
@@ -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;
index a9ae35a07ea7f9bc9a52ee56ed9ba3923967748f..f59da7e2c5559a696d475b7c4326fb10606f88ff 100644 (file)
@@ -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;
index fb601ab6a46ce991e93a228c9150ad67b28f7fb6..e8ecf54cb43d2d517bdcb295cf9b180752832df8 100644 (file)
@@ -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);