From 910808d4c158295febc11a25911b37fb5709a531 Mon Sep 17 00:00:00 2001 From: Akash Kumar Date: Wed, 27 Nov 2024 15:56:19 +0530 Subject: [PATCH] [Network.WiFi] Implement API to get MAC of TDLS connected peer Signed-off-by: Akash Kumar --- src/Tizen.Network.WiFi/Interop/Interop.WiFi.cs | 2 ++ .../Tizen.Network.WiFi/WiFiManager.cs | 12 ++++++++++++ .../Tizen.Network.WiFi/WiFiManagerImpl.cs | 11 +++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/Tizen.Network.WiFi/Interop/Interop.WiFi.cs b/src/Tizen.Network.WiFi/Interop/Interop.WiFi.cs index 580f0cc0268..10e5c65ef9a 100755 --- a/src/Tizen.Network.WiFi/Interop/Interop.WiFi.cs +++ b/src/Tizen.Network.WiFi/Interop/Interop.WiFi.cs @@ -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 { diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs index d7dd257d003..dfd571edcde 100755 --- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs +++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs @@ -536,5 +536,17 @@ static public Task StartMultiScan(int frequency) WiFiManagerImpl.Instance.SetSpecificScanFreq(frequency); return WiFiManagerImpl.Instance.StartMultiScan(); } + + /// + /// Gets MAC address of peer connected through TDLS. + /// + /// 11 + /// MAC address of the TDLS peer if connected on success or an empty string. + /// http://tizen.org/privilege/network.get + [EditorBrowsable(EditorBrowsableState.Never)] + static public string GetTDLSConnectedPeer() + { + return WiFiManagerImpl.Instance.GetTDLSConnectedPeer(); + } } } diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs index 64c2740f7d0..4a9ab715a43 100644 --- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs +++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs @@ -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)