internal static partial class Libraries
{
public const string Connection = "libcapi-network-connection.so.1";
- public const string WiFi = "libcapi-network-wifi.so.1";
- public const string Bluetooth = "libcapi-network-bluetooth.so.0";
- public const string Smartcard = "libcapi-network-smartcard.so.0";
- public const string Nfc = "libcapi-network-nfc.so.0";
- public const string WiFiDirect = "libwifi-direct.so.1";
- public const string Glib = "libglib-2.0.so.0";
public const string Libc = "libc.so.6";
}
}
{
private IntPtr _profileHandle;
private AddressFamily _family;
+ private const String DefaultIPv4 = "0.0.0.0";
+ private const String DefaultIPv6 = "::";
internal ConnectionAddressInformation(IntPtr handle, AddressFamily family)
{
{
IntPtr Value;
int ret = Interop.ConnectionProfile.GetDnsAddress(_profileHandle, 1, (int)_family, out Value);
- if ((ConnectionError)ret != ConnectionError.None)
- {
- Log.Error(Globals.LogTag, "It failed to get dns1 address, " + (ConnectionError)ret);
- }
- string result = Marshal.PtrToStringAnsi(Value);
- Interop.Libc.Free(Value);
- if (result == null || result.Length == 0)
- return System.Net.IPAddress.Parse("0.0.0.0");
- return System.Net.IPAddress.Parse(result);
+ return ParseIPAddress(ret, Value);
}
set
{
IntPtr Value;
int ret = Interop.ConnectionProfile.GetDnsAddress(_profileHandle, 2, (int)_family, out Value);
- if ((ConnectionError)ret != ConnectionError.None)
- {
- Log.Error(Globals.LogTag, "It failed to get dns2 address, " + (ConnectionError)ret);
- }
- string result = Marshal.PtrToStringAnsi(Value);
- Interop.Libc.Free(Value);
- if (result == null || result.Length == 0)
- return System.Net.IPAddress.Parse("0.0.0.0");
- return System.Net.IPAddress.Parse(result);
+ return ParseIPAddress(ret, Value);
}
-
set
{
int ret = Interop.ConnectionProfile.SetDnsAddress(_profileHandle, 2, (int)_family, value.ToString());
{
IntPtr Value;
int ret = Interop.ConnectionProfile.GetGatewayAddress(_profileHandle, (int)_family, out Value);
- if ((ConnectionError)ret != ConnectionError.None)
- {
- Log.Error(Globals.LogTag, "It failed to get gateway, " + (ConnectionError)ret);
- }
- string result = Marshal.PtrToStringAnsi(Value);
- Interop.Libc.Free(Value);
- if (result == null || result.Length == 0)
- return System.Net.IPAddress.Parse("0.0.0.0");
- return System.Net.IPAddress.Parse(result);
+ return ParseIPAddress(ret, Value);
}
set
{
IntPtr Value;
int ret = Interop.ConnectionProfile.GetSubnetMask(_profileHandle, (int)_family, out Value);
- if ((ConnectionError)ret != ConnectionError.None)
- {
- Log.Error(Globals.LogTag, "It failed to get subnet mask, " + (ConnectionError)ret);
- }
- string result = Marshal.PtrToStringAnsi(Value);
- Interop.Libc.Free(Value);
- if (result == null || result.Length == 0)
- return System.Net.IPAddress.Parse("0.0.0.0");
- return System.Net.IPAddress.Parse(result);
+ return ParseIPAddress(ret, Value);
}
set
{
IntPtr Value;
int ret = Interop.ConnectionProfile.GetIPAddress(_profileHandle, (int)_family, out Value);
- if ((ConnectionError)ret != ConnectionError.None)
- {
- Log.Error(Globals.LogTag, "It failed to get ip, " + (ConnectionError)ret);
- }
- string result = Marshal.PtrToStringAnsi(Value);
- Interop.Libc.Free(Value);
- if (result == null || result.Length == 0)
- return System.Net.IPAddress.Parse("0.0.0.0");
- return System.Net.IPAddress.Parse(result);
+ return ParseIPAddress(ret, Value);
}
set
{
string dhcpServer;
int ret = Interop.ConnectionProfile.GetDhcpServerAddress(_profileHandle, _family, out dhcpServer);
- if ((ConnectionError)ret != ConnectionError.None)
+ if ((ConnectionError)ret != ConnectionError.None ||
+ dhcpServer == null || dhcpServer.Length == 0)
{
Log.Error(Globals.LogTag, "It failed to get the DHCP server address, " + (ConnectionError)ret);
+ return DefaultIPAddress();
}
+ return System.Net.IPAddress.Parse(dhcpServer);
+ }
+ }
- if (dhcpServer == null || dhcpServer.Length == 0)
- {
- return System.Net.IPAddress.Parse("0.0.0.0");
- }
-
- else
- {
- return System.Net.IPAddress.Parse(dhcpServer);
- }
+ private System.Net.IPAddress ParseIPAddress(int ret, IntPtr addrPtr)
+ {
+ if (ret != (int)ConnectionError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get address, Error - " + (ConnectionError)ret);
+ return DefaultIPAddress();
}
+
+ string addr = Marshal.PtrToStringAnsi(addrPtr);
+ if (addr == null || addr.Length == 0)
+ return DefaultIPAddress();
+ Interop.Libc.Free(addrPtr);
+ return System.Net.IPAddress.Parse(addr);
+ }
+
+ private System.Net.IPAddress DefaultIPAddress()
+ {
+ if (_family == AddressFamily.IPv4)
+ return System.Net.IPAddress.Parse(DefaultIPv4);
+ else
+ return System.Net.IPAddress.Parse(DefaultIPv6);
}
}
}
private void createHandle(string id, bool hidden)
{
- int ret = -1;
+ int ret;
if (id == null)
{
throw new ArgumentNullException("Essid is null");
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on ConnectAsync\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on ConnectAsync\n" + e);
task.SetException(e);
}
}, null);
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on ConnectWpsAsync\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on ConnectWpsAsync\n" + e);
wpsTask.SetException(e);
Log.Info(Globals.LogTag, "Remove task for ConnectWpsAsync");
_wpsTaskMap.Remove(_apHandle);
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on ConnectWpsWithoutSsidAsync\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on ConnectWpsWithoutSsidAsync\n" + e);
wpsWithoutSsidTask.SetException(e);
wpsWithoutSsidTask = null;
Log.Info(Globals.LogTag, "task is null");
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on Disconnect\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on Disconnect\n" + e);
task.SetException(e);
}
}, null);
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on ForgetAPAsync\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on ForgetAPAsync\n" + e);
task.SetException(e);
}
}, null);
WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
}
}
- }
+ }
/// <summary>
/// An abstract class which is used to represent the WPS information of the access point.
private Interop.WiFi.SafeWiFiAPHandle _handle;
private AddressFamily _family;
+ private const string DefaultIPv4 = "0.0.0.0";
+ private const string DefaultIPv6 = "::";
+
internal WiFiAddressInformation(Interop.WiFi.SafeWiFiAPHandle handle, AddressFamily family)
{
_handle = handle;
{
IntPtr addrPtr;
int ret = Interop.WiFi.AP.GetDnsAddress(_handle, 1, (int)_family, out addrPtr);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get first dns address, Error - " + (WiFiError)ret);
- return System.Net.IPAddress.Parse("0.0.0.0");
- }
- string addrStr = Marshal.PtrToStringAnsi(addrPtr);
- Interop.Libc.Free(addrPtr);
- if (addrStr == null || addrStr.Length == 0)
- return System.Net.IPAddress.Parse("0.0.0.0");
- return System.Net.IPAddress.Parse(addrStr);
+ return ParseIPAddress(ret, addrPtr);
}
set
{
{
IntPtr addrPtr;
int ret = Interop.WiFi.AP.GetDnsAddress(_handle, 2, (int)_family, out addrPtr);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get second dns address, Error - " + (WiFiError)ret);
- return System.Net.IPAddress.Parse("0.0.0.0");
- }
- string addrStr = Marshal.PtrToStringAnsi(addrPtr);
- Interop.Libc.Free(addrPtr);
- if (addrStr == null || addrStr.Length == 0)
- return System.Net.IPAddress.Parse("0.0.0.0");
- return System.Net.IPAddress.Parse(addrStr);
- }
+ return ParseIPAddress(ret, addrPtr);
+ }
set
{
int ret = Interop.WiFi.AP.SetDnsAddress(_handle, 2, (int)_family, value.ToString());
{
IntPtr addrPtr;
int ret = Interop.WiFi.AP.GetGatewayAddress(_handle, (int)_family, out addrPtr);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get gateway address, Error - " + (WiFiError)ret);
- return System.Net.IPAddress.Parse("0.0.0.0");
- }
- string addrStr = Marshal.PtrToStringAnsi(addrPtr);
- Interop.Libc.Free(addrPtr);
- if (addrStr == null || addrStr.Length == 0)
- return System.Net.IPAddress.Parse("0.0.0.0");
- return System.Net.IPAddress.Parse(addrStr);
+ return ParseIPAddress(ret, addrPtr);
}
set
{
{
IntPtr addrPtr;
int ret = Interop.WiFi.AP.GetSubnetMask(_handle, (int)_family, out addrPtr);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get subnet mask, Error - " + (WiFiError)ret);
- return System.Net.IPAddress.Parse("0.0.0.0");
- }
- string addrStr = Marshal.PtrToStringAnsi(addrPtr);
- Interop.Libc.Free(addrPtr);
- if (addrStr == null || addrStr.Length == 0)
- return System.Net.IPAddress.Parse("0.0.0.0");
- return System.Net.IPAddress.Parse(addrStr);
+ return ParseIPAddress(ret, addrPtr);
}
set
{
{
IntPtr addrPtr;
int ret = Interop.WiFi.AP.GetIPAddress(_handle, (int)_family, out addrPtr);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get ip address, Error - " + (WiFiError)ret);
- return System.Net.IPAddress.Parse("0.0.0.0");
- }
- string addrStr = Marshal.PtrToStringAnsi(addrPtr);
- Interop.Libc.Free(addrPtr);
- if (addrStr == null || addrStr.Length == 0)
- return System.Net.IPAddress.Parse("0.0.0.0");
- return System.Net.IPAddress.Parse(addrStr);
+ return ParseIPAddress(ret, addrPtr);
}
set
{
get
{
string dhcpServer;
- int ret = Interop.WiFi.AP.GetDhcpServerAddress(_handle, AddressFamily.IPv4, out dhcpServer);
- if (ret != (int)WiFiError.None)
+ int ret = Interop.WiFi.AP.GetDhcpServerAddress(_handle, _family, out dhcpServer);
+ if (ret != (int)WiFiError.None || dhcpServer == null || dhcpServer.Length == 0)
{
Log.Error(Globals.LogTag, "Failed to get DHCP server address, Error - " + (WiFiError)ret);
- }
-
- if (dhcpServer == null || dhcpServer.Length == 0)
- {
- return IPAddress.Parse("0.0.0.0");
+ return DefaultIPAddress();
}
return IPAddress.Parse(dhcpServer);
}
}
+ private System.Net.IPAddress ParseIPAddress(int ret, IntPtr addrPtr)
+ {
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get address, Error - " + (WiFiError)ret);
+ return DefaultIPAddress();
+ }
+
+ string addr = Marshal.PtrToStringAnsi(addrPtr);
+ if (addr == null || addr.Length == 0)
+ return DefaultIPAddress();
+ Interop.Libc.Free(addrPtr);
+ return System.Net.IPAddress.Parse(addr);
+ }
+
+ private System.Net.IPAddress DefaultIPAddress()
+ {
+ if (_family == AddressFamily.IPv4)
+ return System.Net.IPAddress.Parse(DefaultIPv4);
+ else
+ return System.Net.IPAddress.Parse(DefaultIPv6);
+ }
}
}
{
static internal void ThrowWiFiException(int e, IntPtr handle)
{
- ThrowExcption(e, (handle == IntPtr.Zero), false, "");
+ ThrowException(e, (handle == IntPtr.Zero), false, "");
}
static internal void ThrowWiFiException(int e, IntPtr handle1, IntPtr handle2)
{
- ThrowExcption(e, (handle1 == IntPtr.Zero), (handle2 == IntPtr.Zero), "");
+ ThrowException(e, (handle1 == IntPtr.Zero), (handle2 == IntPtr.Zero), "");
}
static internal void ThrowWiFiException(int e, string message)
{
- ThrowExcption(e, false, false, message);
+ ThrowException(e, false, false, message);
}
static internal void ThrowWiFiException(int e, IntPtr handle, string message)
{
- ThrowExcption(e, (handle == IntPtr.Zero), false, message);
+ ThrowException(e, (handle == IntPtr.Zero), false, message);
}
static internal void ThrowWiFiException(int e, IntPtr handle1, IntPtr handle2, string message)
{
- ThrowExcption(e, (handle1 == IntPtr.Zero), (handle2 == IntPtr.Zero), message);
+ ThrowException(e, (handle1 == IntPtr.Zero), (handle2 == IntPtr.Zero), message);
}
- static private void ThrowExcption(int e, bool isHandle1Null, bool isHandle2Null, string message)
+ static private void ThrowException(int e, bool isHandle1Null, bool isHandle2Null, string message)
{
WiFiError err = (WiFiError)e;
if (err == WiFiError.NotSupportedError)
private int _requestId = 0;
private string _macAddress;
+ //private string PrivilegeNetworkSet = "http://tizen.org/privilege/network.set";
+ private string PrivilegeNetworkGet = "http://tizen.org/privilege/network.get";
+ private string PrivilegeNetworkProfile = "http://tizen.org/privilege/network.get";
+
internal string MacAddress
{
get
int tid = Thread.CurrentThread.ManagedThreadId;
Log.Info(Globals.LogTag, "PInvoke wifi_manager_initialize");
int ret = Interop.WiFi.Initialize(tid, out handle);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to initialize wifi, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, "http://tizen.org/privilege/network.get");
- }
+ CheckReturnValue(ret, "Initialize", PrivilegeNetworkGet);
handle.SetTID(tid);
return handle;
}
};
int ret = Interop.WiFi.GetForeachFoundAPs(GetSafeHandle(), callback, IntPtr.Zero);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get all APs, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), "http://tizen.org/privilege/network.get");
- }
+ CheckReturnValue(ret, "GetForeachFoundAPs", PrivilegeNetworkGet);
return apList;
}
};
int ret = Interop.WiFi.GetForeachFoundSpecificAPs(GetSafeHandle(), callback, IntPtr.Zero);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get specific APs, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), "http://tizen.org/privilege/network.get");
- }
-
+ CheckReturnValue(ret, "GetForeachFoundSpecificAPs", PrivilegeNetworkGet);
+
return apList;
}
};
int ret = Interop.WiFi.GetForeachFoundBssids(GetSafeHandle(), callback, IntPtr.Zero);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get bssid APs, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), "http://tizen.org/privilege/network.get");
- }
+ CheckReturnValue(ret, "GetForeachFoundBssids", PrivilegeNetworkGet);
return apList;
}
};
int ret = Interop.WiFi.Config.GetForeachConfiguration(GetSafeHandle(), callback, IntPtr.Zero);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to get configurations, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), "http://tizen.org/privilege/network.profile");
- }
-
+ CheckReturnValue(ret, "GetForeachConfiguration", PrivilegeNetworkProfile);
return configList;
}
IntPtr configHandle = config.GetHandle();
int ret = Interop.WiFi.Config.SaveConfiguration(GetSafeHandle(), configHandle);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to save configuration, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), "http://tizen.org/privilege/network.profile");
- }
- }
+ CheckReturnValue(ret, "SaveConfiguration", PrivilegeNetworkProfile);
+ }
internal WiFiAP GetConnectedAP()
{
Log.Info(Globals.LogTag, "GetConnectedAP");
IntPtr apHandle;
int ret = Interop.WiFi.GetConnectedAP(GetSafeHandle(), out apHandle);
- if (ret != (int)WiFiError.None)
+ if (ret == (int)WiFiError.NoConnectionError)
{
- if (ret == (int)WiFiError.NoConnectionError)
- {
- Log.Error(Globals.LogTag, "No connection " + (WiFiError)ret);
- return null;
- }
- else if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- else
- {
- Log.Error(Globals.LogTag, "Failed to get connected AP, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), "http://tizen.org/privilege/network.get");
- }
+ Log.Error(Globals.LogTag, "No connection " + (WiFiError)ret);
+ return null;
}
+ CheckReturnValue(ret, "GetConnectedAP", PrivilegeNetworkGet);
WiFiAP ap = new WiFiAP(apHandle);
return ap;
}
try
{
int ret = Interop.WiFi.Activate(GetSafeHandle(), _callback_map[id], id);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
- }
+ CheckReturnValue(ret, "Activate", "");
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on ActivateAsync\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on ActivateAsync\n" + e);
task.SetException(e);
}
}, null);
try
{
int ret = Interop.WiFi.ActivateWithWiFiPickerTested(GetSafeHandle(), _callback_map[id], id);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
- }
+ CheckReturnValue(ret, "ActivateWithWiFiPickerTested", "");
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on ActivateWithWiFiPickerTestedAsync\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on ActivateWithWiFiPickerTestedAsync\n" + e);
task.SetException(e);
}
}, null);
try
{
int ret = Interop.WiFi.Deactivate(GetSafeHandle(), _callback_map[id], id);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to deactivate wifi, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
- }
+ CheckReturnValue(ret, "Deactivate", "");
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on Deactivate\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on Deactivate\n" + e);
task.SetException(e);
}
}, null);
try
{
int ret = Interop.WiFi.Scan(GetSafeHandle(), _callback_map[id], id);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to scan all AP, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
- }
+ CheckReturnValue(ret, "Scan", "");
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on Scan\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on Scan\n" + e);
task.SetException(e);
}
}, null);
try
{
int ret = Interop.WiFi.ScanSpecificAP(GetSafeHandle(), essid, _callback_map[id], id);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to scan with specific AP, Error - " + (WiFiError)ret);
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
- }
+ CheckReturnValue(ret, "ScanSpecificAP", "");
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on ScanSpecificAPAsync\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on ScanSpecificAPAsync\n" + e);
task.SetException(e);
}
}, null);
try
{
int ret = Interop.WiFi.BssidScan(GetSafeHandle(), _callback_map[id], id);
- if (ret != (int)WiFiError.None)
- {
- Log.Error(Globals.LogTag, "Failed to scan Bssid AP, Error - " + (WiFiError)ret);
- if (ret == (int)WiFiError.InvalidParameterError)
- {
- throw new InvalidOperationException("Invalid handle");
- }
- WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle());
- }
+ CheckReturnValue(ret, "BssidScan", "");
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on BssidScan\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on BssidScan\n" + e);
task.SetException(e);
}
}, null);
return task.Task;
}
+
+ private void CheckReturnValue(int ret, string method, string privilege)
+ {
+ if (ret != (int)WiFiError.None)
+ {
+ Log.Error(Globals.LogTag, method + " Fail, Error - " + (WiFiError)ret);
+ if (ret == (int)WiFiError.InvalidParameterError)
+ {
+ throw new InvalidOperationException("Invalid handle");
+ }
+ WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), privilege);
+ }
+ }
}
}
RegisterDeviceStateChangedEvent();
} catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on adding DeviceStateChanged\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on adding DeviceStateChanged\n" + e);
return;
}
}
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on removing DeviceStateChanged\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on removing DeviceStateChanged\n" + e);
}
}
}, null);
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on adding ConnectionStateChanged\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on adding ConnectionStateChanged\n" + e);
return;
}
}
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on removing ConnectionStateChanged\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on removing ConnectionStateChanged\n" + e);
}
}
}, null);
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on adding RssiLevelChanged\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on adding RssiLevelChanged\n" + e);
return;
}
}
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on removing RssiLevelChanged\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on removing RssiLevelChanged\n" + e);
}
}
}, null);
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on adding BackgroundScanFinished\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on adding BackgroundScanFinished\n" + e);
return;
}
}
}
catch (Exception e)
{
- Log.Error(Globals.LogTag, "Exception on removing BackgroundScanFinished\n" + e.ToString());
+ Log.Error(Globals.LogTag, "Exception on removing BackgroundScanFinished\n" + e);
}
}
}, null);