Skip to content

Commit

Permalink
[Network.WiFiDirect] Implement API for getting MAC address of connect…
Browse files Browse the repository at this point in the history
…ed TDLS peer

Signed-off-by: Akash Kumar <[email protected]>
  • Loading branch information
akash1-kumar committed Nov 26, 2024
1 parent 263875e commit 2e80bb9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Tizen.Network.WiFi/Interop/Interop.WiFi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ internal static partial class WiFi
internal static extern int SetScanStateChangedCallback(SafeWiFiManagerHandle wifi, ScanStateChangedCallback callback, IntPtr userData);
[DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_unset_scan_state_changed_cb")]
internal static extern int UnsetScanStateChangedCallback(SafeWiFiManagerHandle wifi);
[DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_tdls_get_connected_peer")]
internal static extern int GetTdlsConnectedPeer(SafeWiFiManagerHandle wifi, out string peerMacAddress);

internal static class AP
{
Expand Down
12 changes: 12 additions & 0 deletions src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,5 +536,17 @@ static public Task StartMultiScan(int frequency)
WiFiManagerImpl.Instance.SetSpecificScanFreq(frequency);
return WiFiManagerImpl.Instance.StartMultiScan();
}

/// <summary>
/// Gets MAC address of peer connected through TDLS.
/// </summary>
/// <since_tizen> 11 </since_tizen>
/// <returns>MAC address of the TDLS peer if connected on success or an empty string.</returns>
/// <privilege>http://tizen.org/privilege/network.get</privilege>
[EditorBrowsable(EditorBrowsableState.Never)]
static public string GetTDLSConnectedPeer()
{
return WiFiManagerImpl.Instance.GetTDLSConnectedPeer();
}
}
}
11 changes: 11 additions & 0 deletions src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,17 @@ internal Task StartMultiScan()
return task.Task;
}

internal string GetTDLSConnectedPeer()
{
string address = "";
int ret = Interop.WiFi.GetTdlsConnectedPeer(GetSafeHandle(), out address);
if (ret != (int)WiFiError.None)
{
Log.Error(Globals.LogTag, "Failed to get mac address, Error - " + (WiFiError)ret);
}
return String.Copy(address);
}

private void CheckReturnValue(int ret, string method, string privilege)
{
if (ret != (int)WiFiError.None)
Expand Down

0 comments on commit 2e80bb9

Please sign in to comment.