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.
19 namespace Tizen.Network.WiFi
22 /// A class for manager the network information of the access point(AP). It allows applications to manager network informaiton.
24 public class WiFiAP : IDisposable
26 private IntPtr _apHandle = IntPtr.Zero;
27 private WiFiNetwork _network;
28 private WiFiSecurity _security;
29 private bool disposed = false;
32 /// The network information of the access point(AP).
34 public WiFiNetwork NetworkInformation
42 /// The security information of the access point(AP).
44 public WiFiSecurity SecurityInformation
52 internal WiFiAP(IntPtr handle)
54 Log.Debug(Globals.LogTag, "New WiFiAP. Handle: " + handle);
59 /// Creates a object for the access point.
61 /// <param name="essid">The ESSID (Extended Service Set Identifier) can be UTF-8 encoded </param>
62 public WiFiAP(string essid)
64 Log.Debug(Globals.LogTag, "New WiFiAP. Essid: " + essid);
65 createHandle(essid, true);
69 /// Creates a object for the hidden access point.
71 /// <param name="essid">The ESSID (Extended Service Set Identifier) can be UTF-8 encoded </param>
72 /// <param name="hidden">The value to set hidden AP</param>
73 public WiFiAP(string essid, bool hidden)
75 createHandle(essid, hidden);
87 GC.SuppressFinalize(this);
90 private void Dispose(bool disposing)
99 Interop.WiFi.AP.Destroy(_apHandle);
100 _apHandle = IntPtr.Zero;
105 private void createHandle(string id, bool hidden)
110 ret = Interop.WiFi.AP.Create(WiFiManagerImpl.Instance.GetHandle(), id, out _apHandle);
114 ret = Interop.WiFi.AP.CreateHiddenAP(WiFiManagerImpl.Instance.GetHandle(), id, out _apHandle);
117 if (ret != (int)WiFiError.None)
119 Log.Error(Globals.LogTag, "Failed to create handle, Error - " + (WiFiError)ret);
120 WiFiErrorFactory.ThrowWiFiException(ret);
124 private void Initialize()
126 _network = new WiFiNetwork(_apHandle);
127 _security = new WiFiSecurity(_apHandle);
131 /// Refreshes the access point information.
133 public void Refresh()
135 int ret = Interop.WiFi.AP.Refresh(_apHandle);
136 if (ret != (int)WiFiError.None)
138 Log.Error(Globals.LogTag, "Failed to refresh ap handle, Error - " + (WiFiError)ret);
139 WiFiErrorFactory.ThrowWiFiException(ret, _apHandle);
143 internal IntPtr GetHandle()