Add API detail for Wi-Fi set/get tethering txpower. 77/71177/5 accepted/tizen/common/20160606.141816 accepted/tizen/ivi/20160602.230620 accepted/tizen/mobile/20160602.230553 accepted/tizen/tv/20160602.230610 accepted/tizen/wearable/20160602.230537 submit/tizen/20160602.021703 submit/tizen_common/20160606.122615
authorSumit Aggarwal <aggarwal.s@samsung.com>
Tue, 24 May 2016 15:58:40 +0000 (21:28 +0530)
committertaesubkim <taesub.kim@samsung.com>
Thu, 2 Jun 2016 02:27:17 +0000 (11:27 +0900)
Change-Id: Ib866dddaa4b200e00a5987636a7079d83e96b5f0
Signed-off-by: Sumit Aggarwal <aggarwal.s@samsung.com>
include/tethering.xml [changed mode: 0644->0755]
packaging/capi-network-tethering.spec
src/tethering.c
test/tethering_test.c

old mode 100644 (file)
new mode 100755 (executable)
index ac8d415..c76221e
                        <arg type="t" name="rx_data" direction="out"/>
                        <arg type="t" name="tx_data" direction="out"/>
                </method>
+               <method name="hostapd_set_txpower">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="u" name="txpower" direction="in"/>
+                       <arg type="u" name="result" direction="out"/>
+               </method>
 
+               <method name="hostapd_get_txpower">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="u" name="result" direction="out"/>
+               </method>
                <!-- Signal (D-Bus) definitions -->
                <signal name="net_closed">
                        <arg type="s" name="arg1" direction="out"/>
index 35d953cda9c31580b504c009c76dafe249774e5f..4be421ff69820a5bb203662fc95f521fca7e11b1 100644 (file)
@@ -1,6 +1,6 @@
 Name:          capi-network-tethering
 Summary:       Tethering Framework
-Version:       1.0.36
+Version:       1.0.37
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index d63720eb2b02d7d11ed49f966ea9d5f2fb3627f8..93f1f581b758e82cf508a65ad69d794db657f394 100755 (executable)
@@ -3303,3 +3303,60 @@ API int tethering_wifi_is_dhcp_enabled(tethering_h tethering, bool *dhcp_enabled
 
        return TETHERING_ERROR_NONE;
 }
+
+API int tethering_wifi_set_txpower(tethering_h tethering, unsigned int txpower)
+{
+       GError *error = NULL;
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+       _retvm_if(tethering_is_enabled(tethering, TETHERING_TYPE_WIFI) == false,
+                       TETHERING_ERROR_NOT_ENABLED,
+                       "tethering type[%d] is not enabled\n", TETHERING_TYPE_WIFI);
+       __tethering_h *th = (__tethering_h *)tethering;
+
+       g_dbus_proxy_call_sync(th->client_bus_proxy, "hostapd_set_txpower",
+                       g_variant_new("(u)", txpower),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1, th->cancellable, &error);
+       if (error) {
+               ERR("g_dbus_proxy_call_sync is failed and error is %s\n", error->message);
+               g_clear_error(&error);
+               return TETHERING_ERROR_OPERATION_FAILED;
+       }
+       return TETHERING_ERROR_NONE;
+}
+
+API int tethering_wifi_get_txpower(tethering_h tethering, unsigned int *txpower)
+{
+       GError *error = NULL;
+       GVariant *result = NULL;
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+       _retvm_if(tethering_is_enabled(tethering, TETHERING_TYPE_WIFI) == false,
+                       TETHERING_ERROR_NOT_ENABLED,
+                       "tethering type[%d] is not enabled\n", TETHERING_TYPE_WIFI);
+
+       __tethering_h *th = (__tethering_h *)tethering;
+
+       result = g_dbus_proxy_call_sync(th->client_bus_proxy, "hostapd_get_txpower",
+                       NULL,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1, th->cancellable, &error);
+
+       if (result != NULL) {
+               g_variant_get(result, "(u)", txpower);
+               g_variant_unref(result);
+       } else {
+               if (error)
+                       ERR("g_dbus_proxy_call_sync is failed and error is %s\n", error->message);
+               g_clear_error(&error);
+               return TETHERING_ERROR_OPERATION_FAILED;
+       }
+       g_clear_error(&error);
+       return TETHERING_ERROR_NONE;
+}
+
index 1aca12d78c7e987bd15b206465b794424575ef41..3410d306bc8665a30306a293c77dc7a5825fa955 100755 (executable)
@@ -941,6 +941,36 @@ static int test_tethering_wifi_reload_settings(void)
        return 1;
 }
 
+static int test_tethering_wifi_get_txpower(void)
+{
+       int ret = TETHERING_ERROR_NONE;
+
+       unsigned int txpower = 0;
+       ret = tethering_wifi_get_txpower(th, &txpower);
+       if (__is_err(ret) == true) {
+               printf("Fail to get txpower!!\n");
+               return -1;
+       }
+       g_print("tethering_hostapd_get_txpower received [%d]\n",txpower);
+       return 1;
+}
+static int test_tethering_wifi_set_txpower(void)
+{
+       int ret;
+       unsigned int txpower = 0;
+
+       printf("Input tx power for Wi-Fi tethering: ");
+       ret = scanf("%d", &txpower);
+
+       ret = tethering_wifi_set_txpower(th, txpower);
+       if (__is_err(ret) == true) {
+               printf("Fail to set txpower!!\n");
+               return -1;
+       }
+
+       return 1;
+}
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop;
@@ -994,6 +1024,8 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("o       - Enable dhcp server\n");
                printf("p       - Enable dhcp server with range\n");
                printf("q       - Is dhcp server enabled?\n");
+               printf("r       - Get Wi-Fi txpower\n");
+               printf("s       - Set Wi-Fi txpower\n");
                printf("0       - Exit \n");
                printf("ENTER  - Show options menu.......\n");
        }
@@ -1062,6 +1094,12 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'q':
                rv = test_tethering_wifi_is_dhcp_enabled();
                break;
+       case 'r':
+               rv = test_tethering_wifi_get_txpower();
+               break;
+       case 's':
+               rv = test_tethering_wifi_set_txpower();
+               break;
        }
 
        if (rv == 1)