3 namespace Tizen.Network.Bluetooth
6 /// A class which is used to handle the connection to Bluetooth HID like keyboards and mouse.
8 /// <privilege> http://tizen.org/privilege/bluetooth </privilege>
9 public class BluetoothHid : BluetoothProfile
11 internal BluetoothHid()
16 /// The HidConnectionStateChanged event is called when the HID host connection state is changed.
18 public event EventHandler<HidConnectionStateChangedEventArgs> HidConnectionStateChanged
22 BluetoothHidImpl.Instance.HidConnectionStateChanged += value;
26 BluetoothHidImpl.Instance.HidConnectionStateChanged -= value;
31 /// Connects the remote device with the HID service.
34 /// The device must be bonded with the remote device by CreateBond().
35 /// If connection request succeeds, the HidConnectionStateChanged event will be invoked.
37 /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
38 /// or when the connection attempt to the remote device fails.</exception>
41 if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
43 int ret = BluetoothHidImpl.Instance.Connect(RemoteAddress);
44 if (ret != (int)BluetoothError.None)
46 Log.Error(Globals.LogTag, "Failed to Connect - " + (BluetoothError)ret);
47 BluetoothErrorFactory.ThrowBluetoothException(ret);
52 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
57 /// Disconnects the remote device with the HID service.
59 /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
60 /// or when the disconnection attempt to the remote device fails.</exception>
61 public void Disconnect()
63 if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
65 int ret = BluetoothHidImpl.Instance.Disconnect(RemoteAddress);
66 if (ret != (int)BluetoothError.None)
68 Log.Error(Globals.LogTag, "Failed to Disconnect - " + (BluetoothError)ret);
69 BluetoothErrorFactory.ThrowBluetoothException(ret);
74 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);