From: Nishant Chaprana Date: Mon, 20 Jul 2020 11:08:15 +0000 (+0530) Subject: Add dbus method call to get supported channels X-Git-Tag: submit/tizen/20200804.230001^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fwifi-direct-manager.git;a=commitdiff_plain;h=e4fe47ae02a7d538595d9b75f8fc587e0283f136 Add dbus method call to get supported channels Change-Id: I6b9938b8380e92a70d4fcc24a38e8085450eccf2 Signed-off-by: Nishant Chaprana --- diff --git a/include/wifi-direct-method.h b/include/wifi-direct-method.h index dd9c656..fe0099e 100644 --- a/include/wifi-direct-method.h +++ b/include/wifi-direct-method.h @@ -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); diff --git a/oem/wifi-direct-oem.c b/oem/wifi-direct-oem.c index 8a94aba..05393aa 100644 --- a/oem/wifi-direct-oem.c +++ b/oem/wifi-direct-oem.c @@ -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); +} diff --git a/oem/wifi-direct-oem.h b/oem/wifi-direct-oem.h index e10689c..60be73c 100644 --- a/oem/wifi-direct-oem.h +++ b/oem/wifi-direct-oem.h @@ -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); diff --git a/packaging/wifi-direct-manager.spec b/packaging/wifi-direct-manager.spec index cb20cc6..ba94b27 100644 --- a/packaging/wifi-direct-manager.spec +++ b/packaging/wifi-direct-manager.spec @@ -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 diff --git a/plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-plugin-wpasupplicant.h b/plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-plugin-wpasupplicant.h index 148ff9b..2bcf192 100644 --- a/plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-plugin-wpasupplicant.h +++ b/plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-plugin-wpasupplicant.h @@ -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 diff --git a/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c b/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c index 0463461..acfbfbe 100644 --- a/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c +++ b/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c @@ -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(¶ms, 0x0, sizeof(dbus_method_param_s)); + memset(data, 0x0, sizeof(wfd_oem_supported_channels_s)); + + dbus_set_method_param(¶ms, "GetSupportedChannels", g_pd->iface_path, g_pd->g_dbus); + params.params = NULL; + + res = dbus_method_call(¶ms, 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; +} diff --git a/plugin/wpasupplicant/emul/wfd-plugin-wpasupplicant-emul.c b/plugin/wpasupplicant/emul/wfd-plugin-wpasupplicant-emul.c index 6179081..d8aca48 100644 --- a/plugin/wpasupplicant/emul/wfd-plugin-wpasupplicant-emul.c +++ b/plugin/wpasupplicant/emul/wfd-plugin-wpasupplicant-emul.c @@ -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; +} diff --git a/src/wifi-direct-dbus.c b/src/wifi-direct-dbus.c index d9a7c52..6b44185 100644 --- a/src/wifi-direct-dbus.c +++ b/src/wifi-direct-dbus.c @@ -277,6 +277,10 @@ const gchar wfd_manager_introspection_xml[] = { "" "" "" + "" + "" + "" + "" "" "" "" diff --git a/src/wifi-direct-iface.c b/src/wifi-direct-iface.c index 6bb7360..efbcb31 100644 --- a/src/wifi-direct-iface.c +++ b/src/wifi-direct-iface.c @@ -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}, diff --git a/src/wifi-direct-method.c b/src/wifi-direct-method.c index 72deac8..0744a91 100755 --- a/src/wifi-direct-method.c +++ b/src/wifi-direct-method.c @@ -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