2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.ComponentModel;
19 using System.Collections.Generic;
21 namespace Tizen.Network.WiFiDirect
24 /// A class which is used to manage settings of Wi-Fi Direct.<br/>
25 /// This class is used to discover peer devices and manage settings of Wi-Fi Direct.
27 public static class WiFiDirectManager
30 /// Gets the IsInitialized.
33 /// A property to check whether the Wifidirect is initialized or not.
36 /// http://tizen.org/privilege/wifidirect
39 /// If it is not initialized, false will be returned.
41 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
42 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
43 [EditorBrowsable(EditorBrowsableState.Never)]
44 public static bool IsInitialized
48 return WiFiDirectManagerImpl.Instance.IsInitialize;
52 /// Gets the IsGroupOwner.
55 /// A property to check whether the device is group owner or not.
58 /// http://tizen.org/privilege/wifidirect
61 /// Wi-Fi Direct must be activated.
62 /// If it is deactivated, false will be returned.
64 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
65 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
66 public static bool IsGroupOwner
70 if (Globals.IsActivated)
72 return WiFiDirectManagerImpl.Instance.IsGroupOwner;
83 /// Gets the IsAutonomousGroup.
86 /// A property to check whether the current group is the autonomous group or not.
89 /// http://tizen.org/privilege/wifidirect
92 /// Wi-Fi Direct must be activated.
93 /// If it is deactivated, false will be returned.
95 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
96 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
97 public static bool IsAutonomousGroup
101 if (Globals.IsActivated)
103 return WiFiDirectManagerImpl.Instance.IsAutonomousGroup;
117 /// SSID of local device.
120 /// http://tizen.org/privilege/wifidirect
123 /// If there is any error, null will be returned.
125 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
126 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
127 public static string Ssid
131 if (Globals.IsInitialize)
133 return WiFiDirectManagerImpl.Instance.Ssid;
144 /// Gets the NetworkInterface.
147 /// Name of network interface.
150 /// http://tizen.org/privilege/wifidirect
153 /// Wi-Fi Direct must be activated.
154 /// If it is deactivated, null will be returned.
156 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
157 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
158 public static string NetworkInterface
162 if (Globals.IsActivated)
164 return WiFiDirectManagerImpl.Instance.NetworkInterface;
175 /// Gets the IpAddress.
178 /// IP address of a local device.
181 /// http://tizen.org/privilege/wifidirect
184 /// Wi-Fi Direct must be activated.
185 /// If it is deactivated, null will be returned.
187 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
188 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
189 public static string IpAddress
193 if (Globals.IsActivated)
195 return WiFiDirectManagerImpl.Instance.IpAddress;
206 /// Gets the SubnetMask.
212 /// http://tizen.org/privilege/wifidirect
215 /// Wi-Fi Direct must be activated.
216 /// If it is deactivated, null will be returned.
218 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
219 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
220 public static string SubnetMask
224 if (Globals.IsActivated)
226 return WiFiDirectManagerImpl.Instance.SubnetMask;
237 /// Gets the GatewayAddress.
243 /// http://tizen.org/privilege/wifidirect
246 /// Wi-Fi Direct must be activated.
247 /// If it is deactivated, null will be returned.
249 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
250 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
251 public static string GatewayAddress
255 if (Globals.IsActivated)
257 return WiFiDirectManagerImpl.Instance.GatewayAddress;
268 /// Gets the MacAddress.
271 /// Mac address of a local device.
274 /// http://tizen.org/privilege/wifidirect
277 /// If there is any error, null will be returned.
279 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
280 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
281 public static string MacAddress
285 if (Globals.IsInitialize)
287 return WiFiDirectManagerImpl.Instance.MacAddress;
301 /// State of Wi-Fi direct service.
304 /// http://tizen.org/privilege/wifidirect
306 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
307 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
308 public static WiFiDirectState State
312 return WiFiDirectManagerImpl.Instance.State;
317 /// A property to check whether the device is discoverable or not by P2P discovery.
323 /// http://tizen.org/privilege/wifidirect
325 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
326 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
327 public static bool IsDiscoverable
331 if (Globals.IsInitialize)
333 return WiFiDirectManagerImpl.Instance.IsDiscoverable;
344 /// Gets the IsListenOnly.
347 /// A property to check whether the local device is listening only.
350 /// http://tizen.org/privilege/wifidirect
353 /// Wi-Fi Direct must be activated.
354 /// If it is deactivated, false will be returned.
356 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
357 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
358 public static bool IsListenOnly
362 if (Globals.IsActivated)
364 return WiFiDirectManagerImpl.Instance.IsListenOnly;
375 /// Gets the PrimaryType.
378 /// Primary device type of local device.
381 /// http://tizen.org/privilege/wifidirect
384 /// If there is any error, 0 will be returned.
386 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
387 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
388 public static WiFiDirectPrimaryDeviceType PrimaryType
392 if (Globals.IsInitialize)
394 return WiFiDirectManagerImpl.Instance.PrimaryType;
399 return default(WiFiDirectPrimaryDeviceType);
405 /// Gets the SecondaryType.
408 /// Secondary device type of local device.
411 /// http://tizen.org/privilege/wifidirect
414 /// If there is any error, 0 will be returned.
416 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
417 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
418 public static WiFiDirectSecondaryDeviceType SecondaryType
422 if (Globals.IsInitialize)
424 return WiFiDirectManagerImpl.Instance.SecondaryType;
429 return default(WiFiDirectSecondaryDeviceType);
435 /// Gets the WpsMode.
438 /// Supported WPS (Wi-Fi Protected Setup) types at local device.
441 /// http://tizen.org/privilege/wifidirect
444 /// If there is any error, -1 will be returned.
446 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
447 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
448 public static int WpsMode
452 if (Globals.IsInitialize)
454 return WiFiDirectManagerImpl.Instance.WpsMode;
468 /// WPS (Wi-Fi Protected Setup) type.
471 /// http://tizen.org/privilege/wifidirect
473 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
474 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
475 public static WiFiDirectWpsType Wps
479 if (Globals.IsInitialize)
481 return WiFiDirectManagerImpl.Instance.WpsType;
486 return default(WiFiDirectWpsType);
492 /// Gets the OperatingChannel.
495 /// Channel number on which the P2P Device is operating as the P2P Group.
498 /// http://tizen.org/privilege/wifidirect
501 /// If there is any error, -1 will be returned.
503 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
504 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
505 public static int OperatingChannel
509 if (Globals.IsInitialize)
511 return WiFiDirectManagerImpl.Instance.OperatingChannel;
522 /// Gets and sets the PersistentGroupEnabled.
525 /// A property to check whether persistent group is enabled.
528 /// http://tizen.org/privilege/wifidirect
530 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
531 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
532 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
533 public static bool PersistentGroupEnabled
537 if (Globals.IsInitialize)
539 return WiFiDirectManagerImpl.Instance.PersistentGroupEnabled;
550 if (Globals.IsInitialize)
552 WiFiDirectManagerImpl.Instance.PersistentGroupEnabled = value;
558 /// Gets and sets the AutoConnect.
561 /// Autoconnection mode status.
564 /// http://tizen.org/privilege/wifidirect
566 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
567 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
568 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
569 public static bool AutoConnect
573 if (Globals.IsInitialize)
575 return WiFiDirectManagerImpl.Instance.AutoConnect;
586 if (Globals.IsInitialize)
588 WiFiDirectManagerImpl.Instance.AutoConnect = value;
594 /// Gets and sets the WpsPin.
600 /// http://tizen.org/privilege/wifidirect
603 /// Wi-Fi Direct must be activated.
604 /// If it is deactivated, null will be returned during get and Not permitted exception message will be returned during set.
606 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
607 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
608 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
609 public static string WpsPin
613 if (Globals.IsActivated)
615 return WiFiDirectManagerImpl.Instance.WpsPin;
626 if (Globals.IsActivated)
628 WiFiDirectManagerImpl.Instance.WpsPin = value;
633 Log.Error(Globals.LogTag, "Wifi-direct is not activated");
634 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
640 /// Gets and sets the Name.
643 /// Name of local device.
646 /// http://tizen.org/privilege/wifidirect
648 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
649 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
650 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
651 public static string Name
655 if (Globals.IsInitialize)
657 return WiFiDirectManagerImpl.Instance.Name;
668 if (Globals.IsInitialize)
670 WiFiDirectManagerImpl.Instance.Name = value;
676 /// Gets and sets the RequestedWps.
679 /// Requested WPS (Wi-Fi Protected Setup) type.
682 /// http://tizen.org/privilege/wifidirect
684 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
685 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
686 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
687 public static WiFiDirectWpsType RequestedWps
691 if (Globals.IsInitialize)
693 return WiFiDirectManagerImpl.Instance.RequestedWps;
698 return default(WiFiDirectWpsType);
704 if (Globals.IsInitialize)
706 WiFiDirectManagerImpl.Instance.RequestedWps = value;
712 /// Gets and sets the GroupOwnerIntent.
715 /// Intent of the group owner.
718 /// http://tizen.org/privilege/wifidirect
720 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
721 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
722 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
723 public static int GroupOwnerIntent
727 if (Globals.IsInitialize)
729 return WiFiDirectManagerImpl.Instance.GroupOwnerIntent;
740 if (Globals.IsInitialize)
742 WiFiDirectManagerImpl.Instance.GroupOwnerIntent = value;
748 /// Gets and sets the MaxClients.
751 /// Max number of clients.
754 /// http://tizen.org/privilege/wifidirect
756 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
757 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
758 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
759 public static int MaxClients
763 if (Globals.IsInitialize)
765 return WiFiDirectManagerImpl.Instance.MaxClients;
776 if (Globals.IsInitialize)
778 WiFiDirectManagerImpl.Instance.MaxClients = value;
784 /// Gets and sets the Passphrase.
785 /// It is used during Wi-Fi Direct Group creation.
788 /// Wi-Fi Protected Access (WPA) password.
791 /// http://tizen.org/privilege/wifidirect
794 /// Wi-Fi Direct must be activated.
795 /// If it is deactivated, null will be returned during get and Not permitted exception message will be returned during set.
797 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
798 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
799 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
800 public static string Passphrase
804 if (Globals.IsActivated)
806 return WiFiDirectManagerImpl.Instance.Passphrase;
817 if (Globals.IsActivated)
819 WiFiDirectManagerImpl.Instance.Passphrase = value;
824 Log.Error(Globals.LogTag, "Wi-Fi direct is not activated");
825 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
831 /// Gets and sets the SessionTimer.
834 /// Connection session timer value in second.
837 /// http://tizen.org/privilege/wifidirect
840 /// Wi-Fi Direct must be activated.
841 /// If it is deactivated, -1 will be returned during get and Not permitted exception message will be returned during set.
843 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
844 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
845 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
846 public static int SessionTimer
850 if (Globals.IsActivated)
852 return WiFiDirectManagerImpl.Instance.SessionTimer;
863 if (Globals.IsActivated)
865 WiFiDirectManagerImpl.Instance.SessionTimer = value;
870 Log.Error(Globals.LogTag, "Wi-Fi direct is not activated");
871 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
877 /// (event) StateChanged is raised when Wi-Fi Direct state is changed.
879 public static event EventHandler<StateChangedEventArgs> StateChanged
883 WiFiDirectManagerImpl.Instance.StateChanged += value;
888 WiFiDirectManagerImpl.Instance.StateChanged -= value;
893 /// (event) DiscoveryStateChanged is raised when Wi-Fi Direct discovery state is changed.
895 public static event EventHandler<DiscoveryStateChangedEventArgs> DiscoveryStateChanged
899 if (Globals.IsInitialize)
901 WiFiDirectManagerImpl.Instance.DiscoveryStateChanged += value;
907 if (Globals.IsInitialize)
909 WiFiDirectManagerImpl.Instance.DiscoveryStateChanged -= value;
915 /// (event) DeviceStateChanged is raised when device state is changed.
917 public static event EventHandler<DeviceStateChangedEventArgs> DeviceStateChanged
921 if (Globals.IsInitialize)
923 WiFiDirectManagerImpl.Instance.DeviceStateChanged += value;
929 if (Globals.IsInitialize)
931 WiFiDirectManagerImpl.Instance.DeviceStateChanged -= value;
937 /// (event) PeerFound is raised when peer is found.
939 public static event EventHandler<PeerFoundEventArgs> PeerFound
943 if (Globals.IsInitialize)
945 WiFiDirectManagerImpl.Instance.PeerFound += value;
951 if (Globals.IsInitialize)
953 WiFiDirectManagerImpl.Instance.PeerFound -= value;
959 /// (event) ConnectionStatusChanged is raised when status of connection is changed.
961 public static event EventHandler<ConnectionStatusChangedEventArgs> ConnectionStatusChanged
965 if (Globals.IsInitialize)
967 WiFiDirectManagerImpl.Instance.ConnectionStatusChanged += value;
973 if (Globals.IsInitialize)
975 WiFiDirectManagerImpl.Instance.ConnectionStatusChanged -= value;
981 /// Activates the Wi-Fi Direct service.
984 /// If this succeeds, DeviceStateChanged event will be invoked.
986 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
987 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
988 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
989 public static void Activate()
991 if (Globals.IsInitialize)
993 WiFiDirectManagerImpl.Instance.Activate();
998 Log.Error(Globals.LogTag, "Wi-Fi direct is not initialized");
999 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotInitialized);
1004 /// Deactivates the Wi-Fi Direct service.
1007 /// http://tizen.org/privilege/wifidirect
1010 /// http://tizen.org/feature/network.wifidirect
1013 /// Wi-Fi Direct must be activated.
1014 /// If this succeeds, DeviceStateChanged event will be invoked.
1016 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1017 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1018 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1019 public static void Deactivate()
1021 if (Globals.IsActivated)
1023 WiFiDirectManagerImpl.Instance.Deactivate();
1028 Log.Error(Globals.LogTag, "Wi-Fi direct is not activated");
1029 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1034 /// Starts discovery to find all P2P capable devices.
1036 /// <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>
1037 /// <param name="duration">Duration of discovery period, in seconds.</param>
1038 /// <param name="channel">Discovery channel.It is optional, default enum value FullScan is assigned.</param>
1040 /// http://tizen.org/privilege/wifidirect
1043 /// http://tizen.org/feature/network.wifidirect
1046 /// Wi-Fi Direct must be activated.
1047 /// If this succeeds, DiscoveryStateChanged and PeerFound event will be invoked.
1049 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1050 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1051 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1052 public static void StartDiscovery(bool listenOnly, int duration, WiFiDirectDiscoveryChannel channel = WiFiDirectDiscoveryChannel.FullScan)
1054 if (Globals.IsActivated)
1056 WiFiDirectManagerImpl.Instance.StartDiscovery(listenOnly, duration, channel);
1061 Log.Error(Globals.LogTag, "Wi-Fi direct is not activated");
1062 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1067 /// Cancels discovery process.
1070 /// http://tizen.org/privilege/wifidirect
1073 /// http://tizen.org/feature/network.wifidirect
1076 /// Discovery must be started by StartDiscovery.
1077 /// If this succeeds, DiscoveryStateChanged and PeerFound event will be invoked.
1079 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1080 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1081 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1082 public static void CancelDiscovery()
1084 if (WiFiDirectManager.State == WiFiDirectState.Discovering)
1086 WiFiDirectManagerImpl.Instance.CancelDiscovery();
1091 Log.Error(Globals.LogTag, "Wi-Fi direct discovery is not started");
1092 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1097 /// Gets the information of discovered peers.
1099 /// <returns> List of discovered peer objects.</returns>
1101 /// http://tizen.org/privilege/wifidirect
1104 /// http://tizen.org/feature/network.wifidirect
1107 /// Wi-Fi Direct must be activated.
1109 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1110 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1111 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1112 public static IEnumerable<WiFiDirectPeer> GetDiscoveredPeers()
1114 if (Globals.IsActivated)
1116 return WiFiDirectManagerImpl.Instance.GetDiscoveredPeers();
1126 /// Gets the information of connected peers.
1128 /// <returns> List of connected peer objects.</returns>
1130 /// http://tizen.org/privilege/wifidirect
1133 /// http://tizen.org/feature/network.wifidirect
1136 /// Wi-Fi Direct must be activated.
1138 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1139 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1140 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1141 public static IEnumerable<WiFiDirectPeer> GetConnectedPeers()
1143 if (Globals.IsActivated)
1145 return WiFiDirectManagerImpl.Instance.GetConnectedPeers();
1155 /// Disconnects all connected links to peers.
1158 /// http://tizen.org/privilege/wifidirect
1161 /// http://tizen.org/feature/network.wifidirect
1164 /// Wi-Fi Direct must be activated.
1165 /// If this succeeds, ConnectionStatusChanged event will be invoked.
1167 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1168 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1169 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1170 public static void DisconnectAll()
1172 if (Globals.IsActivated)
1174 WiFiDirectManagerImpl.Instance.DisconnectAll();
1179 Log.Error(Globals.LogTag, "Wifi-direct is not activated");
1180 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1185 /// Creates a Wi-Fi Direct group and sets up device as the group owner.
1188 /// http://tizen.org/privilege/wifidirect
1191 /// http://tizen.org/feature/network.wifidirect
1194 /// Wi-Fi Direct must be activated.
1195 /// If this succeeds, ConnectionStatusChanged event will be invoked with GroupCreated.
1197 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1198 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1199 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1200 public static void CreateGroup()
1202 if (Globals.IsActivated)
1204 WiFiDirectManagerImpl.Instance.CreateGroup();
1209 Log.Error(Globals.LogTag, "Wifi-direct is not activated");
1210 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1215 /// Destroys the Wi-Fi Direct group owned by a local device.If creating a group is in progress, this API cancels that process.
1218 /// http://tizen.org/privilege/wifidirect
1221 /// http://tizen.org/feature/network.wifidirect
1224 /// Wi-Fi Direct must be activated.
1225 /// If this succeeds, ConnectionStatusChanged event will be invoked with GroupDestroyed.
1227 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1228 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1229 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1230 public static void DestroyGroup()
1232 if (Globals.IsActivated)
1234 WiFiDirectManagerImpl.Instance.DestroyGroup();
1239 Log.Error(Globals.LogTag, "Wifi-direct is not activated");
1240 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1245 /// Set the WPS config PBC as preferred method for connection.
1248 /// http://tizen.org/privilege/wifidirect
1251 /// http://tizen.org/feature/network.wifidirect
1253 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1254 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1255 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1256 public static void ActivatePushButton()
1258 if (Globals.IsActivated)
1260 WiFiDirectManagerImpl.Instance.ActivatePushButton();
1265 Log.Error(Globals.LogTag, "Wifi-direct is not activated");
1266 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1271 /// Gets the supported WPS types.
1273 /// <returns>The list of supported wps types.</returns>
1275 /// http://tizen.org/privilege/wifidirect
1278 /// http://tizen.org/feature/network.wifidirect
1280 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1281 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1282 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1283 public static IEnumerable<WiFiDirectWpsType> GetSupportedWpsTypes()
1285 if (Globals.IsInitialize)
1287 return WiFiDirectManagerImpl.Instance.GetSupportedWpsTypes();
1297 /// Gets the persistent groups.
1299 /// <returns>List of the persistent group objects.</returns>
1301 /// http://tizen.org/privilege/wifidirect
1304 /// http://tizen.org/feature/network.wifidirect
1306 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1307 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1308 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1309 public static IEnumerable<WiFiDirectPersistentGroup> GetPersistentGroups()
1311 if (Globals.IsInitialize)
1313 return WiFiDirectManagerImpl.Instance.GetPersistentGroups();
1323 /// Removes a persistent group.
1325 /// <param name="group">Persistent group owner.</param>
1327 /// http://tizen.org/privilege/wifidirect
1330 /// http://tizen.org/feature/network.wifidirect
1332 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1333 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1334 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1335 public static void RemovePersistentGroup(WiFiDirectPersistentGroup group)
1337 if (Globals.IsInitialize)
1339 WiFiDirectManagerImpl.Instance.RemovePersistentGroup(group);
1344 Log.Error(Globals.LogTag, "Wifi-direct is not activated");
1345 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotInitialized);
1350 /// Initializes or Deintializes the WiFi-Direct Display(MIRACAST) service.
1352 /// <param name="enable">Enables/Disables service.</param>
1354 /// http://tizen.org/privilege/wifidirect
1357 /// http://tizen.org/feature/network.wifidirect
1358 /// http://tizen.org/feature/network.wifi.direct.display
1361 /// Wi-Fi Direct must be activated.
1363 /// <exception cref="NotSupportedException">
1364 /// Thrown during one of the following cases :
1365 /// 1. When the wifidirect is not supported
1366 /// 2. When the wifidirect display feature is not supported
1368 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1369 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1370 public static void InitMiracast(bool enable)
1372 if (Globals.IsActivated)
1374 WiFiDirectManagerImpl.Instance.InitMiracast(enable);
1379 Log.Error(Globals.LogTag, "Wifi-direct is not activated");
1380 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1385 /// Enables Wi-Fi Display functionality.
1388 /// http://tizen.org/privilege/wifidirect
1391 /// http://tizen.org/feature/network.wifidirect
1392 /// http://tizen.org/feature/network.wifi.direct.display
1395 /// Wi-Fi Direct must be activated.
1397 /// <exception cref="NotSupportedException">
1398 /// Thrown during one of the following cases :
1399 /// 1. When the wifidirect is not supported
1400 /// 2. When the wifidirect display feature is not supported
1402 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1403 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1404 public static void InitDisplay()
1406 if (Globals.IsActivated)
1408 WiFiDirectManagerImpl.Instance.InitDisplay();
1413 Log.Error(Globals.LogTag, "Wifi-direct is not activated");
1414 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1419 /// Disable Wi-Fi Display(WFD) functionality and disable the support of WFD Information Element(IE).
1422 /// http://tizen.org/privilege/wifidirect
1425 /// http://tizen.org/feature/network.wifidirect
1426 /// http://tizen.org/feature/network.wifi.direct.display
1429 /// Wi-Fi Direct must be activated and WFD must be enabled.
1431 /// <exception cref="NotSupportedException">
1432 /// Thrown during one of the following cases :
1433 /// 1. When the wifidirect is not supported
1434 /// 2. When the wifidirect display feature is not supported
1436 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1437 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1438 public static void DeinitDisplay()
1440 if (Globals.IsActivated && Globals.s_isDisplay)
1442 WiFiDirectManagerImpl.Instance.DeinitDisplay();
1447 Log.Error(Globals.LogTag, "Wifi-direct is not activated and/or Wi-Fi display is not enabled");
1448 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1453 /// Sets the Wi-Fi Display parameters for the WFD IE of local device.
1455 /// <param name="type">WFD Device Type: define the Role of WFD device like source or sink.</param>
1456 /// <param name="port">Specifies Session Management Control Port number. It should be 2 bytes(0~65535).</param>
1457 /// <param name="hdcp">CP support bit: (1 = enable the hdcp support, 0 = disable the hdcp support).</param>
1459 /// http://tizen.org/privilege/wifidirect
1462 /// http://tizen.org/feature/network.wifidirect
1463 /// http://tizen.org/feature/network.wifi.direct.display
1466 /// Wi-Fi Direct must be activated and WFD must be enabled.
1468 /// <exception cref="NotSupportedException">
1469 /// Thrown during one of the following cases :
1470 /// 1. When the wifidirect is not supported
1471 /// 2. When the wifidirect display feature is not supported
1473 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1474 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1475 public static void SetDisplay(WiFiDirectDisplayType type, int port, int hdcp)
1477 if (Globals.IsActivated && Globals.s_isDisplay)
1479 WiFiDirectManagerImpl.Instance.SetDisplay(type, port, hdcp);
1484 Log.Error(Globals.LogTag, "Wifi-direct is not activated and/or Wi-Fi display is not enabled");
1485 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1490 /// Sets the Wi-Fi Display session availability.
1492 /// <param name="availability">Wi-Fi Display session availability.</param>
1494 /// http://tizen.org/privilege/wifidirect
1497 /// http://tizen.org/feature/network.wifidirect
1498 /// http://tizen.org/feature/network.wifi.direct.display
1501 /// Wi-Fi Direct must be activated and WFD must be enabled.
1503 /// <exception cref="NotSupportedException">
1504 /// Thrown during one of the following cases :
1505 /// 1. When the wifidirect is not supported
1506 /// 2. When the wifidirect display feature is not supported
1508 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1509 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1510 public static void SetDisplayAvailability(bool availability)
1512 if (Globals.IsActivated && Globals.s_isDisplay)
1514 WiFiDirectManagerImpl.Instance.SetDisplayAvailability(availability);
1519 Log.Error(Globals.LogTag, "Wifi-direct is not activated and/or Wi-Fi display is not enabled");
1520 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1525 /// Sets the automatic group removal feature when all peers are disconnected.
1527 /// <param name="enable">Enables/Disables group removal feature.</param>
1529 /// http://tizen.org/privilege/wifidirect
1532 /// http://tizen.org/feature/network.wifidirect
1535 /// Wi-Fi Direct must be activated.
1536 /// 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.
1538 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1539 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1540 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1541 public static void SetAutoGroupRemove(bool enable)
1543 if (Globals.IsActivated)
1545 WiFiDirectManagerImpl.Instance.SetAutoGroupRemove(enable);
1550 Log.Error(Globals.LogTag, "Wifi-direct is not activated");
1551 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);
1556 /// Registers the service.
1558 /// <returns>The service Id of service getting registered.</returns>
1559 /// <param name="type">Type of Wi-Fi Direct Service.</param>
1560 /// <param name="info">Service specific information.</param>
1561 /// <param name="serviceInfo">Service information.</param>
1563 /// http://tizen.org/privilege/wifidirect
1566 /// http://tizen.org/feature/network.wifidirect
1567 /// http://tizen.org/feature/network.wifi.direct.service_discovery
1570 /// Wi-Fi Direct must be activated.
1571 /// If there is any error while registering service, 0 will be returned.
1573 /// <exception cref="NotSupportedException">
1574 /// Thrown during one of the following cases :
1575 /// 1. When the wifidirect is not supported
1576 /// 2. When the wifidirect service discovery is not supported
1578 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1579 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1580 public static uint RegisterService(WiFiDirectServiceType type, string info, string serviceInfo)
1582 if (Globals.IsActivated)
1584 return WiFiDirectManagerImpl.Instance.RegisterService(type, info, serviceInfo);
1594 /// Deregisters for a service used for WiFi Direct Service Discovery.
1596 /// <param name="serviceId"> Service ID for which service has to be deregistered.</param>
1598 /// http://tizen.org/privilege/wifidirect
1601 /// http://tizen.org/feature/network.wifidirect
1602 /// http://tizen.org/feature/network.wifi.direct.service_discovery
1605 /// Wi-Fi Direct must be activated.
1607 /// <exception cref="NotSupportedException">
1608 /// Thrown during one of the following cases :
1609 /// 1. When the wifidirect is not supported
1610 /// 2. When the wifidirect service discovery is not supported
1612 /// <exception cref="InvalidOperationException">The object is in invalid state.</exception>
1613 /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
1614 public static void DeregisterService(uint serviceId)
1616 if (Globals.IsActivated)
1618 WiFiDirectManagerImpl.Instance.DeregisterService(serviceId);
1623 Log.Error(Globals.LogTag, "Wifi-direct is not activated");
1624 WiFiDirectErrorFactory.ThrowWiFiDirectException((int)WiFiDirectError.NotPermitted);