From f9613e526b6822b91f424e134afc3ba9bd97982d Mon Sep 17 00:00:00 2001 From: Akash Kumar Date: Tue, 15 Oct 2024 09:36:26 +0530 Subject: [PATCH] Implement CreateGroup with ssid Signed-off-by: Akash Kumar --- .../Interop/Interop.WiFiDirect.cs | 2 ++ .../WiFiDirectManager.cs | 32 +++++++++++++++++++ .../WiFiDirectManagerImpl.cs | 10 ++++++ 3 files changed, 44 insertions(+) diff --git a/src/Tizen.Network.WiFiDirect/Interop/Interop.WiFiDirect.cs b/src/Tizen.Network.WiFiDirect/Interop/Interop.WiFiDirect.cs index 6ff39f15306..36658885931 100644 --- a/src/Tizen.Network.WiFiDirect/Interop/Interop.WiFiDirect.cs +++ b/src/Tizen.Network.WiFiDirect/Interop/Interop.WiFiDirect.cs @@ -113,6 +113,8 @@ internal static partial class WiFiDirect internal static extern int GetConnectedPeers(ConnectedPeerCallback callback, IntPtr userData); [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_create_group")] internal static extern int CreateGroup(); + [DllImport(Libraries.WiFiDirect, EntryPoint = "wifi_direct_create_group_with_ssid")] + internal static extern int CreateGroupWithSsid(string ssid); [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_destroy_group")] internal static extern int DestroyGroup(); [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_group_owner")] diff --git a/src/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManager.cs b/src/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManager.cs index cd26d3da168..3e24882df28 100644 --- a/src/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManager.cs +++ b/src/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManager.cs @@ -1251,6 +1251,38 @@ public static void CreateGroup() } } + /// + /// Creates a Wi-Fi Direct group with given SSID and sets up device as the group owner. + /// + /// + /// http://tizen.org/privilege/wifidirect + /// + /// + /// http://tizen.org/feature/network.wifidirect + /// + /// + /// Wi-Fi Direct must be activated. + /// If this succeeds, ConnectionStatusChanged event will be invoked with GroupCreated. + /// + /// The object is in invalid state. + /// The required feature is not supported. + /// Thrown when application does not have privilege to access this method. + /// 12 + [EditorBrowsable(EditorBrowsableState.Never)] + public static void CreateGroup(string ssid) + { + if (Globals.IsActivated) + { + WiFiDirectManagerImpl.Instance.CreateGroup(ssid); + } + + else + { + Log.Error(Globals.LogTag, "Wifi-direct is not activated"); + WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted); + } + } + /// /// Destroys the Wi-Fi Direct group owned by a local device.If creating a group is in progress, this API cancels that process. /// diff --git a/src/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManagerImpl.cs b/src/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManagerImpl.cs index 252afa1daef..dc5bee0f0db 100644 --- a/src/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManagerImpl.cs +++ b/src/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManagerImpl.cs @@ -973,6 +973,16 @@ internal void CreateGroup() } } + internal void CreateGroup(string ssid) + { + int ret = Interop.WiFiDirect.CreateGroupWithSsid(ssid); + if (ret != (int)WiFiDirectError.None) + { + Log.Error(Globals.LogTag, "Failed to create a WiFi-Direct group with ssid, Error - " + (WiFiDirectError)ret); + WiFiDirectErrorFactory.ThrowWiFiDirectException(ret); + } + } + internal void DestroyGroup() { int ret = Interop.WiFiDirect.DestroyGroup();