internal static extern int ForgetAP(SafeWiFiManagerHandle wifi, IntPtr ap, VoidCallback callback, IntPtr userData);
[DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_update_ap")]
internal static extern int UpdateAP(SafeWiFiManagerHandle wifi, IntPtr ap);
+ [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_specific_scan_create")]
+ internal static extern int SpecificScanCreate(SafeWiFiManagerHandle wifi, out IntPtr specificScanHandle);
+ [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_specific_scan_destroy")]
+ internal static extern int SpecificScanDestroy(SafeWiFiManagerHandle wifi, IntPtr specificScanHandle);
+ [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_specific_scan_set_ssid")]
+ internal static extern int SpecificScanSetSsid(IntPtr specificScanHandle, string essid);
+ [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_specific_scan_set_freq")]
+ internal static extern int SpecificScanSetFrequency(IntPtr specificScanHandle, int freq);
+ [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_specific_ap_start_multi_scan")]
+ internal static extern int SpecificApStartMultiScan(SafeWiFiManagerHandle wifi, IntPtr specificScanHandle, VoidCallback callback, IntPtr userData);
//Wi-Fi Monitor
[DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_get_connection_state")]
internal static extern int GetEapSubjectMatch(SafeWiFiConfigHandle config, out IntPtr subjectMatch);
[DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_config_set_eap_subject_match")]
internal static extern int SetEapSubjectMatch(SafeWiFiConfigHandle config, string subjectMatch);
+ [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_config_get_frequency")]
+ internal static extern int GetSavedConfigFrequency(IntPtr config, out int freq);
}
internal sealed class SafeWiFiAPHandle : SafeHandle
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using Tizen.Network.Connection;
+using System.ComponentModel;
namespace Tizen.Network.WiFi
{
}
}
+ /// <summary>
+ /// The Frequency of the access point (AP).
+ /// </summary>
+ /// <since_tizen> 9 </since_tizen>
+ /// <value>Frequency assigned to AP in the Wi-Fi configuration.</value>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int Frequency
+ {
+
+ get
+ {
+ Log.Debug(Globals.LogTag, "Frequency");
+ int freq;
+ int ret = Interop.WiFi.Config.GetSavedConfigFrequency(_configHandle, out freq);
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get Freq, Error - " + (WiFiError)ret);
+ return 0;
+ }
+ Log.Debug(Globals.LogTag, "Frequency is " + freq);
+ return freq;
+ }
+ }
+
internal WiFiConfiguration(IntPtr handle)
{
_configHandle = handle;
{
return WiFiManagerImpl.Instance.BssidScanAsync();
}
+
+ /// <summary>
+ /// Create Specific scan handle.
+ /// </summary>
+ /// <since_tizen> 9 </since_tizen>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the permission is denied.</exception>
+ /// <exception cref="OutOfMemoryException">Thrown when system is out of memory.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ static public void CreateSpecificHandle()
+ {
+ WiFiManagerImpl.Instance.CreateSpecificScanHandle();
+ }
+
+ /// <summary>
+ /// Destroys Specific scan handle.
+ /// </summary>
+ /// <since_tizen> 9 </since_tizen>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+ /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the permission is denied.</exception>
+ /// <exception cref="OutOfMemoryException">Thrown when system is out of memory.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ static public void DestroySpecificHandle()
+ {
+ WiFiManagerImpl.Instance.DestroySpecificScanHandle();
+ }
+
+ /// <summary>
+ /// Starts Multi Scan.
+ /// </summary>
+ /// <remarks>
+ /// This method must be called from MainThread.
+ /// </remarks>
+ /// <since_tizen> 9 </since_tizen>
+ /// <param name="frequency">Frequency for which MultiScan is to be run.</param>
+ /// <returns>A task indicating whether the StartMultiScan method is done or not.</returns>
+ /// <feature>http://tizen.org/feature/network.wifi</feature>
+ /// <privilege>http://tizen.org/privilege/network.set</privilege>
+ /// <privilege>http://tizen.org/privilege/network.get</privilege>
+ /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when the permission is denied.</exception>
+ /// <exception cref="OutOfMemoryException">Thrown when system is out of memory.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ static public Task StartMultiScan(int frequency)
+ {
+ WiFiManagerImpl.Instance.SetSpecificScanFreq(frequency);
+ return WiFiManagerImpl.Instance.StartMultiScan();
+ }
}
}
private int _requestId = 0;
private string _macAddress;
+ private IntPtr _specificScanHandle;
//private string PrivilegeNetworkSet = "http://tizen.org/privilege/network.set";
private string PrivilegeNetworkGet = "http://tizen.org/privilege/network.get";
return task.Task;
}
+ internal void CreateSpecificScanHandle()
+ {
+ Log.Debug(Globals.LogTag, "CreateSpecificScanHandle");
+ int ret = Interop.WiFi.SpecificScanCreate(GetSafeHandle(), out _specificScanHandle);
+ CheckReturnValue(ret, "CreateSpecificScanHandle", PrivilegeNetworkProfile);
+ }
+
+ internal void DestroySpecificScanHandle()
+ {
+ Log.Debug(Globals.LogTag, "DestroySpecificScanHandle");
+ int ret = Interop.WiFi.SpecificScanDestroy(GetSafeHandle(), _specificScanHandle);
+ CheckReturnValue(ret, "DestroySpecificScanHandle", PrivilegeNetworkProfile);
+ _specificScanHandle = IntPtr.Zero;
+ }
+
+ internal void SetSpecificScanFreq(int freq)
+ {
+ Log.Debug(Globals.LogTag, "SetSpecificScanFreq");
+ int ret = Interop.WiFi.SpecificScanSetFrequency(_specificScanHandle, freq);
+ CheckReturnValue(ret, "SetSpecificScanFreq", PrivilegeNetworkProfile);
+ }
+
+ internal Task StartMultiScan()
+ {
+ Log.Debug(Globals.LogTag, "StartMultiScan");
+ TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+ IntPtr id;
+ lock (_callback_map)
+ {
+ id = (IntPtr)_requestId++;
+ _callback_map[id] = (error, key) =>
+ {
+ Log.Info(Globals.LogTag, "Multi Scan done");
+ if (error != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Error occurs during multi scanning, " + (WiFiError)error);
+ task.SetException(new InvalidOperationException("Error occurs during multi scanning, " + (WiFiError)error));
+ }
+ else
+ {
+ task.SetResult(true);
+ }
+ lock (_callback_map)
+ {
+ _callback_map.Remove(key);
+ }
+ };
+ }
+
+ context.Post((x) =>
+ {
+ Log.Info(Globals.LogTag, "Interop.WiFi.SpecificApStartMultiScan");
+ try
+ {
+ int ret = (int)WiFiError.None;
+ lock (_callback_map)
+ {
+ ret = Interop.WiFi.SpecificApStartMultiScan(GetSafeHandle(), _specificScanHandle, _callback_map[id], id);
+ }
+ CheckReturnValue(ret, "MultiScan", "");
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on Multi Scan\n" + e);
+ task.SetException(e);
+ }
+ }, null);
+
+ return task.Task;
+ }
+
private void CheckReturnValue(int ret, string method, string privilege)
{
if (ret != (int)WiFiError.None)