Add API detail for Wi-Fi set/get tethering txpower. 81/71181/1
authorSumit Aggarwal <aggarwal.s@samsung.com>
Tue, 24 May 2016 16:05:37 +0000 (21:35 +0530)
committerSumit Aggarwal <aggarwal.s@samsung.com>
Tue, 24 May 2016 16:05:37 +0000 (21:35 +0530)
Change-Id: I54bb09fbc2b6e06b13628c5ca244e34b9cdbf608
Signed-off-by: Sumit Aggarwal <aggarwal.s@samsung.com>
include/mobileap_softap.h
include/tethering-dbus-interface.xml [changed mode: 0644->0755]
src/mobileap_main.c [changed mode: 0644->0755]
src/mobileap_softap.c

index 57a591a..91b6481 100755 (executable)
@@ -246,4 +246,6 @@ gboolean _mobileap_set_state(int state);
 void _flush_dhcp_ack_timer(void);
 void _destroy_dhcp_ack_timer(char *mac_addr);
 
+int _set_hostapd_tx_power(unsigned int txpower);
+unsigned int _get_hostapd_tx_power(void);
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index 90ba391..f6495fa
                        <arg type="s" name="rangestop" direction="in"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
+               <method name="hostapd_set_txpower">
+                       <arg type="u" name="txpower" direction="in"/>
+                       <arg type="u" name="result" direction="out"/>
+               </method>
 
+               <method name="hostapd_get_txpower">
+                       <arg type="u" name="result" direction="out"/>
+               </method>
                <!-- Signal (D-Bus) definitions -->
                <signal name="net_closed">
                </signal>
old mode 100644 (file)
new mode 100755 (executable)
index 7eaeaf0..b0b8b6a
@@ -353,6 +353,45 @@ gboolean softap_get_station_info(Softap *obj,
        return TRUE;
 }
 
+gboolean tethering_set_hostapd_tx_power(Tethering *obj,
+                       GDBusMethodInvocation *context, gint txpower)
+{
+       DBG("+\n");
+
+       GVariant *var = NULL;
+       int result = 0;
+
+       g_assert(obj != NULL);
+       g_assert(context != NULL);
+       result = _set_hostapd_tx_power(txpower);
+       var = g_variant_new("(u)", result);
+
+       g_dbus_method_invocation_return_value(context, var);
+       g_variant_unref(var);
+
+       DBG("-\n");
+       return TRUE;
+}
+
+gboolean tethering_get_hostapd_tx_power(Tethering *obj,
+                       GDBusMethodInvocation *context)
+{
+       DBG("+\n");
+
+       GVariant *var = NULL;
+       unsigned int txpower = 0;
+
+       g_assert(obj != NULL);
+       g_assert(context != NULL);
+       txpower = _get_hostapd_tx_power();
+       var = g_variant_new("(u)", txpower);
+       g_dbus_method_invocation_return_value(context, var);
+       g_variant_unref(var);
+
+       DBG("-\n");
+       return TRUE;
+}
+
 static void __handle_dnsmasq_dhcp_status_changed_cb(GDBusConnection *connection,
                        const gchar *sender_name, const gchar *object_path,
                        const gchar *interface_name, const gchar *signal_name,
@@ -512,6 +551,10 @@ static void on_bus_acquired_cb(GDBusConnection *connection, const gchar *name,
                        G_CALLBACK(softap_reload_settings), NULL);
        g_signal_connect(softap_obj, "handle-get-station-info",
                        G_CALLBACK(softap_get_station_info), NULL);
+       g_signal_connect(tethering_obj, "handle-hostapd-get-txpower",
+                       G_CALLBACK(tethering_get_hostapd_tx_power), NULL);
+       g_signal_connect(tethering_obj, "handle-hostapd-set-txpower",
+                       G_CALLBACK(tethering_set_hostapd_tx_power), NULL);
 
        _init_network((void *)tethering_obj);
        _register_vconf_cb((void *)tethering_obj);
index cf08b0a..730e836 100755 (executable)
@@ -1564,3 +1564,42 @@ void _destroy_dhcp_ack_timer(char *mac_addr)
        DBG("-\n");
        return;
 }
+int _set_hostapd_tx_power(unsigned int txpower)
+{
+       int ret = 0;
+       char req[HOSTAPD_REQ_MAX_LEN] = {0, };
+       int buf_len = 0;
+       char buf[MOBILE_AP_STR_INFO_LEN] = {0, };
+       buf_len = sizeof(buf);
+       snprintf(req, sizeof(req), "%s%u","SET txpower ",txpower);
+       ret = __send_hostapd_req(hostapd_ctrl_fd, req, strlen(req), buf, &buf_len);
+       if (ret != MOBILE_AP_ERROR_NONE) {
+               ERR("__send_to_hostapd is failed : %d\n", ret);
+               return ret;
+       }
+       return MOBILE_AP_ERROR_NONE;
+}
+
+unsigned int _get_hostapd_tx_power(void)
+{
+       int ret = 0;
+       int buf_len = 0;
+       char req[HOSTAPD_REQ_MAX_LEN] = {0, };
+       char buf[MOBILE_AP_STR_INFO_LEN] = {0, };
+       buf_len = sizeof(buf);
+       snprintf(req, sizeof(req), "%s","GET txpower");
+       ret = __send_hostapd_req(hostapd_ctrl_fd,
+                       req, strlen(req), buf, &buf_len);
+       if (ret != MOBILE_AP_ERROR_NONE) {
+               ERR("__send_hostapd_req is failed : %d\n", ret);
+               return ret;
+       }
+       if (!strncmp(buf, "FAIL", 4)) {
+               ERR("FAIL is returned\n");
+       }
+       if (buf[0] == '\0') {
+               ERR("NULL string\n");
+       }
+       return (atoi (buf));
+}
+