Release 8.0.0.15764
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Bluetooth / Interop / Interop.Bluetooth.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using Tizen.Network.Bluetooth;
19 using System.Runtime.InteropServices;
20
21 internal static partial class Interop
22 {
23     internal static partial class Bluetooth
24     {
25         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
26         internal delegate void StateChangedCallback(int result, int state, IntPtr userData);
27
28         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
29         internal delegate void NameChangedCallback(string deviceName, IntPtr userData);
30
31         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
32         internal delegate void VisibilityModeChangedCallback(int result, int visibility, IntPtr userData);
33
34         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
35         internal delegate void VisibilityDurationChangedCallback(int duration, IntPtr userData);
36
37         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
38         internal delegate void DiscoveryStateChangedCallback(int result, BluetoothDeviceDiscoveryState state, IntPtr deviceInfo, IntPtr userData);
39
40         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
41         internal delegate bool BondedDeviceCallback([MarshalAs(UnmanagedType.Struct)]ref BluetoothDeviceStruct device, IntPtr userData);
42
43         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
44         internal delegate void BondCreatedCallback(int result, [MarshalAs(UnmanagedType.Struct)]ref BluetoothDeviceStruct device, IntPtr userData);
45         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
46         internal delegate void BondDestroyedCallback(int result, string deviceAddress, IntPtr userData);
47         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
48         internal delegate void AuthorizationChangedCallback(int authorization, string deviceAddress, IntPtr userData);
49         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
50         internal delegate void ServiceSearchedCallback(int result, [MarshalAs(UnmanagedType.Struct)]ref BluetoothDeviceSdpStruct sdp, IntPtr userData);
51         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
52         internal delegate void DeviceConnectionStateChangedCallback(bool connected, [MarshalAs(UnmanagedType.Struct)]ref BluetoothDeviceConnectionStruct device, IntPtr userData);
53         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
54         internal delegate bool ConnectedProfileCallback(int profile, IntPtr userData);
55
56         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
57         internal delegate void DataReceivedCallback([MarshalAs(UnmanagedType.Struct)]ref SocketDataStruct socketData, IntPtr userData);
58         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
59         internal delegate void SocketConnectionStateChangedCallback(int result, BluetoothSocketState connectionState, [MarshalAs(UnmanagedType.Struct)]ref SocketConnectionStruct socketConnection, IntPtr userData);
60
61         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
62         internal delegate void AudioConnectionStateChangedCallback(int result, bool connected, string deviceAddress, int profileType, IntPtr userData);
63
64         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
65         internal delegate void ConnectionRequestedCallback(string deviceAddress, IntPtr userData);
66         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
67         internal delegate void PushRequestedCallback(string file, long size, IntPtr userData);
68
69         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
70         internal delegate void TransferProgressCallback(string file, long size, int percent, IntPtr userData);
71         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
72         internal delegate void TransferFinishedCallback(int result, string file, long size, IntPtr userData);
73
74         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
75         internal delegate void PushRespondedCallback(int result, string deviceAddress, IntPtr userData);
76         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
77         internal delegate void PushProgressCallback(string file, long size, int percent, IntPtr userData);
78         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
79         internal delegate void PushFinishedCallback(int result, string deviceAddress, IntPtr userData);
80
81         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
82         internal delegate void TargetConnectionStateChangedCallback(bool connected, string deviceAddress, IntPtr userData);
83         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
84         internal delegate void EqualizerStateChangedCallback(int equalizer, IntPtr userData);
85         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
86         internal delegate void RepeatModeChangedCallback(int repeat, IntPtr userData);
87         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
88         internal delegate void ShuffleModeChangedCallback(int shuffle, IntPtr userData);
89         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
90         internal delegate void ScanModeChangedCallback(int scan, IntPtr userData);
91
92         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
93         internal delegate void AvrcpControlConnectionChangedCallback(bool connected, string remoteAddress, IntPtr userData);
94         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
95         internal delegate void PositionChangedCallback(uint position, IntPtr userData);
96         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
97         internal delegate void PlayStatusChangedCallback(int play_status, IntPtr userData);
98         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
99         internal delegate void TrackInfoChangedCallback([MarshalAs(UnmanagedType.Struct)]ref TrackInfoStruct track, IntPtr userData);
100
101         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
102         internal delegate void ConnectionChangedCallback(int result, bool connected, string deviceAddress, IntPtr userData);
103         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
104         internal delegate void ClientCharacteristicValueChangedCallback(IntPtr characteristicHandle, string value, int len, IntPtr userData);
105         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
106         internal delegate void GattClientRequestedCallback(int result, IntPtr handle, IntPtr userData);
107         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
108         internal delegate bool GattForEachCallback(int total, int index, IntPtr handle, IntPtr userData);
109
110         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_initialize")]
111         internal static extern int Initialize();
112         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_deinitialize")]
113         internal static extern int Deinitialize();
114
115         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_enable")]
116         internal static extern int EnableAdapter();
117         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_disable")]
118         internal static extern int DisableAdapter();
119         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_name")]
120         internal static extern int GetName(out string name);
121         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_name")]
122         internal static extern int SetName(string name);
123         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_state")]
124         internal static extern int GetState(out BluetoothState isActivated);
125         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_address")]
126         internal static extern int GetAddress(out string address);
127         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_visibility")]
128         internal static extern int SetVisibility(VisibilityMode visibilityMode, int duration);
129         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_visibility")]
130         internal static extern int GetVisibility(out int visibility, out int duration);
131         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_is_discovering")]
132         internal static extern int IsDiscovering(out bool isDiscovering);
133         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_start_device_discovery")]
134         internal static extern int StartDiscovery();
135         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_stop_device_discovery")]
136         internal static extern int StopDiscovery();
137         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_foreach_bonded_device")]
138         internal static extern int GetBondedDevices(BondedDeviceCallback bondedDeviceCb, IntPtr userData);
139         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_bonded_device_info")]
140         internal static extern int GetBondedDeviceByAddress(string deviceAddress, out IntPtr deviceInfo);
141         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_free_device_info")]
142         internal static extern int FreeDeviceInfo(IntPtr deviceInfo);
143         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_is_service_used")]
144         internal static extern int IsServiceUsed(string serviceUuid, out bool used);
145         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_get_local_oob_data")]
146         internal static extern int GetOobData(out IntPtr hash, out IntPtr randomizer, out int hashLen, out int randomizerLen);
147         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_remote_oob_data")]
148         internal static extern int SetOobData(string deviceAddress, IntPtr hash, IntPtr randomizer, int hashLen, int randomizerLen);
149         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_remove_remote_oob_data")]
150         internal static extern int RemoveOobData(string deviceAddress);
151         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_state_changed_cb")]
152         internal static extern int SetStateChangedCallback(StateChangedCallback stateChangedCb, IntPtr userData);
153         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_unset_state_changed_cb")]
154         internal static extern int UnsetStateChangedCallback();
155         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_name_changed_cb")]
156         internal static extern int SetNameChangedCallback(NameChangedCallback nameChangedCb, IntPtr userData);
157         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_unset_name_changed_cb")]
158         internal static extern int UnsetNameChangedCallback();
159         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_visibility_mode_changed_cb")]
160         internal static extern int SetVisibilityModeChangedCallback(VisibilityModeChangedCallback visibilityChangedCb, IntPtr userData);
161         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_unset_visibility_mode_changed_cb")]
162         internal static extern int UnsetVisibilityModeChangedCallback();
163         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_visibility_duration_changed_cb")]
164         internal static extern int SetVisibilityDurationChangedCallback(VisibilityDurationChangedCallback durationChangedCb, IntPtr userData);
165         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_unset_visibility_duration_changed_cb")]
166         internal static extern int UnsetVisibilityDurationChangedCallback();
167         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_set_device_discovery_state_changed_cb")]
168         internal static extern int SetDiscoveryStateChangedCallback(DiscoveryStateChangedCallback discoveryChangedCb, IntPtr userData);
169         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_unset_device_discovery_state_changed_cb")]
170         internal static extern int UnsetDiscoveryStateChangedCallback();
171
172         //Bluetooth Device
173         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_create_bond")]
174         internal static extern int CreateBond(string deviceAddress);
175         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_destroy_bond")]
176         internal static extern int DestroyBond(string deviceAddress);
177         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_cancel_bonding")]
178         internal static extern int CancelBonding();
179
180         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_alias")]
181         internal static extern int SetAlias(string deviceAddress, string alias);
182         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_authorization")]
183         internal static extern int SetAuthorization(string deviceAddress, int state);
184
185         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_get_service_mask_from_uuid_list")]
186         internal static extern int GetMaskFromUuid([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 1)] string[] uuids, int count, out BluetoothServiceClassType serviceMask);
187
188         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_start_service_search")]
189         internal static extern int StartServiceSearch(string deviceAddress);
190
191         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_foreach_connected_profiles")]
192         internal static extern int GetConnectedProfiles(string deviceAddress, ConnectedProfileCallback connectedProfileCb, IntPtr userData);
193         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_is_profile_connected")]
194         internal static extern int IsProfileConnected(string deviceAddress, int profile, out bool connectionStatus);
195
196         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_bond_created_cb")]
197         internal static extern int SetBondCreatedCallback(BondCreatedCallback bondCreatedCb, IntPtr userData);
198         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_unset_bond_created_cb")]
199         internal static extern int UnsetBondCreatedCallback();
200
201         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_bond_destroyed_cb")]
202         internal static extern int SetBondDestroyedCallback(BondDestroyedCallback bondDestroyedCb, IntPtr userData);
203         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_unset_bond_destroyed_cb")]
204         internal static extern int UnsetBondDestroyedCallback();
205
206         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_authorization_changed_cb")]
207         internal static extern int SetAuthorizationChangedCallback(AuthorizationChangedCallback authorizationChangedCb, IntPtr userData);
208         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_unset_authorization_changed_cb")]
209         internal static extern int UnsetAuthorizationChangedCallback();
210
211         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_service_searched_cb")]
212         internal static extern int SetServiceSearchedCallback(ServiceSearchedCallback serviceSearchedCb, IntPtr userData);
213         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_unset_service_searched_cb")]
214         internal static extern int UnsetServiceSearchedCallback();
215
216         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_set_connection_state_changed_cb")]
217         internal static extern int SetConnectionStateChangedCallback(DeviceConnectionStateChangedCallback connectionChangedCb, IntPtr userData);
218         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_device_unset_connection_state_changed_cb")]
219         internal static extern int UnsetConnectionStateChangedCallback();
220
221         // Bluetooth LE Adapter
222
223         //Callback for event
224         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
225         internal delegate void AdapterLeScanResultChangedCallBack(int result,
226             [MarshalAs(UnmanagedType.Struct)]ref BluetoothLeScanDataStruct scanData, IntPtr userData);
227
228         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
229         public delegate void AdvertisingStateChangedCallBack(int result, IntPtr advertiserHandle,
230                             BluetoothLeAdvertisingState advertisingState, IntPtr userData);
231
232         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
233         public delegate void GattConnectionStateChangedCallBack(int result, bool connected,
234                                         string remoteAddress, IntPtr userData);
235
236         //Bluetooth Le Adapter Apis
237         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_start_scan")]
238         public static extern int StartScan(AdapterLeScanResultChangedCallBack callback, IntPtr userData);
239
240         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_stop_scan")]
241         public static extern int StopScan();
242
243         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_set_scan_mode")]
244         public static extern int SetLeScanMode(BluetoothLeScanMode mode);
245
246         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_service_uuids")]
247         public static extern int GetScanResultServiceUuid(ref BluetoothLeScanDataStruct scanData,
248             BluetoothLePacketType packetType, ref IntPtr uuids, ref int count);
249
250         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_device_name")]
251         public static extern int GetLeScanResultDeviceName(ref BluetoothLeScanDataStruct scanData,
252                             BluetoothLePacketType packetType, out string deviceName);
253
254         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_tx_power_level")]
255         public static extern int GetScanResultTxPowerLevel(ref BluetoothLeScanDataStruct scanData,
256                             BluetoothLePacketType packetType, out int txPowerLevel);
257
258         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_service_solicitation_uuids")]
259         public static extern int GetScanResultSvcSolicitationUuids(ref BluetoothLeScanDataStruct scanData,
260                             BluetoothLePacketType packetType, out IntPtr uuids, out int count);
261
262         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_service_data_list")]
263         public static extern int GetScanResultServiceDataList(ref BluetoothLeScanDataStruct scanData,
264                             BluetoothLePacketType PacketType, out IntPtr serviceDataArray, out int count);
265
266         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_free_service_data_list")]
267         public static extern int FreeServiceDataList(IntPtr serviceData, int count);
268
269         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_appearance")]
270         public static extern int GetScanResultAppearance(ref BluetoothLeScanDataStruct scanData,
271                             BluetoothLePacketType packetType, out int appearance);
272
273         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_get_scan_result_manufacturer_data")]
274         public static extern int GetScanResultManufacturerData(ref BluetoothLeScanDataStruct scanData,
275                             BluetoothLePacketType packetType, out int manufId, out IntPtr manufData,
276                             out int manufDataLength);
277
278         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_connect")]
279         internal static extern int GattConnect(string deviceAddress, bool autoConnect);
280
281         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_disconnect")]
282         internal static extern int GattDisconnect(string deviceAddress);
283
284         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_set_connection_state_changed_cb")]
285         internal static extern int SetGattConnectionStateChangedCallback(
286             GattConnectionStateChangedCallBack gattConnectionChangedCb, IntPtr userData);
287
288         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_unset_connection_state_changed_cb")]
289         internal static extern int UnsetGattConnectionStateChangedCallback();
290
291         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_create_advertiser")]
292         public static extern int CreateAdvertiser(out IntPtr advertiserHandle);
293
294         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_destroy_advertiser")]
295         public static extern int DestroyAdvertiser(IntPtr advertiserHandle);
296
297         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_add_advertising_service_uuid")]
298         public static extern int AddAdvertisingServiceUuid(IntPtr advertiserHandle,
299                                     BluetoothLePacketType PacketType, string uuid);
300
301         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_add_advertising_service_solicitation_uuid")]
302         public static extern int AddAdvertisingServiceSolicitationUuid(IntPtr advertiserHandle,
303             BluetoothLePacketType PacketType, string uuid);
304
305         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_add_advertising_service_data")]
306         public static extern int AddAdvertisingServiceData(IntPtr advertiserHandle,
307             BluetoothLePacketType PacketType, string uuid, IntPtr serviceData, int serviceDatalength);
308
309         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_set_advertising_appearance")]
310         public static extern int SetAdvertisingAppearance(IntPtr advertiserHandle,
311                                     BluetoothLePacketType packetType, int appearance);
312
313         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_add_advertising_manufacturer_data")]
314         public static extern int AddAdvertisingManufData(IntPtr advertiserHandle, BluetoothLePacketType packetType,
315             int manufId, IntPtr manufData, int manufacturerDataLength);
316
317         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_set_advertising_device_name")]
318         public static extern int SetAdvertisingDeviceName(IntPtr advertiserHandle, BluetoothLePacketType packetType,
319                                                 bool includeName);
320
321         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_set_advertising_tx_power_level")]
322         public static extern int SetAdvertisingTxPowerLevel(IntPtr advertiserHandle, BluetoothLePacketType packetType,
323                                                 bool includePowerLevel);
324
325         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_clear_advertising_data")]
326         public static extern int ClearAdvertisingData(IntPtr advertiserHandle, BluetoothLePacketType packetType);
327
328         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_start_advertising_new")]
329         public static extern int BluetoothLeStartAdvertising(IntPtr advertiserHandle,
330                                          AdvertisingStateChangedCallBack callback, IntPtr userData);
331
332         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_stop_advertising")]
333         public static extern int BluetoothLeStopAdvertising(IntPtr advertiserHandle);
334
335         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_set_advertising_mode")]
336         public static extern int SetAdvertisingMode(IntPtr advertiserHandle,
337                                         BluetoothLeAdvertisingMode advertisingMode);
338
339         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_adapter_le_set_advertising_connectable")]
340         public static extern int SetAdvertisingConnectable(IntPtr advertiserHandle,
341                                         bool connectable);
342
343         //Bluetooth Socket
344         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
345         internal delegate void SocketConnectionRequestedCallback(int socket_fd, string remoteAddress, IntPtr userData);
346
347         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_create_rfcomm")]
348         internal static extern int CreateServerSocket(string serviceUuid, out int socketFd);
349         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_destroy_rfcomm")]
350         internal static extern int DestroyServerSocket(int socketFd);
351         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_listen_and_accept_rfcomm")]
352         internal static extern int Listen(int socketFd, int pendingConnections);
353         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_listen")]
354         internal static extern int ListenWithoutAccept(int socketFd, int pendingConnections);
355         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_accept")]
356         internal static extern int Accept(int socketFd);
357         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_reject")]
358         internal static extern int Reject(int socketFd);
359         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_connect_rfcomm")]
360         internal static extern int ConnectSocket(string address, string serviceUuid);
361         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_disconnect_rfcomm")]
362         internal static extern int DisconnectSocket(int socketFd);
363         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_send_data")]
364         internal static extern int SendData(int socketFd, string data, int dataLength);
365         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_send_data")]
366         internal static extern int SendData(int socketFd, byte[] data, int dataLength);
367         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_set_data_received_cb")]
368         internal static extern int SetDataReceivedCallback(DataReceivedCallback callback, IntPtr userData);
369         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_unset_data_received_cb")]
370         internal static extern int UnsetDataReceivedCallback();
371         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_set_connection_state_changed_cb")]
372         internal static extern int SetConnectionStateChangedCallback(SocketConnectionStateChangedCallback callback, IntPtr userData);
373         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_unset_connection_state_changed_cb")]
374         internal static extern int UnsetSocketConnectionStateChangedCallback();
375         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_set_connection_requested_cb")]
376         internal static extern int SetSocketConnectionRequestedCallback(SocketConnectionRequestedCallback socketConnectionRequestedCb, IntPtr userData);
377         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_socket_unset_connection_requested_cb")]
378         internal static extern int UnsetSocketConnectionRequestedCallback();
379
380         // Bluetooth Audio
381         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
382         internal delegate void AgScoStateChangedCallback(int result, bool opened, IntPtr userData);
383
384         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_initialize")]
385         internal static extern int InitializeAudio();
386         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_deinitialize")]
387         internal static extern int DeinitializeAudio();
388         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_connect")]
389         internal static extern int Connect(string deviceAddress, int profileType);
390         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_disconnect")]
391         internal static extern int Disconnect(string deviceAddress, int profileType);
392         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_set_connection_state_changed_cb")]
393         internal static extern int SetAudioConnectionStateChangedCallback(AudioConnectionStateChangedCallback audioStateChangedCb, IntPtr userData);
394         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_audio_unset_connection_state_changed_cb")]
395         internal static extern int UnsetAudioConnectionStateChangedCallback();
396         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_ag_open_sco")]
397         internal static extern int OpenAgSco();
398         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_ag_close_sco")]
399         internal static extern int CloseAgSco();
400         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_ag_is_sco_opened")]
401         internal static extern int IsAgScoOpened(out bool opened);
402         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_ag_set_sco_state_changed_cb")]
403         internal static extern int SetAgScoStateChangedCallback(AgScoStateChangedCallback scoStateChangedCb, IntPtr userData);
404         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_ag_unset_sco_state_changed_cb")]
405         internal static extern int UnsetAgScoStateChangedCallback();
406         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_ag_notify_voice_recognition_state")]
407         internal static extern int NotifyAgVoiceRecognitionState(bool enable);
408
409         // Bluetooth Hid
410         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
411         internal delegate void HidConnectionStateChangedCallback(int result, bool connected, string deviceAddress, IntPtr userData);
412         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
413         internal delegate void HidDeviceConnectionStateChangedCallback(int result, bool connected, string deviceAddress, IntPtr userData);
414         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
415         internal delegate void HidDeviceDataReceivedCallback(ref BluetoothHidDeviceReceivedDataStruct receivedData, IntPtr userData);
416
417         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_host_initialize")]
418         internal static extern int InitializeHid(HidConnectionStateChangedCallback hidConnectionChangedCb, IntPtr userData);
419         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_host_deinitialize")]
420         internal static extern int DeinitializeHid();
421         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_host_connect")]
422         internal static extern int Connect(string deviceAddress);
423         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_host_disconnect")]
424         internal static extern int Disconnect(string deviceAddress);
425
426         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_device_activate")]
427         internal static extern int ActivateHidDevice(HidDeviceConnectionStateChangedCallback stateChangedCb, IntPtr userData);
428         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_device_deactivate")]
429         internal static extern int DeactivateHidDevice();
430         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_device_connect")]
431         internal static extern int ConnectHidDevice(string deviceAddress);
432         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_device_disconnect")]
433         internal static extern int DisconnectHidDevice(string deviceAddress);
434         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_device_send_mouse_event")]
435         internal static extern int SendHidDeviceMouseEvent(string deviceAddress, BluetoothHidMouseData mouseData);
436         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_device_send_key_event")]
437         internal static extern int SendHidDeviceKeyEvent(string deviceAddress, BluetoothHidKeyData keyData);
438         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_device_set_data_received_cb")]
439         internal static extern int SetHidDeviceDataReceivedCallback(HidDeviceDataReceivedCallback dataReceivedCb, IntPtr userData);
440         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_device_unset_data_received_cb")]
441         internal static extern int UnsetHidDeviceDataReceivedCallback();
442         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_hid_device_reply_to_report")]
443         internal static extern int ReplyToReportHidDevice(string deviceAddress, BluetoothHidHeaderType headerType, BluetoothHidParamType paramType, byte[] value, int len, IntPtr userData);
444
445         // Bluetooth OPP
446         // Opp Server
447         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_server_initialize")]
448         internal static extern int InitializeOppServer(string deviceAddress, PushRequestedCallback pushRequestedCb, IntPtr userData);
449
450         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_server_deinitialize")]
451         internal static extern int DinitializeOppServer();
452
453         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_server_initialize_by_connection_request")]
454         internal static extern int InitializeOppServerCustom(string deviceAddress, ConnectionRequestedCallback connectionRequestedCb, IntPtr userData);
455
456         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_server_accept")]
457         internal static extern int OppServerAcceptPush(TransferProgressCallback transferProgressCb, TransferFinishedCallback transferFinishedCb, string name, IntPtr userData, out int transferId);
458
459         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_server_reject")]
460         internal static extern int OppServerRejectPush();
461
462         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_server_cancel_transfer")]
463         internal static extern int OppServerCancelTransfer(int transferId);
464
465         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_server_set_destination")]
466         internal static extern int OppServerSetDestinationPath(string path);
467
468         // Opp Client
469         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_client_initialize")]
470         internal static extern int InitializeOppClient();
471
472         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_client_deinitialize")]
473         internal static extern int DeinitializeOppClient();
474
475         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_client_add_file")]
476         internal static extern int OppClientAddFile(string filePath);
477
478         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_client_clear_files")]
479         internal static extern int OppClientClearFiles();
480
481         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_client_cancel_push")]
482         internal static extern int OppClientCancelPush();
483
484         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_opp_client_push_files")]
485         internal static extern int OppClientPushFile(string filePath, PushRespondedCallback pushRespondedCb, PushProgressCallback pushProgressCb, PushFinishedCallback pushFinishedCb, IntPtr userData);
486
487         //Bluetooth Avrcp
488         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_initialize")]
489         internal static extern int InitializeAvrcp(TargetConnectionStateChangedCallback targetStateChangedCb, IntPtr userData);
490         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_deinitialize")]
491         internal static extern int DeinitializeAvrcp();
492         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_equalizer_state")]
493         internal static extern int NotifyEqualizerState(int state);
494         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_repeat_mode")]
495         internal static extern int NotifyRepeatMode(int repeat);
496         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_shuffle_mode")]
497         internal static extern int NotifyShuffleMode(int shuffle);
498         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_scan_mode")]
499         internal static extern int NotifyScanMode(int scan);
500         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_player_state")]
501         internal static extern int NotifyPlayerState(int state);
502         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_position")]
503         internal static extern int NotifyCurrentPosition(uint position);
504         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_target_notify_track")]
505         internal static extern int NotifyTrack(string title, string artist, string album, string genre, uint trackNum, uint totaltracks, uint duration);
506
507         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_set_equalizer_state_changed_cb")]
508         internal static extern int SetEqualizerStateChangedCallback(EqualizerStateChangedCallback equalizerStateChangedCb, IntPtr userData);
509         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_unset_equalizer_state_changed_cb")]
510         internal static extern int UnsetEqualizerStateChangedCallback();
511         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_set_repeat_mode_changed_cb")]
512         internal static extern int SetRepeatModeChangedCallback(RepeatModeChangedCallback repeatModeChangedCb, IntPtr userData);
513         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_unset_repeat_mode_changed_cb")]
514         internal static extern int UnsetRepeatModeChangedCallback();
515         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_set_shuffle_mode_changed_cb")]
516         internal static extern int SetShuffleModeChangedCallback(ShuffleModeChangedCallback shuffleModeChangedCb, IntPtr userData);
517         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_unset_shuffle_mode_changed_cb")]
518         internal static extern int UnsetShuffleModeChangedCallback();
519         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_set_scan_mode_changed_cb")]
520         internal static extern int SetScanModeChangedCallback(ScanModeChangedCallback scanModeChangedCb, IntPtr userData);
521         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_unset_scan_mode_changed_cb")]
522         internal static extern int UnsetScanModeChangedCallback();
523
524         // Bluetooth AVRCP Control
525
526         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_initialize")]
527         internal static extern int AvrcpControlInitialize(AvrcpControlConnectionChangedCallback callback, IntPtr userData);
528
529         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_deinitialize")]
530         internal static extern int AvrcpControlDeinitialize();
531
532         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_connect")]
533         internal static extern int AvrcpControlConnect(string address);
534
535         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_disconnect")]
536         internal static extern int AvrcpControlDisconnect(string address);
537
538         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_set_equalizer_state")]
539         internal static extern int SetEqualizerState(EqualizerState state);
540
541         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_get_equalizer_state")]
542         internal static extern int GetEqualizerState(out EqualizerState state);
543
544         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_set_repeat_mode")]
545         internal static extern int SetRepeatMode(RepeatMode mode);
546
547         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_get_repeat_mode")]
548         internal static extern int GetRepeatMode(out RepeatMode mode);
549
550         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_set_shuffle_mode")]
551         internal static extern int SetShuffleMode(ShuffleMode mode);
552
553         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_get_shuffle_mode")]
554         internal static extern int GetShuffleMode(out ShuffleMode mode);
555
556         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_set_scan_mode")]
557         internal static extern int SetScanMode(ScanMode mode);
558
559         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_get_scan_mode")]
560         internal static extern int GetScanMode(out ScanMode mode);
561
562         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_get_position")]
563         internal static extern int GetPosition(out uint position);
564
565         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_get_play_status")]
566         internal static extern int GetPlayStatus(out PlayerState state);
567
568         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_get_track_info")]
569         internal static extern int GetTrackInfo(out IntPtr infoptr);
570
571         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_free_track_info")]
572         internal static extern int FreeTrackInfo(IntPtr infoptr);
573
574         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_send_player_command")]
575         internal static extern int SendPlayerCommand(PlayerCommand command);
576
577         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_send_player_command_to")]
578         internal static extern int SendPlayerCommandTo(PlayerCommand command, string remoteAddress);
579
580         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_set_absolute_volume")]
581         internal static extern int SetAbsoluteVolume(uint volume);
582
583         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_increase_volume")]
584         internal static extern int IncreaseVolume();
585
586         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_decrease_volume")]
587         internal static extern int DecreaseVolume();
588
589         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_control_send_delay_report")]
590         internal static extern int SendDelayReport(uint value);
591
592         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_set_position_changed_cb")]
593         internal static extern int SetPositionChangedCallback(PositionChangedCallback PositionChangedCb, IntPtr userData);
594
595         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_unset_position_changed_cb")]
596         internal static extern int UnsetPositionChangedCallback();
597
598         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_set_play_status_changed_cb")]
599         internal static extern int SetPlayStatusChangedCallback(PlayStatusChangedCallback PlayStatusChangedCb, IntPtr userData);
600
601         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_unset_play_status_changed_cb")]
602         internal static extern int UnsetPlayStatusChangedCallback();
603
604         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_set_track_info_changed_cb")]
605         internal static extern int SetTrackInfoChangedCallback(TrackInfoChangedCallback TrackInfoChangedCb, IntPtr userData);
606
607         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_avrcp_unset_track_info_changed_cb")]
608         internal static extern int UnsetTrackInfoChangedCallback();
609
610         // Bluetooth GATT
611
612         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
613         internal delegate bool BtGattForeachCallback(int total, int index, IntPtr gattHandle, IntPtr userData);
614
615         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
616         internal delegate void BtGattServerReadValueRequestedCallback(string clientAddress, int requestId, IntPtr serverHandle, IntPtr gattHandle, int offset, IntPtr userData);
617
618         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
619         internal delegate void BtGattServerWriteValueRequestedCallback(string clientAddress, int requestId, IntPtr serverHandle, IntPtr gattHandle, bool response_needed, int offset, IntPtr value, int len, IntPtr userData);
620
621         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
622         internal delegate void BtClientCharacteristicValueChangedCallback(IntPtr characteristicHandle, IntPtr value, int len, IntPtr userData);
623
624         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
625         internal delegate void BtGattServerNotificationStateChangeCallback(bool notify, IntPtr serverHandle, IntPtr characteristicHandle, IntPtr userData);
626
627         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
628         internal delegate void BtGattServerNotificationSentCallback(int result, string clientAddress, IntPtr serverHandle, IntPtr characteristicHandle, bool completed, IntPtr userData);
629
630         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
631         internal delegate void BtGattClientRequestCompletedCallback(int result, IntPtr requestHandle, IntPtr userData);
632
633         // Gatt Attribute
634
635         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_destroy")]
636         internal static extern int BtGattDestroy(IntPtr gattHandle);
637
638         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_get_uuid")]
639         internal static extern int BtGattGetUuid(BluetoothGattAttributeHandle gattHandle, out string uuid);
640
641         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_get_value")]
642         internal static extern int BtGattGetValue(BluetoothGattAttributeHandle gattHandle, out IntPtr nativeValue, out int valueLength);
643
644         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_set_value")]
645         internal static extern int BtGattSetValue(BluetoothGattAttributeHandle gattHandle, byte[] value, int valueLength);
646
647         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_get_int_value")]
648         internal static extern int BtGattGetIntValue(BluetoothGattAttributeHandle gattHandle, int type, int offset, out int value);
649
650         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_set_int_value")]
651         internal static extern int BtGattSetIntValue(BluetoothGattAttributeHandle gattHandle, int type, int value, int offset);
652
653         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_get_float_value")]
654         internal static extern int BtGattGetFloatValue(BluetoothGattAttributeHandle gattHandle, int type, int offset, out float value);
655
656         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_set_float_value")]
657         internal static extern int BtGattSetFloatValue(BluetoothGattAttributeHandle gattHandle, int type, int mantissa, int exponent, int offset);
658
659         // GATT Descriptor
660
661         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_descriptor_create")]
662         internal static extern int BtGattDescriptorCreate(string uuid, int permissions, byte[] value, int valueLength, out BluetoothGattAttributeHandle descriptorHandle);
663
664         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_descriptor_get_permissions")]
665         internal static extern int BtGattDescriptorGetPermissions(BluetoothGattAttributeHandle descriptorHandle, out int permissions);
666
667         // GATT Characteristic
668
669         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_create")]
670         internal static extern int BtGattCharacteristicCreate(string uuid, int permissions, int properties, byte[] value, int valueLength, out BluetoothGattAttributeHandle characteristicHandle);
671
672         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_get_permissions")]
673         internal static extern int BtGattCharacteristicGetPermissions(BluetoothGattAttributeHandle characteristicHandle, out int permissions);
674
675         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_get_properties")]
676         internal static extern int BtGattCharacteristicGetProperties(BluetoothGattAttributeHandle characteristicHandle, out int properties);
677
678         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_set_properties")]
679         internal static extern int BtGattCharacteristicSetProperties(BluetoothGattAttributeHandle characteristicHandle, int properties);
680
681         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_get_write_type")]
682         internal static extern int BtGattCharacteristicGetWriteType(BluetoothGattAttributeHandle characteristicHandle, out int writeType);
683
684         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_set_write_type")]
685         internal static extern int BtGattCharacteristicSetWriteType(BluetoothGattAttributeHandle characteristicHandle, int writeType);
686
687         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_add_descriptor")]
688         internal static extern int BtGattCharacteristicAddDescriptor(BluetoothGattAttributeHandle characteristicHandle, BluetoothGattAttributeHandle descriptorHandle);
689
690         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_get_descriptor")]
691         internal static extern int BtGattCharacteristicGetDescriptor(BluetoothGattAttributeHandle characteristicHandle, string uuid, out BluetoothGattAttributeHandle descriptorHandle);
692
693         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_characteristic_foreach_descriptors")]
694         internal static extern int BtGattCharacteristicForeachDescriptors(BluetoothGattAttributeHandle characteristicHandle, BtGattForeachCallback callback, IntPtr userData);
695
696         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_set_characteristic_value_changed_cb")]
697         internal static extern int BtGattClientSetCharacteristicValueChangedCallback(BluetoothGattAttributeHandle characteristicHandle, BtClientCharacteristicValueChangedCallback cb, IntPtr userData);
698
699         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_unset_characteristic_value_changed_cb")]
700         internal static extern int BtGattClientUnsetCharacteristicValueChangedCallback(BluetoothGattAttributeHandle characteristicHandle);
701
702         // GATT Service
703
704         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_create")]
705         internal static extern int BtGattServiceCreate(string uuid, int type, out BluetoothGattAttributeHandle serviceHandle);
706
707         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_add_characteristic")]
708         internal static extern int BtGattServiceAddCharacteristic(BluetoothGattAttributeHandle serviceHandle, BluetoothGattAttributeHandle characteristicHandle);
709
710         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_get_characteristic")]
711         internal static extern int BtGattServiceGetCharacteristic(BluetoothGattAttributeHandle serviceHandle, string uuid, out BluetoothGattAttributeHandle characteristicHandle);
712
713         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_foreach_characteristics")]
714         internal static extern int BtGattServiceForeachCharacteristics(BluetoothGattAttributeHandle serviceHandle, BtGattForeachCallback callback, IntPtr userData);
715
716         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_add_included_service")]
717         internal static extern int BtGattServiceAddIncludedService(BluetoothGattAttributeHandle serviceHandle, BluetoothGattAttributeHandle includedServiceHandle);
718
719         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_get_included_service")]
720         internal static extern int BtGattServiceGetIncludedService(BluetoothGattAttributeHandle serviceHandle, string uuid, out BluetoothGattAttributeHandle includedServiceHandle);
721
722         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_service_foreach_included_services")]
723         internal static extern int BtGattServiceForeachIncludedServices(BluetoothGattAttributeHandle serviceHandle, BtGattForeachCallback callback, IntPtr userData);
724
725         // GATT Client
726
727         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_destroy")]
728         internal static extern int BtGattClientDestroy(IntPtr clientHandle);
729
730         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_create")]
731         internal static extern int BtGattClientCreate(string remoteAddress, out BluetoothGattClientHandle clientHandle);
732
733         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_get_remote_address")]
734         internal static extern int BtGattClientGetRemoteAddress(BluetoothGattClientHandle clientHandle, out string remoteAddress);
735
736         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_get_service")]
737         internal static extern int BtGattClientGetService(BluetoothGattClientHandle clientHandle, string uuid, out BluetoothGattAttributeHandle serviceHandle);
738
739         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_foreach_services")]
740         internal static extern int BtGattClientForeachServices(BluetoothGattClientHandle clientHandle, BtGattForeachCallback callback, IntPtr userData);
741
742         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_read_value")]
743         internal static extern int BtGattClientReadValue(BluetoothGattAttributeHandle gattHandle, BtGattClientRequestCompletedCallback callback, IntPtr userData);
744
745         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_client_write_value")]
746         internal static extern int BtGattClientWriteValue(BluetoothGattAttributeHandle gattHandle, BtGattClientRequestCompletedCallback callback, IntPtr userData);
747
748         // GATT Server
749
750         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_destroy")]
751         internal static extern int BtGattServerDestroy(IntPtr serverHandle);
752
753         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_create")]
754         internal static extern int BtGattServerCreate(out BluetoothGattServerHandle serverHandle);
755
756         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_initialize")]
757         internal static extern int BtGattServerInitialize();
758
759         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_deinitialize")]
760         internal static extern int BtGattServerDeinitialize();
761
762         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_set_read_value_requested_cb")]
763         internal static extern int BtGattServerSetReadValueRequestedCallback(BluetoothGattAttributeHandle gattHandle, BtGattServerReadValueRequestedCallback callback, IntPtr userData);
764
765         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_set_write_value_requested_cb")]
766         internal static extern int BtGattServerSetWriteValueRequestedCallback(BluetoothGattAttributeHandle gattHandle, BtGattServerWriteValueRequestedCallback callback, IntPtr userData);
767
768         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_set_characteristic_notification_state_change_cb")]
769         internal static extern int BtGattServeSetNotificationStateChangeCallback(BluetoothGattAttributeHandle characteristicHandle, BtGattServerNotificationStateChangeCallback callback, IntPtr userData);
770
771         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_start")]
772         internal static extern int BtGattServerStart();
773
774         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_register_service")]
775         internal static extern int BtGattServerRegisterService(BluetoothGattServerHandle serverHandle, BluetoothGattAttributeHandle serviceHandle);
776
777         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_unregister_service")]
778         internal static extern int BtGattServerUnregisterService(BluetoothGattServerHandle serverHandle, BluetoothGattAttributeHandle serviceHandle);
779
780         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_unregister_all_services")]
781         internal static extern int BtGattServerUnregisterAllServices(BluetoothGattServerHandle serverHandle);
782
783         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_get_service")]
784         internal static extern int BtGattServerGetService(BluetoothGattServerHandle serverHandle, string uuid, out BluetoothGattAttributeHandle serviceHandle);
785
786         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_foreach_services")]
787         internal static extern int BtGattServerForeachServices(BluetoothGattServerHandle serverHandle, BtGattForeachCallback callback, IntPtr userData);
788
789         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_send_response")]
790         internal static extern int BtGattServerSendResponse(int requestId, int requestType, int offset, int status, byte[] value, int valueLen);
791
792         [DllImport(Libraries.Bluetooth, EntryPoint = "bt_gatt_server_notify_characteristic_changed_value")]
793         internal static extern int BtGattServerNotify(BluetoothGattAttributeHandle characteristicHandle, BtGattServerNotificationSentCallback callback, string clientAddress, IntPtr userData);
794     }
795 }
796
797