Skip to content

Commit

Permalink
Implement CreateGroup with ssid
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Kumar <[email protected]>
  • Loading branch information
akash1-kumar committed Oct 15, 2024
1 parent 44299e5 commit f9613e5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Tizen.Network.WiFiDirect/Interop/Interop.WiFiDirect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,38 @@ public static void CreateGroup()
}
}

/// <summary>
/// Creates a Wi-Fi Direct group with given SSID and sets up device as the group owner.
/// </summary>
/// <privilege>
/// http://tizen.org/privilege/wifidirect
/// </privilege>
/// <feature>
/// http://tizen.org/feature/network.wifidirect
/// </feature>
/// <remarks>
/// Wi-Fi Direct must be activated.
/// If this succeeds, ConnectionStatusChanged event will be invoked with GroupCreated.
/// </remarks>
/// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
/// <since_tizen> 12 </since_tizen>
[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);
}
}

/// <summary>
/// Destroys the Wi-Fi Direct group owned by a local device.If creating a group is in progress, this API cancels that process.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f9613e5

Please sign in to comment.