f40c7c8cd70bb2eba38549667595818680d1652c
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Bluetooth / Tizen.Network.Bluetooth / BluetoothDevice.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 System.Collections.Generic;
19 using System.Runtime.InteropServices;
20 using System.Collections.Concurrent;
21 using System.Collections.ObjectModel;
22 using System.Collections.Specialized;
23
24 namespace Tizen.Network.Bluetooth
25 {
26     /// <summary>
27     /// This class is used to handle the connection with other devices and set authorization of other devices.<br/>
28     /// The BluetoothDevice class is used to search for services available on remote devices.
29     /// </summary>
30     /// <privilege> http://tizen.org/privilege/bluetooth </privilege>
31     /// <since_tizen> 3 </since_tizen>
32     public class BluetoothDevice
33     {
34         private event EventHandler<BondCreatedEventArgs> _bondCreated;
35         private event EventHandler<BondDestroyedEventArgs> _bondDestroyed;
36         private event EventHandler<AuthorizationChangedEventArgs> _authorizationChanged;
37         private event EventHandler<ServiceSearchedEventArgs> _serviceSearched;
38         private event EventHandler<DeviceConnectionStateChangedEventArgs> _connectionChanged;
39
40         private Interop.Bluetooth.BondCreatedCallback _bondCreatedCallback;
41         private Interop.Bluetooth.BondDestroyedCallback _bondDestroyedCallback;
42         private Interop.Bluetooth.AuthorizationChangedCallback _authorizationChangedCallback;
43         private Interop.Bluetooth.ServiceSearchedCallback _serviceSearchedCallback;
44         private Interop.Bluetooth.DeviceConnectionStateChangedCallback _connectionChangedCallback;
45
46         internal string RemoteDeviceAddress;
47         internal string RemoteDeviceName;
48         internal int RemoteDeviceRssi;
49         internal BluetoothClass RemoteDeviceClass;
50         internal Collection<string> RemoteDeviceService;
51         internal int RemoteDeviceCount;
52         internal bool RemotePaired;
53         internal bool RemoteAuthorized;
54         internal bool RemoteConnected;
55         internal BluetoothAppearanceType RemoteAppearance;
56         internal int RemoteManufLength;
57         internal string RemoteManufData;
58
59         internal BluetoothDevice()
60         {
61         }
62
63         /// <summary>
64         /// The address of the device.
65         /// </summary>
66         /// <since_tizen> 3 </since_tizen>
67         public string Address
68         {
69             get
70             {
71                 return RemoteDeviceAddress;
72             }
73         }
74         /// <summary>
75         /// The name of the device.
76         /// </summary>
77         /// <since_tizen> 3 </since_tizen>
78         public string Name
79         {
80             get
81             {
82                 return RemoteDeviceName;
83             }
84         }
85         /// <summary>
86         /// The strength indicator of received signal of the device.
87         /// </summary>
88         /// <since_tizen> 3 </since_tizen>
89         public int Rssi
90         {
91             get
92             {
93                 return RemoteDeviceRssi;
94             }
95         }
96         /// <summary>
97         /// The class of the device.
98         /// </summary>
99         /// <since_tizen> 3 </since_tizen>
100         public BluetoothClass Class
101         {
102             get
103             {
104                 return RemoteDeviceClass;
105             }
106         }
107         /// <summary>
108         /// The service UUID list of the device.
109         /// </summary>
110         /// <since_tizen> 3 </since_tizen>
111         public IEnumerable<string> ServiceUuidList
112         {
113             get
114             {
115                 return RemoteDeviceService;
116             }
117         }
118         /// <summary>
119         /// The number of services.
120         /// </summary>
121         /// <since_tizen> 3 </since_tizen>
122         public int ServiceCount
123         {
124             get
125             {
126                 return RemoteDeviceCount;
127             }
128         }
129         /// <summary>
130         /// The paired state of the device.
131         /// </summary>
132         /// <since_tizen> 3 </since_tizen>
133         public bool IsPaired
134         {
135             get
136             {
137                 return RemotePaired;
138             }
139         }
140         /// <summary>
141         /// The connection state of the device.
142         /// </summary>
143         /// <since_tizen> 3 </since_tizen>
144         public bool IsConnected
145         {
146             get
147             {
148                 return RemoteConnected;
149             }
150         }
151         /// <summary>
152         /// The authorization state of the device.
153         /// </summary>
154         /// <since_tizen> 3 </since_tizen>
155         public bool IsAuthorized
156         {
157             get
158             {
159                 return RemoteAuthorized;
160             }
161         }
162         /// <summary>
163         /// The Bluetooth appearance.
164         /// </summary>
165         /// <since_tizen> 3 </since_tizen>
166         public BluetoothAppearanceType AppearanceType
167         {
168             get
169             {
170                 return RemoteAppearance;
171             }
172         }
173
174         /// <summary>
175         /// The length of the manufacturer data.
176         /// </summary>
177         /// <since_tizen> 3 </since_tizen>
178         public int ManufacturerDataLength
179         {
180             get
181             {
182                 return RemoteManufLength;
183             }
184         }
185         /// <summary>
186         /// The manufacturer data.
187         /// </summary>
188         /// <since_tizen> 3 </since_tizen>
189         public string ManufacturerData
190         {
191             get
192             {
193                 return RemoteManufData;
194             }
195         }
196
197         /// <summary>
198         /// The BondCreated event is raised when the process of creating the bond is finished.
199         /// </summary>
200         /// <since_tizen> 3 </since_tizen>
201         public event EventHandler<BondCreatedEventArgs> BondCreated
202         {
203             add
204             {
205                 if (_bondCreated == null)
206                 {
207                     RegisterBondCreatedEvent();
208                 }
209                 _bondCreated += value;
210             }
211             remove
212             {
213                 _bondCreated -= value;
214                 if (_bondCreated == null)
215                 {
216                     UnregisterBondCreatedEvent();
217                 }
218             }
219         }
220
221         /// <summary>
222         /// The BondDestroyed event is raised when the bond is destroyed.
223         /// </summary>
224         /// <since_tizen> 3 </since_tizen>
225         public event EventHandler<BondDestroyedEventArgs> BondDestroyed
226         {
227             add
228             {
229                 if (_bondDestroyed == null)
230                 {
231                     RegisterBondDestroyedEvent();
232                 }
233                 _bondDestroyed += value;
234             }
235             remove
236             {
237                 _bondDestroyed -= value;
238                 if (_bondDestroyed == null)
239                 {
240                     UnregisterBondDestroyedEvent();
241                 }
242             }
243         }
244
245         /// <summary>
246         /// The AuthorizationChanged event is raised when the authorization of the device is changed.
247         /// </summary>
248         /// <since_tizen> 3 </since_tizen>
249         public event EventHandler<AuthorizationChangedEventArgs> AuthorizationChanged
250         {
251             add
252             {
253                 if (_authorizationChanged == null)
254                 {
255                     RegisterAuthorizationChangedEvent();
256                 }
257                 _authorizationChanged += value;
258             }
259             remove
260             {
261                 _authorizationChanged -= value;
262                 if (_authorizationChanged == null)
263                 {
264                     UnregisterAuthorizationChangedEvent();
265                 }
266             }
267         }
268
269         /// <summary>
270         /// The ServiceSearched event is raised when the process of service searched is finished.
271         /// </summary>
272         /// <since_tizen> 3 </since_tizen>
273         public event EventHandler<ServiceSearchedEventArgs> ServiceSearched
274         {
275             add
276             {
277                 if (_serviceSearched == null)
278                 {
279                     RegisterServiceSearchedEvent();
280                 }
281                 _serviceSearched += value;
282             }
283             remove
284             {
285                 _serviceSearched -= value;
286                 if (_serviceSearched == null)
287                 {
288                     UnregisterServiceSearchedEvent();
289                 }
290             }
291         }
292
293         /// <summary>
294         /// The ConnectionStateChanged event is raised when the connection state is changed.
295         /// </summary>
296         /// <since_tizen> 3 </since_tizen>
297         public event EventHandler<DeviceConnectionStateChangedEventArgs> ConnectionStateChanged
298         {
299             add
300             {
301                 if (_connectionChanged == null)
302                 {
303                     RegisterConnectionChangedEvent();
304                 }
305                 _connectionChanged += value;
306             }
307             remove
308             {
309                 _connectionChanged -= value;
310                 if (_connectionChanged == null)
311                 {
312                     UnregisterConnectionChangedEvent();
313                 }
314             }
315         }
316
317         private void RegisterBondCreatedEvent()
318         {
319             _bondCreatedCallback = (int result, ref BluetoothDeviceStruct device, IntPtr userData) =>
320             {
321                 if (_bondCreated != null)
322                 {
323                     BluetoothError res = (BluetoothError)result;
324                     _bondCreated(null, new BondCreatedEventArgs(res, BluetoothUtils.ConvertStructToDeviceClass(device)));
325                 }
326             };
327             int ret = Interop.Bluetooth.SetBondCreatedCallback(_bondCreatedCallback, IntPtr.Zero);
328             if (ret != (int)BluetoothError.None)
329             {
330                 Log.Error(Globals.LogTag, "Failed to set bond created callback, Error - " + (BluetoothError)ret);
331             }
332         }
333
334         private void UnregisterBondCreatedEvent()
335         {
336             int ret = Interop.Bluetooth.UnsetBondCreatedCallback();
337             if (ret != (int)BluetoothError.None)
338             {
339                 Log.Error(Globals.LogTag, "Failed to unset bond created callback, Error - " + (BluetoothError)ret);
340             }
341         }
342
343         private void RegisterBondDestroyedEvent()
344         {
345             _bondDestroyedCallback = (int result, string deviceAddress, IntPtr userData) =>
346             {
347                 if (_bondDestroyed != null)
348                 {
349                     BluetoothError res = (BluetoothError)result;
350                     _bondDestroyed(null, new BondDestroyedEventArgs(res, deviceAddress));
351                 }
352             };
353             int ret = Interop.Bluetooth.SetBondDestroyedCallback(_bondDestroyedCallback, IntPtr.Zero);
354             if (ret != (int)BluetoothError.None)
355             {
356                 Log.Error(Globals.LogTag, "Failed to set bond destroyed callback, Error - " + (BluetoothError)ret);
357             }
358         }
359
360         private void UnregisterBondDestroyedEvent()
361         {
362             int ret = Interop.Bluetooth.UnsetBondDestroyedCallback();
363             if (ret != (int)BluetoothError.None)
364             {
365                 Log.Error(Globals.LogTag, "Failed to unset bond destroyed callback, Error - " + (BluetoothError)ret);
366             }
367         }
368
369         private void RegisterServiceSearchedEvent()
370         {
371             _serviceSearchedCallback = (int result, ref BluetoothDeviceSdpStruct sdp, IntPtr userData) =>
372             {
373                 Log.Info(Globals.LogTag, "Servicesearched cb is called");
374                 if (_serviceSearched != null)
375                 {
376                     BluetoothError res = (BluetoothError)result;
377                     _serviceSearched(null, new ServiceSearchedEventArgs(res, BluetoothUtils.ConvertStructToSdpData(sdp)));
378                 }
379             };
380             int ret = Interop.Bluetooth.SetServiceSearchedCallback(_serviceSearchedCallback, IntPtr.Zero);
381             if (ret != (int)BluetoothError.None)
382             {
383                 Log.Error(Globals.LogTag, "Failed to set service searched callback, Error - " + (BluetoothError)ret);
384             }
385         }
386
387         private void UnregisterServiceSearchedEvent()
388         {
389             int ret = Interop.Bluetooth.UnsetServiceSearchedCallback();
390             if (ret != (int)BluetoothError.None)
391             {
392                 Log.Error(Globals.LogTag, "Failed to unset service searched callback, Error - " + (BluetoothError)ret);
393             }
394         }
395
396         private void RegisterAuthorizationChangedEvent()
397         {
398             _authorizationChangedCallback = (int authorization, string deviceAddress, IntPtr userData) =>
399             {
400                 Log.Info(Globals.LogTag, "Authorization changed cb is called");
401                 if (_authorizationChanged != null)
402                 {
403                     BluetoothAuthorizationType auth = (BluetoothAuthorizationType)authorization;
404                     _authorizationChanged(null, new AuthorizationChangedEventArgs(auth, deviceAddress));
405                 }
406             };
407             int ret = Interop.Bluetooth.SetAuthorizationChangedCallback(_authorizationChangedCallback, IntPtr.Zero);
408             if (ret != (int)BluetoothError.None)
409             {
410                 Log.Error(Globals.LogTag, "Failed to set authroization changed callback, Error - " + (BluetoothError)ret);
411             }
412         }
413
414         private void UnregisterAuthorizationChangedEvent()
415         {
416             int ret = Interop.Bluetooth.UnsetAuthorizationChangedCallback();
417             if (ret != (int)BluetoothError.None)
418             {
419                 Log.Error(Globals.LogTag, "Failed to unset authroization changed callback, Error - " + (BluetoothError)ret);
420             }
421         }
422
423         private void RegisterConnectionChangedEvent()
424         {
425             _connectionChangedCallback = (bool connected, ref BluetoothDeviceConnectionStruct device, IntPtr userData) =>
426             {
427                 Log.Info(Globals.LogTag, "Connection state changed cb is called");
428                 if (_connectionChanged != null)
429                 {
430                     _connectionChanged(null, new DeviceConnectionStateChangedEventArgs(connected, BluetoothUtils.ConvertStructToConnectionData(device)));
431                 }
432             };
433
434             int ret = Interop.Bluetooth.SetConnectionStateChangedCallback(_connectionChangedCallback, IntPtr.Zero);
435             if (ret != (int)BluetoothError.None)
436             {
437                 Log.Error(Globals.LogTag, "Failed to set connection state changed callback, Error - " + (BluetoothError)ret);
438             }
439         }
440
441         private void UnregisterConnectionChangedEvent()
442         {
443             int ret = Interop.Bluetooth.UnsetConnectionStateChangedCallback();
444             if (ret != (int)BluetoothError.None)
445             {
446                 Log.Error(Globals.LogTag, "Failed to unset connection state changed callback, Error - " + (BluetoothError)ret);
447             }
448         }
449
450         /// <summary>
451         /// Creates a bond with the remote Bluetooth device.
452         /// </summary>
453         /// <remarks>
454         /// The Bluetooth must be enabled and the remote device must be discoverable by StartDiscovery(). The bond can be destroyed by DestroyBond().
455         /// The bonding request can be cancelled by CancelBonding(). If this succeeds, the BondCreated event will be invoked.
456         /// </remarks>
457         /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not enabled
458         /// or when the create bonding process to the remote device fails.</exception>
459         /// <since_tizen> 3 </since_tizen>
460         public void CreateBond()
461         {
462             if (BluetoothAdapter.IsBluetoothEnabled)
463             {
464                 int ret = Interop.Bluetooth.CreateBond(RemoteDeviceAddress);
465                 if (ret != (int)BluetoothError.None)
466                 {
467                     Log.Error(Globals.LogTag, "Failed to create bond, Error - " + (BluetoothError)ret);
468                     BluetoothErrorFactory.ThrowBluetoothException(ret);
469                 }
470             }
471         }
472
473         /// <summary>
474         /// Cancels the bonding process.
475         /// </summary>
476         /// <remarks>
477         /// Bonding must be in progress by CreateBond().
478         /// </remarks>
479         /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not enabled
480         /// or when the cancel bonding procedure to remote device fails.</exception>
481         /// <since_tizen> 3 </since_tizen>
482         public void CancelBonding()
483         {
484             int ret = Interop.Bluetooth.CancelBonding();
485             if (ret != (int)BluetoothError.None)
486             {
487                 Log.Error(Globals.LogTag, "Failed to cancel bonding process, Error - " + (BluetoothError)ret);
488                 BluetoothErrorFactory.ThrowBluetoothException(ret);
489             }
490         }
491
492         /// <summary>
493         /// Destroys the bond.
494         /// </summary>
495         /// <remarks>
496         /// The Bluetooth must be enabled and the bond must be created by CreateBond().
497         /// If this succeeds, the BondDestroyed event will be invoked.
498         /// </remarks>
499         /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not enabled
500         /// or when the destroy bonding procedure fails.</exception>
501         /// <since_tizen> 3 </since_tizen>
502         public void DestroyBond()
503         {
504             if (BluetoothAdapter.IsBluetoothEnabled)
505             {
506                 int ret = Interop.Bluetooth.DestroyBond(RemoteDeviceAddress);
507                 if (ret != (int)BluetoothError.None)
508                 {
509                     Log.Error(Globals.LogTag, "Failed to destroy bond, Error - " + (BluetoothError)ret);
510                     BluetoothErrorFactory.ThrowBluetoothException(ret);
511                 }
512             }
513         }
514
515         /// <summary>
516         /// Sets an alias for the bonded device.
517         /// </summary>
518         /// <remarks>
519         /// The Bluetooth must be enabled and the bond must be created by CreateBond().
520         /// </remarks>
521         /// <param name="aliasName">The alias name of the remote device.</param>
522         /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not enabled
523         /// or when the set alias name to remote device fails.</exception>
524         /// <since_tizen> 3 </since_tizen>
525         public void SetAlias(string aliasName)
526         {
527             if (BluetoothAdapter.IsBluetoothEnabled)
528             {
529                 int ret = Interop.Bluetooth.SetAlias(RemoteDeviceAddress, aliasName);
530                 if (ret != (int)BluetoothError.None)
531                 {
532                     Log.Error(Globals.LogTag, "Failed to set alias name, Error - " + (BluetoothError)ret);
533                     BluetoothErrorFactory.ThrowBluetoothException(ret);
534                 }
535             }
536         }
537
538         /// <summary>
539         /// Sets the authorization of a bonded device.
540         /// </summary>
541         /// <remarks>
542         /// The Bluetooth must be enabled and the bond must be created by CreateBond().
543         /// If this succeeds, the AuthorizationChanged event will be invoked.
544         /// </remarks>
545         /// <param name="authorizationState">The authorization state.</param>
546         /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not enabled
547         /// or when the set authorization to remote device fails.</exception>
548         /// <since_tizen> 3 </since_tizen>
549         public void SetAuthorization(BluetoothAuthorizationType authorizationState)
550         {
551             if (BluetoothAdapter.IsBluetoothEnabled)
552             {
553                 int ret = Interop.Bluetooth.SetAuthorization(RemoteDeviceAddress, (int)authorizationState);
554                 if (ret != (int)BluetoothError.None)
555                 {
556                     Log.Error(Globals.LogTag, "Failed to set authroization state, Error - " + (BluetoothError)ret);
557                     BluetoothErrorFactory.ThrowBluetoothException(ret);
558                 }
559             }
560         }
561
562         /// <summary>
563         /// Gets the mask from the UUID.
564         /// </summary>
565         /// <returns>The service mask list converted from the given UUID list.</returns>
566         /// <param name="uuids">The UUID list of the device.</param>
567         /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not enabled
568         /// or when the get Mask from UUID fails.</exception>
569         /// <since_tizen> 3 </since_tizen>
570         public BluetoothServiceClassType GetMaskFromUuid(string[] uuids)
571         {
572             BluetoothServiceClassType serviceMask;
573
574             int ret = Interop.Bluetooth.GetMaskFromUuid(uuids, uuids.Length, out serviceMask);
575             if (ret != (int)BluetoothError.None)
576             {
577                 Log.Error(Globals.LogTag, "Failed to get service mask, Error - " + (BluetoothError)ret);
578                 BluetoothErrorFactory.ThrowBluetoothException(ret);
579             }
580             return serviceMask;
581         }
582
583         /// <summary>
584         /// Starts the search for services supported by the specified device.
585         /// </summary>
586         /// <remarks>
587         /// The Bluetooth must be enabled and remote device must be discoverable by StartDiscovery(). The bond must be created by CreateBond().
588         /// If this succeeds, the ServiceSearched event will be invoked.
589         /// </remarks>
590         /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not enabled
591         /// or when the remote device service search fails.</exception>
592         /// <since_tizen> 3 </since_tizen>
593         public void StartServiceSearch()
594         {
595             Log.Info(Globals.LogTag, "startservicesearch entry");
596             if (BluetoothAdapter.IsBluetoothEnabled)
597             {
598                 int ret = Interop.Bluetooth.StartServiceSearch(RemoteDeviceAddress);
599                 if (ret != (int)BluetoothError.None)
600                 {
601                     Log.Error(Globals.LogTag, "Failed to start service search, Error - " + (BluetoothError)ret);
602                     BluetoothErrorFactory.ThrowBluetoothException(ret);
603                 }
604             }
605         }
606
607         /// <summary>
608         /// Gets the connected profiles.
609         /// </summary>
610         /// <remarks>
611         /// The Bluetooth must be enabled.
612         /// </remarks>
613         /// <returns>The connected Bluetooth profiles.</returns>
614         /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not enabled
615         /// or when there is no BT connection.</exception>
616         /// <since_tizen> 3 </since_tizen>
617         public IEnumerable<BluetoothProfileType> GetConnectedProfiles()
618         {
619             if (BluetoothAdapter.IsBluetoothEnabled)
620             {
621                 List<BluetoothProfileType> profileList = new List<BluetoothProfileType>();
622                 Interop.Bluetooth.ConnectedProfileCallback callback = (int profile, IntPtr userData) =>
623                 {
624                     if (!profile.Equals(null))
625                     {
626                         profileList.Add((BluetoothProfileType)profile);
627                     }
628                     return true;
629                 };
630                 int ret = Interop.Bluetooth.GetConnectedProfiles(RemoteDeviceAddress, callback, IntPtr.Zero);
631                 if (ret != (int)BluetoothError.None)
632                 {
633                     Log.Error(Globals.LogTag, "Failed to get connected profiles, Error - " + (BluetoothError)ret);
634                     BluetoothErrorFactory.ThrowBluetoothException(ret);
635                 }
636                 return profileList;
637             }
638             else
639             {
640                 return null;
641             }
642         }
643
644         /// <summary>
645         /// Determines if profile is connected to the specified remote device.
646         /// </summary>
647         /// <remarks>
648         /// The Bluetooth must be enabled.
649         /// </remarks>
650         /// <returns><c>true</c> if profile is connected, otherwise <c>false</c>.</returns>
651         /// <param name="profileType">The Bluetooth profile type.</param>
652         /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not enabled
653         /// or when there is no BT connection.</exception>
654         /// <since_tizen> 3 </since_tizen>
655         public bool IsProfileConnected(BluetoothProfileType profileType)
656         {
657             if (BluetoothAdapter.IsBluetoothEnabled)
658             {
659                 bool isConnected;
660                 int ret = Interop.Bluetooth.IsProfileConnected(RemoteDeviceAddress, (int)profileType, out isConnected);
661                 if (ret != (int)BluetoothError.None)
662                 {
663                     Log.Error(Globals.LogTag, "Failed to get profile connected state, Error - " + (BluetoothError)ret);
664                 }
665                 return isConnected;
666             }
667             else
668             {
669                 return false;
670             }
671         }
672
673         /// <summary>
674         /// Returns the instance of the Bluetooth profile type.
675         /// </summary>
676         /// <remarks>
677         /// The Bluetooth must be enabled.
678         /// </remarks>
679         /// <returns>The profile instance.</returns>
680         /// <since_tizen> 3 </since_tizen>
681         public T GetProfile<T>() where T : BluetoothProfile
682         {
683             // TODO : Need to check capability of supporting profiles
684             var profile = Activator.CreateInstance<T>();
685             profile.RemoteAddress = RemoteDeviceAddress;
686             return profile;
687         }
688
689         /// <summary>
690         /// Creates the client socket.
691         /// </summary>
692         /// <returns>The IBluetoothClientSocket instance.</returns>
693         /// <param name="serviceUuid">The UUID of the service.</param>
694         /// <since_tizen> 3 </since_tizen>
695         public IBluetoothClientSocket CreateSocket(string serviceUuid)
696         {
697             BluetoothSocket clientSocket = new BluetoothSocket();
698             clientSocket.remoteAddress = this.Address;
699             clientSocket.serviceUuid = serviceUuid;
700             return (IBluetoothClientSocket)clientSocket;
701         }
702     }
703 }