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