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 Tizen.Network.WiFiDirect;
19 using System.Runtime.InteropServices;
22 /// The Interop class for Wi-Fi Direct.
24 internal static partial class Interop
27 /// The Wi-Fi Direct native APIs.
29 internal static partial class WiFiDirect
31 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
32 internal delegate void DiscoveryStateChangedCallback(int result, WiFiDirectDiscoveryState state, IntPtr userData);
33 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
34 internal delegate void PeerFoundCallback(int result, WiFiDirectDiscoveryState state, string address, IntPtr userData);
35 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
36 internal delegate void DeviceStateChangedCallback(int result, WiFiDirectDeviceState state, IntPtr userData);
37 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
38 internal delegate void ConnectionStateChangedCallback(int result, WiFiDirectConnectionState state, string address, IntPtr userData);
39 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
40 internal delegate void ClientIpAddressAssignedCallback(string macAddress, string ipAddress, string interfaceAddress, IntPtr userData);
41 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
42 internal delegate void ServiceStateChangedCallback(int result, WiFiDirectServiceDiscoveryState state, WiFiDirectServiceType type, IntPtr responseData, string address, IntPtr userData);
43 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
44 internal delegate void StateChangedCallback(WiFiDirectState state, IntPtr userData);
46 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
47 internal delegate bool DiscoveredPeerCallback(ref DiscoveredPeerStruct peer, IntPtr userData);
48 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
49 internal delegate bool ConnectedPeerCallback(ref ConnectedPeerStruct peer, IntPtr userData);
50 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
51 internal delegate bool WpsTypeCallback(WiFiDirectWpsType type, IntPtr userData);
52 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
53 internal delegate bool PersistentGroupCallback(string address, string ssid, IntPtr userData);
55 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_state_changed_cb")]
56 internal static extern int SetStateChangedCallback(StateChangedCallback stateChangedCb, IntPtr userData);
57 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_state_changed_cb")]
58 internal static extern int UnsetStateChangedCallback();
60 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_device_state_changed_cb")]
61 internal static extern int SetDeviceStateChangedCallback(DeviceStateChangedCallback deviceChangedCb, IntPtr userData);
62 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_device_state_changed_cb")]
63 internal static extern int UnsetDeviceStateChangedCallback();
65 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_discovery_state_changed_cb")]
66 internal static extern int SetDiscoveryStateChangedCallback(DiscoveryStateChangedCallback discoveryStateChangedCb, IntPtr userData);
67 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_discovery_state_changed_cb")]
68 internal static extern int UnsetDiscoveryStateChangedCallback();
70 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_peer_found_cb")]
71 internal static extern int SetPeerFoundCallback(PeerFoundCallback peerFoundCb, IntPtr userData);
72 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_peer_found_cb")]
73 internal static extern int UnsetPeerFoundCallback();
75 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_connection_state_changed_cb")]
76 internal static extern int SetConnectionChangedCallback(ConnectionStateChangedCallback connectionCb, IntPtr userData);
77 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_connection_state_changed_cb")]
78 internal static extern int UnsetConnectionChangedCallback();
80 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_client_ip_address_assigned_cb")]
81 internal static extern int SetIpAddressAssignedCallback(ClientIpAddressAssignedCallback callback, IntPtr userData);
82 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_client_ip_address_assigned_cb")]
83 internal static extern int UnsetIpAddressAssignedCallback();
85 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_service_state_changed_cb")]
86 internal static extern int SetServiceStateChangedCallback(ServiceStateChangedCallback serviceStateChangedCb, IntPtr userData);
87 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_unset_service_state_changed_cb")]
88 internal static extern int UnsetServiceStateChangedCallback();
90 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_initialize")]
91 internal static extern int Initialize();
92 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_deinitialize")]
93 internal static extern int Deinitialize();
94 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_activate")]
95 internal static extern int Activate();
96 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_deactivate")]
97 internal static extern int Deactivate();
98 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_start_discovery_specific_channel")]
99 internal static extern int StartDiscoveryInChannel(bool listenOnly, int timeout, WiFiDirectDiscoveryChannel channel);
100 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_cancel_discovery")]
101 internal static extern int StopDiscovery();
102 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_foreach_discovered_peers")]
103 internal static extern int GetDiscoveredPeers(DiscoveredPeerCallback callback, IntPtr userData);
104 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_connect")]
105 internal static extern int Connect(string address);
106 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_cancel_connection")]
107 internal static extern int CancelConnection(string address);
108 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_disconnect_all")]
109 internal static extern int DisconnectAll();
110 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_disconnect")]
111 internal static extern int Disconnect(string address);
112 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_foreach_connected_peers")]
113 internal static extern int GetConnectedPeers(ConnectedPeerCallback callback, IntPtr userData);
114 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_create_group")]
115 internal static extern int CreateGroup();
116 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_destroy_group")]
117 internal static extern int DestroyGroup();
118 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_group_owner")]
119 internal static extern int IsGroupOwner(out bool isGroupOwner);
120 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_autonomous_group")]
121 internal static extern int IsAutonomousGroup(out bool isAutonomous);
122 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_device_name")]
123 internal static extern int SetName(string name);
124 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_device_name")]
125 internal static extern int GetName(out string name);
126 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_ssid")]
127 internal static extern int GetSsid(out string ssid);
128 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_network_interface_name")]
129 internal static extern int GetInterfaceName(out string name);
130 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_ip_address")]
131 internal static extern int GetIpAddress(out string address);
132 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_subnet_mask")]
133 internal static extern int GetSubnetMask(out string mask);
134 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_gateway_address")]
135 internal static extern int GetGatewayAddress(out string address);
136 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_mac_address")]
137 internal static extern int GetMacAddress(out string address);
138 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_state")]
139 internal static extern int GetState(out WiFiDirectState state);
140 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_discoverable")]
141 internal static extern int IsDiscoverable(out bool isDiscoverable);
142 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_listening_only")]
143 internal static extern int IsListeningOnly(out bool listenOnly);
144 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_primary_device_type")]
145 internal static extern int GetPrimaryType(out WiFiDirectPrimaryDeviceType type);
146 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_secondary_device_type")]
147 internal static extern int GetSecondaryType(out WiFiDirectSecondaryDeviceType type);
148 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_activate_pushbutton")]
149 internal static extern int ActivatePushButton();
150 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_wps_pin")]
151 internal static extern int SetWpsPin(string pin);
152 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_wps_pin")]
153 internal static extern int GetWpsPin(out string pin);
154 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_supported_wps_mode")]
155 internal static extern int GetWpsMode(out int mode);
156 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_foreach_supported_wps_types")]
157 internal static extern int GetWpsTypes(WpsTypeCallback callback, IntPtr userData);
158 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_local_wps_type")]
159 internal static extern int GetLocalWpsType(out WiFiDirectWpsType type);
160 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_req_wps_type")]
161 internal static extern int SetReqWpsType(WiFiDirectWpsType type);
162 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_req_wps_type")]
163 internal static extern int GetReqWpsType(out WiFiDirectWpsType type);
164 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_group_owner_intent")]
165 internal static extern int SetIntent(int intent);
166 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_group_owner_intent")]
167 internal static extern int GetIntent(out int intent);
168 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_max_clients")]
169 internal static extern int SetMaxClients(int max);
170 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_max_clients")]
171 internal static extern int GetMaxClients(out int max);
172 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_passphrase")]
173 internal static extern int SetPassPhrase(string passphrase);
174 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_passphrase")]
175 internal static extern int GetPassPhrase(out string passphrase);
176 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_operating_channel")]
177 internal static extern int GetChannel(out int channel);
178 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_autoconnection_mode")]
179 internal static extern int SetAutoConnectionMode(bool mode);
180 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_autoconnection_mode")]
181 internal static extern int GetAutoConnectionMode(out bool mode);
182 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_autoconnection_peer")]
183 internal static extern int SetAutoConnectionPeer(string address);
184 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_persistent_group_enabled")]
185 internal static extern int SetPersistentGroupState(bool enabled);
186 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_is_persistent_group_enabled")]
187 internal static extern int GetPersistentGroupState(out bool enabled);
188 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_foreach_persistent_groups")]
189 internal static extern int GetPersistentGroups(PersistentGroupCallback callback, IntPtr userData);
190 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_remove_persistent_group")]
191 internal static extern int RemovePersistentGroup(string address, string ssid);
192 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_start_service_discovery")]
193 internal static extern int StartServiceDiscovery(string address, WiFiDirectServiceType type);
194 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_cancel_service_discovery")]
195 internal static extern int StopServiceDiscovery(string address, WiFiDirectServiceType type);
196 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_register_service")]
197 internal static extern int RegisterService(WiFiDirectServiceType type, string info1, string info2, out uint serviceId);
198 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_deregister_service")]
199 internal static extern int DeregisterService(uint serviceId);
200 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_init_miracast")]
201 internal static extern int InitMiracast(bool enable);
202 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_info")]
203 internal static extern int GetDiscoveredPeerInfo(string address, out IntPtr peer);
204 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_init_display")]
205 internal static extern int InitDisplay();
206 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_deinit_display")]
207 internal static extern int DeinitDisplay();
208 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_display")]
209 internal static extern int SetDisplay(WiFiDirectDisplayType type, int port, int hdcp);
210 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_display_availability")]
211 internal static extern int SetDisplayAvailability(bool availability);
212 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_display_type")]
213 internal static extern int GetDisplayType(string address, out WiFiDirectDisplayType type);
214 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_display_availability")]
215 internal static extern int GetDisplayAvailability(string address, out bool availability);
216 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_display_hdcp")]
217 internal static extern int GetDisplayHdcp(string address, out int hdcp);
218 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_display_port")]
219 internal static extern int GetDisplayPort(string address, out int port);
220 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_display_throughput")]
221 internal static extern int GetDisplayThroughput(string address, out int throughput);
222 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_peer_rssi")]
223 internal static extern int GetRssi(string address, out int rssi);
224 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_get_session_timer")]
225 internal static extern int GetSessionTimer(out int seconds);
226 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_session_timer")]
227 internal static extern int SetSessionTimer(int seconds);
228 [DllImport(Libraries.WiFiDirect,EntryPoint = "wifi_direct_set_auto_group_removal")]
229 internal static extern int SetAutoGroupRemoval(bool enable);