summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Jiung <jiung.yu@samsung.com>2016-12-22 14:22:24 +0900
committerYu Jiung <jiung.yu@samsung.com>2016-12-26 11:16:40 +0900
commit4ecefb3d2b5f7c6677f1793f7e54f79f76a374be (patch)
tree30fb18c0768be9c3f660bd03a73d89f2e367586f
parentccab26a94b82b516f04ca9c7268f050fbb4e438e (diff)
downloadwifi-direct-4ecefb3d2b5f7c6677f1793f7e54f79f76a374be.tar.gz
wifi-direct-4ecefb3d2b5f7c6677f1793f7e54f79f76a374be.tar.bz2
wifi-direct-4ecefb3d2b5f7c6677f1793f7e54f79f76a374be.zip
Change-Id: I8a4d5635a1ee4fd80f97624dcf0ba764018ca857 Signed-off-by: Yu jiung <jiung.yu@samsung.com>
-rw-r--r--LICENSE202
-rw-r--r--Tizen.Network.WiFiDirect/Interop/Interop.Libraries.cs25
-rw-r--r--Tizen.Network.WiFiDirect/Interop/Interop.WiFiDirect.cs229
-rw-r--r--Tizen.Network.WiFiDirect/Properties/AssemblyInfo.cs36
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.Net45.csproj73
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.Net45.project.json11
-rwxr-xr-xTizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.csproj82
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.nuspec21
-rwxr-xr-xTizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.project.json10
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.sln22
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.snkbin0 -> 596 bytes
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectData.cs165
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectEnumerations.cs651
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectError.cs65
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectEventArgs.cs382
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManager.cs1237
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManagerImpl.cs1241
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectPeer.cs736
-rw-r--r--Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectPersistentGroup.cs57
-rw-r--r--packaging/csapi-network-wifi-direct.manifest5
-rw-r--r--packaging/csapi-network-wifi-direct.spec44
21 files changed, 5294 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/Tizen.Network.WiFiDirect/Interop/Interop.Libraries.cs b/Tizen.Network.WiFiDirect/Interop/Interop.Libraries.cs
new file mode 100644
index 0000000..c036d47
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Interop/Interop.Libraries.cs
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+ internal static partial class Libraries
+ {
+ public const string WiFiDirect = "libwifi-direct.so.1";
+ public const string Glib = "libglib-2.0.so.0";
+ public const string Libc = "libc.so.6";
+ }
+}
diff --git a/Tizen.Network.WiFiDirect/Interop/Interop.WiFiDirect.cs b/Tizen.Network.WiFiDirect/Interop/Interop.WiFiDirect.cs
new file mode 100644
index 0000000..ac9afc1
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Interop/Interop.WiFiDirect.cs
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Network.WiFiDirect;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Interop class for Wi-Fi Direct
+/// </summary>
+internal static partial class Interop
+{
+ /// <summary>
+ /// Wi-Fi Direct Native Apis
+ /// </summary>
+ internal static partial class WiFiDirect
+ {
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void DiscoveryStateChangedCallback(int result, WiFiDirectDiscoveryState state, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void PeerFoundCallback(int result, WiFiDirectDiscoveryState state, string address, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void DeviceStateChangedCallback(int result, WiFiDirectDeviceState state, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ConnectionStateChangedCallback(int result, WiFiDirectConnectionState state, string address, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ClientIpAddressAssignedCallback(string macAddress, string ipAddress, string interfaceAddress, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ServiceStateChangedCallback(int result, WiFiDirectServiceDiscoveryState state, WiFiDirectServiceType type, IntPtr responseData, string address, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void StateChangedCallback(WiFiDirectState state, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool DiscoveredPeerCallback(ref DiscoveredPeerStruct peer, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool ConnectedPeerCallback(ref ConnectedPeerStruct peer, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool WpsTypeCallback(WiFiDirectWpsType type, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool PersistentGroupCallback(string address, string ssid, IntPtr userData);
+
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_state_changed_cb")]
+ internal static extern int SetStateChangedCallback(StateChangedCallback stateChangedCb, IntPtr userData);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_state_changed_cb")]
+ internal static extern int UnsetStateChangedCallback();
+
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_device_state_changed_cb")]
+ internal static extern int SetDeviceStateChangedCallback(DeviceStateChangedCallback deviceChangedCb, IntPtr userData);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_device_state_changed_cb")]
+ internal static extern int UnsetDeviceStateChangedCallback();
+
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_discovery_state_changed_cb")]
+ internal static extern int SetDiscoveryStateChangedCallback(DiscoveryStateChangedCallback discoveryStateChangedCb, IntPtr userData);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_discovery_state_changed_cb")]
+ internal static extern int UnsetDiscoveryStateChangedCallback();
+
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_peer_found_cb")]
+ internal static extern int SetPeerFoundCallback(PeerFoundCallback peerFoundCb, IntPtr userData);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_peer_found_cb")]
+ internal static extern int UnsetPeerFoundCallback();
+
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_connection_state_changed_cb")]
+ internal static extern int SetConnectionChangedCallback(ConnectionStateChangedCallback connectionCb, IntPtr userData);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_connection_state_changed_cb")]
+ internal static extern int UnsetConnectionChangedCallback();
+
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_client_ip_address_assigned_cb")]
+ internal static extern int SetIpAddressAssignedCallback(ClientIpAddressAssignedCallback callback, IntPtr userData);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_client_ip_address_assigned_cb")]
+ internal static extern int UnsetIpAddressAssignedCallback();
+
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_service_state_changed_cb")]
+ internal static extern int SetServiceStateChangedCallback(ServiceStateChangedCallback serviceStateChangedCb, IntPtr userData);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_service_state_changed_cb")]
+ internal static extern int UnsetServiceStateChangedCallback();
+
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_initialize")]
+ internal static extern int Initialize();
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_deinitialize")]
+ internal static extern int Deinitialize();
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_activate")]
+ internal static extern int Activate();
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_deactivate")]
+ internal static extern int Deactivate();
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_start_discovery_specific_channel")]
+ internal static extern int StartDiscoveryInChannel(bool listenOnly, int timeout, WiFiDirectDiscoveryChannel channel);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_cancel_discovery")]
+ internal static extern int StopDiscovery();
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_foreach_discovered_peers")]
+ internal static extern int GetDiscoveredPeers(DiscoveredPeerCallback callback, IntPtr userData);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_connect")]
+ internal static extern int Connect(string address);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_cancel_connection")]
+ internal static extern int CancelConnection(string address);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_disconnect_all")]
+ internal static extern int DisconnectAll();
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_disconnect")]
+ internal static extern int Disconnect(string address);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_foreach_connected_peers")]
+ internal static extern int GetConnectedPeers(ConnectedPeerCallback callback, IntPtr userData);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_create_group")]
+ internal static extern int CreateGroup();
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_destroy_group")]
+ internal static extern int DestroyGroup();
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_group_owner")]
+ internal static extern int IsGroupOwner(out bool isGroupOwner);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_autonomous_group")]
+ internal static extern int IsAutonomousGroup(out bool isAutonomous);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_device_name")]
+ internal static extern int SetName(string name);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_device_name")]
+ internal static extern int GetName(out string name);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_ssid")]
+ internal static extern int GetSsid(out string ssid);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_network_interface_name")]
+ internal static extern int GetInterfaceName(out string name);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_ip_address")]
+ internal static extern int GetIpAddress(out string address);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_subnet_mask")]
+ internal static extern int GetSubnetMask(out string mask);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_gateway_address")]
+ internal static extern int GetGatewayAddress(out string address);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_mac_address")]
+ internal static extern int GetMacAddress(out string address);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_state")]
+ internal static extern int GetState(out WiFiDirectState state);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_discoverable")]
+ internal static extern int IsDiscoverable(out bool isDiscoverable);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_listening_only")]
+ internal static extern int IsListeningOnly(out bool listenOnly);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_primary_device_type")]
+ internal static extern int GetPrimaryType(out WiFiDirectPrimaryDeviceType type);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_secondary_device_type")]
+ internal static extern int GetSecondaryType(out WiFiDirectSecondaryDeviceType type);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_activate_pushbutton")]
+ internal static extern int ActivatePushButton();
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_wps_pin")]
+ internal static extern int SetWpsPin(string pin);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_wps_pin")]
+ internal static extern int GetWpsPin(out string pin);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_supported_wps_mode")]
+ internal static extern int GetWpsMode(out int mode);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_foreach_supported_wps_types")]
+ internal static extern int GetWpsTypes(WpsTypeCallback callback, IntPtr userData);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_local_wps_type")]
+ internal static extern int GetLocalWpsType(out WiFiDirectWpsType type);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_req_wps_type")]
+ internal static extern int SetReqWpsType(WiFiDirectWpsType type);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_req_wps_type")]
+ internal static extern int GetReqWpsType(out WiFiDirectWpsType type);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_group_owner_intent")]
+ internal static extern int SetIntent(int intent);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_group_owner_intent")]
+ internal static extern int GetIntent(out int intent);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_max_clients")]
+ internal static extern int SetMaxClients(int max);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_max_clients")]
+ internal static extern int GetMaxClients(out int max);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_passphrase")]
+ internal static extern int SetPassPhrase(string passphrase);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_passphrase")]
+ internal static extern int GetPassPhrase(out string passphrase);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_operating_channel")]
+ internal static extern int GetChannel(out int channel);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_autoconnection_mode")]
+ internal static extern int SetAutoConnectionMode(bool mode);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_autoconnection_mode")]
+ internal static extern int GetAutoConnectionMode(out bool mode);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_autoconnection_peer")]
+ internal static extern int SetAutoConnectionPeer(string address);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_persistent_group_enabled")]
+ internal static extern int SetPersistentGroupState(bool enabled);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_persistent_group_enabled")]
+ internal static extern int GetPersistentGroupState(out bool enabled);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_foreach_persistent_groups")]
+ internal static extern int GetPersistentGroups(PersistentGroupCallback callback, IntPtr userData);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_remove_persistent_group")]
+ internal static extern int RemovePersistentGroup(string address, string ssid);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_start_service_discovery")]
+ internal static extern int StartServiceDiscovery(string address, WiFiDirectServiceType type);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_cancel_service_discovery")]
+ internal static extern int StopServiceDiscovery(string address, WiFiDirectServiceType type);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_register_service")]
+ internal static extern int RegisterService(WiFiDirectServiceType type, string info1, string info2, out uint serviceId);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_deregister_service")]
+ internal static extern int DeregisterService(uint serviceId);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_init_miracast")]
+ internal static extern int InitMiracast(bool enable);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_info")]
+ internal static extern int GetDiscoveredPeerInfo(string address, out IntPtr peer);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_init_display")]
+ internal static extern int InitDisplay();
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_deinit_display")]
+ internal static extern int DeinitDisplay();
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_display")]
+ internal static extern int SetDisplay(WiFiDirectDisplayType type, int port, int hdcp);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_display_availability")]
+ internal static extern int SetDisplayAvailability(bool availability);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_display_type")]
+ internal static extern int GetDisplayType(string address, out WiFiDirectDisplayType type);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_display_availability")]
+ internal static extern int GetDisplayAvailability(string address, out bool availability);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_display_hdcp")]
+ internal static extern int GetDisplayHdcp(string address, out int hdcp);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_display_port")]
+ internal static extern int GetDisplayPort(string address, out int port);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_display_throughput")]
+ internal static extern int GetDisplayThroughput(string address, out int throughput);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_session_timer")]
+ internal static extern int GetSessionTimer(out int seconds);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_session_timer")]
+ internal static extern int SetSessionTimer(int seconds);
+ [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_auto_group_removal")]
+ internal static extern int SetAutoGroupRemoval(bool enable);
+ }
+}
diff --git a/Tizen.Network.WiFiDirect/Properties/AssemblyInfo.cs b/Tizen.Network.WiFiDirect/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..ca90f33
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tizen.Network.WiFiDirect")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Samsung Electronics")]
+[assembly: AssemblyProduct("Tizen.Network.WiFiDirect")]
+[assembly: AssemblyCopyright("Copyright © Samsung Electronics 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("08c34d73-7986-4e6e-8c21-5343c7feec86")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.Net45.csproj b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.Net45.csproj
new file mode 100644
index 0000000..22b05ed
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.Net45.csproj
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{E937D82B-AE58-409A-95C9-8F044EF58485}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.Network.WiFiDirect</RootNamespace>
+ <AssemblyName>Tizen.Network.WiFiDirect</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\Net45\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\Net45\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Tizen.Network.WiFiDirect.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Interop\Interop.WiFiDirect.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectData.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectEnumerations.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectError.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectEventArgs.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectManagerImpl.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectManager.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectPeer.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectPersistentGroup.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Tizen.Network.WiFiDirect.nuspec" />
+ <None Include="Tizen.Network.WiFiDirect.Net45.project.json" />
+ <None Include="Tizen.Network.WiFiDirect.snk" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.Net45.project.json b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.Net45.project.json
new file mode 100644
index 0000000..6ce3032
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.Net45.project.json
@@ -0,0 +1,11 @@
+{
+ "dependencies": {
+ "Tizen": "1.0.2"
+ },
+ "frameworks": {
+ "net45": {}
+ },
+ "runtimes": {
+ "win": {}
+ }
+}
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.csproj b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.csproj
new file mode 100755
index 0000000..83600d1
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.csproj
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{08C34D73-7986-4E6E-8C21-5343C7FEEC86}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.Network.WiFiDirect</RootNamespace>
+ <AssemblyName>Tizen.Network.WiFiDirect</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup>
+ <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
+ <NoStdLib>true</NoStdLib>
+ <NoWarn>$(NoWarn);1701;1702</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Tizen.Network.WiFiDirect.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Interop\Interop.WiFiDirect.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectData.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectEnumerations.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectError.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectEventArgs.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectManager.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectManagerImpl.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectPeer.cs" />
+ <Compile Include="Tizen.Network.WiFiDirect\WiFiDirectPersistentGroup.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Tizen.Network.WiFiDirect.nuspec" />
+ <None Include="Tizen.Network.WiFiDirect.project.json" />
+ <None Include="Tizen.Network.WiFiDirect.snk" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+ <PropertyGroup>
+ <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and
+ https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild
+ -->
+ <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
+ properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and
+ to prevent it from outputting a warning (MSB3644).
+ -->
+ <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>
+ <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
+ <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.nuspec b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.nuspec
new file mode 100644
index 0000000..039b102
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.nuspec
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<package>
+ <metadata>
+ <id>Tizen.Network.WiFiDirect</id>
+ <version>$version$</version>
+ <authors>Samsung Electronics</authors>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
+ <projectUrl>https://www.tizen.org/</projectUrl>
+ <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>
+ <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>
+ <description>Provides the Wi-Fi Direct APIs for Tizen.Network.WiFiDirect</description>
+ <dependencies>
+ <dependency id="Tizen" version="1.0.2" />
+ </dependencies>
+ </metadata>
+ <files>
+ <file src="bin/$Configuration$/Tizen.Network.WiFiDirect.dll" target="lib/netstandard1.3" />
+ <file src="bin/$Configuration$/Net45/Tizen.Network.WiFiDirect.dll" target="lib/net45" />
+ </files>
+</package>
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.project.json b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.project.json
new file mode 100755
index 0000000..f463d9b
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.project.json
@@ -0,0 +1,10 @@
+{
+ "dependencies": {
+ "NETStandard.Library": "1.6.0",
+ "System.Threading.Thread": "4.3.0",
+ "Tizen": "1.0.2"
+ },
+ "frameworks": {
+ "netstandard1.3": {}
+ }
+}
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.sln b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.sln
new file mode 100644
index 0000000..e448ba7
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Network.WiFiDirect", "Tizen.Network.WiFiDirect.csproj", "{08C34D73-7986-4E6E-8C21-5343C7FEEC86}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {08C34D73-7986-4E6E-8C21-5343C7FEEC86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {08C34D73-7986-4E6E-8C21-5343C7FEEC86}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {08C34D73-7986-4E6E-8C21-5343C7FEEC86}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {08C34D73-7986-4E6E-8C21-5343C7FEEC86}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.snk b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.snk
new file mode 100644
index 0000000..cffdfb5
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect.snk
Binary files differ
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectData.cs b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectData.cs
new file mode 100644
index 0000000..10e2862
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectData.cs
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.ObjectModel;
+
+namespace Tizen.Network.WiFiDirect
+{
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct DiscoveredPeerStruct
+ {
+ [MarshalAsAttribute(UnmanagedType.LPStr)]
+ internal string _name;
+
+ [MarshalAsAttribute(UnmanagedType.LPStr)]
+ internal string _macAddress;
+
+ [MarshalAsAttribute(UnmanagedType.LPStr)]
+ internal string _interfaceAddress;
+
+ internal int _channel;
+
+ [MarshalAsAttribute(UnmanagedType.I1)]
+ internal bool _isConnected;
+
+ [MarshalAsAttribute(UnmanagedType.I1)]
+ internal bool _isGroupOwner;
+
+ [MarshalAsAttribute(UnmanagedType.I1)]
+ internal bool _isPersistentGroupOwner;
+
+ internal WiFiDirectPrimaryDeviceType _primaryType;
+
+ internal WiFiDirectSecondaryDeviceType _secondaryType;
+
+ internal int _wpsTypes;
+
+ [MarshalAsAttribute(UnmanagedType.I1)]
+ internal bool _isP2PInvitationSupported;
+
+ internal uint _serviceCount;
+
+ internal IntPtr _serviceList;
+
+ [MarshalAsAttribute(UnmanagedType.I1)]
+ internal bool _isMiracast;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct ConnectedPeerStruct
+ {
+ [MarshalAsAttribute(UnmanagedType.LPStr)]
+ internal string _name;
+
+ [MarshalAsAttribute(UnmanagedType.LPStr)]
+ internal string _ipAddress;
+
+ [MarshalAsAttribute(UnmanagedType.LPStr)]
+ internal string _macAddress;
+
+ [MarshalAsAttribute(UnmanagedType.LPStr)]
+ internal string _interfaceAddress;
+
+ internal int _channel;
+
+ [MarshalAsAttribute(UnmanagedType.I1)]
+ internal bool _isP2PSupport;
+
+ internal WiFiDirectPrimaryDeviceType _primaryType;
+
+ internal WiFiDirectSecondaryDeviceType _secondaryType;
+
+ internal uint _serviceCount;
+
+ internal IntPtr _serviceList;
+
+ [MarshalAsAttribute(UnmanagedType.I1)]
+ internal bool _isMiracast;
+ }
+
+ internal static class WiFiDirectUtils
+ {
+ internal static WiFiDirectPeer ConvertStructToDiscoveredPeer(DiscoveredPeerStruct peer)
+ {
+ WiFiDirectPeer resultPeer = new WiFiDirectPeer();
+ resultPeer._peerDeviceName = peer._name;
+ resultPeer._peerMacAddress = peer._macAddress;
+ resultPeer._peerInterfaceAddress = peer._interfaceAddress;
+ resultPeer._peerChannel = peer._channel;
+ resultPeer._isPeerConnected = peer._isConnected;
+ resultPeer._isPeerGroupOwner = peer._isGroupOwner;
+ resultPeer._isPeerPersistentGroupOwner = peer._isPersistentGroupOwner;
+ resultPeer._peerPrimaryType = peer._primaryType;
+ resultPeer._peerSecondaryType = peer._secondaryType;
+ resultPeer._peerWpsTypes = peer._wpsTypes;
+ resultPeer._p2PInvitationSupported = peer._isP2PInvitationSupported;
+ Collection<string> uuidList = null;
+
+ if (peer._serviceCount > 0)
+ {
+ IntPtr[] serviceList = new IntPtr[peer._serviceCount];
+ Marshal.Copy(peer._serviceList, serviceList, 0, (int)peer._serviceCount);
+ uuidList = new Collection<string>();
+ foreach (IntPtr service in serviceList)
+ {
+ string registeredService = Marshal.PtrToStringAnsi(service);
+ uuidList.Add(registeredService);
+ }
+
+ resultPeer._peerServiceCount = peer._serviceCount;
+ resultPeer._peerServiceList = uuidList;
+ }
+
+ resultPeer._isPeerMiracastDevice = peer._isMiracast;
+ return resultPeer;
+ }
+
+ internal static WiFiDirectPeer ConvertStructToConnectedPeer(ConnectedPeerStruct peer)
+ {
+ WiFiDirectPeer resultPeer = new WiFiDirectPeer();
+ resultPeer._peerDeviceName = peer._name;
+ resultPeer._peerIpAddress = peer._ipAddress;
+ resultPeer._peerMacAddress = peer._macAddress;
+ resultPeer._peerInterfaceAddress = peer._interfaceAddress;
+ resultPeer._peerChannel = peer._channel;
+ resultPeer._peerP2PSupport = peer._isP2PSupport;
+ resultPeer._peerPrimaryType = peer._primaryType;
+ resultPeer._peerSecondaryType = peer._secondaryType;
+ Collection<string> uuidList = null;
+
+ if (peer._serviceCount > 0)
+ {
+ IntPtr[] serviceList = new IntPtr[peer._serviceCount];
+ Marshal.Copy(peer._serviceList, serviceList, 0, (int)peer._serviceCount);
+ uuidList = new Collection<string>();
+ foreach (IntPtr service in serviceList)
+ {
+ string registeredService = Marshal.PtrToStringAnsi(service);
+ uuidList.Add(registeredService);
+ }
+
+ resultPeer._peerServiceCount = peer._serviceCount;
+ resultPeer._peerServiceList = uuidList;
+ }
+
+ resultPeer._isPeerMiracastDevice = peer._isMiracast;
+ return resultPeer;
+ }
+ }
+
+}
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectEnumerations.cs b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectEnumerations.cs
new file mode 100644
index 0000000..e15f92e
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectEnumerations.cs
@@ -0,0 +1,651 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Network.WiFiDirect
+{
+ /// <summary>
+ /// Enumeration for Wi-Fi Direct discovery state.
+ /// </summary>
+ public enum WiFiDirectDiscoveryState
+ {
+ /// <summary>
+ /// Only listen has started.
+ /// </summary>
+ OnlyListenStarted = 0,
+ /// <summary>
+ /// Discovery started.
+ /// </summary>
+ Started,
+ /// <summary>
+ /// A remote peer is found.
+ /// </summary>
+ Found,
+ /// <summary>
+ /// Discovery finished.
+ /// </summary>
+ Finished,
+ /// <summary>
+ /// A remote peer is lost.
+ /// </summary>
+ Lost
+ }
+
+ /// <summary>
+ /// Enumeration for Wi-Fi Direct display device type.
+ /// </summary>
+ public enum WiFiDirectDisplayType
+ {
+ /// <summary>
+ /// Configure as WFD source.
+ /// </summary>
+ Source = 0,
+ /// <summary>
+ /// Configure as WFD primary sink.
+ /// </summary>
+ Prisink,
+ /// <summary>
+ /// Configure as WFD secondary sink.
+ /// </summary>
+ Secsink,
+ /// <summary>
+ /// Configure as WFD dual role.
+ /// </summary>
+ Dual
+ }
+
+ /// <summary>
+ /// Enumeration for Wi-Fi Discovery channel.
+ /// </summary>
+ public enum WiFiDirectDiscoveryChannel
+ {
+ /// <summary>
+ /// Scan full channel.
+ /// </summary>
+ FullScan = 0,
+ /// <summary>
+ /// The social channel.
+ /// </summary>
+ SocialChannel = 1611,
+ /// <summary>
+ /// Scan channel 1.
+ /// </summary>
+ Channel1 = 1,
+ /// <summary>
+ /// Scan channel 6.
+ /// </summary>
+ Channel6 = 6,
+ /// <summary>
+ /// Scan channel 11.
+ /// </summary>
+ Channel11 = 11
+ }
+
+ /// <summary>
+ /// Enumeration for Wi-Fi Direct connection state.
+ /// </summary>
+ public enum WiFiDirectConnectionState
+ {
+ /// <summary>
+ /// Connection is requested.
+ /// </summary>
+ ConnectionRequest,
+ /// <summary>
+ /// Wps is requested.
+ /// </summary>
+ ConnectionWpsRequest,
+ /// <summary>
+ /// Connection in progress.
+ /// </summary>
+ ConnectionInProgress,
+ /// <summary>
+ /// Connected .
+ /// </summary>
+ ConnectionRsp,
+ /// <summary>
+ /// Disconnected by remote group client.
+ /// </summary>
+ DisassociationInd,
+ /// <summary>
+ /// Disconnected by local device.
+ /// </summary>
+ DisconnectRsp,
+ /// <summary>
+ /// Disconnected by remote group owner.
+ /// </summary>
+ DisconnectInd,
+ /// <summary>
+ /// Group is created.
+ /// </summary>
+ GroupCreated,
+ /// <summary>
+ /// Group is destroyed.
+ /// </summary>
+ GroupDestroyed
+ }
+
+ /// <summary>
+ /// Enumeration for Wi-Fi Direct primary device type.
+ /// </summary>
+ public enum WiFiDirectPrimaryDeviceType
+ {
+ /// <summary>
+ /// Computer.
+ /// </summary>
+ Computer = 1,
+ /// <summary>
+ /// Input device.
+ /// </summary>
+ InputDevice = 2,
+ /// <summary>
+ /// Printer.
+ /// </summary>
+ Printer = 3,
+ /// <summary>
+ /// Camera.
+ /// </summary>
+ Camera = 4,
+ /// <summary>
+ /// Storage.
+ /// </summary>
+ Storage = 5,
+ /// <summary>
+ /// Network Infrastructure.
+ /// </summary>
+ NetworkInfrastructure = 6,
+ /// <summary>
+ /// Display.
+ /// </summary>
+ Display = 7,
+ /// <summary>
+ /// Multimedia device.
+ /// </summary>
+ MultimediaDevice = 8,
+ /// <summary>
+ /// Game device.
+ /// </summary>
+ GameDevice = 9,
+ /// <summary>
+ /// Telephone.
+ /// </summary>
+ Telephone = 10,
+ /// <summary>
+ /// Audio.
+ /// </summary>
+ Audio = 11,
+ /// <summary>
+ /// Others.
+ /// </summary>
+ Other = 255
+ }
+
+ /// <summary>
+ /// Enumeration for Wi-Fi Direct secondary device type.
+ /// </summary>
+ /// </summary>
+ public enum WiFiDirectSecondaryDeviceType
+ {
+ /// <summary>
+ /// Computer PC.
+ /// </summary>
+ ComputerPc = 1,
+ /// <summary>
+ /// Computer server.
+ /// </summary>
+ ComputerServer = 2,
+ /// <summary>
+ /// Computer media center.
+ /// </summary>
+ ComputerMediaCenter = 3,
+ /// <summary>
+ /// Computer UMPC.
+ /// </summary>
+ ComputerUmpc = 4,
+ /// <summary>
+ /// Computer notebook.
+ /// </summary>
+ ComputerNotebook = 5,
+ /// <summary>
+ /// Computer desktop
+ /// </summary>
+ ComputerDesktop = 6,
+ /// <summary>
+ /// Computer MID.
+ /// </summary>
+ ComputerMid = 7,
+ /// <summary>
+ /// Computer netbook.
+ /// </summary>
+ ComputerNetbook = 8,
+ /// <summary>
+ /// Input keyboard.
+ /// </summary>
+ InputKeyboard = 1,
+ /// <summary>
+ /// Input mouse.
+ /// </summary>
+ InputMouse = 2,
+ /// <summary>
+ /// Input joystick.
+ /// </summary>
+ InputJoystick = 3,
+ /// <summary>
+ /// Input trackball.
+ /// </summary>
+ InputTrackball = 4,
+ /// <summary>
+ /// Input controller.
+ /// </summary>
+ InputController = 5,
+ /// <summary>
+ /// Inpute remote.
+ /// </summary>
+ InputRemote = 6,
+ /// <summary>
+ /// Input touch screen.
+ /// </summary>
+ InputTouchScreen = 7,
+ /// <summary>
+ /// Input biometric reader.
+ /// </summary>
+ InputBiometricReader = 8,
+ /// <summary>
+ /// Input barcode reader.
+ /// </summary>
+ InputBarcodeReader = 9,
+ /// <summary>
+ /// Printer.
+ /// </summary>
+ Printer = 1,
+ /// <summary>
+ /// Printer scanner.
+ /// </summary>
+ PrinterScanner = 2,
+ /// <summary>
+ /// Printer fax.
+ /// </summary>
+ PrinterFax = 3,
+ /// <summary>
+ /// Printer copier.
+ /// </summary>
+ PrinterCopier = 4,
+ /// <summary>
+ /// Printer all-in-one.
+ /// </summary>
+ PrinterAllInOne = 5,
+ /// <summary>
+ /// Digital still camera.
+ /// </summary>
+ CameraDigital = 1,
+ /// <summary>
+ /// Video camera.
+ /// </summary>
+ CameraVideo = 2,
+ /// <summary>
+ /// Webcam.
+ /// </summary>
+ CameraWebcam = 3,
+ /// <summary>
+ /// Security camera.
+ /// </summary>
+ CameraSecurity = 4,
+ /// <summary>
+ /// Storage NAS.
+ /// </summary>
+ StorageNas = 1,
+ /// <summary>
+ /// Network ap.
+ /// </summary>
+ NetworkAp = 1,
+ /// <summary>
+ /// Network router.
+ /// </summary>
+ NetworkRouter = 2,
+ /// <summary>
+ /// Network switch.
+ /// </summary>
+ NetworkSwitch = 3,
+ /// <summary>
+ /// Network gateway.
+ /// </summary>
+ NetworkGateway = 4,
+ /// <summary>
+ /// Display tv.
+ /// </summary>
+ DisplayTv = 1,
+ /// <summary>
+ /// Display picture frame.
+ /// </summary>
+ DisplayPicFrame = 2,
+ /// <summary>
+ /// Display projector.
+ /// </summary>
+ DisplayProjector = 3,
+ /// <summary>
+ /// Display monitor.
+ /// </summary>
+ DisplayMonitor = 4,
+ /// <summary>
+ /// Multimedia DAR.
+ /// </summary>
+ MultimediaDar = 1,
+ /// <summary>
+ /// Multimedia PVR.
+ /// </summary>
+ MultimediaPvr = 2,
+ /// <summary>
+ /// Multimedia MCX.
+ /// </summary>
+ MultimediaMcx = 3,
+ /// <summary>
+ /// Multimedia set-top box.
+ /// </summary>
+ MultimediaStb = 4,
+ /// <summary>
+ /// Media Server / Media Adapter / Media Extender.
+ /// </summary>
+ MultimediaMsMaMe = 5,
+ /// <summary>
+ /// Multimedia portable video player.
+ /// </summary>
+ MultimediaPvp = 6,
+ /// <summary>
+ /// Game xbox.
+ /// </summary>
+ GameXbox = 1,
+ /// <summary>
+ /// The game xbox 360.
+ /// </summary>
+ GameXbox360,
+ /// <summary>
+ /// Game play station.
+ /// </summary>
+ GamePlayStation = 2,
+ /// <summary>
+ /// Game console.
+ /// </summary>
+ GameConsole = 3,
+ /// <summary>
+ /// Game portable.
+ /// </summary>
+ GamePortable = 4,
+ /// <summary>
+ /// Windows mobile.
+ /// </summary>
+ TelephoneWindowsMobile = 1,
+ /// <summary>
+ /// Phone - single mode.
+ /// </summary>
+ TelephonePhoneSingle = 2,
+ /// <summary>
+ /// Phone - dual mode.
+ /// </summary>
+ TelephonePhoneDual = 3,
+ /// <summary>
+ /// Smart Phone - single mode.
+ /// </summary>
+ TelephoneSmartphoneSingle = 4,
+ /// <summary>
+ /// Smart Phone - dual mode.
+ /// </summary>
+ TelephoneSmartphoneDual = 5,
+ /// <summary>
+ /// Audio tuner.
+ /// </summary>
+ AudioTuner = 1,
+ /// <summary>
+ /// Audio speaker.
+ /// </summary>
+ AudioSpeaker = 2,
+ /// <summary>
+ /// Audio pmp.
+ /// </summary>
+ AudioPmp = 3,
+ /// <summary>
+ /// Audio headset.
+ /// </summary>
+ AudioHeadset = 4,
+ /// <summary>
+ /// Audio headphone.
+ /// </summary>
+ AudioHeadphone = 5,
+ /// <summary>
+ /// Audio microphone.
+ /// </summary>
+ AudioMic = 6
+ }
+
+ /// <summary>
+ /// Enumeration for Wi-Fi Direct link status.
+ /// </summary>
+ /// </summary>
+ public enum WiFiDirectState
+ {
+ /// <summary>
+ /// Deactivated.
+ /// </summary>
+ Deactivated = 0,
+ /// <summary>
+ /// Deactivating.
+ /// </summary>
+ Deactivating,
+ /// <summary>
+ /// Activating.
+ /// </summary>
+ Activating,
+ /// <summary>
+ /// Activated.
+ /// </summary>
+ Activated,
+ /// <summary>
+ /// Discovering.
+ /// </summary>
+ Discovering,
+ /// <summary>
+ /// Connecting.
+ /// </summary>
+ Connecting,
+ /// <summary>
+ /// Disconnecting.
+ /// </summary>
+ Disconnecting,
+ /// <summary>
+ /// Connected.
+ /// </summary>
+ Connected,
+ /// <summary>
+ /// Group owner.
+ /// </summary>
+ GroupOwner
+ }
+
+ /// <summary>
+ /// Enumeration for Wi-Fi WPS type.
+ /// </summary>
+ public enum WiFiDirectWpsType
+ {
+ /// <summary>
+ /// No WPS type.
+ /// </summary>
+ None = 0x00,
+ /// <summary>
+ /// Push button configuration.
+ /// </summary>
+ Pbc = 0x01,
+ /// <summary>
+ /// Display pin code.
+ /// </summary>
+ PinDisplay = 0x02,
+ /// <summary>
+ /// Provide the keypad to input the pin.
+ /// </summary>
+ PinKeypad = 0x04
+ }
+
+ /// <summary>
+ /// Enumeration for Service Discovery type.
+ /// </summary>
+ public enum WiFiDirectServiceType
+ {
+ /// <summary>
+ /// Service discovery Type all.
+ /// </summary>
+ All,
+ /// <summary>
+ /// Service discovery Type bonjour.
+ /// </summary>
+ Bonjour,
+ /// <summary>
+ /// Service discovery Type UPNP.
+ /// </summary>
+ Upnp,
+ /// <summary>
+ /// Service discovery Type ws discovery.
+ /// </summary>
+ WsDiscovery,
+ /// <summary>
+ /// Service discovery Type wifi-display.
+ /// </summary>
+ WiFiDisplay,
+ /// <summary>
+ /// Service discovery Type bt address.
+ /// </summary>
+ BtAddress,
+ /// <summary>
+ /// Service discovery Type contact info.
+ /// </summary>
+ ContactInfo,
+ /// <summary>
+ /// Service discovery Type vendor-specific.
+ /// </summary>
+ Vendor
+ }
+
+ /// <summary>
+ /// Enumeration for Wi-Fi Direct service Discovery state.
+ /// </summary>
+ public enum WiFiDirectServiceDiscoveryState
+ {
+ /// <summary>
+ /// Service discovery started.
+ /// </summary>
+ Started,
+ /// <summary>
+ /// Service discovery found.
+ /// </summary>
+ Found,
+ /// <summary>
+ /// Service discovery finished.
+ /// </summary>
+ Finished
+ }
+
+ /// <summary>
+ /// Enumeration for Wi-Fi Direct device state.
+ /// </summary>
+ public enum WiFiDirectDeviceState
+ {
+ /// <summary>
+ /// Activated.
+ /// </summary>
+ Activated,
+ /// <summary>
+ /// Deactivated.
+ /// </summary>
+ Deactivated
+ }
+
+ /// <summary>
+ /// Enumeration for Wi-Fi Direct error code.
+ /// </summary>
+ public enum WiFiDirectError
+ {
+ /// <summary>
+ /// Successful.
+ /// </summary>
+ None = ErrorCode.None,
+ /// <summary>
+ /// Operation not permitted.
+ /// </summary>
+ NotPermitted = ErrorCode.NotPermitted,
+ /// <summary>
+ /// Out of memory.
+ /// </summary>
+ OutOfMemory = ErrorCode.OutOfMemory,
+ /// <summary>
+ /// Permission denied.
+ /// </summary>
+ PermissionDenied = ErrorCode.PermissionDenied,
+ /// <summary>
+ /// Device or resource busy.
+ /// </summary>
+ ResourceBusy = ErrorCode.ResourceBusy,
+ /// <summary>
+ /// Invalid function parameter.
+ /// </summary>
+ InvalidParameter = ErrorCode.InvalidParameter,
+ /// <summary>
+ /// Connection timed out.
+ /// </summary>
+ ConnectionTimeOut = ErrorCode.ConnectionTimeout,
+ /// <summary>
+ /// Not supported.
+ /// </summary>
+ NotSupported = ErrorCode.NotSupported,
+ /// <summary>
+ /// Not initialized.
+ /// </summary>
+ NotInitialized = -0x01C60000 | 0x01,
+ /// <summary>
+ /// I/O error.
+ /// </summary>
+ CommunicationFailed = -0x01C60000 | 0x02,
+ /// <summary>
+ /// WiFi is being used.
+ /// </summary>
+ WiFiUsed = -0x01C60000 | 0x03,
+ /// <summary>
+ /// Mobile AP is being used.
+ /// </summary>
+ MobileApUsed = -0x01C60000 | 0x04,
+ /// <summary>
+ /// Connection failed.
+ /// </summary>
+ ConnectionFailed = -0x01C60000 | 0x05,
+ /// <summary>
+ /// Authentication failed.
+ /// </summary>
+ AuthFailed = -0x01C60000 | 0x06,
+ /// <summary>
+ /// Operation failed.
+ /// </summary>
+ OperationFailed = -0x01C60000 | 0x07,
+ /// <summary>
+ /// Too many client.
+ /// </summary>
+ TooManyClient = -0x01C60000 | 0x08,
+ /// <summary>
+ /// Already initialized client.
+ /// </summary>
+ AlreadyInitialized = -0x01C60000 | 0x09,
+ /// <summary>
+ /// Connection cancelled by local device.
+ /// </summary>
+ ConnectionCancelled = -0x01C60000 | 0x10
+ }
+}
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectError.cs b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectError.cs
new file mode 100644
index 0000000..325a5c9
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectError.cs
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Network.WiFiDirect
+{
+ internal static class WiFiDirectErrorFactory
+ {
+ internal static void ThrowWiFiDirectException(int exception)
+ {
+ WiFiDirectError _error = (WiFiDirectError)exception;
+ switch (_error)
+ {
+ case WiFiDirectError.InvalidParameter:
+ throw new InvalidOperationException("Invalid parameter");
+ case WiFiDirectError.AlreadyInitialized:
+ throw new InvalidOperationException("Already initialized");
+ case WiFiDirectError.AuthFailed:
+ throw new InvalidOperationException("Authentication failed");
+ case WiFiDirectError.CommunicationFailed:
+ throw new InvalidOperationException("Communication failed");
+ case WiFiDirectError.ConnectionCancelled:
+ throw new InvalidOperationException("Connection cancelled");
+ case WiFiDirectError.ConnectionFailed:
+ throw new InvalidOperationException("Connection failed");
+ case WiFiDirectError.ConnectionTimeOut:
+ throw new InvalidOperationException("Connection timed out");
+ case WiFiDirectError.MobileApUsed:
+ throw new InvalidOperationException("Mobile Ap is being used");
+ case WiFiDirectError.NotInitialized:
+ throw new InvalidOperationException("Not initialized");
+ case WiFiDirectError.NotPermitted:
+ throw new InvalidOperationException("Not permitted");
+ case WiFiDirectError.NotSupported:
+ throw new NotSupportedException("Not supported");
+ case WiFiDirectError.OperationFailed:
+ throw new InvalidOperationException("Operation failed");
+ case WiFiDirectError.OutOfMemory:
+ throw new InvalidOperationException("Out of memory");
+ case WiFiDirectError.PermissionDenied:
+ throw new InvalidOperationException("Permission denied");
+ case WiFiDirectError.ResourceBusy:
+ throw new InvalidOperationException("Resource is busy");
+ case WiFiDirectError.TooManyClient:
+ throw new InvalidOperationException("Too many client");
+ case WiFiDirectError.WiFiUsed:
+ throw new InvalidOperationException("Wi-fi is being used");
+ }
+ }
+ }
+}
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectEventArgs.cs b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectEventArgs.cs
new file mode 100644
index 0000000..b87af3b
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectEventArgs.cs
@@ -0,0 +1,382 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Network.WiFiDirect
+{
+ /// <summary>
+ /// An extended EventArgs class which contains changed connection state during connecting or disconnecting peer device.
+ /// </summary>
+ public class ConnectionStateChangedEventArgs : EventArgs
+ {
+ private WiFiDirectError _error;
+ private WiFiDirectConnectionState _state;
+ private string _macAddress;
+
+ internal ConnectionStateChangedEventArgs(WiFiDirectError error, WiFiDirectConnectionState state, string macAddress)
+ {
+ _error = error;
+ _state = state;
+ _macAddress = macAddress;
+ }
+
+ /// <summary>
+ /// Wi-Fi Direct result.
+ /// </summary>
+ public WiFiDirectError Error
+ {
+ get
+ {
+ return _error;
+ }
+ }
+
+ /// <summary>
+ /// Wi-Fi Direct connection state of peer.
+ /// </summary>
+ public WiFiDirectConnectionState State
+ {
+ get
+ {
+ return _state;
+ }
+ }
+
+ /// <summary>
+ /// MacAddress of peer.
+ /// </summary>
+ public string MacAddress
+ {
+ get
+ {
+ return _macAddress;
+ }
+ }
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains address properties of the peer when it connects to a group owner.
+ /// </summary>
+ public class IpAddressAssignedEventArgs : EventArgs
+ {
+ private string _macAddress;
+ private string _ipAddress;
+ private string _interfaceAddress;
+
+ internal IpAddressAssignedEventArgs(string macAddress, string ipAddress, string interfaceAddress)
+ {
+ _macAddress = macAddress;
+ _ipAddress = ipAddress;
+ _interfaceAddress = interfaceAddress;
+ }
+
+ /// <summary>
+ /// MacAddress of connected peer.
+ /// </summary>
+ public string MacAddress
+ {
+ get
+ {
+ return _macAddress;
+ }
+ }
+
+ /// <summary>
+ /// IpAddress of connected peer.
+ /// </summary>
+ public string IpAddress
+ {
+ get
+ {
+ return _ipAddress;
+ }
+ }
+
+ /// <summary>
+ /// InterfaceAddress of connected peer.
+ /// </summary>
+ public string InterfaceAddress
+ {
+ get
+ {
+ return _interfaceAddress;
+ }
+ }
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains changed Wi-Fi Direct state of local device.
+ /// </summary>
+ public class StateChangedEventArgs : EventArgs
+ {
+ private WiFiDirectState _state;
+
+ internal StateChangedEventArgs(WiFiDirectState state)
+ {
+ _state = state;
+ }
+
+ /// <summary>
+ /// Wi-Fi Direct state.
+ /// </summary>
+ public WiFiDirectState State
+ {
+ get
+ {
+ return _state;
+ }
+ }
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains changed Wi-Fi Direct discovery state during Wi-Fi Direct scan operation.
+ /// </summary>
+ public class DiscoveryStateChangedEventArgs : EventArgs
+ {
+ private WiFiDirectError _error;
+ private WiFiDirectDiscoveryState _state;
+
+ internal DiscoveryStateChangedEventArgs(WiFiDirectError error, WiFiDirectDiscoveryState state)
+ {
+ _error = error;
+ _state = state;
+ }
+
+ /// <summary>
+ /// Wi-Fi Direct result.
+ /// </summary>
+ public WiFiDirectError Error
+ {
+ get
+ {
+ return _error;
+ }
+ }
+
+ /// <summary>
+ /// Wi-Fi Direct Discovery state.
+ /// </summary>
+ public WiFiDirectDiscoveryState DiscoveryState
+ {
+ get
+ {
+ return _state;
+ }
+ }
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains found peer information during Wi-Fi Direct scan operation.
+ /// </summary>
+ public class PeerFoundEventArgs : EventArgs
+ {
+ private WiFiDirectError _error;
+ private WiFiDirectDiscoveryState _state;
+ private WiFiDirectPeer _peer;
+
+ internal PeerFoundEventArgs(WiFiDirectError error, WiFiDirectDiscoveryState state, WiFiDirectPeer peer)
+ {
+ _error = error;
+ _state = state;
+ _peer = peer;
+ }
+
+ /// <summary>
+ /// Wi-Fi Direct result.
+ /// </summary>
+ public WiFiDirectError Error
+ {
+ get
+ {
+ return _error;
+ }
+ }
+
+ /// <summary>
+ /// Wi-Fi Direct Discovery state.
+ /// </summary>
+ public WiFiDirectDiscoveryState DiscoveryState
+ {
+ get
+ {
+ return _state;
+ }
+ }
+
+ /// <summary>
+ /// Found peer.
+ /// </summary>
+ public WiFiDirectPeer Peer
+ {
+ get
+ {
+ return _peer;
+ }
+ }
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains changed device state during activation or deactivation.
+ /// </summary>
+ public class DeviceStateChangedEventArgs : EventArgs
+ {
+ private WiFiDirectError _error;
+ private WiFiDirectDeviceState _state;
+
+ internal DeviceStateChangedEventArgs(WiFiDirectError error, WiFiDirectDeviceState state)
+ {
+ _error = error;
+ _state = state;
+ }
+
+ /// <summary>
+ /// Wi-Fi Direct result.
+ /// </summary>
+ public WiFiDirectError Error
+ {
+ get
+ {
+ return _error;
+ }
+ }
+
+ /// <summary>
+ /// State of the device.
+ /// </summary>
+ public WiFiDirectDeviceState DeviceState
+ {
+ get
+ {
+ return _state;
+ }
+ }
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains changed service information during service discovery.
+ /// </summary>
+ public class ServiceStateChangedEventArgs : EventArgs
+ {
+ private WiFiDirectError _error;
+ private WiFiDirectServiceDiscoveryState _state;
+ private WiFiDirectServiceType _type;
+ private string _response;
+ private WiFiDirectPeer _peer;
+
+ internal ServiceStateChangedEventArgs(WiFiDirectError error, WiFiDirectServiceDiscoveryState state, WiFiDirectServiceType type, string response, WiFiDirectPeer peer)
+ {
+ _error = error;
+ _state = state;
+ _type = type;
+ _response = response;
+ _peer = peer;
+ }
+
+ /// <summary>
+ /// Wi-Fi Direct result.
+ /// </summary>
+ public WiFiDirectError Error
+ {
+ get
+ {
+ return _error;
+ }
+ }
+
+ /// <summary>
+ /// Service discovery state.
+ /// </summary>
+ public WiFiDirectServiceDiscoveryState ServiceDiscoveryState
+ {
+ get
+ {
+ return _state;
+ }
+ }
+
+ /// <summary>
+ /// Types of service.
+ /// </summary>
+ public WiFiDirectServiceType ServiceType
+ {
+ get
+ {
+ return _type;
+ }
+ }
+
+ /// <summary>
+ /// Received response.
+ /// </summary>
+ public string Response
+ {
+ get
+ {
+ return _response;
+ }
+ }
+
+ /// <summary>
+ /// Peer servicing device.
+ /// </summary>
+ public WiFiDirectPeer Peer
+ {
+ get
+ {
+ return _peer;
+ }
+ }
+ }
+
+ /// <summary>
+ /// An extended EventArgs class which contains changed connection state during disconnect all peers or group related operations.
+ /// </summary>
+ public class ConnectionStatusChangedEventArgs : EventArgs
+ {
+ private WiFiDirectError _error;
+ private WiFiDirectConnectionState _state;
+
+ internal ConnectionStatusChangedEventArgs(WiFiDirectError error, WiFiDirectConnectionState state)
+ {
+ _error = error;
+ _state = state;
+ }
+
+ /// <summary>
+ /// Wi-Fi Direct result.
+ /// </summary>
+ public WiFiDirectError Error
+ {
+ get
+ {
+ return _error;
+ }
+ }
+
+ /// <summary>
+ /// Connection state.
+ /// </summary>
+ public WiFiDirectConnectionState ConnectionState
+ {
+ get
+ {
+ return _state;
+ }
+ }
+ }
+}
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManager.cs b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManager.cs
new file mode 100644
index 0000000..139e0c5
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManager.cs
@@ -0,0 +1,1237 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Network.WiFiDirect
+{
+ /// <summary>
+ /// A class which is used to manage settings of Wi-Fi Direct.<br>
+ /// This class is used to discover peer devices and manage settings of Wi-Fi Direct.
+ /// </summary>
+ /// <privilege> http://tizen.org/privilege/wifidirect </privilege>
+ public static class WiFiDirectManager
+ {
+ /// <summary>
+ /// A property to check whether the device is group owner or not.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If it is deactivated, false will be returned.
+ /// </remarks>
+ public static bool IsGroupOwner
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.IsGroupOwner;
+ }
+
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /// <summary>
+ /// A property to check whether the current group is the autonomous group or not.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If it is deactivated, false will be returned.
+ /// </remarks>
+ public static bool IsAutonomousGroup
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.IsAutonomousGroup;
+ }
+
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /// <summary>
+ /// SSID of local device.
+ /// </summary>
+ /// <remarks>
+ /// If there is any error, null will be returned.
+ /// </remarks>
+ public static string Ssid
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.Ssid;
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Name of network interface.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If it is deactivated, null will be returned.
+ /// </remarks>
+ public static string NetworkInterface
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.NetworkInterface;
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// IP address of a local device.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If it is deactivated, null will be returned.
+ /// </remarks>
+ public static string IpAddress
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.IpAddress;
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Subnet mask.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If it is deactivated, null will be returned.
+ /// </remarks>
+ public static string SubnetMask
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.SubnetMask;
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gateway address.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If it is deactivated, null will be returned.
+ /// </remarks>
+ public static string GatewayAddress
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.GatewayAddress;
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Mac address of a local device.
+ /// </summary>
+ /// <remarks>
+ /// If there is any error, null will be returned.
+ /// </remarks>
+ public static string MacAddress
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.MacAddress;
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// State of Wi-Fi direct service.
+ /// </summary>
+ public static WiFiDirectState State
+ {
+ get
+ {
+ return WiFiDirectManagerImpl.Instance.State;
+ }
+ }
+
+ /// <summary>
+ /// A property to check whether the device is discoverable or not by P2P discovery.
+ /// </summary>
+ public static bool IsDiscoverable
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.IsDiscoverable;
+ }
+
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /// <summary>
+ /// A property to check whether the local device is listening only.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If it is deactivated, false will be returned.
+ /// </remarks>
+ public static bool IsListenOnly
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.IsListenOnly;
+ }
+
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Primary device type of local device.
+ /// </summary>
+ /// <remarks>
+ /// If there is any error, 0 will be returned.
+ /// </remarks>
+ public static WiFiDirectPrimaryDeviceType PrimaryType
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.PrimaryType;
+ }
+
+ else
+ {
+ return default(WiFiDirectPrimaryDeviceType);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Secondary device type of local device.
+ /// </summary>
+ /// <remarks>
+ /// If there is any error, 0 will be returned.
+ /// </remarks>
+ public static WiFiDirectSecondaryDeviceType SecondaryType
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.SecondaryType;
+ }
+
+ else
+ {
+ return default(WiFiDirectSecondaryDeviceType);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Supported WPS (Wi-Fi Protected Setup) types at local device.
+ /// </summary>
+ /// <remarks>
+ /// If there is any error, -1 will be returned.
+ /// </remarks>
+ public static int WpsMode
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.WpsMode;
+ }
+
+ else
+ {
+ return -1;
+ }
+ }
+ }
+
+ /// <summary>
+ /// WPS (Wi-Fi Protected Setup) type.
+ /// </summary>
+ public static WiFiDirectWpsType Wps
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.WpsType;
+ }
+
+ else
+ {
+ return default(WiFiDirectWpsType);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Channel number on which the P2P Device is operating as the P2P Group.
+ /// </summary>
+ /// <remarks>
+ /// If there is any error, -1 will be returned.
+ /// </remarks>
+ public static int OperatingChannel
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.OperatingChannel;
+ }
+
+ else
+ {
+ return -1;
+ }
+ }
+ }
+
+ /// <summary>
+ /// A property to check whether persistent group is enabled.
+ /// </summary>
+ /// <exception cref="NotSupportedException">Thrown while setting this property when the wifidirect is not supported</exception>
+ public static bool PersistentGroupEnabled
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.PersistentGroupEnabled;
+ }
+
+ else
+ {
+ return false;
+ }
+ }
+
+ set
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.PersistentGroupEnabled = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Autoconnection mode status.
+ /// </summary>
+ /// <exception cref="NotSupportedException">Thrown while setting this property when the wifidirect is not supported</exception>
+ public static bool AutoConnect
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.AutoConnect;
+ }
+
+ else
+ {
+ return false;
+ }
+ }
+
+ set
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.AutoConnect = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// WPS PIN number.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If it is deactivated, null will be returned during get and Not permitted exception message will be returned during set.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown while setting this property when the wifidirect is not supported</exception>
+ public static string WpsPin
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.WpsPin;
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+
+ set
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.WpsPin = value;
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Name of local device.
+ /// </summary>
+ /// <exception cref="NotSupportedException">Thrown while setting this property when the wifidirect is not supported</exception>
+ public static string Name
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.Name;
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+
+ set
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.Name = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Requested WPS (Wi-Fi Protected Setup) type.
+ /// </summary>
+ /// <exception cref="NotSupportedException">Thrown while setting this property when the wifidirect is not supported</exception>
+ public static WiFiDirectWpsType RequestedWps
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.RequestedWps;
+ }
+
+ else
+ {
+ return default(WiFiDirectWpsType);
+ }
+ }
+
+ set
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.RequestedWps = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Intent of the group owner.
+ /// </summary>
+ /// <exception cref="NotSupportedException">Thrown while setting this property when the wifidirect is not supported</exception>
+ public static int GroupOwnerIntent
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.GroupOwnerIntent;
+ }
+
+ else
+ {
+ return -1;
+ }
+ }
+
+ set
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.GroupOwnerIntent = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Max number of clients.
+ /// </summary>
+ /// <exception cref="NotSupportedException">Thrown while setting this property when the wifidirect is not supported</exception>
+ public static int MaxClients
+ {
+ get
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.MaxClients;
+ }
+
+ else
+ {
+ return -1;
+ }
+ }
+
+ set
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.MaxClients = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Wi-Fi Protected Access (WPA) password.
+ /// It is used during Wi-Fi Direct Group creation.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If it is deactivated, null will be returned during get and Not permitted exception message will be returned during set.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown while setting this property when the wifidirect is not supported</exception>
+ public static string Passphrase
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.Passphrase;
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+
+ set
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.Passphrase = value;
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wi-Fi direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Connection session timer value in second.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If it is deactivated, -1 will be returned during get and Not permitted exception message will be returned during set.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown while setting this property when the wifidirect is not supported</exception>
+ public static int SessionTimer
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.SessionTimer;
+ }
+
+ else
+ {
+ return -1;
+ }
+ }
+
+ set
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.SessionTimer = value;
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wi-Fi direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+ }
+
+ /// <summary>
+ /// (event) StateChanged is raised when Wi-Fi Direct state is changed.
+ /// </summary>
+ public static event EventHandler<StateChangedEventArgs> StateChanged
+ {
+ add
+ {
+ WiFiDirectManagerImpl.Instance.StateChanged += value;
+ }
+
+ remove
+ {
+ WiFiDirectManagerImpl.Instance.StateChanged -= value;
+ }
+ }
+
+ /// <summary>
+ /// (event) DiscoveryStateChanged is raised when Wi-Fi Direct discovery state is changed.
+ /// </summary>
+ public static event EventHandler<DiscoveryStateChangedEventArgs> DiscoveryStateChanged
+ {
+ add
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.DiscoveryStateChanged += value;
+ }
+ }
+
+ remove
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.DiscoveryStateChanged -= value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// (event) DeviceStateChanged is raised when device state is changed.
+ /// </summary>
+ public static event EventHandler<DeviceStateChangedEventArgs> DeviceStateChanged
+ {
+ add
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.DeviceStateChanged += value;
+ }
+ }
+
+ remove
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.DeviceStateChanged -= value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// (event) PeerFound is raised when peer is found.
+ /// </summary>
+ public static event EventHandler<PeerFoundEventArgs> PeerFound
+ {
+ add
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.PeerFound += value;
+ }
+ }
+
+ remove
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.PeerFound -= value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// (event) ConnectionStatusChanged is raised when status of connection is changed.
+ /// </summary>
+ public static event EventHandler<ConnectionStatusChangedEventArgs> ConnectionStatusChanged
+ {
+ add
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.ConnectionStatusChanged += value;
+ }
+ }
+
+ remove
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.ConnectionStatusChanged -= value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Activates the Wi-Fi Direct service.
+ /// </summary>
+ /// <remarks>
+ /// If this succeeds, DeviceStateChanged event will be invoked.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ public static void Activate()
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.Activate();
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wi-Fi direct is not initialized");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotInitialized);
+ }
+ }
+
+ /// <summary>
+ /// Deactivates the Wi-Fi Direct service.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If this succeeds, DeviceStateChanged event will be invoked.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ public static void Deactivate()
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.Deactivate();
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wi-Fi direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Starts discovery to find all P2P capable devices.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If this succeeds, DiscoveryStateChanged and PeerFound event will be invoked.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ /// <param name="listenOnly">Listen status.If False, then cycle between Scan and Listen.If True, then skip the initial 802.11 Scan and enter Listen state.</param>
+ /// <param name="duration">Duration of discovery period, in seconds.</param>
+ /// <param name="channel">Discovery channel.It is optional, default enum value FullScan is assigned.</param>
+ public static void StartDiscovery(bool listenOnly, int duration, WiFiDirectDiscoveryChannel channel = WiFiDirectDiscoveryChannel.FullScan)
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.StartDiscovery(listenOnly, duration, channel);
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wi-Fi direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Cancels discovery process.
+ /// </summary>
+ /// <remarks>
+ /// Discovery must be started by StartDiscovery.
+ /// If this succeeds, DiscoveryStateChanged and PeerFound event will be invoked.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ public static void CancelDiscovery()
+ {
+ if (WiFiDirectManager.State == WiFiDirectState.Discovering)
+ {
+ WiFiDirectManagerImpl.Instance.CancelDiscovery();
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wi-Fi direct discovery is not started");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Gets the information of discovered peers.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ /// <returns> List of discovered peer objects.</returns>
+ public static IEnumerable<WiFiDirectPeer> GetDiscoveredPeers()
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.GetDiscoveredPeers();
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// Gets the information of connected peers.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ /// <returns> List of connected peer objects.</returns>
+ public static IEnumerable<WiFiDirectPeer> GetConnectedPeers()
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.GetConnectedPeers();
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// Disconnects all connected links to peers.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If this succeeds, ConnectionStatusChanged event will be invoked.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ public static void DisconnectAll()
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.DisconnectAll();
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Creates a Wi-Fi Direct group and sets up device as the group owner.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If this succeeds, ConnectionStatusChanged event will be invoked with GroupCreated.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ public static void CreateGroup()
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.CreateGroup();
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Destroys the Wi-Fi Direct group owned by a local device.If creating a group is in progress, this API cancels that process.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If this succeeds, ConnectionStatusChanged event will be invoked with GroupDestroyed.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ public static void DestroyGroup()
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.DestroyGroup();
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Set the WPS config PBC as preferred method for connection.
+ /// </summary>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ public static void ActivatePushButton()
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.ActivatePushButton();
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Gets the supported WPS types.
+ /// </summary>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ /// <returns>The list of supported wps types.</returns>
+ public static IEnumerable<WiFiDirectWpsType> GetSupportedWpsTypes()
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.GetSupportedWpsTypes();
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// Gets the persistent groups.
+ /// </summary>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ /// <returns>List of the persistent group objects.</returns>
+ public static IEnumerable<WiFiDirectPersistentGroup> GetPersistentGroups()
+ {
+ if (Globals.IsInitialize)
+ {
+ return WiFiDirectManagerImpl.Instance.GetPersistentGroups();
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// Removes a persistent group.
+ /// </summary>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ /// <param name="group">Persistent group owner.</param>
+ public static void RemovePersistentGroup(WiFiDirectPersistentGroup group)
+ {
+ if (Globals.IsInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.RemovePersistentGroup(group);
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotInitialized);
+ }
+ }
+
+ /// <summary>
+ /// Initializes or Deintializes the WiFi-Direct Display(MIRACAST) service.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">
+ /// Thrown during one of the following cases :
+ /// 1. When the wifidirect is not supported
+ /// 2. When the wifidirect display feature is not supported
+ /// </exception>
+ /// <param name="enable">Enables/Disables service.</param>
+ public static void InitMiracast(bool enable)
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.InitMiracast(enable);
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Enables Wi-Fi Display functionality.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">
+ /// Thrown during one of the following cases :
+ /// 1. When the wifidirect is not supported
+ /// 2. When the wifidirect display feature is not supported
+ /// </exception>
+ public static void InitDisplay()
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.InitDisplay();
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Disable Wi-Fi Display(WFD) functionality and disable the support of WFD Information Element(IE).
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated and WFD must be enabled.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">
+ /// Thrown during one of the following cases :
+ /// 1. When the wifidirect is not supported
+ /// 2. When the wifidirect display feature is not supported
+ /// </exception>
+ public static void DeinitDisplay()
+ {
+ if (Globals.IsActivated && Globals.s_isDisplay)
+ {
+ WiFiDirectManagerImpl.Instance.DeinitDisplay();
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated and/or Wi-Fi display is not enabled");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Sets the Wi-Fi Display parameters for the WFD IE of local device.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated and WFD must be enabled.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">
+ /// Thrown during one of the following cases :
+ /// 1. When the wifidirect is not supported
+ /// 2. When the wifidirect display feature is not supported
+ /// </exception>
+ /// <param name="type">WFD Device Type: define the Role of WFD device like source or sink.</param>
+ /// <param name="port">Specifies Session Management Control Port number. It should be 2 bytes(0~65535).</param>
+ /// <param name="hdcp">CP support bit: (1 = enable the hdcp support, 0 = disable the hdcp support).</param>
+ public static void SetDisplay(WiFiDirectDisplayType type, int port, int hdcp)
+ {
+ if (Globals.IsActivated && Globals.s_isDisplay)
+ {
+ WiFiDirectManagerImpl.Instance.SetDisplay(type, port, hdcp);
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated and/or Wi-Fi display is not enabled");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Sets the Wi-Fi Display session availability.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated and WFD must be enabled.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">
+ /// Thrown during one of the following cases :
+ /// 1. When the wifidirect is not supported
+ /// 2. When the wifidirect display feature is not supported
+ /// </exception>
+ /// <param name="availability">Wi-Fi Display session availability.</param>
+ public static void SetDisplayAvailability(bool availability)
+ {
+ if (Globals.IsActivated && Globals.s_isDisplay)
+ {
+ WiFiDirectManagerImpl.Instance.SetDisplayAvailability(availability);
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated and/or Wi-Fi display is not enabled");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Sets the automatic group removal feature when all peers are disconnected.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// ConnectionStatusChanged event will be invoked with GroupDestroyed when this feature is enabled and there's no connected group client and if device is group owner.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ /// <param name="enable">Enables/Disables group removal feature.</param>
+ public static void SetAutoGroupRemove(bool enable)
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.SetAutoGroupRemove(enable);
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Registers the service.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If there is any error while registering service, 0 will be returned.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">
+ /// Thrown during one of the following cases :
+ /// 1. When the wifidirect is not supported
+ /// 2. When the wifidirect service discovery is not supported
+ /// </exception>
+ /// <returns>The service Id of service getting registered.</returns>
+ /// <param name="type">Type of Wi-Fi Direct Service.</param>
+ /// <param name="info">Service specific information.</param>
+ /// <param name="serviceInfo">Service information.</param>
+ public static uint RegisterService(WiFiDirectServiceType type, string info, string serviceInfo)
+ {
+ if (Globals.IsActivated)
+ {
+ return WiFiDirectManagerImpl.Instance.RegisterService(type, info, serviceInfo);
+ }
+
+ else
+ {
+ return 0;
+ }
+ }
+
+ /// <summary>
+ /// Deregisters for a service used for WiFi Direct Service Discovery.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">
+ /// Thrown during one of the following cases :
+ /// 1. When the wifidirect is not supported
+ /// 2. When the wifidirect service discovery is not supported
+ /// </exception>
+ /// <param name="serviceId"> Service ID for which service has to be deregistered.</param>
+ public static void DeregisterService(uint serviceId)
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectManagerImpl.Instance.DeregisterService(serviceId);
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+ }
+}
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManagerImpl.cs b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManagerImpl.cs
new file mode 100644
index 0000000..f376264
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectManagerImpl.cs
@@ -0,0 +1,1241 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+namespace Tizen.Network.WiFiDirect
+{
+ internal class WiFiDirectThreadLocal
+ {
+ private int _threadId;
+ internal WiFiDirectThreadLocal(int id)
+ {
+ _threadId = id;
+ }
+
+ public int ThreadId
+ {
+ get
+ {
+ return _threadId;
+ }
+ }
+
+ ~WiFiDirectThreadLocal()
+ {
+ Log.Info(Globals.LogTag, "Deinitializing Wi-Fi direct");
+ int ret = Interop.WiFiDirect.Deinitialize();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to deinitialize Wi-Fi direct, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+
+ else
+ {
+ Globals.s_isInitialize = false;
+ }
+ }
+ }
+
+ internal static class Globals
+ {
+ internal const string LogTag = "Tizen.Network.WiFiDirect";
+ internal static bool s_isInitialize = false;
+ internal static bool s_isDisplay = false;
+ private static ThreadLocal<WiFiDirectThreadLocal> s_threadName = new ThreadLocal<WiFiDirectThreadLocal>(() =>
+ {
+ Log.Info(Globals.LogTag, "In threadlocal delegate");
+ return new WiFiDirectThreadLocal(Thread.CurrentThread.ManagedThreadId);
+ });
+ internal static bool IsActivated
+ {
+ get
+ {
+ WiFiDirectState _state = WiFiDirectManager.State;
+ if (IsInitialize)
+ {
+ if (_state == WiFiDirectState.Deactivated || _state == WiFiDirectState.Deactivating)
+ {
+ return false;
+ }
+
+ else
+ {
+ return true;
+ }
+ }
+
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ private static bool IsUniqueThread()
+ {
+ if (s_threadName.IsValueCreated)
+ {
+ Log.Info(Globals.LogTag, "This thread is old");
+ return false;
+ }
+
+ else
+ {
+ WiFiDirectThreadLocal obj = s_threadName.Value;
+ Log.Info(Globals.LogTag, "This thread is new , Id = " + obj.ThreadId);
+ return true;
+ }
+ }
+
+ internal static bool IsInitialize
+ {
+ get
+ {
+ if(Globals.IsUniqueThread() || !Globals.s_isInitialize)
+ {
+ WiFiDirectManagerImpl.Instance.Initialize();
+ }
+
+ return (Globals.s_isInitialize);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Implementation of Wi-Fi Direct Apis
+ /// </summary>
+ internal partial class WiFiDirectManagerImpl : IDisposable
+ {
+ private event EventHandler<StateChangedEventArgs> _stateChanged;
+ private event EventHandler<DiscoveryStateChangedEventArgs > _discoveryStateChanged;
+ private event EventHandler<PeerFoundEventArgs > _peerFound;
+ private event EventHandler<DeviceStateChangedEventArgs > _deviceStateChanged;
+ private event EventHandler<ConnectionStatusChangedEventArgs > _connectionStatusChanged;
+
+ private Interop.WiFiDirect.StateChangedCallback _stateChangedCallback;
+ private Interop.WiFiDirect.DiscoveryStateChangedCallback _discoveryStateChangedCallback;
+ private Interop.WiFiDirect.PeerFoundCallback _peerFoundCallback;
+ private Interop.WiFiDirect.DeviceStateChangedCallback _deviceStateChangedCallback;
+ private Interop.WiFiDirect.ConnectionStateChangedCallback _connectionChangedCallback;
+
+ internal event EventHandler<StateChangedEventArgs> StateChanged
+ {
+ add
+ {
+ if (_stateChanged == null)
+ {
+ RegisterStateChangedEvent();
+ }
+
+ _stateChanged += value;
+ }
+
+ remove
+ {
+ _stateChanged -= value;
+ if (_stateChanged == null)
+ {
+ UnregisterStateChangedEvent();
+ }
+ }
+ }
+
+ internal event EventHandler<DiscoveryStateChangedEventArgs> DiscoveryStateChanged
+ {
+ add
+ {
+ if (_discoveryStateChanged == null)
+ {
+ RegisterDiscoveryStateChangedEvent();
+ }
+
+ _discoveryStateChanged += value;
+ }
+
+ remove
+ {
+ _discoveryStateChanged -= value;
+ if (_discoveryStateChanged == null)
+ {
+ UnregisterDiscoveryStateChangedEvent();
+ }
+ }
+ }
+
+ internal event EventHandler<PeerFoundEventArgs> PeerFound
+ {
+ add
+ {
+ if (_peerFound == null)
+ {
+ RegisterPeerFoundEvent();
+ }
+
+ _peerFound += value;
+ }
+
+ remove
+ {
+ _peerFound -= value;
+ if (_peerFound == null)
+ {
+ UnregisterPeerFoundEvent();
+ }
+ }
+ }
+
+ internal event EventHandler<DeviceStateChangedEventArgs> DeviceStateChanged
+ {
+ add
+ {
+ if (_deviceStateChanged == null)
+ {
+ RegisterDeviceStateChangedEvent();
+ }
+
+ _deviceStateChanged += value;
+ }
+
+ remove
+ {
+ _deviceStateChanged -= value;
+ if (_deviceStateChanged == null)
+ {
+ UnregisterDeviceStateChangedEvent();
+ }
+ }
+ }
+
+ internal event EventHandler<ConnectionStatusChangedEventArgs> ConnectionStatusChanged
+ {
+ add
+ {
+ if (_connectionStatusChanged == null)
+ {
+ RegisterConnectionStatusChangedEvent();
+ }
+
+ _connectionStatusChanged += value;
+ }
+
+ remove
+ {
+ _connectionStatusChanged -= value;
+ if (_connectionStatusChanged == null)
+ {
+ UnregisterConnectionStatusChangedEvent();
+ }
+ }
+ }
+
+ private bool _disposed = false;
+ private static WiFiDirectManagerImpl _instance;
+
+ private void RegisterStateChangedEvent()
+ {
+ _stateChangedCallback = (WiFiDirectState stateInfo, IntPtr userData) =>
+ {
+ if (_stateChanged != null)
+ {
+ WiFiDirectState state = stateInfo;
+ _stateChanged(null, new StateChangedEventArgs(state));
+ }
+ };
+ int ret = Interop.WiFiDirect.SetStateChangedCallback(_stateChangedCallback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set Wi-Fi Direct state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void UnregisterStateChangedEvent()
+ {
+ int ret = Interop.WiFiDirect.UnsetStateChangedCallback();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to unset Wi-Fi Direct state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void RegisterDiscoveryStateChangedEvent()
+ {
+ _discoveryStateChangedCallback = (int result, WiFiDirectDiscoveryState stateInfo, IntPtr userData) =>
+ {
+ if (_discoveryStateChanged != null)
+ {
+ WiFiDirectError error = (WiFiDirectError)result;
+ WiFiDirectDiscoveryState state = stateInfo;
+ _discoveryStateChanged(null, new DiscoveryStateChangedEventArgs(error, state));
+ }
+ };
+ int ret = Interop.WiFiDirect.SetDiscoveryStateChangedCallback(_discoveryStateChangedCallback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set Wi-Fi Direct discovery state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void UnregisterDiscoveryStateChangedEvent()
+ {
+ int ret = Interop.WiFiDirect.UnsetDiscoveryStateChangedCallback();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to unset Wi-Fi Direct discovery state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void RegisterPeerFoundEvent()
+ {
+ _peerFoundCallback = (int result, WiFiDirectDiscoveryState stateInfo, string address, IntPtr userData) =>
+ {
+ if (_peerFound != null)
+ {
+ WiFiDirectError error = (WiFiDirectError)result;
+ WiFiDirectDiscoveryState state = stateInfo;
+ IntPtr peer;
+ Interop.WiFiDirect.GetDiscoveredPeerInfo(address, out peer);
+ DiscoveredPeerStruct peerStruct = (DiscoveredPeerStruct)Marshal.PtrToStructure(peer, typeof(DiscoveredPeerStruct));
+ _peerFound(null, new PeerFoundEventArgs(error, state, WiFiDirectUtils.ConvertStructToDiscoveredPeer(peerStruct)));
+ }
+ };
+ int ret = Interop.WiFiDirect.SetPeerFoundCallback(_peerFoundCallback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set Wi-Fi Direct discovery state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void UnregisterPeerFoundEvent()
+ {
+ int ret = Interop.WiFiDirect.UnsetPeerFoundCallback();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to unset Wi-Fi Direct discovery state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void RegisterDeviceStateChangedEvent()
+ {
+ _deviceStateChangedCallback = (int result, WiFiDirectDeviceState stateInfo, IntPtr userData) =>
+ {
+ if (_deviceStateChanged != null)
+ {
+ WiFiDirectError error = (WiFiDirectError)result;
+ WiFiDirectDeviceState state = stateInfo;
+ _deviceStateChanged(null, new DeviceStateChangedEventArgs(error, state));
+ }
+ };
+ int ret = Interop.WiFiDirect.SetDeviceStateChangedCallback(_deviceStateChangedCallback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set device state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void UnregisterDeviceStateChangedEvent()
+ {
+ int ret = Interop.WiFiDirect.UnsetDeviceStateChangedCallback();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to unset device state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void RegisterConnectionStatusChangedEvent()
+ {
+ _connectionChangedCallback = (int result, WiFiDirectConnectionState stateInfo, string address, IntPtr userData) =>
+ {
+ if (_connectionStatusChanged != null)
+ {
+ WiFiDirectError error = (WiFiDirectError)result;
+ WiFiDirectConnectionState state = stateInfo;
+
+ _connectionStatusChanged(null, new ConnectionStatusChangedEventArgs(error, state));
+ }
+ };
+ int ret = Interop.WiFiDirect.SetConnectionChangedCallback(_connectionChangedCallback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set connection status changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void UnregisterConnectionStatusChangedEvent()
+ {
+ int ret = Interop.WiFiDirect.UnsetConnectionChangedCallback();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to unset connection status changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ internal bool IsGroupOwner
+ {
+ get
+ {
+ bool isGroupOwner;
+ int ret = Interop.WiFiDirect.IsGroupOwner(out isGroupOwner);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get whether this device is the group owner or not, Error - " + (WiFiDirectError)ret);
+ }
+
+ return isGroupOwner;
+ }
+ }
+
+ internal bool IsAutonomousGroup
+ {
+ get
+ {
+ bool isAutonomousGroup;
+ int ret = Interop.WiFiDirect.IsAutonomousGroup(out isAutonomousGroup);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to check whether the current group is autonomous or not, Error - " + (WiFiDirectError)ret);
+ }
+
+ return isAutonomousGroup;
+ }
+ }
+
+ internal string Ssid
+ {
+ get
+ {
+ string ssid;
+ int ret = Interop.WiFiDirect.GetSsid(out ssid);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get SSID of local device, Error - " + (WiFiDirectError)ret);
+ return null;
+ }
+
+ return ssid;
+ }
+ }
+
+ internal string NetworkInterface
+ {
+ get
+ {
+ string networkInterface;
+ int ret = Interop.WiFiDirect.GetInterfaceName(out networkInterface);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get name of network interface, Error - " + (WiFiDirectError)ret);
+ return "";
+ }
+
+ return networkInterface;
+ }
+ }
+
+ internal string IpAddress
+ {
+ get
+ {
+ string ipAddress;
+ int ret = Interop.WiFiDirect.GetIpAddress(out ipAddress);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get IP address of local device, Error - " + (WiFiDirectError)ret);
+ return "";
+ }
+
+ return ipAddress;
+ }
+ }
+
+ internal string SubnetMask
+ {
+ get
+ {
+ string subnetMask;
+ int ret = Interop.WiFiDirect.GetSubnetMask(out subnetMask);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get subnet mask, Error - " + (WiFiDirectError)ret);
+ return "";
+ }
+
+ return subnetMask;
+ }
+ }
+
+ internal string GatewayAddress
+ {
+ get
+ {
+ string gatewayAddress;
+ int ret = Interop.WiFiDirect.GetGatewayAddress(out gatewayAddress);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get gateway address, Error - " + (WiFiDirectError)ret);
+ return "";
+ }
+
+ return gatewayAddress;
+ }
+ }
+
+ internal string MacAddress
+ {
+ get
+ {
+ string macAddress;
+ int ret = Interop.WiFiDirect.GetMacAddress(out macAddress);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get mac address, Error - " + (WiFiDirectError)ret);
+ return null;
+ }
+
+ return macAddress;
+ }
+ }
+
+ internal WiFiDirectState State
+ {
+ get
+ {
+ WiFiDirectState state;
+ int ret = Interop.WiFiDirect.GetState(out state);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get state of Wi-Fi direct service, Error - " + (WiFiDirectError)ret);
+ }
+
+ return state;
+ }
+ }
+
+ internal bool IsDiscoverable
+ {
+ get
+ {
+ bool isDiscoverable;
+ int ret = Interop.WiFiDirect.IsDiscoverable(out isDiscoverable);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to check whether the device is discoverable, Error - " + (WiFiDirectError)ret);
+ }
+
+ return isDiscoverable;
+ }
+ }
+
+ internal bool IsListenOnly
+ {
+ get
+ {
+ bool isListenOnly;
+ int ret = Interop.WiFiDirect.IsListeningOnly(out isListenOnly);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to check whether the local device is listening only, Error - " + (WiFiDirectError)ret);
+ }
+
+ return isListenOnly;
+ }
+ }
+
+ internal WiFiDirectPrimaryDeviceType PrimaryType
+ {
+ get
+ {
+ WiFiDirectPrimaryDeviceType primaryType;
+ int ret = Interop.WiFiDirect.GetPrimaryType(out primaryType);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the primary device type of local device, Error - " + (WiFiDirectError)ret);
+ }
+
+ return primaryType;
+ }
+ }
+
+ internal WiFiDirectSecondaryDeviceType SecondaryType
+ {
+ get
+ {
+ WiFiDirectSecondaryDeviceType secondaryType;
+ int ret = Interop.WiFiDirect.GetSecondaryType(out secondaryType);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the secondary device type of local device, Error - " + (WiFiDirectError)ret);
+ }
+
+ return secondaryType;
+ }
+ }
+
+ internal int WpsMode
+ {
+ get
+ {
+ int mode;
+ int ret = Interop.WiFiDirect.GetWpsMode(out mode);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get supproted wps modes at local device, Error - " + (WiFiDirectError)ret);
+ return -1;
+ }
+
+ return mode;
+ }
+ }
+
+ internal WiFiDirectWpsType WpsType
+ {
+ get
+ {
+ WiFiDirectWpsType wpsType;
+ int ret = Interop.WiFiDirect.GetLocalWpsType(out wpsType);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the WPS type, Error - " + (WiFiDirectError)ret);
+ }
+
+ return wpsType;
+ }
+ }
+
+ internal int OperatingChannel
+ {
+ get
+ {
+ int channel;
+ int ret = Interop.WiFiDirect.GetChannel(out channel);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get operating channel, Error - " + (WiFiDirectError)ret);
+ return -1;
+ }
+
+ return channel;
+ }
+ }
+
+ internal bool PersistentGroupEnabled
+ {
+ get
+ {
+ bool isEnabled;
+ int ret = Interop.WiFiDirect.GetPersistentGroupState(out isEnabled);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to check persistent group state, Error - " + (WiFiDirectError)ret);
+ }
+
+ return isEnabled;
+ }
+
+ set
+ {
+ int ret = Interop.WiFiDirect.SetPersistentGroupState(value);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set the persistent group state, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+ }
+
+ internal bool AutoConnect
+ {
+ get
+ {
+ bool isAutoConnect;
+ int ret = Interop.WiFiDirect.GetAutoConnectionMode(out isAutoConnect);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get autoconnection mode status, Error - " + (WiFiDirectError)ret);
+ }
+
+ return isAutoConnect;
+ }
+
+ set
+ {
+ int ret = Interop.WiFiDirect.SetAutoConnectionMode(value);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set the autoconnection mode, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+ }
+
+ internal string WpsPin
+ {
+ get
+ {
+ string pin;
+ int ret = Interop.WiFiDirect.GetWpsPin(out pin);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get WPS pin, Error - " + (WiFiDirectError)ret);
+ }
+
+ return pin;
+ }
+
+ set
+ {
+ int ret = Interop.WiFiDirect.SetWpsPin(value.ToString());
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set or update WPS pin, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+ }
+
+ internal string Name
+ {
+ get
+ {
+ string name;
+ int ret = Interop.WiFiDirect.GetName(out name);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get name of local device, Error - " + (WiFiDirectError)ret);
+ return null;
+ }
+
+ return name;
+ }
+
+ set
+ {
+ int ret = Interop.WiFiDirect.SetName(value.ToString());
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set name of local device, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+ }
+
+ internal WiFiDirectWpsType RequestedWps
+ {
+ get
+ {
+ WiFiDirectWpsType wpsType;
+ int ret = Interop.WiFiDirect.GetReqWpsType(out wpsType);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the requested WPS type, Error - " + (WiFiDirectError)ret);
+ }
+
+ return wpsType;
+ }
+
+ set
+ {
+ int ret = Interop.WiFiDirect.SetReqWpsType(value);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set the requested WPS type, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+ }
+
+ internal int GroupOwnerIntent
+ {
+ get
+ {
+ int intent;
+ int ret = Interop.WiFiDirect.GetIntent(out intent);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the intent of the group owner, Error - " + (WiFiDirectError)ret);
+ }
+
+ return intent;
+ }
+
+ set
+ {
+ int ret = Interop.WiFiDirect.SetIntent(value);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set the intent of the group owner, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+ }
+
+ internal int MaxClients
+ {
+ get
+ {
+ int maxClients;
+ int ret = Interop.WiFiDirect.GetMaxClients(out maxClients);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the max number of clients, Error - " + (WiFiDirectError)ret);
+ }
+
+ return maxClients;
+ }
+
+ set
+ {
+ int ret = Interop.WiFiDirect.SetMaxClients(value);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set the max number of clients, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+ }
+
+ internal string Passphrase
+ {
+ get
+ {
+ string passphrase;
+ int ret = Interop.WiFiDirect.GetPassPhrase(out passphrase);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get Wi-Fi Protected Access password, Error - " + (WiFiDirectError)ret);
+ return "";
+ }
+
+ return passphrase;
+ }
+
+ set
+ {
+ int ret = Interop.WiFiDirect.SetPassPhrase(value.ToString());
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set or update Wi-Fi Protected Access password, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+ }
+
+ internal int SessionTimer
+ {
+ get
+ {
+ int sessionTimer;
+ int ret = Interop.WiFiDirect.GetSessionTimer(out sessionTimer);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the timer used to expire the connection session, Error - " + (WiFiDirectError)ret);
+ }
+
+ return sessionTimer;
+ }
+
+ set
+ {
+ int ret = Interop.WiFiDirect.SetSessionTimer(value);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set the timer used to expire the connection session, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+ }
+
+ internal void Activate()
+ {
+ int ret = Interop.WiFiDirect.Activate();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to activate Wi-Fi direct service, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal void Deactivate()
+ {
+ int ret = Interop.WiFiDirect.Deactivate();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to deactivate Wi-Fi direct service, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal void StartDiscovery(bool listenOnly, int duration, WiFiDirectDiscoveryChannel channel = WiFiDirectDiscoveryChannel.FullScan)
+ {
+ int ret = Interop.WiFiDirect.StartDiscoveryInChannel(listenOnly, duration, channel);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to start discovery, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal void CancelDiscovery()
+ {
+ int ret = Interop.WiFiDirect.StopDiscovery();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to cancel discovery, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal IEnumerable<WiFiDirectPeer> GetDiscoveredPeers()
+ {
+ List<WiFiDirectPeer> discoveredPeerList = new List<WiFiDirectPeer>();
+ Interop.WiFiDirect.DiscoveredPeerCallback callback = (ref DiscoveredPeerStruct peer, IntPtr userData) =>
+ {
+ if (!peer.Equals(null))
+ {
+ discoveredPeerList.Add(WiFiDirectUtils.ConvertStructToDiscoveredPeer(peer));
+ }
+
+ return true;
+ };
+ int ret = Interop.WiFiDirect.GetDiscoveredPeers(callback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get information of discovered peers, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+
+ return discoveredPeerList;
+ }
+
+ internal IEnumerable<WiFiDirectPeer> GetConnectedPeers()
+ {
+ List<WiFiDirectPeer> connectedPeerList = new List<WiFiDirectPeer>();
+ Interop.WiFiDirect.ConnectedPeerCallback callback = (ref ConnectedPeerStruct peer, IntPtr userData) =>
+ {
+ if (!peer.Equals(null))
+ {
+ connectedPeerList.Add(WiFiDirectUtils.ConvertStructToConnectedPeer(peer));
+ }
+
+ return true;
+ };
+ int ret = Interop.WiFiDirect.GetConnectedPeers(callback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get information of connected peers, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+
+ return connectedPeerList;
+ }
+
+ internal void DisconnectAll()
+ {
+ int ret = Interop.WiFiDirect.DisconnectAll();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to disconnect all connected links, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal void CreateGroup()
+ {
+ int ret = Interop.WiFiDirect.CreateGroup();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to create a WiFi-Direct group, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal void DestroyGroup()
+ {
+ int ret = Interop.WiFiDirect.DestroyGroup();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to destroy the WiFi-Direct group, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal void ActivatePushButton()
+ {
+ int ret = Interop.WiFiDirect.ActivatePushButton();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set the Wps config PBC, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal IEnumerable<WiFiDirectWpsType> GetSupportedWpsTypes()
+ {
+ List<WiFiDirectWpsType> wpsList = new List<WiFiDirectWpsType>();
+ Interop.WiFiDirect.WpsTypeCallback callback = (WiFiDirectWpsType type, IntPtr userData) =>
+ {
+ if (!type.Equals(null))
+ {
+ wpsList.Add(type);
+ }
+
+ return true;
+ };
+ int ret = Interop.WiFiDirect.GetWpsTypes(callback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the supported WPS types, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+
+ return wpsList;
+ }
+
+ internal IEnumerable<WiFiDirectPersistentGroup> GetPersistentGroups()
+ {
+ List<WiFiDirectPersistentGroup> persistentGroupList = new List<WiFiDirectPersistentGroup>();
+ Interop.WiFiDirect.PersistentGroupCallback callback = (string address, string ssid, IntPtr userData) =>
+ {
+ if (address != null && ssid != null)
+ {
+ persistentGroupList.Add(new WiFiDirectPersistentGroup(address, ssid));
+ }
+
+ return true;
+ };
+ int ret = Interop.WiFiDirect.GetPersistentGroups(callback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the persistent groups, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+
+ return persistentGroupList;
+ }
+
+ internal void RemovePersistentGroup(WiFiDirectPersistentGroup group)
+ {
+ int ret = Interop.WiFiDirect.RemovePersistentGroup(group.MacAddress, group.Ssid);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to remove a persistent group, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal void InitMiracast(bool enable)
+ {
+ int ret = Interop.WiFiDirect.InitMiracast(enable);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set the WiFi-Direct Display(MIRACAST) service, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal void InitDisplay()
+ {
+ int ret = Interop.WiFiDirect.InitDisplay();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to enable Wi-Fi Display functionality, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+
+ else
+ {
+ Globals.s_isDisplay = true;
+ }
+ }
+
+ internal void DeinitDisplay()
+ {
+ int ret = Interop.WiFiDirect.DeinitDisplay();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to disable Wi-Fi Display functionality, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+
+ else
+ {
+ Globals.s_isDisplay = false;
+ }
+ }
+
+ internal void SetDisplay(WiFiDirectDisplayType type, int port, int hdcp)
+ {
+ int ret = Interop.WiFiDirect.SetDisplay(type, port, hdcp);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set the Wi-Fi Display parameters, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal void SetDisplayAvailability(bool availability)
+ {
+ int ret = Interop.WiFiDirect.SetDisplayAvailability(availability);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set the Wi-Fi Display session availability, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal void SetAutoGroupRemove(bool enable)
+ {
+ int ret = Interop.WiFiDirect.SetAutoGroupRemoval(enable);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set automatic group removal feature when all peers are disconnected, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal uint RegisterService(WiFiDirectServiceType type, string info, string serviceInfo)
+ {
+ uint serviceId;
+ int ret = Interop.WiFiDirect.RegisterService(type, info, serviceInfo, out serviceId);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to register for service, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+
+ return serviceId;
+ }
+
+ internal void DeregisterService(uint serviceId)
+ {
+ int ret = Interop.WiFiDirect.DeregisterService(serviceId);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to deregister service, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ internal static WiFiDirectManagerImpl Instance
+ {
+ get
+ {
+ if (_instance == null)
+ {
+ _instance = new WiFiDirectManagerImpl();
+ }
+
+ return _instance;
+ }
+ }
+
+ private WiFiDirectManagerImpl()
+ {
+ }
+
+ internal void Initialize()
+ {
+ int ret = Interop.WiFiDirect.Initialize();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to initialize Wi-Fi direct, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+
+ else
+ {
+ Globals.s_isInitialize = true;
+ }
+ }
+
+ ~WiFiDirectManagerImpl()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (_disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ // Free managed objects.
+ }
+
+ //Free unmanaged objects
+ RemoveAllRegisteredEvent();
+ Deinitialize();
+ _disposed = true;
+ }
+
+ private void Deinitialize()
+ {
+ int ret = Interop.WiFiDirect.Deinitialize();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to deinitialize Wi-Fi direct, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+
+ else
+ {
+ Globals.s_isInitialize = false;
+ }
+ }
+
+ private void RemoveAllRegisteredEvent()
+ {
+ //unregister all remaining events when this object is released.
+ if (_stateChanged != null)
+ {
+ UnregisterStateChangedEvent();
+ }
+
+ if (_discoveryStateChanged != null)
+ {
+ UnregisterDiscoveryStateChangedEvent();
+ }
+
+ if (_peerFound != null)
+ {
+ UnregisterPeerFoundEvent();
+ }
+
+ if (_deviceStateChanged != null)
+ {
+ UnregisterDeviceStateChangedEvent();
+ }
+
+ if (_connectionStatusChanged != null)
+ {
+ UnregisterConnectionStatusChangedEvent();
+ }
+ }
+ }
+}
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectPeer.cs b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectPeer.cs
new file mode 100644
index 0000000..a97e466
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectPeer.cs
@@ -0,0 +1,736 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Collections.Concurrent;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+
+namespace Tizen.Network.WiFiDirect
+{
+ /// <summary>
+ /// WiFiDirectPeer class is used to handle the connection with remote devices using WiFi Direct.
+ /// </summary>
+ /// <privilege> http://tizen.org/privilege/wifidirect </privilege>
+ public class WiFiDirectPeer
+ {
+ private event EventHandler<ConnectionStateChangedEventArgs> _connectionStateChanged;
+ private event EventHandler<IpAddressAssignedEventArgs> _ipAddressAssigned;
+ private event EventHandler<ServiceStateChangedEventArgs> _serviceStateChanged;
+
+ private Interop.WiFiDirect.ConnectionStateChangedCallback _connectionStateChangedCallback;
+ private Interop.WiFiDirect.ClientIpAddressAssignedCallback _ipAddressAssignedCallback;
+ private Interop.WiFiDirect.ServiceStateChangedCallback _serviceStateChangedCallback;
+
+ internal string _peerDeviceName;
+ internal string _peerIpAddress;
+ internal string _peerMacAddress;
+ internal string _peerInterfaceAddress;
+ internal int _peerChannel;
+ internal bool _isPeerConnected;
+ internal bool _isPeerGroupOwner;
+ internal bool _isPeerPersistentGroupOwner;
+ internal bool _peerP2PSupport;
+ internal WiFiDirectPrimaryDeviceType _peerPrimaryType;
+ internal WiFiDirectSecondaryDeviceType _peerSecondaryType;
+ internal int _peerWpsTypes;
+ internal bool _p2PInvitationSupported;
+ internal uint _peerServiceCount;
+ internal IEnumerable<string> _peerServiceList;
+ internal bool _isPeerMiracastDevice;
+
+ internal WiFiDirectPeer()
+ {
+ }
+
+ /// <summary>
+ /// Name of Peer device.
+ /// </summary>
+ public string Name
+ {
+ get
+ {
+ return _peerDeviceName;
+ }
+ }
+
+ /// <summary>
+ /// Ip address of the peer device.
+ /// </summary>
+ public string IpAddress
+ {
+ get
+ {
+ return _peerIpAddress;
+ }
+ }
+
+ /// <summary>
+ /// Mac address of the peer device.
+ /// </summary>
+ public string MacAddress
+ {
+ get
+ {
+ return _peerMacAddress;
+ }
+ }
+
+ /// <summary>
+ /// Interface address of the peer device.
+ /// </summary>
+ public string InterfaceAddress
+ {
+ get
+ {
+ return _peerInterfaceAddress;
+ }
+ }
+
+ /// <summary>
+ /// Listening channel of the peer device.
+ /// </summary>
+ public int Channel
+ {
+ get
+ {
+ return _peerChannel;
+ }
+ }
+
+ /// <summary>
+ /// Connected state of the peer device.
+ /// </summary>
+ public bool IsConnected
+ {
+ get
+ {
+ return _isPeerConnected;
+ }
+ }
+
+ /// <summary>
+ /// P2P group state of the peer device.
+ /// </summary>
+ public bool IsGroupOwner
+ {
+ get
+ {
+ return _isPeerGroupOwner;
+ }
+ }
+
+ /// <summary>
+ /// Persistent group state of the peer device.
+ /// </summary>
+ public bool IsPersistentGroupOwner
+ {
+ get
+ {
+ return _isPeerPersistentGroupOwner;
+ }
+ }
+
+ /// <summary>
+ /// P2P state of the peer device.
+ /// </summary>
+ public bool P2PSupport
+ {
+ get
+ {
+ return _peerP2PSupport;
+ }
+ }
+
+ /// <summary>
+ /// Primary catagory of the peer device.
+ /// </summary>
+ public WiFiDirectPrimaryDeviceType PrimaryType
+ {
+ get
+ {
+ return _peerPrimaryType;
+ }
+ }
+
+ /// <summary>
+ /// Sub category of the peer device.
+ /// </summary>
+ public WiFiDirectSecondaryDeviceType SecondaryType
+ {
+ get
+ {
+ return _peerSecondaryType;
+ }
+ }
+
+ /// <summary>
+ /// List of supported WPS type of the peer device.
+ /// </summary>
+ public int WpsTypes
+ {
+ get
+ {
+ return _peerWpsTypes;
+ }
+ }
+
+ /// <summary>
+ /// P2P invitation state of the peer device.
+ /// </summary>
+ public bool IsP2PInvitationSupported
+ {
+ get
+ {
+ return _p2PInvitationSupported;
+ }
+ }
+
+ /// <summary>
+ /// Number of registered services of the peer device.
+ /// </summary>
+ public uint ServiceCount
+ {
+ get
+ {
+ return _peerServiceCount;
+ }
+ }
+
+ /// <summary>
+ /// List of registered services of the peer device.
+ /// </summary>
+ public IEnumerable<string> ServiceList
+ {
+ get
+ {
+ return _peerServiceList;
+ }
+ }
+
+ /// <summary>
+ /// Checks if peer device is a wifi display device.
+ /// </summary>
+ public bool IsMiracastDevice
+ {
+ get
+ {
+ return _isPeerMiracastDevice;
+ }
+ }
+
+ /// <summary>
+ /// Wi-Fi Display device type of the peer device.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If there is any error, default value of WiFiDirectDisplayType will be returned.
+ /// </remarks>
+ public WiFiDirectDisplayType Display
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ WiFiDirectDisplayType displayType;
+ int ret = Interop.WiFiDirect.GetDisplayType(_peerMacAddress, out displayType);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the peer display type, Error - " + (WiFiDirectError)ret);
+ }
+
+ return displayType;
+ }
+
+ else
+ {
+ return default(WiFiDirectDisplayType);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Wi-Fi Display Session Availability of the peer device.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If there is any error, false will be returned.
+ /// </remarks>
+ public bool DisplayAvailability
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ bool displayAvailability;
+ int ret = Interop.WiFiDirect.GetDisplayAvailability(_peerMacAddress, out displayAvailability);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the peer display availability, Error - " + (WiFiDirectError)ret);
+ }
+
+ return displayAvailability;
+ }
+
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Hdcp information of the peer device.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If there is any error, -1 will be returned.
+ /// </remarks>
+ public int Hdcp
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ int hdcpSupport;
+ int ret = Interop.WiFiDirect.GetDisplayHdcp(_peerMacAddress, out hdcpSupport);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the peer display hdcp support, Error - " + (WiFiDirectError)ret);
+ return -1;
+ }
+
+ return hdcpSupport;
+ }
+
+ else
+ {
+ return -1;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Port of the connected peer device.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If there is any error, -1 will be returned.
+ /// </remarks>
+ public int Port
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ int displayPort;
+ int ret = Interop.WiFiDirect.GetDisplayPort(_peerMacAddress, out displayPort);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the peer display port, Error - " + (WiFiDirectError)ret);
+ return -1;
+ }
+
+ return displayPort;
+ }
+
+ else
+ {
+ return -1;
+ }
+ }
+ }
+
+ /// <summary>
+ /// WiFi Display max throughput of the peer device.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If there is any error, -1 will be returned.
+ /// </remarks>
+ public int Throughput
+ {
+ get
+ {
+ if (Globals.IsActivated)
+ {
+ int displayThroughput;
+ int ret = Interop.WiFiDirect.GetDisplayThroughput(_peerMacAddress, out displayThroughput);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to get the peer display max throughput, Error - " + (WiFiDirectError)ret);
+ return -1;
+ }
+
+ return displayThroughput;
+ }
+
+ else
+ {
+ return -1;
+ }
+ }
+ }
+
+ /// <summary>
+ /// (event) ConnectionStateChanged event is raised when the connection state of the peer device changes.
+ /// </summary>
+ public event EventHandler<ConnectionStateChangedEventArgs> ConnectionStateChanged
+ {
+ add
+ {
+ if (Globals.IsInitialize)
+ {
+ if (_connectionStateChanged == null)
+ {
+ RegisterConnectionStateChangedEvent();
+ }
+
+ _connectionStateChanged += value;
+ }
+ }
+
+ remove
+ {
+ if (Globals.IsInitialize)
+ {
+ _connectionStateChanged -= value;
+ if (_connectionStateChanged == null)
+ {
+ UnregisterConnectionStateChangedEvent();
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// (event) IpAddressAssigned event is raised when ip address of the peer device is assigned.
+ /// </summary>
+ public event EventHandler<IpAddressAssignedEventArgs> IpAddressAssigned
+ {
+ add
+ {
+ if (Globals.IsInitialize)
+ {
+ if (_ipAddressAssigned == null)
+ {
+ RegisterIpAddressAssignedEvent();
+ }
+
+ _ipAddressAssigned += value;
+ }
+ }
+
+ remove
+ {
+ if (Globals.IsInitialize)
+ {
+ _ipAddressAssigned -= value;
+ if (_ipAddressAssigned == null)
+ {
+ UnregisterIpAddressAssignedEvent();
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// (event) ServiceStateChanged is raised when state of service discovery is changed.
+ /// </summary>
+ public event EventHandler<ServiceStateChangedEventArgs> ServiceStateChanged
+ {
+ add
+ {
+ if (Globals.IsInitialize)
+ {
+ if (_serviceStateChanged == null)
+ {
+ RegisterServiceStateChangedEvent();
+ }
+
+ _serviceStateChanged += value;
+ }
+ }
+
+ remove
+ {
+ if (Globals.IsInitialize)
+ {
+ _serviceStateChanged -= value;
+ if (_serviceStateChanged == null)
+ {
+ UnregisterServiceStateChangedEvent();
+ }
+ }
+ }
+ }
+
+ private void RegisterConnectionStateChangedEvent()
+ {
+ _connectionStateChangedCallback = (int result, WiFiDirectConnectionState state, string address, IntPtr userData) =>
+ {
+ if (_connectionStateChanged != null)
+ {
+ WiFiDirectError res = (WiFiDirectError)result;
+ _connectionStateChanged(null, new ConnectionStateChangedEventArgs(res, state, address));
+ }
+ };
+ int ret = Interop.WiFiDirect.SetConnectionChangedCallback(_connectionStateChangedCallback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set connection state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void UnregisterConnectionStateChangedEvent()
+ {
+ int ret = Interop.WiFiDirect.UnsetConnectionChangedCallback();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to unset connection state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void RegisterIpAddressAssignedEvent()
+ {
+ _ipAddressAssignedCallback = (string macAddress, string ipAddress, string interfaceAddress, IntPtr userData) =>
+ {
+ if (_ipAddressAssigned != null)
+ {
+ _ipAddressAssigned(null, new IpAddressAssignedEventArgs(macAddress, ipAddress, interfaceAddress));
+ }
+ };
+ int ret = Interop.WiFiDirect.SetIpAddressAssignedCallback(_ipAddressAssignedCallback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set ip address assigned callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void UnregisterIpAddressAssignedEvent()
+ {
+ int ret = Interop.WiFiDirect.UnsetIpAddressAssignedCallback();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to unset ip address assigned callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void RegisterServiceStateChangedEvent()
+ {
+ _serviceStateChangedCallback = (int result, WiFiDirectServiceDiscoveryState stateInfo, WiFiDirectServiceType typeInfo, IntPtr responseData, string address, IntPtr userData) =>
+ {
+ if (_serviceStateChanged != null)
+ {
+ WiFiDirectError error = (WiFiDirectError)result;
+ WiFiDirectServiceDiscoveryState state = stateInfo;
+ WiFiDirectServiceType type = typeInfo;
+ string response = Marshal.PtrToStringAnsi(responseData);
+ IntPtr peer;
+ Interop.WiFiDirect.GetDiscoveredPeerInfo(address, out peer);
+ DiscoveredPeerStruct peerStruct = (DiscoveredPeerStruct)Marshal.PtrToStructure(peer, typeof(DiscoveredPeerStruct));
+
+ _serviceStateChanged(null, new ServiceStateChangedEventArgs(error, state, type, response, WiFiDirectUtils.ConvertStructToDiscoveredPeer(peerStruct)));
+ }
+ };
+ int ret = Interop.WiFiDirect.SetServiceStateChangedCallback(_serviceStateChangedCallback, IntPtr.Zero);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set service state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ private void UnregisterServiceStateChangedEvent()
+ {
+ int ret = Interop.WiFiDirect.UnsetServiceStateChangedCallback();
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to unset service state changed callback, Error - " + (WiFiDirectError)ret);
+ }
+ }
+
+ /// <summary>
+ /// Connects to a specified remote device.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If this succeeds, ConnectionStateChanged event will be invoked.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ public void Connect()
+ {
+ if (Globals.IsActivated)
+ {
+ int ret = Interop.WiFiDirect.Connect(_peerMacAddress);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to connect, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Cancels the connection now in progress.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ public void CancelConnection()
+ {
+ if (Globals.IsActivated)
+ {
+ int ret = Interop.WiFiDirect.CancelConnection(_peerMacAddress);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to cancel the connection, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Disconnects the specified remote device.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If this succeeds, ConnectionStateChanged event will be invoked.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ public void Disconnect()
+ {
+ if (Globals.IsActivated)
+ {
+ int ret = Interop.WiFiDirect.Disconnect(_peerMacAddress);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to disconnect, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Allows a device to connect automatically.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Thrown when the wifidirect is not supported</exception>
+ public void SetAutoConnect()
+ {
+ if (Globals.IsActivated)
+ {
+ int ret = Interop.WiFiDirect.SetAutoConnectionPeer(_peerMacAddress);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set auto connection, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Starts the Wi-Fi Direct service discovery.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// If this succeeds, ServiceStateChanged event will be invoked.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">
+ /// Thrown during one of the following cases :
+ /// 1. When the wifidirect is not supported
+ /// 2. When the wifidirect service discovery is not supported
+ /// </exception>
+ /// <param name="type">Type of service.</param>
+ public void StartServiceDiscovery(WiFiDirectServiceType type)
+ {
+ if (Globals.IsActivated)
+ {
+ int ret = Interop.WiFiDirect.StartServiceDiscovery(_peerMacAddress, type);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to start Wi-Fi Direct service discovery, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+
+ /// <summary>
+ /// Stops the Wi-Fi Direct service discovery.
+ /// </summary>
+ /// <remarks>
+ /// Wi-Fi Direct must be activated.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">
+ /// Thrown during one of the following cases :
+ /// 1. When the wifidirect is not supported
+ /// 2. When the wifidirect service discovery is not supported
+ /// </exception>
+ /// <param name="type">Type of service.</param>
+ public void CancelServiceDiscovery(WiFiDirectServiceType type)
+ {
+ if (Globals.IsActivated)
+ {
+ int ret = Interop.WiFiDirect.StopServiceDiscovery(_peerMacAddress, type);
+ if (ret != (int)WiFiDirectError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to stop Wi-Fi Direct service discovery, Error - " + (WiFiDirectError)ret);
+ WiFiDirectErrorFactory.ThrowWiFiDirectException(ret);
+ }
+ }
+
+ else
+ {
+ Log.Error(Globals.LogTag, "Wifi-direct is not activated");
+ WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
+ }
+ }
+ }
+}
diff --git a/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectPersistentGroup.cs b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectPersistentGroup.cs
new file mode 100644
index 0000000..10274c9
--- /dev/null
+++ b/Tizen.Network.WiFiDirect/Tizen.Network.WiFiDirect/WiFiDirectPersistentGroup.cs
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Network.WiFiDirect
+{
+ /// <summary>
+ /// A class to handle persistent groups.
+ /// </summary>
+ public class WiFiDirectPersistentGroup
+ {
+ private string _address;
+ private string _ssid;
+
+ internal WiFiDirectPersistentGroup(string address, string id)
+ {
+ _address = address;
+ _ssid = id;
+ }
+
+ /// <summary>
+ /// MAC address of the persistent group owner.
+ /// </summary>
+ public string MacAddress
+ {
+ get
+ {
+ return _address;
+ }
+ }
+
+ /// <summary>
+ /// SSID (Service Set Identifier) of the persistent group owner.
+ /// </summary>
+ public string Ssid
+ {
+ get
+ {
+ return _ssid;
+ }
+ }
+ }
+}
diff --git a/packaging/csapi-network-wifi-direct.manifest b/packaging/csapi-network-wifi-direct.manifest
new file mode 100644
index 0000000..75b0fa5
--- /dev/null
+++ b/packaging/csapi-network-wifi-direct.manifest
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
diff --git a/packaging/csapi-network-wifi-direct.spec b/packaging/csapi-network-wifi-direct.spec
new file mode 100644
index 0000000..515f562
--- /dev/null
+++ b/packaging/csapi-network-wifi-direct.spec
@@ -0,0 +1,44 @@
+Name: csapi-network-wifi-direct
+Summary: Tizen Wi-Fi Direct API for C#
+Version: 1.0.2
+Release: 1
+Group: Development/Libraries
+License: Apache-2.0
+URL: https://www.tizen.org
+Source0: %{name}-%{version}.tar.gz
+Source1: %{name}.manifest
+
+AutoReqProv: no
+ExcludeArch: aarch64 %ix86
+
+BuildRequires: dotnet-build-tools
+
+# C# API Requires
+BuildRequires: csapi-tizen-nuget
+
+%define Assemblies Tizen.Network.WiFiDirect
+
+%description
+%{summary}
+
+%dotnet_import_sub_packages
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%build
+for ASM in %{Assemblies}; do
+%dotnet_build $ASM
+%dotnet_pack $ASM/$ASM.nuspec %{version}
+done
+
+%install
+for ASM in %{Assemblies}; do
+%dotnet_install $ASM
+done
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%attr(644,root,root) %{dotnet_assembly_files}