Add dbus method call to get supported channels 35/238935/4 submit/tizen/20200804.230001
authorNishant Chaprana <n.chaprana@samsung.com>
Mon, 20 Jul 2020 11:08:15 +0000 (16:38 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Tue, 4 Aug 2020 04:34:56 +0000 (10:04 +0530)
Change-Id: I6b9938b8380e92a70d4fcc24a38e8085450eccf2
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
include/wifi-direct-method.h
oem/wifi-direct-oem.c
oem/wifi-direct-oem.h
packaging/wifi-direct-manager.spec
plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c
plugin/wpasupplicant/emul/wfd-plugin-wpasupplicant-emul.c
src/wifi-direct-dbus.c
src/wifi-direct-iface.c
src/wifi-direct-method.c

index dd9c656..fe0099e 100644 (file)
@@ -82,6 +82,7 @@ void set_max_client_handler(GVariant *parameters, void *dest);
 void set_autoconnection_mode_handler(GVariant *parameters, void *dest);
 void is_autoconnection_mode_handler(GVariant *parameters, void *dest);
 void get_operating_channel_handler(GVariant *parameters, void *dest);
+void get_supported_channels_handler(GVariant *parameters, void *dest);
 void set_autoconnection_peer_handler(GVariant *parameters, void *dest);
 void get_interface_name_handler(GVariant *parameters, void *dest);
 void get_subnet_mask_handler(GVariant *parameters, void *dest);
index 8a94aba..05393aa 100644 (file)
@@ -753,3 +753,11 @@ int wfd_oem_remove_all_persistent_device(wfd_oem_ops_s *ops)
 
        return ops->remove_all_persistent_device();
 }
