X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.Network.Bluetooth%2FTizen.Network.Bluetooth%2FBluetoothDevice.cs;h=6f3586f7b05706a304ed88aff1a526281250ae7b;hb=8249d6a42f7f4bbadc05791d46bdf79a3df10775;hp=b0debee213ebffba841e9e630876357324f34cbb;hpb=ffbf5f5fee4c1e8a04e64ccb0e4f7396ce561638;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git
diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothDevice.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothDevice.cs
index b0debee..6f3586f 100644
--- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothDevice.cs
+++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothDevice.cs
@@ -20,14 +20,17 @@ using System.Runtime.InteropServices;
using System.Collections.Concurrent;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
+using System.Reflection;
+using System.ComponentModel;
namespace Tizen.Network.Bluetooth
{
///
- /// This class is used to handle the connection with other devices and set authorization of other devices.
+ /// This class is used to handle the connection with other devices and set authorization of other devices.
/// The BluetoothDevice class is used to search for services available on remote devices.
///
/// http://tizen.org/privilege/bluetooth
+ /// 3
public class BluetoothDevice
{
private event EventHandler _bondCreated;
@@ -41,6 +44,7 @@ namespace Tizen.Network.Bluetooth
private Interop.Bluetooth.AuthorizationChangedCallback _authorizationChangedCallback;
private Interop.Bluetooth.ServiceSearchedCallback _serviceSearchedCallback;
private Interop.Bluetooth.DeviceConnectionStateChangedCallback _connectionChangedCallback;
+ private Interop.Bluetooth.ConnectedProfileCallback _connectedProfileCallback;
internal string RemoteDeviceAddress;
internal string RemoteDeviceName;
@@ -60,8 +64,19 @@ namespace Tizen.Network.Bluetooth
}
///
+ /// The constructor
+ ///
+ /// 9
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public BluetoothDevice(BluetoothLeDevice leDevice)
+ {
+ RemoteDeviceAddress = leDevice?.RemoteAddress;
+ }
+
+ ///
/// The address of the device.
///
+ /// 3
public string Address
{
get
@@ -72,6 +87,7 @@ namespace Tizen.Network.Bluetooth
///
/// The name of the device.
///
+ /// 3
public string Name
{
get
@@ -82,6 +98,7 @@ namespace Tizen.Network.Bluetooth
///
/// The strength indicator of received signal of the device.
///
+ /// 3
public int Rssi
{
get
@@ -92,6 +109,7 @@ namespace Tizen.Network.Bluetooth
///
/// The class of the device.
///
+ /// 3
public BluetoothClass Class
{
get
@@ -102,6 +120,7 @@ namespace Tizen.Network.Bluetooth
///
/// The service UUID list of the device.
///
+ /// 3
public IEnumerable ServiceUuidList
{
get
@@ -112,6 +131,7 @@ namespace Tizen.Network.Bluetooth
///
/// The number of services.
///
+ /// 3
public int ServiceCount
{
get
@@ -122,6 +142,7 @@ namespace Tizen.Network.Bluetooth
///
/// The paired state of the device.
///
+ /// 3
public bool IsPaired
{
get
@@ -132,6 +153,7 @@ namespace Tizen.Network.Bluetooth
///
/// The connection state of the device.
///
+ /// 3
public bool IsConnected
{
get
@@ -142,6 +164,7 @@ namespace Tizen.Network.Bluetooth
///
/// The authorization state of the device.
///
+ /// 3
public bool IsAuthorized
{
get
@@ -152,6 +175,7 @@ namespace Tizen.Network.Bluetooth
///
/// The Bluetooth appearance.
///
+ /// 3
public BluetoothAppearanceType AppearanceType
{
get
@@ -163,6 +187,7 @@ namespace Tizen.Network.Bluetooth
///
/// The length of the manufacturer data.
///
+ /// 3
public int ManufacturerDataLength
{
get
@@ -173,6 +198,7 @@ namespace Tizen.Network.Bluetooth
///
/// The manufacturer data.
///
+ /// 3
public string ManufacturerData
{
get
@@ -184,6 +210,7 @@ namespace Tizen.Network.Bluetooth
///
/// The BondCreated event is raised when the process of creating the bond is finished.
///
+ /// 3
public event EventHandler BondCreated
{
add
@@ -207,6 +234,7 @@ namespace Tizen.Network.Bluetooth
///
/// The BondDestroyed event is raised when the bond is destroyed.
///
+ /// 3
public event EventHandler BondDestroyed
{
add
@@ -230,6 +258,7 @@ namespace Tizen.Network.Bluetooth
///
/// The AuthorizationChanged event is raised when the authorization of the device is changed.
///
+ /// 3
public event EventHandler AuthorizationChanged
{
add
@@ -253,6 +282,7 @@ namespace Tizen.Network.Bluetooth
///
/// The ServiceSearched event is raised when the process of service searched is finished.
///
+ /// 3
public event EventHandler ServiceSearched
{
add
@@ -276,6 +306,7 @@ namespace Tizen.Network.Bluetooth
///
/// The ConnectionStateChanged event is raised when the connection state is changed.
///
+ /// 3
public event EventHandler ConnectionStateChanged
{
add
@@ -436,8 +467,9 @@ namespace Tizen.Network.Bluetooth
/// The Bluetooth must be enabled and the remote device must be discoverable by StartDiscovery(). The bond can be destroyed by DestroyBond().
/// The bonding request can be cancelled by CancelBonding(). If this succeeds, the BondCreated event will be invoked.
///
- /// Thrown when the BT/BTLE is not enabled
+ /// Thrown when the BT/BTLE is not enabled
/// or when the create bonding process to the remote device fails.
+ /// 3
public void CreateBond()
{
if (BluetoothAdapter.IsBluetoothEnabled)
@@ -457,8 +489,9 @@ namespace Tizen.Network.Bluetooth
///
/// Bonding must be in progress by CreateBond().
///
- /// Thrown when the BT/BTLE is not enabled
+ /// Thrown when the BT/BTLE is not enabled
/// or when the cancel bonding procedure to remote device fails.
+ /// 3
public void CancelBonding()
{
int ret = Interop.Bluetooth.CancelBonding();
@@ -476,8 +509,9 @@ namespace Tizen.Network.Bluetooth
/// The Bluetooth must be enabled and the bond must be created by CreateBond().
/// If this succeeds, the BondDestroyed event will be invoked.
///
- /// Thrown when the BT/BTLE is not enabled
+ /// Thrown when the BT/BTLE is not enabled
/// or when the destroy bonding procedure fails.
+ /// 3
public void DestroyBond()
{
if (BluetoothAdapter.IsBluetoothEnabled)
@@ -498,8 +532,9 @@ namespace Tizen.Network.Bluetooth
/// The Bluetooth must be enabled and the bond must be created by CreateBond().
///
/// The alias name of the remote device.
- /// Thrown when the BT/BTLE is not enabled
+ /// Thrown when the BT/BTLE is not enabled
/// or when the set alias name to remote device fails.
+ /// 3
public void SetAlias(string aliasName)
{
if (BluetoothAdapter.IsBluetoothEnabled)
@@ -521,8 +556,9 @@ namespace Tizen.Network.Bluetooth
/// If this succeeds, the AuthorizationChanged event will be invoked.
///
/// The authorization state.
- /// Thrown when the BT/BTLE is not enabled
+ /// Thrown when the BT/BTLE is not enabled
/// or when the set authorization to remote device fails.
+ /// 3
public void SetAuthorization(BluetoothAuthorizationType authorizationState)
{
if (BluetoothAdapter.IsBluetoothEnabled)
@@ -541,8 +577,9 @@ namespace Tizen.Network.Bluetooth
///
/// The service mask list converted from the given UUID list.
/// The UUID list of the device.
- /// Thrown when the BT/BTLE is not enabled
+ /// Thrown when the BT/BTLE is not enabled
/// or when the get Mask from UUID fails.
+ /// 3
public BluetoothServiceClassType GetMaskFromUuid(string[] uuids)
{
BluetoothServiceClassType serviceMask;
@@ -563,8 +600,9 @@ namespace Tizen.Network.Bluetooth
/// The Bluetooth must be enabled and remote device must be discoverable by StartDiscovery(). The bond must be created by CreateBond().
/// If this succeeds, the ServiceSearched event will be invoked.
///
- /// Thrown when the BT/BTLE is not enabled
+ /// Thrown when the BT/BTLE is not enabled
/// or when the remote device service search fails.
+ /// 3
public void StartServiceSearch()
{
Log.Info(Globals.LogTag, "startservicesearch entry");
@@ -586,14 +624,15 @@ namespace Tizen.Network.Bluetooth
/// The Bluetooth must be enabled.
///
/// The connected Bluetooth profiles.
- /// Thrown when the BT/BTLE is not enabled
+ /// Thrown when the BT/BTLE is not enabled
/// or when there is no BT connection.
+ /// 3
public IEnumerable GetConnectedProfiles()
{
if (BluetoothAdapter.IsBluetoothEnabled)
{
List profileList = new List();
- Interop.Bluetooth.ConnectedProfileCallback callback = (int profile, IntPtr userData) =>
+ _connectedProfileCallback = (int profile, IntPtr userData) =>
{
if (!profile.Equals(null))
{
@@ -601,7 +640,7 @@ namespace Tizen.Network.Bluetooth
}
return true;
};
- int ret = Interop.Bluetooth.GetConnectedProfiles(RemoteDeviceAddress, callback, IntPtr.Zero);
+ int ret = Interop.Bluetooth.GetConnectedProfiles(RemoteDeviceAddress, _connectedProfileCallback, IntPtr.Zero);
if (ret != (int)BluetoothError.None)
{
Log.Error(Globals.LogTag, "Failed to get connected profiles, Error - " + (BluetoothError)ret);
@@ -623,8 +662,9 @@ namespace Tizen.Network.Bluetooth
///
/// true if profile is connected, otherwise false.
/// The Bluetooth profile type.
- /// Thrown when the BT/BTLE is not enabled
+ /// Thrown when the BT/BTLE is not enabled
/// or when there is no BT connection.
+ /// 3
public bool IsProfileConnected(BluetoothProfileType profileType)
{
if (BluetoothAdapter.IsBluetoothEnabled)
@@ -649,34 +689,21 @@ namespace Tizen.Network.Bluetooth
///
/// The Bluetooth must be enabled.
///
+ /// The profile instance.
+ /// 3
public T GetProfile() where T : BluetoothProfile
{
- /*
- * FIXME: Find a proper way for dynamic allocation.
- */
- T profile = null;
- String type = typeof(T).ToString();
- if (type.Equals("Tizen.Network.Bluetooth.BluetoothAudio"))
- {
- BluetoothAudio audio = new BluetoothAudio();
- profile = (audio as T);
- }
- else if (type.Equals("Tizen.Network.Bluetooth.BluetoothAvrcp"))
- {
- BluetoothAvrcp avrcp = new BluetoothAvrcp();
- profile = (avrcp as T);
- }
- else if (type.Equals("Tizen.Network.Bluetooth.BluetoothHid"))
+ try
{
- BluetoothHid hid = new BluetoothHid();
- profile = (hid as T);
+ // TODO : Need to check capability of supporting profiles
+ var profile = (T)Activator.CreateInstance(typeof(T), true);
+ profile.RemoteAddress = RemoteDeviceAddress;
+ return profile;
}
-
- if (profile != null)
+ catch (TargetInvocationException err)
{
- profile.RemoteAddress = RemoteDeviceAddress;
+ throw err.InnerException;
}
- return profile;
}
///
@@ -684,6 +711,7 @@ namespace Tizen.Network.Bluetooth
///
/// The IBluetoothClientSocket instance.
/// The UUID of the service.
+ /// 3
public IBluetoothClientSocket CreateSocket(string serviceUuid)
{
BluetoothSocket clientSocket = new BluetoothSocket();