2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
21 using System.Runtime.InteropServices;
23 namespace Tizen.Network.Connection
26 /// This Class is WiFiProfile
28 public class WiFiProfile : ConnectionProfile
30 internal WiFiProfile(IntPtr Handle) : base(Handle)
39 /// Gets the ESSID (Extended Service Set Identifier).
46 int ret = Interop.ConnectionWiFiProfile.GetEssid(ProfileHandle, out value);
47 if ((ConnectionError)ret != ConnectionError.None)
49 Log.Error(Globals.LogTag, "It failed to create profile handle, " + (ConnectionError)ret);
51 string result = Marshal.PtrToStringAnsi(value);
52 Interop.Libc.Free(value);
58 /// Gets the BSSID (Basic Service Set Identifier).
65 int ret = Interop.ConnectionWiFiProfile.GetBssid(ProfileHandle, out value);
66 if ((ConnectionError)ret != ConnectionError.None)
68 Log.Error(Globals.LogTag, "It failed to get bssid, " + (ConnectionError)ret);
70 string result = Marshal.PtrToStringAnsi(value);
71 Interop.Libc.Free(value);
84 int ret = Interop.ConnectionWiFiProfile.GetRssi(ProfileHandle, out value);
85 if ((ConnectionError)ret != ConnectionError.None)
87 Log.Error(Globals.LogTag, "It failed to get rssi, " + (ConnectionError)ret);
94 /// Gets the frequency (MHz).
101 int ret = Interop.ConnectionWiFiProfile.GetFrequency(ProfileHandle, out value);
102 if ((ConnectionError)ret != ConnectionError.None)
104 Log.Error(Globals.LogTag, "It failed to get frequency, " + (ConnectionError)ret);
111 /// Gets the max speed (Mbps).
118 int ret = Interop.ConnectionWiFiProfile.GetMaxSpeed(ProfileHandle, out value);
119 if ((ConnectionError)ret != ConnectionError.None)
121 Log.Error(Globals.LogTag, "It failed to get max speed, " + (ConnectionError)ret);
128 /// Gets the security type of Wi-Fi.
130 public WiFiSecureType SecureType
135 int ret = Interop.ConnectionWiFiProfile.GetSecurityType(ProfileHandle, out value);
136 if ((ConnectionError)ret != ConnectionError.None)
138 Log.Error(Globals.LogTag, "It failed to get security type, " + (ConnectionError)ret);
140 return (WiFiSecureType)value;
145 /// Gets the encryption type of Wi-Fi.
147 public WiFiEncryptionType EncryptionType
152 int ret = Interop.ConnectionWiFiProfile.GetEncryptionType(ProfileHandle, out value);
153 if ((ConnectionError)ret != ConnectionError.None)
155 Log.Error(Globals.LogTag, "It failed to get encryption type, " + (ConnectionError)ret);
157 return (WiFiEncryptionType)value;
162 /// Checks whether passphrase is required.
164 public bool PassphraseRequired
169 int ret = Interop.ConnectionWiFiProfile.IsRequiredPassphrase(ProfileHandle, out value);
170 if ((ConnectionError)ret != ConnectionError.None)
172 Log.Error(Globals.LogTag, "It failed to get PassphraseRequired, " + (ConnectionError)ret);
179 /// Checks whether the WPS (Wi-Fi Protected Setup) is supported.
181 public bool WpsSupported
186 int ret = Interop.ConnectionWiFiProfile.IsSupportedWps(ProfileHandle, out value);
187 if ((ConnectionError)ret != ConnectionError.None)
189 Log.Error(Globals.LogTag, "It failed to get IsSupportedWps, " + (ConnectionError)ret);
196 /// Sets the passphrase of the Wi-Fi WPA.
198 public int SetPassphrase(string passphrase)
200 int ret = Interop.ConnectionWiFiProfile.SetPassphrase(ProfileHandle, (string)passphrase);
201 if ((ConnectionError)ret != ConnectionError.NoConnection)
203 Log.Error(Globals.LogTag, "It failed to set passphrase, " + (ConnectionError)ret);
204 ConnectionErrorFactory.ThrowConnectionException(ret);