+
+int wfd_oem_get_supported_channels(wfd_oem_ops_s *ops, wfd_oem_supported_channels_s *data)
+{
+       if (!ops || !ops->get_supported_channels)
+               return -1;
+
+       return ops->get_supported_channels(data);
+}
index e10689c..60be73c 100644 (file)
@@ -76,6 +76,8 @@ extern "C" {
 
 #define OEM_MAX_PEER_NUM 8
 
+#define P2P_MAX_CHANNELS 50
+
 typedef enum {
        WFD_OEM_SC_SUCCESS = 0,
        WFD_OEM_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE = 1,
@@ -582,6 +584,11 @@ typedef struct {
 } wfd_oem_persistent_group_s;
 
 typedef struct {
+       int channels[P2P_MAX_CHANNELS];
+       int count;
+} wfd_oem_supported_channels_s;
+
+typedef struct {
        void (*deactivated_cb) (wfd_oem_event_s *event);
        void (*peer_found_cb) (wfd_oem_event_s *event);
        void (*peer_disappeared_cb) (wfd_oem_event_s *event);
@@ -701,6 +708,8 @@ typedef struct {
        int (*remove_persistent_device) (unsigned char *peer_mac_addr);
        int (*remove_all_persistent_device) (void);
 
+       int (*get_supported_channels) (wfd_oem_supported_channels_s *data);
+
        void *extra_data;
 } wfd_oem_ops_s;
 
@@ -778,6 +787,8 @@ int wfd_oem_set_supported_wps_mode(wfd_oem_ops_s *ops, int wps_mode);
 int wfd_oem_remove_persistent_device(wfd_oem_ops_s *ops, unsigned char *peer_mac_address);
 int wfd_oem_remove_all_persistent_device(wfd_oem_ops_s *ops);
 
+int wfd_oem_get_supported_channels(wfd_oem_ops_s *ops, wfd_oem_supported_channels_s *data);
+
 #if defined TIZEN_ENABLE_PRD
 typedef struct {
        void (*prd_example_cb) (wfd_oem_event_s *event);
index cb20cc6..ba94b27 100644 (file)
@@ -6,7 +6,7 @@
 
 Name:          wifi-direct-manager
 Summary:       Wi-Fi Direct manger
-Version:       1.2.282
+Version:       1.3.1
 Release:       1
 Group:      Network & Connectivity/Wireless
 License:    Apache-2.0
index 148ff9b..2bcf192 100644 (file)
@@ -386,6 +386,8 @@ int ws_set_supported_wps_mode(int wps_mode);
 int ws_remove_persistent_device(unsigned char *mac_addr);
 int ws_remove_all_persistent_device(void);
 
+int ws_get_supported_channels(wfd_oem_supported_channels_s *data);
+
 #ifdef __cplusplus
 }
 #endif
index 0463461..acfbfbe 100644 (file)
@@ -144,6 +144,8 @@ static wfd_oem_ops_s supplicant_ops = {
        .remove_persistent_device = ws_remove_persistent_device,
        .remove_all_persistent_device = ws_remove_all_persistent_device,
 
+       .get_supported_channels = ws_get_supported_channels,
+
        .extra_data = NULL
 };
 
@@ -7874,3 +7876,56 @@ int ws_remove_all_persistent_device(void)
        __WDP_LOG_FUNC_EXIT__;
        return res;
 }
+
+static void __ws_get_supported_channels_reply(GVariant *reply, void *user_data)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       GVariantIter *iter = NULL;
+       wfd_oem_supported_channels_s *data = (wfd_oem_supported_channels_s *)user_data;
+
+       if (reply) {
+               int channel = 0;
+
+               g_variant_get(reply, "(ai)", &iter);
+
+               while (g_variant_iter_loop(iter, "i", &channel))
+                       data->channels[data->count++] = channel;
+
+               g_variant_iter_free (iter);
+
+       } else {
+               WDP_LOGE("Reply is NULL");
+       }
+       __WDP_LOG_FUNC_EXIT__;
+}
+
+int ws_get_supported_channels(wfd_oem_supported_channels_s *data)
+{
+       __WDP_LOG_FUNC_ENTER__;
+       int res = 0;
+       dbus_method_param_s params;
+
+       if (!g_pd) {
+               WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       memset(&params, 0x0, sizeof(dbus_method_param_s));
+       memset(data, 0x0, sizeof(wfd_oem_supported_channels_s));
+
+       dbus_set_method_param(&params, "GetSupportedChannels", g_pd->iface_path, g_pd->g_dbus);
+       params.params = NULL;
+
+       res = dbus_method_call(&params, SUPPLICANT_P2PDEVICE,
+                       __ws_get_supported_channels_reply, data);
+       if (res < 0) {
+               WDP_LOGE("Failed to GetSupportedChannels");
+       } else {
+               WDP_LOGD("Succeeded to GetSupportedChannels");
+       }
+
+       __WDP_LOG_FUNC_EXIT__;
+       return res;
+}
index 6179081..d8aca48 100644 (file)
@@ -81,6 +81,8 @@ static wfd_oem_ops_s supplicant_ops = {
        .get_vsie = ws_get_vsie,
        .remove_vsie = ws_remove_vsie,
 
+       .get_supported_channels = ws_get_supported_channels,
+
        };
 
 int wfd_plugin_load(wfd_oem_ops_s **ops)
@@ -545,3 +547,11 @@ int ws_remove_vsie(wfd_oem_vsie_frames_e frame_id, const char *vsie)
        __WDP_LOG_FUNC_EXIT__;
        return -1;
 }
+
+int ws_get_supported_channels(wfd_oem_supported_channels_s *data)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       __WDP_LOG_FUNC_EXIT__;
+       return -1;
+}
index d9a7c52..6b44185 100644 (file)
@@ -277,6 +277,10 @@ const gchar wfd_manager_introspection_xml[] = {
                                "<arg type='i' name='error_code' direction='out'/>"
                                "<arg type='i' name='operating_channel' direction='out'/>"
                        "</method>"
+                       "<method name='GetSupportedChannels'>"
+                               "<arg type='i' name='error_code' direction='out'/>"
+                               "<arg type='au' name='supported_channels' direction='out'/>"
+                       "</method>"
                        "<method name='SetAutoConnectionPeer'>"
                                "<arg type='s' name='peer_mac_address' direction='in'/>"
                                "<arg type='i' name='error_code' direction='out'/>"
index 6bb7360..efbcb31 100644 (file)
@@ -124,6 +124,7 @@ static wfd_manager_iface_method_handler wfd_manager_iface_config[] = {
                {"SetAutoConnectionMode", set_autoconnection_mode_handler},
                {"IsAutoConnectionMode", is_autoconnection_mode_handler},
                {"GetOperatingChannel", get_operating_channel_handler},
+               {"GetSupportedChannels", get_supported_channels_handler},
                {"SetAutoConnectionPeer", set_autoconnection_peer_handler},
                {"GetConnectingPeer", get_connecting_peer_handler},
                {"GetInterfaceName", get_interface_name_handler},
index 72deac8..0744a91 100755 (executable)
@@ -1666,6 +1666,36 @@ void get_operating_channel_handler(GVariant *parameters, void *dest)
        return;
 }
 
+void get_supported_channels_handler(GVariant *parameters, void *dest)
+{
+       __WDS_LOG_FUNC_ENTER__;//LCOV_EXCL_LINE
+       wfd_manager_s *manager = wfd_get_manager();
+       GVariant *return_parameters = NULL;
+       GVariantBuilder *builder = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
+       wfd_oem_supported_channels_s channel_data = {0, };
+
+       WIFI_DIRECT_METHOD_RET_IF_NULL(manager);
+
+       ret = wfd_oem_get_supported_channels(manager->oem_ops, &channel_data);
+       if (ret < 0)
+               WIFI_DIRECT_METHOD_RET_ERR(WIFI_DIRECT_ERROR_OPERATION_FAILED, dest);
+
+       WDS_LOGD("Supported channels :-");
+       builder = g_variant_builder_new(G_VARIANT_TYPE("au"));
+       for (int i = 0; i < channel_data.count; i++) {
+               WDS_LOGD("-> [%d]", channel_data.channels[i]);
+               g_variant_builder_add(builder, "u", channel_data.channels[i]);
+       }
+
+       return_parameters = g_variant_new("(iau)", ret, builder);
+       g_variant_builder_unref(builder);
+       wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+       __WDS_LOG_FUNC_EXIT__;//LCOV_EXCL_LINE
+       return;
+}
+
 void set_autoconnection_peer_handler(GVariant *parameters, void *dest)
 {
        __WDS_LOG_FUNC_ENTER__;//LCOV_EXCL_LINE