[wfd-manager]: Feature: Added support of "OperChannel" Method 09/69409/2
authorManeesh Jain <maneesh.jain@samsung.com>
Fri, 13 May 2016 05:57:00 +0000 (11:27 +0530)
committerManeesh Jain <maneesh.jain@samsung.com>
Fri, 13 May 2016 05:59:00 +0000 (22:59 -0700)
Description: "OperChannel": This method is used to configure
     the operating channel in Supplicant.

Change-Id: If0fe4dc2ac14331d9eb366d078ac08ec3a4b7d73
Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
oem/wifi-direct-oem.h
plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c
plugin/wpasupplicant/ctrl_iface_sock/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/ctrl_iface_sock/wfd-plugin-wpasupplicant.c
plugin/wpasupplicant/emul/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/emul/wfd-plugin-wpasupplicant-emul.c

index 4e2f21f..c8ab33c 100755 (executable)
@@ -497,6 +497,7 @@ typedef struct _wfd_oem_ops_s {
 
        int (*refresh) (void);
        int (*save_config) (void);
+       int (*set_operating_channel)(int channel);
 
 
 } wfd_oem_ops_s;
index d2d0cc5..bf2c129 100755 (executable)
@@ -441,6 +441,7 @@ int ws_set_display(wfd_oem_display_s *wifi_display);
 
 int ws_refresh();
 int ws_save_config(void);
+int ws_set_operating_channel(int channel);
 
 
 #endif /* __WFD_PLUGIN_WPASUPPLICANT_H__ */
index f429206..dae7e8d 100755 (executable)
@@ -128,6 +128,7 @@ static wfd_oem_ops_s supplicant_ops = {
 
        .refresh = ws_refresh,
        .save_config =  ws_save_config,
+       .set_operating_channel = ws_set_operating_channel,
 
        };
 
@@ -5267,3 +5268,42 @@ int ws_save_config(void)
        return res;
 }
 
+int ws_set_operating_channel(int channel)
+{
+       __WDP_LOG_FUNC_ENTER__;
+       GDBusConnection *g_dbus = NULL;
+       GVariant *value = NULL;
+       GVariant *param = NULL;
+       GVariantBuilder *builder = NULL;
+       dbus_method_param_s params;
+       int res = 0;
+
+       g_dbus = g_pd->g_dbus;
+       if (!g_dbus) {
+               WDP_LOGE("DBus connection is NULL");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       memset(&params, 0x0, sizeof(dbus_method_param_s));
+
+       dbus_set_method_param(&params, DBUS_PROPERTIES_METHOD_SET, g_pd->iface_path, g_dbus);
+
+       builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
+       g_variant_builder_add (builder, "{sv}", "OperChannel", g_variant_new_uint32(channel));
+       value = g_variant_new ("a{sv}", builder);
+       g_variant_builder_unref (builder);
+
+       param = g_variant_new("(ssv)", SUPPLICANT_P2PDEVICE, "P2PDeviceConfig", value);
+       params.params = param;
+
+       res = dbus_method_call(&params, DBUS_PROPERTIES_INTERFACE, NULL, NULL);
+       if (res < 0)
+               WDP_LOGE("Failed to send command to wpa_supplicant");
+       else
+               WDP_LOGD("Succeeded to set Operating Channel");
+
+       __WDP_LOG_FUNC_EXIT__;
+       return res;
+}
+
index 25890ff..4613696 100755 (executable)
@@ -580,5 +580,6 @@ int ws_set_display(wfd_oem_display_s *wifi_display);
 
 int ws_refresh();
 int ws_save_config(void);
+int ws_set_operating_channel(int channel);
 
 #endif /* __WFD_PLUGIN_WPASUPPLICANT_H__ */
index 484a7e8..0358b38 100755 (executable)
@@ -271,6 +271,7 @@ static wfd_oem_ops_s supplicant_ops = {
 
        .refresh = ws_refresh,
        .save_config = ws_save_config,
+       .set_operating_channel = ws_set_operating_channel,
 
        };
 
@@ -4871,3 +4872,36 @@ int ws_save_config()
        return 0;
 }
 
+int ws_set_operating_channel(int channel)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       char cmd[80] = {0, };
+       char reply[WS_REPLY_LEN] = {0, };
+       int res = 0;
+       ws_sock_data_s *sock = g_pd->common;
+
+       if (!sock) {
+               WDP_LOGE("Socket is NULL");
+               return -1;
+       }
+
+       snprintf(cmd, sizeof(cmd), WS_CMD_SET "p2p_oper_channel %d", channel);
+
+       res = _ws_send_cmd(sock->ctrl_sock, cmd, reply, sizeof(reply));
+       if (res < 0) {
+               WDP_LOGE("Failed to send command to wpa_supplicant");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (strstr(reply, "FAIL")) {
+               WDP_LOGE("Failed to set Operating channel");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       WDP_LOGD("Succeeded to set P2P Operating Channel");
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
index 9a1de67..3749114 100755 (executable)
@@ -119,5 +119,6 @@ int ws_set_display(wfd_oem_display_s *wifi_display);
 
 int ws_refresh();
 int ws_save_config(void);
+int ws_set_operating_channel(int channel);
 
 #endif /* __WFD_PLUGIN_WPASUPPLICANT_H__ */
index b841baa..c88101b 100755 (executable)
@@ -69,6 +69,7 @@ static wfd_oem_ops_s supplicant_ops = {
        .set_display = ws_set_display,
 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
        .save_config = ws_save_config,
+       .set_operating_channel = ws_set_operating_channel,
 
        };
 
@@ -436,6 +437,8 @@ int ws_set_display(wfd_oem_display_s *wifi_display)
        return -1;
 }
 
+#endif /* TIZEN_FEATURE_WIFI_DISPLAY */
+
 int ws_save_config(void)
 {
        __WDP_LOG_FUNC_ENTER__;
@@ -444,4 +447,11 @@ int ws_save_config(void)
        return -1;
 }
 
-#endif /* TIZEN_FEATURE_WIFI_DISPLAY */
+int ws_set_operating_channel(int channel)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       __WDP_LOG_FUNC_EXIT__;
+       return -1;
+}
+