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_set_autoscan_mode")]
+ internal static extern int SetAutoScanMode(SafeWiFiManagerHandle wifi, int mode);
+ [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_connect_hidden_ap")]
+ internal static extern int ConnectHiddenAP(SafeWiFiManagerHandle wifi, string essid, int secType, string passphrase, VoidCallback callback, IntPtr userData);
[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")]
*/
using System;
+using System.ComponentModel;
namespace Tizen.Network.WiFi
{
/// <since_tizen> 6 </since_tizen>
Scanning = 1
}
+
+ /// <summary>
+ /// Enumeration for the Wi-Fi autoscan mode.
+ /// </summary>
+ /// <since_tizen> 10 </since_tizen>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum WiFiAutoScanMode
+ {
+ /// <summary>
+ /// Auto scan interval is increased exponentially like 4, 8, 16, ...128secs.
+ /// </summary>
+ /// <since_tizen> 10 </since_tizen>
+ Exponential = 0,
+ /// <summary>
+ /// Auto scan interval is fixed with 10secs(for mobile) / 15secs(for wearable).
+ /// </summary>
+ /// <since_tizen> 10 </since_tizen>
+ Periodic = 1
+ }
}
}
/// <summary>
+ /// Set Auto Scan Mode.
+ /// </summary>
+ /// <since_tizen> 10 </since_tizen>
+ /// <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="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ static public void SetAutoScanMode(WiFiAutoScanMode scanMode)
+ {
+ WiFiManagerImpl.Instance.SetAutoScanMode((int)scanMode);
+ }
+
+ /// <summary>
+ /// Hidden Ap connect.
+ /// </summary>
+ /// <remarks>
+ /// This method must be called from MainThread.
+ /// </remarks>
+ /// <since_tizen> 10 </since_tizen>
+ /// <returns>A task indicating whether the HiddenAPConnectAsync 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="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ static public Task HiddenAPConnectAsync(string essid, int secType, string password)
+ {
+ return WiFiManagerImpl.Instance.HiddenAPConnectAsync(essid, secType, password);
+ }
+
+ /// <summary>
/// Create Specific scan handle.
/// </summary>
/// <since_tizen> 9 </since_tizen>
return task.Task;
}
+ internal void SetAutoScanMode(int scanMode)
+ {
+ Log.Info(Globals.LogTag, "SetAutoScanMode");
+ int ret = Interop.WiFi.SetAutoScanMode(GetSafeHandle(), scanMode);
+ CheckReturnValue(ret, "GetSafeHandle", PrivilegeNetworkGet);
+ }
+
+ internal Task HiddenAPConnectAsync(string essid, int secType, string passphrase)
+ {
+ Log.Info(Globals.LogTag, "HiddenAPConnect");
+ TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+ IntPtr id;
+ lock (_callback_map)
+ {
+ id = (IntPtr)_requestId++;
+ _callback_map[id] = (error, key) =>
+ {
+ Log.Info(Globals.LogTag, "HiddenAPConnect Done " + essid);
+ if (error != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Error occurs during HiddenAPConnect, " + (WiFiError)error);
+ task.SetException(new InvalidOperationException("Error occurs during HiddenAPConnect, " + (WiFiError)error));
+ }
+ else
+ {
+ task.SetResult(true);
+ }
+ lock (_callback_map)
+ {
+ _callback_map.Remove(key);
+ }
+ };
+ }
+
+ context.Post((x) =>
+ {
+ Log.Info(Globals.LogTag, "Interop.WiFi.HiddenAPConnect");
+ try
+ {
+ int ret = (int)WiFiError.None;
+ lock (_callback_map)
+ {
+ ret = Interop.WiFi.ConnectHiddenAP(GetSafeHandle(), essid, secType, passphrase, _callback_map[id], id);
+ }
+ CheckReturnValue(ret, "HiddenAPConnect", "");
+ }
+ catch (Exception e)
+ {
+ Log.Error(Globals.LogTag, "Exception on HiddenAPConnect\n" + e);
+ task.SetException(e);
+ }
+ }, null);
+
+ return task.Task;
+ }
+
internal void CreateSpecificScanHandle()
{
Log.Debug(Globals.LogTag, "CreateSpecificScanHandle");