<h2>Table of Contents</h2>
<ul class="toc">
<li>1. <a href="#typedefs-section">Type Definitions</a><ul class="toc">
-<li>1.1. <a href="#BluetoothAddress">BluetoothAddress</a>
+<li>
+ 1.1. <a href="#BluetoothAddress">BluetoothAddress</a>
</li>
-<li>1.2. <a href="#BluetoothUUID">BluetoothUUID</a>
+<li>
+ 1.2. <a href="#BluetoothUUID">BluetoothUUID</a>
</li>
-<li>1.3. <a href="#BluetoothSocketState">BluetoothSocketState</a>
+<li>
+ 1.3. <a href="#BluetoothSocketState">BluetoothSocketState</a>
</li>
-<li>1.4. <a href="#BluetoothProfileType">BluetoothProfileType</a>
+<li>
+ 1.4. <a href="#BluetoothProfileType">BluetoothProfileType</a>
</li>
-<li>1.5. <a href="#BluetoothHealthChannelType">BluetoothHealthChannelType</a>
+<li>
+ 1.5. <a href="#BluetoothHealthChannelType">BluetoothHealthChannelType</a>
</li>
-<li>1.6. <a href="#BluetoothLESolicitationUUID">BluetoothLESolicitationUUID</a>
+<li>
+ 1.6. <a href="#BluetoothLESolicitationUUID">BluetoothLESolicitationUUID</a>
</li>
-<li>1.7. <a href="#BluetoothAdvertisePacketType">BluetoothAdvertisePacketType</a>
+<li>
+ 1.7. <a href="#BluetoothAdvertisePacketType">BluetoothAdvertisePacketType</a>
</li>
-<li>1.8. <a href="#BluetoothAdvertisingState">BluetoothAdvertisingState</a>
+<li>
+ 1.8. <a href="#BluetoothAdvertisingState">BluetoothAdvertisingState</a>
</li>
-<li>1.9. <a href="#BluetoothAdvertisingMode">BluetoothAdvertisingMode</a>
+<li>
+ 1.9. <a href="#BluetoothAdvertisingMode">BluetoothAdvertisingMode</a>
</li>
</ul>
</li>
<tr>
<td><a href="#BluetoothManager">BluetoothManager</a></td>
<td>
-<a href="#BluetoothAdapter">BluetoothAdapter</a> <a href="#BluetoothManager::getDefaultAdapter">getDefaultAdapter</a> ()<br>
- <a href="#BluetoothLEAdapter">BluetoothLEAdapter</a> <a href="#BluetoothManager::getLEAdapter">getLEAdapter</a> ()</td>
+<div>
+<a href="#BluetoothAdapter">BluetoothAdapter</a> <a href="#BluetoothManager::getDefaultAdapter">getDefaultAdapter</a> ()</div>
+<div>
+<a href="#BluetoothLEAdapter">BluetoothLEAdapter</a> <a href="#BluetoothManager::getLEAdapter">getLEAdapter</a> ()</div>
+</td>
</tr>
<tr>
<td><a href="#BluetoothAdapter">BluetoothAdapter</a></td>
-<td>void <a href="#BluetoothAdapter::setName">setName</a> (DOMString name, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothAdapter::setPowered">setPowered</a> (boolean state, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothAdapter::setChangeListener">setChangeListener</a> (<a href="#BluetoothAdapterChangeCallback">BluetoothAdapterChangeCallback</a> listener)<br>
- void <a href="#BluetoothAdapter::unsetChangeListener">unsetChangeListener</a> ()<br>
- void <a href="#BluetoothAdapter::discoverDevices">discoverDevices</a> (<a href="#BluetoothDiscoverDevicesSuccessCallback">BluetoothDiscoverDevicesSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothAdapter::stopDiscovery">stopDiscovery</a> (optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothAdapter::getKnownDevices">getKnownDevices</a> (<a href="#BluetoothDeviceArraySuccessCallback">BluetoothDeviceArraySuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothAdapter::getDevice">getDevice</a> (<a href="#BluetoothAddress">BluetoothAddress</a> address, <a href="#BluetoothDeviceSuccessCallback">BluetoothDeviceSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothAdapter::createBonding">createBonding</a> (<a href="#BluetoothAddress">BluetoothAddress</a> address, <a href="#BluetoothDeviceSuccessCallback">BluetoothDeviceSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothAdapter::destroyBonding">destroyBonding</a> (<a href="#BluetoothAddress">BluetoothAddress</a> address, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothAdapter::registerRFCOMMServiceByUUID">registerRFCOMMServiceByUUID</a> (<a href="#BluetoothUUID">BluetoothUUID</a> uuid, DOMString name, <a href="#BluetoothServiceSuccessCallback">BluetoothServiceSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- <a href="#BluetoothProfileHandler">BluetoothProfileHandler</a> <a href="#BluetoothAdapter::getBluetoothProfileHandler">getBluetoothProfileHandler</a> (<a href="#BluetoothProfileType">BluetoothProfileType</a> profileType)</td>
+<td>
+<div>void <a href="#BluetoothAdapter::setName">setName</a> (DOMString name, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothAdapter::setChangeListener">setChangeListener</a> (<a href="#BluetoothAdapterChangeCallback">BluetoothAdapterChangeCallback</a> listener)</div>
+<div>void <a href="#BluetoothAdapter::unsetChangeListener">unsetChangeListener</a> ()</div>
+<div>void <a href="#BluetoothAdapter::discoverDevices">discoverDevices</a> (<a href="#BluetoothDiscoverDevicesSuccessCallback">BluetoothDiscoverDevicesSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothAdapter::stopDiscovery">stopDiscovery</a> (optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothAdapter::getKnownDevices">getKnownDevices</a> (<a href="#BluetoothDeviceArraySuccessCallback">BluetoothDeviceArraySuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothAdapter::getDevice">getDevice</a> (<a href="#BluetoothAddress">BluetoothAddress</a> address, <a href="#BluetoothDeviceSuccessCallback">BluetoothDeviceSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothAdapter::createBonding">createBonding</a> (<a href="#BluetoothAddress">BluetoothAddress</a> address, <a href="#BluetoothDeviceSuccessCallback">BluetoothDeviceSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothAdapter::destroyBonding">destroyBonding</a> (<a href="#BluetoothAddress">BluetoothAddress</a> address, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothAdapter::registerRFCOMMServiceByUUID">registerRFCOMMServiceByUUID</a> (<a href="#BluetoothUUID">BluetoothUUID</a> uuid, DOMString name, <a href="#BluetoothServiceSuccessCallback">BluetoothServiceSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>
+<a href="#BluetoothProfileHandler">BluetoothProfileHandler</a> <a href="#BluetoothAdapter::getBluetoothProfileHandler">getBluetoothProfileHandler</a> (<a href="#BluetoothProfileType">BluetoothProfileType</a> profileType)</div>
+</td>
</tr>
<tr>
<td><a href="#BluetoothLEAdapter">BluetoothLEAdapter</a></td>
-<td>void <a href="#BluetoothLEAdapter::startScan">startScan</a> (<a href="#BluetoothLEScanCallback">BluetoothLEScanCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothLEAdapter::stopScan">stopScan</a> ()<br>
- void <a href="#BluetoothLEAdapter::startAdvertise">startAdvertise</a> (<a href="#BluetoothLEAdvertiseData">BluetoothLEAdvertiseData</a> advertiseData, <a href="#BluetoothAdvertisePacketType">BluetoothAdvertisePacketType</a> packetType, <a href="#BluetoothLEAdvertiseCallback">BluetoothLEAdvertiseCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback, optional <a href="#BluetoothAdvertisingMode">BluetoothAdvertisingMode</a>? mode, optional boolean? connectable)<br>
- void <a href="#BluetoothLEAdapter::stopAdvertise">stopAdvertise</a> ()</td>
+<td>
+<div>void <a href="#BluetoothLEAdapter::startScan">startScan</a> (<a href="#BluetoothLEScanCallback">BluetoothLEScanCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothLEAdapter::stopScan">stopScan</a> ()</div>
+<div>void <a href="#BluetoothLEAdapter::startAdvertise">startAdvertise</a> (<a href="#BluetoothLEAdvertiseData">BluetoothLEAdvertiseData</a> advertiseData, <a href="#BluetoothAdvertisePacketType">BluetoothAdvertisePacketType</a> packetType, <a href="#BluetoothLEAdvertiseCallback">BluetoothLEAdvertiseCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback, optional <a href="#BluetoothAdvertisingMode">BluetoothAdvertisingMode</a>? mode, optional boolean? connectable)</div>
+<div>void <a href="#BluetoothLEAdapter::stopAdvertise">stopAdvertise</a> ()</div>
+</td>
</tr>
<tr>
<td><a href="#BluetoothGATTService">BluetoothGATTService</a></td>
</tr>
<tr>
<td><a href="#BluetoothGATTCharacteristic">BluetoothGATTCharacteristic</a></td>
-<td>void <a href="#BluetoothGATTCharacteristic::readValue">readValue</a> (<a href="#ReadValueSuccessCallback">ReadValueSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothGATTCharacteristic::writeValue">writeValue</a> (byte[] value, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- long <a href="#BluetoothGATTCharacteristic::addValueChangeListener">addValueChangeListener</a> (<a href="#ReadValueSuccessCallback">ReadValueSuccessCallback</a> callback)<br>
- void <a href="#BluetoothGATTCharacteristic::removeValueChangeListener">removeValueChangeListener</a> (long watchID)</td>
+<td>
+<div>void <a href="#BluetoothGATTCharacteristic::readValue">readValue</a> (<a href="#ReadValueSuccessCallback">ReadValueSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothGATTCharacteristic::writeValue">writeValue</a> (byte[] value, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>long <a href="#BluetoothGATTCharacteristic::addValueChangeListener">addValueChangeListener</a> (<a href="#ReadValueSuccessCallback">ReadValueSuccessCallback</a> callback)</div>
+<div>void <a href="#BluetoothGATTCharacteristic::removeValueChangeListener">removeValueChangeListener</a> (long watchID)</div>
+</td>
</tr>
<tr>
<td><a href="#BluetoothGATTDescriptor">BluetoothGATTDescriptor</a></td>
-<td>void <a href="#BluetoothGATTDescriptor::readValue">readValue</a> (<a href="#ReadValueSuccessCallback">ReadValueSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothGATTDescriptor::writeValue">writeValue</a> (byte[] value, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</td>
+<td>
+<div>void <a href="#BluetoothGATTDescriptor::readValue">readValue</a> (<a href="#ReadValueSuccessCallback">ReadValueSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothGATTDescriptor::writeValue">writeValue</a> (byte[] value, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+</td>
</tr>
<tr>
<td><a href="#BluetoothLEScanCallback">BluetoothLEScanCallback</a></td>
-<td>void <a href="#BluetoothLEScanCallback::onsuccess">onsuccess</a> (<a href="#BluetoothLEDevice">BluetoothLEDevice</a> device)</td>
+<td><div>void <a href="#BluetoothLEScanCallback::onsuccess">onsuccess</a> (<a href="#BluetoothLEDevice">BluetoothLEDevice</a> device)</div></td>
</tr>
<tr>
<td><a href="#BluetoothLEAdvertiseCallback">BluetoothLEAdvertiseCallback</a></td>
-<td>void <a href="#BluetoothLEAdvertiseCallback::onstate">onstate</a> (<a href="#BluetoothAdvertisingState">BluetoothAdvertisingState</a> state)</td>
+<td><div>void <a href="#BluetoothLEAdvertiseCallback::onstate">onstate</a> (<a href="#BluetoothAdvertisingState">BluetoothAdvertisingState</a> state)</div></td>
</tr>
<tr>
<td><a href="#BluetoothLEConnectChangeCallback">BluetoothLEConnectChangeCallback</a></td>
-<td>void <a href="#BluetoothLEConnectChangeCallback::onconnected">onconnected</a> (<a href="#BluetoothLEDevice">BluetoothLEDevice</a> device)<br>
- void <a href="#BluetoothLEConnectChangeCallback::ondisconnected">ondisconnected</a> (<a href="#BluetoothLEDevice">BluetoothLEDevice</a> device)</td>
+<td>
+<div>void <a href="#BluetoothLEConnectChangeCallback::onconnected">onconnected</a> (<a href="#BluetoothLEDevice">BluetoothLEDevice</a> device)</div>
+<div>void <a href="#BluetoothLEConnectChangeCallback::ondisconnected">ondisconnected</a> (<a href="#BluetoothLEDevice">BluetoothLEDevice</a> device)</div>
+</td>
</tr>
<tr>
<td><a href="#ReadValueSuccessCallback">ReadValueSuccessCallback</a></td>
-<td>void <a href="#ReadValueSuccessCallback::onread">onread</a> (byte[] value)</td>
+<td><div>void <a href="#ReadValueSuccessCallback::onread">onread</a> (byte[] value)</div></td>
</tr>
<tr>
<td><a href="#BluetoothDevice">BluetoothDevice</a></td>
-<td>void <a href="#BluetoothDevice::connectToServiceByUUID">connectToServiceByUUID</a> (<a href="#BluetoothUUID">BluetoothUUID</a> uuid, <a href="#BluetoothSocketSuccessCallback">BluetoothSocketSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</td>
+<td><div>void <a href="#BluetoothDevice::connectToServiceByUUID">connectToServiceByUUID</a> (<a href="#BluetoothUUID">BluetoothUUID</a> uuid, <a href="#BluetoothSocketSuccessCallback">BluetoothSocketSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div></td>
</tr>
<tr>
<td><a href="#BluetoothLEDevice">BluetoothLEDevice</a></td>
-<td>void <a href="#BluetoothLEDevice::connect">connect</a> (optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothLEDevice::disconnect">disconnect</a> (optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- <a href="#BluetoothGATTService">BluetoothGATTService</a> <a href="#BluetoothLEDevice::getService">getService</a> (<a href="#BluetoothUUID">BluetoothUUID</a> uuid)<br>
- <a href="#BluetoothUUID">BluetoothUUID</a>[] <a href="#BluetoothLEDevice::getServiceAllUuids">getServiceAllUuids</a> ()<br>
- long <a href="#BluetoothLEDevice::addConnectStateChangeListener">addConnectStateChangeListener</a> (<a href="#BluetoothLEConnectChangeCallback">BluetoothLEConnectChangeCallback</a> listener)<br>
- void <a href="#BluetoothLEDevice::removeConnectStateChangeListener">removeConnectStateChangeListener</a> (long watchID)</td>
+<td>
+<div>void <a href="#BluetoothLEDevice::connect">connect</a> (optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothLEDevice::disconnect">disconnect</a> (optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>
+<a href="#BluetoothGATTService">BluetoothGATTService</a> <a href="#BluetoothLEDevice::getService">getService</a> (<a href="#BluetoothUUID">BluetoothUUID</a> uuid)</div>
+<div>
+<a href="#BluetoothUUID">BluetoothUUID</a>[] <a href="#BluetoothLEDevice::getServiceAllUuids">getServiceAllUuids</a> ()</div>
+<div>long <a href="#BluetoothLEDevice::addConnectStateChangeListener">addConnectStateChangeListener</a> (<a href="#BluetoothLEConnectChangeCallback">BluetoothLEConnectChangeCallback</a> listener)</div>
+<div>void <a href="#BluetoothLEDevice::removeConnectStateChangeListener">removeConnectStateChangeListener</a> (long watchID)</div>
+</td>
</tr>
<tr>
<td><a href="#BluetoothSocket">BluetoothSocket</a></td>
-<td>unsigned long <a href="#BluetoothSocket::writeData">writeData</a> (byte[] data)<br>
- byte[] <a href="#BluetoothSocket::readData">readData</a> ()<br>
- void <a href="#BluetoothSocket::close">close</a> ()</td>
+<td>
+<div>unsigned long <a href="#BluetoothSocket::writeData">writeData</a> (byte[] data)</div>
+<div>byte[] <a href="#BluetoothSocket::readData">readData</a> ()</div>
+<div>void <a href="#BluetoothSocket::close">close</a> ()</div>
+</td>
</tr>
<tr>
<td><a href="#BluetoothClass">BluetoothClass</a></td>
-<td>boolean <a href="#BluetoothClass::hasService">hasService</a> (unsigned short service)</td>
+<td><div>boolean <a href="#BluetoothClass::hasService">hasService</a> (unsigned short service)</div></td>
</tr>
<tr>
<td><a href="#BluetoothClassDeviceMajor">BluetoothClassDeviceMajor</a></td>
</tr>
<tr>
<td><a href="#BluetoothServiceHandler">BluetoothServiceHandler</a></td>
-<td>void <a href="#BluetoothServiceHandler::unregister">unregister</a> (optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</td>
+<td><div>void <a href="#BluetoothServiceHandler::unregister">unregister</a> (optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div></td>
</tr>
<tr>
<td><a href="#BluetoothProfileHandler">BluetoothProfileHandler</a></td>
</tr>
<tr>
<td><a href="#BluetoothHealthProfileHandler">BluetoothHealthProfileHandler</a></td>
-<td>void <a href="#BluetoothHealthProfileHandler::registerSinkApplication">registerSinkApplication</a> (unsigned short dataType, DOMString name, <a href="#BluetoothHealthApplicationSuccessCallback">BluetoothHealthApplicationSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
- void <a href="#BluetoothHealthProfileHandler::connectToSource">connectToSource</a> (<a href="#BluetoothDevice">BluetoothDevice</a> peer, <a href="#BluetoothHealthApplication">BluetoothHealthApplication</a> application, <a href="#BluetoothHealthChannelSuccessCallback">BluetoothHealthChannelSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</td>
+<td>
+<div>void <a href="#BluetoothHealthProfileHandler::registerSinkApplication">registerSinkApplication</a> (unsigned short dataType, DOMString name, <a href="#BluetoothHealthApplicationSuccessCallback">BluetoothHealthApplicationSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+<div>void <a href="#BluetoothHealthProfileHandler::connectToSource">connectToSource</a> (<a href="#BluetoothDevice">BluetoothDevice</a> peer, <a href="#BluetoothHealthApplication">BluetoothHealthApplication</a> application, <a href="#BluetoothHealthChannelSuccessCallback">BluetoothHealthChannelSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
+</td>
</tr>
<tr>
<td><a href="#BluetoothHealthApplication">BluetoothHealthApplication</a></td>
-<td>void <a href="#BluetoothHealthApplication::unregister">unregister</a> (optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</td>
+<td><div>void <a href="#BluetoothHealthApplication::unregister">unregister</a> (optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div></td>
</tr>
<tr>
<td><a href="#BluetoothHealthChannel">BluetoothHealthChannel</a></td>
-<td>void <a href="#BluetoothHealthChannel::close">close</a> ()<br>
- unsigned long <a href="#BluetoothHealthChannel::sendData">sendData</a> (byte[] data)<br>
- void <a href="#BluetoothHealthChannel::setListener">setListener</a> (<a href="#BluetoothHealthChannelChangeCallback">BluetoothHealthChannelChangeCallback</a> listener)<br>
- void <a href="#BluetoothHealthChannel::unsetListener">unsetListener</a> ()</td>
+<td>
+<div>void <a href="#BluetoothHealthChannel::close">close</a> ()</div>
+<div>unsigned long <a href="#BluetoothHealthChannel::sendData">sendData</a> (byte[] data)</div>
+<div>void <a href="#BluetoothHealthChannel::setListener">setListener</a> (<a href="#BluetoothHealthChannelChangeCallback">BluetoothHealthChannelChangeCallback</a> listener)</div>
+<div>void <a href="#BluetoothHealthChannel::unsetListener">unsetListener</a> ()</div>
+</td>
</tr>
<tr>
<td><a href="#BluetoothAdapterChangeCallback">BluetoothAdapterChangeCallback</a></td>
-<td>void <a href="#BluetoothAdapterChangeCallback::onstatechanged">onstatechanged</a> (boolean powered)<br>
- void <a href="#BluetoothAdapterChangeCallback::onnamechanged">onnamechanged</a> (DOMString name)<br>
- void <a href="#BluetoothAdapterChangeCallback::onvisibilitychanged">onvisibilitychanged</a> (boolean visible)</td>
+<td>
+<div>void <a href="#BluetoothAdapterChangeCallback::onstatechanged">onstatechanged</a> (boolean powered)</div>
+<div>void <a href="#BluetoothAdapterChangeCallback::onnamechanged">onnamechanged</a> (DOMString name)</div>
+<div>void <a href="#BluetoothAdapterChangeCallback::onvisibilitychanged">onvisibilitychanged</a> (boolean visible)</div>
+</td>
</tr>
<tr>
<td><a href="#BluetoothDeviceSuccessCallback">BluetoothDeviceSuccessCallback</a></td>
-<td>void <a href="#BluetoothDeviceSuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothDevice">BluetoothDevice</a> device)</td>
+<td><div>void <a href="#BluetoothDeviceSuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothDevice">BluetoothDevice</a> device)</div></td>
</tr>
<tr>
<td><a href="#BluetoothDeviceArraySuccessCallback">BluetoothDeviceArraySuccessCallback</a></td>
-<td>void <a href="#BluetoothDeviceArraySuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothDevice">BluetoothDevice</a>[] devices)</td>
+<td><div>void <a href="#BluetoothDeviceArraySuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothDevice">BluetoothDevice</a>[] devices)</div></td>
</tr>
<tr>
<td><a href="#BluetoothDiscoverDevicesSuccessCallback">BluetoothDiscoverDevicesSuccessCallback</a></td>
-<td>void <a href="#BluetoothDiscoverDevicesSuccessCallback::onstarted">onstarted</a> ()<br>
- void <a href="#BluetoothDiscoverDevicesSuccessCallback::ondevicefound">ondevicefound</a> (<a href="#BluetoothDevice">BluetoothDevice</a> device)<br>
- void <a href="#BluetoothDiscoverDevicesSuccessCallback::ondevicedisappeared">ondevicedisappeared</a> (<a href="#BluetoothAddress">BluetoothAddress</a> address)<br>
- void <a href="#BluetoothDiscoverDevicesSuccessCallback::onfinished">onfinished</a> (<a href="#BluetoothDevice">BluetoothDevice</a>[] foundDevices)</td>
+<td>
+<div>void <a href="#BluetoothDiscoverDevicesSuccessCallback::onstarted">onstarted</a> ()</div>
+<div>void <a href="#BluetoothDiscoverDevicesSuccessCallback::ondevicefound">ondevicefound</a> (<a href="#BluetoothDevice">BluetoothDevice</a> device)</div>
+<div>void <a href="#BluetoothDiscoverDevicesSuccessCallback::ondevicedisappeared">ondevicedisappeared</a> (<a href="#BluetoothAddress">BluetoothAddress</a> address)</div>
+<div>void <a href="#BluetoothDiscoverDevicesSuccessCallback::onfinished">onfinished</a> (<a href="#BluetoothDevice">BluetoothDevice</a>[] foundDevices)</div>
+</td>
</tr>
<tr>
<td><a href="#BluetoothSocketSuccessCallback">BluetoothSocketSuccessCallback</a></td>
-<td>void <a href="#BluetoothSocketSuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothSocket">BluetoothSocket</a> socket)</td>
+<td><div>void <a href="#BluetoothSocketSuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothSocket">BluetoothSocket</a> socket)</div></td>
</tr>
<tr>
<td><a href="#BluetoothServiceSuccessCallback">BluetoothServiceSuccessCallback</a></td>
-<td>void <a href="#BluetoothServiceSuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothServiceHandler">BluetoothServiceHandler</a> handler)</td>
+<td><div>void <a href="#BluetoothServiceSuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothServiceHandler">BluetoothServiceHandler</a> handler)</div></td>
</tr>
<tr>
<td><a href="#BluetoothHealthApplicationSuccessCallback">BluetoothHealthApplicationSuccessCallback</a></td>
-<td>void <a href="#BluetoothHealthApplicationSuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothHealthApplication">BluetoothHealthApplication</a> application)</td>
+<td><div>void <a href="#BluetoothHealthApplicationSuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothHealthApplication">BluetoothHealthApplication</a> application)</div></td>
</tr>
<tr>
<td><a href="#BluetoothHealthChannelSuccessCallback">BluetoothHealthChannelSuccessCallback</a></td>
-<td>void <a href="#BluetoothHealthChannelSuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothHealthChannel">BluetoothHealthChannel</a> channel)</td>
+<td><div>void <a href="#BluetoothHealthChannelSuccessCallback::onsuccess">onsuccess</a> (<a href="#BluetoothHealthChannel">BluetoothHealthChannel</a> channel)</div></td>
</tr>
<tr>
<td><a href="#BluetoothHealthChannelChangeCallback">BluetoothHealthChannelChangeCallback</a></td>
-<td>void <a href="#BluetoothHealthChannelChangeCallback::onmessage">onmessage</a> (byte[] data)<br>
- void <a href="#BluetoothHealthChannelChangeCallback::onclose">onclose</a> ()</td>
+<td>
+<div>void <a href="#BluetoothHealthChannelChangeCallback::onmessage">onmessage</a> (byte[] data)</div>
+<div>void <a href="#BluetoothHealthChannelChangeCallback::onclose">onclose</a> ()</div>
+</td>
</tr>
</tbody>
</table>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
var advertData =
{
- includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
- appearance: 192, includeTxPowerLevel: false
+ includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
+ appearance: 192, includeTxPowerLevel: false
}
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
var advertData =
{
- includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
- appearance: 192, includeTxPowerLevel: false
+ includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
+ appearance: 192, includeTxPowerLevel: false
}
var advertise = new tizen.BluetoothLEAdvertiseData(advertData);
</pre>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
try
{
- var adapter = tizen.bluetooth.getDefaultAdapter();
+ var adapter = tizen.bluetooth.getDefaultAdapter();
}
catch (err)
{
- console.log(err.name + ": " + err.message);
+ console.log(err.name + ": " + err.message);
}
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
try
{
- var adapter = tizen.bluetooth.getLEAdapter();
+ var adapter = tizen.bluetooth.getLEAdapter();
}
catch (err)
{
- console.log(err.name + ": " + err.message);
+ console.log(err.name + ": " + err.message);
}
</pre>
</div>
optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback,
optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
- void setPowered(boolean state,
- optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback,
- optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
-
void setChangeListener(<a href="#BluetoothAdapterChangeCallback">BluetoothAdapterChangeCallback</a> listener) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
void unsetChangeListener() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
function changeName(newName)
{
- if (adapter.name != newName)
- {
- /* Initiate change name */
- adapter.setName(newName, function()
- {
- console.log("Adapter name changed to " + adapter.name);
- }, function(e)
- {
- console.log("Failed to change name: " + e.message);
- });
- }
+ if (adapter.name != newName)
+ {
+ /* Initiate change name */
+ adapter.setName(newName, function()
+ {
+ console.log("Adapter name changed to " + adapter.name);
+ }, function(e)
+ {
+ console.log("Failed to change name: " + e.message);
+ });
+ }
}
if (bt_always_on === false)
{
- changeName("myDevice");
+ changeName("myDevice");
}
</pre>
</div>
</dd>
-<dt class="method" id="BluetoothAdapter::setPowered">
+<dt class="deprecated method" id="BluetoothAdapter::setPowered">
<a class="backward-compatibility-anchor" name="::Bluetooth::BluetoothAdapter::setPowered"></a><code><b><span class="methodName">setPowered</span></b></code>
</dt>
-<dd>
+<dd class="deprecated">
<div class="brief">
Sets the state of a Bluetooth adapter to on or off by sending a request to Bluetooth hardware to change the power state.
For most Bluetooth actions, the Bluetooth adapter must be powered on.
</div>
-<div class="deprecated"><p><font color="red"><i><b>Deprecated.</b>
- Deprecated since 2.3. Instead, let the user turn on/off Bluetooth through the Settings application. see the <a href="https://developer.tizen.org/development/tutorials/web-application/tizen-features/network/bluetooth">Bluetooth Tutorial</a>.</i></font></p></div>
+<p class="deprecated"><b>Deprecated.</b>
+ Deprecated since 2.3. Instead, let the user turn on/off Bluetooth through the Settings application. See <a href="https://developer.tizen.org/development/guides/web-application/connectivity-and-wireless/bluetooth#Managing_BT_Adapter">Managing Bluetooth Tutorial</a>.
+ </p>
<div class="synopsis"><pre class="signature prettyprint">void setPowered(boolean state, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback);
</pre></div>
<p><span class="version">
function powerOn()
{
- /* If adapter is not powered on */
- if (!adapter.powered)
- {
- /* Initiates power on */
- adapter.setPowered(true, function()
- {
- console.log("Bluetooth powered on success.");
- }, function(e)
- {
- console.log("Failed to power on Bluetooth: " + e.message);
- });
- }
+ /* If adapter is not powered on */
+ if (!adapter.powered)
+ {
+ /* Initiates power on */
+ adapter.setPowered(true, function()
+ {
+ console.log("Bluetooth powered on success.");
+ }, function(e)
+ {
+ console.log("Failed to power on Bluetooth: " + e.message);
+ });
+ }
}
function powerOff()
{
- /* If powered on */
- if (adapter.powered)
- {
- /* Initiates power off */
- adapter.setPowered(false, function()
- {
- console.log("Bluetooth powered off successfully.");
- }, function(e)
- {
- console.log("Failed to power off Bluetooth: " + e.message);
- });
- }
+ /* If powered on */
+ if (adapter.powered)
+ {
+ /* Initiates power off */
+ adapter.setPowered(false, function()
+ {
+ console.log("Bluetooth powered off successfully.");
+ }, function(e)
+ {
+ console.log("Failed to power off Bluetooth: " + e.message);
+ });
+ }
}
var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on");
if (bt_always_on === true)
{
- console.log("Bluetooth cannot be turn off or on because this device must be always enabled.");
+ console.log("Bluetooth cannot be turn off or on because this device must be always enabled.");
}
else
{
- powerOn();
+ powerOn();
}
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
var changeListener =
{
- onstatechanged: function(powered)
- {
- console.log("Power state is changed into: " + powered);
- },
- onnamechanged: function(name)
- {
- console.log("Name is changed to: " + name);
- },
- onvisibilitychanged: function(visible)
- {
- console.log("Visibility is changed into: " + visible);
- }
+ onstatechanged: function(powered)
+ {
+ console.log("Power state is changed into: " + powered);
+ },
+ onnamechanged: function(name)
+ {
+ console.log("Name is changed to: " + name);
+ },
+ onvisibilitychanged: function(visible)
+ {
+ console.log("Visibility is changed into: " + visible);
+ }
};
var adapter = tizen.bluetooth.getDefaultAdapter();
var changeListener =
{
- onstatechanged: function(powered)
- {
- console.log("Power state is changed into: " + powered);
- if (!powered)
- adapter.unsetChangeListener();
- },
- onnamechanged: function(name)
- {
- console.log("Name is changed to: " + name);
- },
- onvisibilitychanged: function(visible)
- {
- console.log("Visibility is changed into: " + visible);
- }
+ onstatechanged: function(powered)
+ {
+ console.log("Power state is changed into: " + powered);
+ if (!powered)
+ adapter.unsetChangeListener();
+ },
+ onnamechanged: function(name)
+ {
+ console.log("Name is changed to: " + name);
+ },
+ onvisibilitychanged: function(visible)
+ {
+ console.log("Visibility is changed into: " + visible);
+ }
};
adapter.setChangeListener(changeListener);
function startDiscovery()
{
- var discoverDevicesSuccessCallback =
- {
- onstarted: function()
- {
- console.log("Device discovery started...");
- },
- ondevicefound: function(device)
- {
- console.log("Found device - name: " + device.name + ", Address: " + device.address);
- },
- ondevicedisappeared: function(address)
- {
- console.log("Device disappeared: " + address);
- },
- onfinished: function(devices)
+ var discoverDevicesSuccessCallback =
+ {
+ onstarted: function()
+ {
+ console.log("Device discovery started...");
+ },
+ ondevicefound: function(device)
+ {
+ console.log("Found device - name: " + device.name + ", Address: "+ device.address);
+ },
+ ondevicedisappeared: function(address)
+ {
+ console.log("Device disappeared: " + address);
+ },
+ onfinished: function(devices)
+ {
+ console.log("Found Devices");
+ for (var i = 0; i < devices.length; i++)
{
- console.log("Found Devices");
- for (var i = 0; i < devices.length; i++)
- {
- console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
- }
- console.log("Total: " + devices.length);
+ console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
}
- };
-
- /* Starts searching for nearby devices, for about 12 sec */
- adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
- {
- console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
- });
+ console.log("Total: " + devices.length);
+ }
+ };
+
+ /* Starts searching for nearby devices, for about 12 sec */
+ adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
+ {
+ console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
+ });
}
function onSetPoweredError(e)
{
- console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
+ console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
}
adapter.setPowered(true, startDiscovery, onSetPoweredError);
/* Calls this method whenever user finds one of the device */
function cancelDiscovery()
{
- adapter.stopDiscovery(function()
- {
- console.log("Stop discovery success.");
- }, function(e)
- {
- console.log("Error while stopDiscovery:" + e.message);
- });
+ adapter.stopDiscovery(function()
+ {
+ console.log("Stop discovery success.");
+ }, function(e)
+ {
+ console.log("Error while stopDiscovery:" + e.message);
+ });
}
function startDiscovery()
{
- var discoverDevicesSuccessCallback =
- {
- onstarted: function()
- {
- console.log("Device discovery started...");
- },
- ondevicefound: function(device)
- {
- console.log("Found device - name: " + device.name + ", Address: " + device.address);
- /* Shows the device to user to check if this is the device user is looking for */
- /* For example, add this to list view */
-
- cancelDiscovery();
- },
- ondevicedisappeared: function(address)
+ var discoverDevicesSuccessCallback =
+ {
+ onstarted: function()
+ {
+ console.log("Device discovery started...");
+ },
+ ondevicefound: function(device)
+ {
+ console.log("Found device - name: " + device.name + ", Address: "+ device.address);
+ /* Shows the device to user to check if this is the device user is looking for */
+ /* For example, add this to list view */
+
+ cancelDiscovery();
+ },
+ ondevicedisappeared: function(address)
+ {
+ console.log("Device disappeared: " + address);
+ /* Removes from list, as it is no longer valid */
+ },
+ onfinished: function(devices)
+ {
+ console.log("Found Devices");
+ for (var i = 0; i < devices.length; i++)
{
- console.log("Device disappeared: " + address);
- /* Removes from list, as it is no longer valid */
- },
- onfinished: function(devices)
- {
- console.log("Found Devices");
- for (var i = 0; i < devices.length; i++)
- {
- console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
- }
- console.log("Total: " + devices.length);
+ console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
}
- };
-
- /* Starts searching for nearby devices, for about 12 sec */
- adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
- {
- console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
- });
+ console.log("Total: " + devices.length);
+ }
+ };
+
+ /* Starts searching for nearby devices, for about 12 sec */
+ adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
+ {
+ console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
+ });
}
function onSetPoweredError(e)
{
- console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
+ console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
}
adapter.setPowered(true, startDiscovery, onSetPoweredError);
function onGotDevices(devices)
{
- console.log("Devices");
- for (var i = 0; i < devices.length; i++)
- {
- console.log(" Name: " + devices[i].name + ", Address: " + devices[i].address);
- }
- console.log("Total: " + devices.length);
+ console.log("Devices");
+ for (var i = 0; i < devices.length; i++)
+ {
+ console.log(" Name: " + devices[i].name + ", Address: " + devices[i].address);
+ }
+ console.log("Total: " + devices.length);
}
function onError(e)
{
- console.log("Error: " + e.message);
+ console.log("Error: " + e.message);
}
function onBluetoothsetPowered()
{
- adapter.getKnownDevices(onGotDevices, onError);
+ adapter.getKnownDevices(onGotDevices, onError);
}
/* Turns on Bluetooth */
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function gotDeviceInfo(device)
{
- console.log("Device Name: " + device.name);
- console.log("Device Address: " + device.address);
- console.log("Device Class: " + device.deviceClass.major);
- console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No"));
+ console.log("Device Name: " + device.name);
+ console.log("Device Address: " + device.address);
+ console.log("Device Class: " + device.deviceClass.major);
+ console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No"));
}
function onError(e)
{
- console.log("Could not get device info:" + e.message);
+ console.log("Could not get device info:" + e.message);
}
var adapter = tizen.bluetooth.getDefaultAdapter();
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onBondingSuccess(device)
{
- console.log("Device Name:" + device.name);
- console.log("Device Address:" + device.address);
- console.log("Device Service UUIDs:" + device.uuids.join("\n"));
+ console.log("Device Name:" + device.name);
+ console.log("Device Address:" + device.address);
+ console.log("Device Service UUIDs:" + device.uuids.join("\n"));
}
function onError(e)
{
- console.log("Could not create bonding, reason:" + e.message);
+ console.log("Could not create bonding, reason:" + e.message);
}
var adapter = tizen.bluetooth.getDefaultAdapter();
function gotDevice(device)
{
- if (device.isBonded)
- {
- /* Initiates destroying bonding */
- adapter.destroyBonding(device.address, function()
- {
- console.log("Succeeded to destroy the bond success with:" + device.address);
- }, function(e)
- {
- console.log("Failed to destroy the bond with " + device.address + ", reason: " + e.message);
- });
- }
+ if (device.isBonded)
+ {
+ /* Initiates destroying bonding */
+ adapter.destroyBonding(device.address, function()
+ {
+ console.log("Succeeded to destroy the bond success with:" + device.address);
+ }, function(e)
+ {
+ console.log("Failed to destroy the bond with " + device.address + ", reason: " + e.message);
+ });
+ }
}
var deviceAddress = "35:F4:59:D1:7A:03";
adapter.getDevice(deviceAddress, gotDevice, function(e)
{
- console.log("Failed to get device info for " + deviceAddress + ", reason: " + e.message);
+ console.log("Failed to get device info for " + deviceAddress + ", reason: " + e.message);
});
</pre>
</div>
function chatServiceSuccessCb(recordHandler)
{
- console.log("Chat service registration succeeds!");
- chatServiceHandler = recordHandler;
- recordHandler.onconnect = function(socket)
- {
- console.log("Client connected: " + socket.peer.name + "," + socket.peer.address);
- serviceSocket = socket;
- /* Messages received from remote device */
- socket.onmessage = function()
- {
- var data = socket.readData();
- /* Handles message code goes here */
- };
+ console.log("Chat service registration succeeds!");
+ chatServiceHandler = recordHandler;
+ recordHandler.onconnect = function(socket)
+ {
+ console.log("Client connected: " + socket.peer.name + "," + socket.peer.address);
+ serviceSocket = socket;
+ /* Messages received from remote device */
+ socket.onmessage = function()
+ {
+ var data = socket.readData();
+ /* Handles message code goes here */
+ };
- socket.onclose = function()
- {
- console.log('The socket is closed.');
- serviceSocket = null;
- };
- };
+ socket.onclose = function()
+ {
+ console.log("The socket is closed.");
+ serviceSocket = null;
+ };
+ };
};
function publishChatService()
{
- var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
- adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb,
- /* Error handler: function(e) {console.log("Could not register service record, Error: " + e.message);} */);
+ var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
+ adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb,
+ /* Error handler */
+ function(e)
+ {
+ console.log( "Could not register service record, Error: " + e.message);
+ });
}
function unregisterChatService()
{
- if (chatServiceHandler != null)
- {
- chatServiceHandler.unregister(function()
- {
- console.log("Chat service is unregistered");
- chatServiceHandler = null;
- }, function(e)
- {
- console.log("Failed to unregister service: " + e.message);
- });
- }
+ if (chatServiceHandler != null)
+ {
+ chatServiceHandler.unregister(function()
+ {
+ console.log("Chat service is unregistered");
+ chatServiceHandler = null;
+ }, function(e)
+ {
+ console.log("Failed to unregister service: " + e.message);
+ });
+ }
}
</pre>
</div>
</li>
</ul>
</div>
+<div class="returntype">
+<p><span class="return">Return value:</span></p>
+ BluetoothProfileHandler Represents the Bluetooth profile handle.
+ </div>
<div class="exceptionlist">
<p><span class="except">Exceptions:</span></p>
<ul class="exception"><li>WebAPIException<ul>
if (healthCapability)
{
- healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
+ healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
}
else
{
- console.log("Bluetooth Health Profile is not supported on this device.");
+ console.log("Bluetooth Health Profile is not supported on this device.");
}
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("[Found device] address: " + device.address);
+ console.log("[Found device] address: " + device.address);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- adapter.stopScan();
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ adapter.stopScan();
+ }
});
</pre>
</div>
var heart_rate_svc_uuid_16 = "180d"; /* Service solicitation UUID, 16-bit UUID is supported (e.g. 180d) */
var advertiseOptions =
{
- includeName: true, /* Whether the device name should be included */
- includeTxPowerLevel: true, /* Whether the transmission power level should be included */
- appearance: 192, /* External appearance of device, 192 - Generic Watch */
- uuids: [battery_svc_uuid_16],
- solicitationuuids: [heart_rate_svc_uuid_16]
+ includeName: true, /* Whether the device name should be included */
+ includeTxPowerLevel: true, /* Whether the transmission power level should be included */
+ appearance: 192, /* External appearance of device, 192 - Generic Watch */
+ uuids: [battery_svc_uuid_16],
+ solicitationuuids: [heart_rate_svc_uuid_16]
};
var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions);
adapter.startAdvertise(advertiseData, "ADVERTISE", function onstate(state)
{
- console.log("Advertiser state: " + state);
+ console.log("Advertiser state: " + state);
}, function(e)
{
- console.log("Failed to startAdvertise: " + e.message);
+ console.log("Failed to startAdvertise: " + e.message);
}, "LOW_LATENCY", connectable);
</pre>
</div>
var heart_rate_svc_uuid_16 = "180d"; /* Service solicitation UUID, 16-bit UUID is supported (e.g. 180d) */
var advertiseOptions =
{
- includeName: true, /* Whether the device name should be included */
- includeTxPowerLevel: true, /* Whether the transmission power level should be included */
- appearance: 192, /* External appearance of device, 192 - Generic Watch */
- uuids: [battery_svc_uuid_16],
- solicitationuuids: [heart_rate_svc_uuid_16]
+ includeName: true, /* Whether the device name should be included */
+ includeTxPowerLevel: true, /* Whether the transmission power level should be included */
+ appearance: 192, /* External appearance of device, 192 - Generic Watch */
+ uuids: [battery_svc_uuid_16],
+ solicitationuuids: [heart_rate_svc_uuid_16]
};
var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions);
adapter.startAdvertise(advertiseData, "ADVERTISE", function onstate(state)
{
- console.log("Advertiser state: " + state);
+ console.log("Advertiser state: " + state);
});
adapter.stopAdvertise();
</pre>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onconnected(device)
{
- console.log("Connected to device");
- var service = device.getService(device.uuids[0]);
- console.log("Service got");
+ console.log("Connected to device");
+ var service = device.getService(device.uuids[0]);
+ console.log("Service got");
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("[Found device] address: " + device.address);
- device.connect(onconnected.bind(null, device), onerror);
+ console.log("[Found device] address: " + device.address);
+ device.connect(onconnected.bind(null, device), onerror);
});
</pre>
</div>
var service = device.getService(device.uuids[0]);
for (var i = 0; i service.services.length; ++i)
{
- console.log("Subservices UUID " + service.services[i].uuid);
+ console.log("Subservices UUID " + service.services[i].uuid);
}
</pre>
</div>
var service = device.getService(device.uuids[0]);
for (var i = 0; i service.characteristics.length; ++i)
{
- console.log("Subservices UUID " + service.characteristics[i].isWritable);
+ console.log("Subservices UUID " + service.characteristics[i].isWritable);
}
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Failed to connect to device: " + e.message);
+ console.log("Failed to connect to device: " + e.message);
}
function proccessDevice(device)
{
- device.connect(onConnected, onerror);
- function onConnected()
- {
- var service = device.getService(device.uuids[0]);
- if (service.characteristics.length > 0)
+ device.connect(onConnected, onerror);
+ function onConnected()
+ {
+ var service = device.getService(device.uuids[0]);
+ if (service.characteristics.length > 0)
+ {
+ var characteristic = service.characteristics[0];
+ characteristic.readValue(function(val)
{
- var characteristic = service.characteristics[0];
- characteristic.readValue(function(val)
- {
- console.log("Value read: " + val);
- device.disconnect();
- });
- }
- }
+ console.log("Value read: " + val);
+ device.disconnect();
+ });
+ }
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- proccessDevice(device);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ proccessDevice(device);
+ }
});
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Failed to connect to device: " + e.message);
+ console.log("Failed to connect to device: " + e.message);
}
function proccessDevice(device)
{
- device.connect(onConnected, onerror);
- function onConnected()
- {
- var service = device.getService(device.uuids[0]);
- if (service.characteristics.length > 0)
+ device.connect(onConnected, onerror);
+ function onConnected()
+ {
+ var service = device.getService(device.uuids[0]);
+ if (service.characteristics.length > 0)
+ {
+ var characteristic = service.characteristics[0];
+ var data = new Array(1, 2, 3, 4, 5, 6);
+ characteristic.writeValue(data, function()
{
- var characteristic = service.characteristics[0];
- var data = new Array(1, 2, 3, 4, 5, 6);
- characteristic.writeValue(data, function()
- {
- console.log("Value written");
- device.disconnect();
- }, function(e)
- {
- console.log("Failed to write: " + e.message);
- });
- }
- }
+ console.log("Value written");
+ device.disconnect();
+ }, function(e)
+ {
+ console.log("Failed to write: " + e.message);
+ });
+ }
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- proccessDevice(device);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ proccessDevice(device);
+ }
});
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function proccessDevice(device)
{
- function onConnected()
- {
- var service = device.getService("5BCE9431-6C75-32AB-AFE0-2EC108A30860");
- if (service.characteristics.length > 0)
- {
- var characteristic = service.characteristics[0];
- var watchID;
-
- watchID = characteristic.addValueChangeListener(function(value)
- {
- console.log("Characteristic value changed: " + value);
- characteristic.removeValueChangeListener(watchID);
- device.disconnect();
- });
- }
- }
+ function onConnected()
+ {
+ var service = device.getService("5BCE9431-6C75-32AB-AFE0-2EC108A30860");
+ if (service.characteristics.length > 0)
+ {
+ var characteristic = service.characteristics[0];
+ var watchID;
- device.connect(onConnected);
+ watchID = characteristic.addValueChangeListener(function(value)
+ {
+ console.log("Characteristic value changed: " + value);
+ characteristic.removeValueChangeListener(watchID);
+ device.disconnect();
+ });
+ }
+ }
+ device.connect(onConnected);
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- adapter.stopScan();
- proccessDevice(device);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ adapter.stopScan();
+ proccessDevice(device);
+ }
});
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Failed to connect to device: " + e.message);
+ console.log("Failed to connect to device: " + e.message);
}
function proccessDevice(device)
{
- device.connect(onConnected, onerror);
- function onConnected()
- {
- var service = device.getService(device.uuids[0]);
- if (service.characteristics.length > 0)
+ device.connect(onConnected, onerror);
+ function onConnected()
+ {
+ var service = device.getService(device.uuids[0]);
+ if (service.characteristics.length > 0)
+ {
+ var characteristic = service.characteristics[0];
+ var descriptor = characteristic.descriptors[0];
+ descriptor.readValue(function(val)
{
- var characteristic = service.characteristics[0];
- var descriptor = characteristic.descriptors[0];
- descriptor.readValue(function(val)
- {
- console.log("Value read: " + val);
- device.disconnect();
- });
- }
- }
+ console.log("Value read: " + val);
+ device.disconnect();
+ });
+ }
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- proccessDevice(device);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ proccessDevice(device);
+ }
});
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Failed to connect to device: " + e.message);
+ console.log("Failed to connect to device: " + e.message);
}
function proccessDevice(device)
{
- device.connect(onConnected, onerror);
- function onConnected()
- {
- var service = device.getService(device.uuids[0]);
- if (service.characteristics.length > 0)
+ device.connect(onConnected, onerror);
+ function onConnected()
+ {
+ var service = device.getService(device.uuids[0]);
+ if (service.characteristics.length > 0)
+ {
+ var characteristic = service.characteristics[0];
+ var data = new Array(1, 2, 3, 4, 5, 6);
+ var descriptor = characteristic.descriptors[0];
+ descriptor.writeValue(data, function()
{
- var characteristic = service.characteristics[0];
- var data = new Array(1, 2, 3, 4, 5, 6);
- var descriptor = characteristic.descriptors[0];
- descriptor.writeValue(data, function()
- {
- console.log("Value written");
- device.disconnect();
- }, function(e)
- {
- console.log("Failed to write: " + e.message);
- });
- }
- }
+ console.log("Value written");
+ device.disconnect();
+ }, function(e)
+ {
+ console.log("Failed to write: " + e.message);
+ });
+ }
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- proccessDevice(device);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ proccessDevice(device);
+ }
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Device Name: " + device.name);
+ console.log("Device Name: " + device.name);
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Device Address: " + device.address);
+ console.log("Device Address: " + device.address);
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Device Major Class: " + device.deviceClass.major);
+ console.log("Device Major Class: " + device.deviceClass.major);
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Is bonded: " + (device.isBonded ? "Yes" : "No"));
+ console.log("Is bonded: " + (device.isBonded ? "Yes" : "No"));
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Is trusted: " + (device.isTrusted ? "Yes" : "No"));
+ console.log("Is trusted: " + (device.isTrusted ? "Yes" : "No"));
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Is connected: " + (device.isConnected ? "Yes" : "No"));
+ console.log("Is connected: " + (device.isConnected ? "Yes" : "No"));
});
</pre>
</div>
var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- var uuids = device.uuids;
- var services = "";
- for (var i = 0; i < uuids.length; i++)
- {
- services += uuids[i] + "\n";
- }
- console.log("Services found: " + services);
- if (uuids.indexOf(CHAT_SERVICE_UUID) != -1)
- {
- /* Connects to service */
- device.connectToServiceByUUID(CHAT_SERVICE_UUID, function(socket)
- {
- /* Connected to service, handle socket */
- }, function(e)
- {
- console.log("Could not connect to chat service !!!. Error: " + e.message);
- });
- }
+ var uuids = device.uuids;
+ var services = "";
+ for (var i = 0; i < uuids.length; i++)
+ {
+ services += uuids[i] + "\n";
+ }
+ console.log("Services found: " + services);
+ if (uuids.indexOf(CHAT_SERVICE_UUID) != -1)
+ {
+ /* Connects to service */
+ device.connectToServiceByUUID(CHAT_SERVICE_UUID, function(socket)
+ {
+ /* Connected to service, handle socket */
+ }, function(e)
+ {
+ console.log("Could not connect to chat service !!!. Error: " + e.message);
+ });
+ }
});
</pre>
</div>
/* Calls a method that is invoked when user wants to send a message to a remote device */
function sendMessage(msg)
{
- /* Validates socket state, if everything is ok */
- if (clientSocket != null && clientSocket.state == "OPEN")
- {
- /* Sends the message */
- clientSocket.writeData(msg);
- }
+ /* Validates socket state, if everything is ok */
+ if (clientSocket != null && clientSocket.state == "OPEN")
+ {
+ /* Sends the message */
+ clientSocket.writeData(msg);
+ }
}
/* Calls a method that is invoked when a socket is open */
function onSocketConnected(socket)
{
- clientSocket = socket;
- console.log("Opening a socket successfully!!!");
- socket.onmessage = function()
- {
- var data = socket.readData();
- var recvmsg = "";
- for (var i = 0; i < data.length; i++)
- {
- recvmsg += String.fromCharCode(data[i]);
- }
- console.log("server msg >> " + recvmsg);
- };
-
- socket.onclose = function()
- {
- console.log("socket disconnected.");
- };
+ clientSocket = socket;
+ console.log("Opening a socket successfully!!!");
+ socket.onmessage = function()
+ {
+ var data = socket.readData();
+ var recvmsg = "";
+ for (var i = 0; i < data.length; i++)
+ {
+ recvmsg += String.fromCharCode(data[i]);
+ }
+ console.log("server msg >> " + recvmsg);
+ };
+
+ socket.onclose = function()
+ {
+ console.log("socket disconnected.");
+ };
}
function onDeviceReady(device)
{
- /* Validates device and service uuid */
- if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
- {
- /* Opens socket */
- device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, function(e)
- {
- console.log("Error connecting to service. Reason: " + e.message);
- });
- }
- else
- {
- console.log("Chat service is not supported by this device");
- }
+ /* Validates device and service uuid */
+ if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
+ {
+ /* Opens socket */
+ device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, function(e)
+ {
+ console.log("Error connecting to service. Reason: " + e.message);
+ });
+ }
+ else
+ {
+ console.log("Chat service is not supported by this device");
+ }
}
function onSetPowered()
{
- /* Gets the BluetoothDevice object */
- adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
+ /* Gets the BluetoothDevice object */
+ adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message); });
}
adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message); });
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("Found device: " + device.address);
+ console.log("Found device: " + device.address);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("Found device: " + device.name);
+ console.log("Found device: " + device.name);
});
</pre>
</div>
</li>
<li class="attribute" id="BluetoothLEDevice::txpowerlevel">
<span class="attrName"><span class="readonly"> readonly
-</span><span class="type">unsigned long </span><span class="name">txpowerlevel</span><span class="optional"> [nullable]</span></span><div class="brief">
+</span><span class="type">long </span><span class="name">txpowerlevel</span><span class="optional"> [nullable]</span></span><div class="brief">
The transmission power level of the Bluetooth LE device from the scan result information.
</div>
<p><span class="version">
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("Found device: " + device.txpowerlevel);
+ console.log("Found device: " + device.txpowerlevel);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("Found device: " + device.appearance);
+ console.log("Found device: " + device.appearance);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- var uuids = device.uuids;
- var services = "";
- for (var i = 0; i < uuids.length; i++)
- {
- services += uuids[i] + "\n";
- }
- console.log("Service found: " + services);
+ var uuids = device.uuids;
+ var services = "";
+ for (var i = 0; i < uuids.length; i++)
+ {
+ services += uuids[i] + "\n";
+ }
+ console.log("Service found: " + services);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- var uuids = device.solicitationuuids;
- var services = "";
- for (var i = 0; i < uuids.length; i++)
- {
- services += uuids[i] + "\n";
- }
- console.log("Service solicitations found: " + services);
+ var uuids = device.solicitationuuids;
+ var services = "";
+ for (var i = 0; i < uuids.length; i++)
+ {
+ services += uuids[i] + "\n";
+ }
+ console.log("Service solicitations found: " + services);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- var serviceData = device.serviceData;
- var data = "";
- for (var i = 0; i < serviceData.length; i++)
- {
- data += serviceData[i].id + serviceData[i].data + "\n";
- }
- console.log("Service data found: " + data);
+ var serviceData = device.serviceData;
+ var data = "";
+ for (var i = 0; i < serviceData.length; i++)
+ {
+ data += serviceData[i].id + serviceData[i].data + "\n";
+ }
+ console.log("Service data found: " + data);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- var manufacturerData = device.manufacturerData;
- console.log("Manufacture id: " + manufacturerData.id);
- console.log("Manufacture data: " + manufacturerData.data);
+ var manufacturerData = device.manufacturerData;
+ console.log("Manufacture id: " + manufacturerData.id);
+ console.log("Manufacture data: " + manufacturerData.data);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("Found device: " + device.name);
- console.log("RSSI: " + device.rssi);
+ console.log("Found device: " + device.name);
+ console.log("RSSI: " + device.rssi);
});
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Failed to connect to device: " + e.message);
+ console.log("Failed to connect to device: " + e.message);
}
function onconnected()
{
- console.log("Connected to device");
+ console.log("Connected to device");
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- device.connect(onconnected, onerror);
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ device.connect(onconnected, onerror);
}
});
</pre>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Error occurred: " + e.message);
+ console.log("Error occurred: " + e.message);
}
function onDeviceFound(device)
{
- function ondisconnect()
- {
- console.log("Disconnected");
- }
-
- function onconnected()
- {
- console.log("Connected to device");
- device.disconnect(ondisconnect, onerror);
- }
-
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- device.connect(onconnected, onerror);
- }
+ function ondisconnect()
+ {
+ console.log("Disconnected");
+ }
+
+ function onconnected()
+ {
+ console.log("Connected to device");
+ device.disconnect(ondisconnect, onerror);
+ }
+
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ device.connect(onconnected, onerror);
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onconnected(device)
{
- console.log("Connected to device");
- var service = device.getService(device.uuids[0]);
- console.log("Service got");
+ console.log("Connected to device");
+ var service = device.getService(device.uuids[0]);
+ console.log("Service got");
}
function onerror(e)
{
- console.log("Error occurred: " + e.message);
+ console.log("Error occurred: " + e.message);
}
function onDeviceFound(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- device.connect(onconnected.bind(null, device), onerror);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ device.connect(onconnected.bind(null, device), onerror);
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
Privilege: </span>
http://tizen.org/privilege/bluetooth
</p>
+<div class="returntype">
+<p><span class="return">Return value:</span></p>
+ BluetoothUUID[] The array of all service UUIDs that belong to the connected GATT server.
+ </div>
<div class="exceptionlist">
<p><span class="except">Exceptions:</span></p>
<ul class="exception"><li>WebAPIException<ul>
- <li class="list"><p> with error type InvalidValuesError, If GATT server is not available.</p></li>
- <li class="list"><p> with error type NotSupportedError, If the feature is not supported.</p></li>
- </ul>
+<li class="list"><p>
+ with error type InvalidValuesError: If GATT server is not available.
+ </p></li>
+<li class="list"><p>
+ with error type NotSupportedError: If the feature is not supported.
+ </p></li>
+</ul>
</li></ul>
</div>
<div class="example">
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+/*Below variable should represent valid address of discoverable bluetooth low energy device */
+var remoteAddress = "11:22:33:44:55:66";
+
function onconnected(device)
{
- console.log("Connected to device");
- var services = device.getServiceAllUuids();
- console.log("Services length " + services.length);
+ console.log("Connected to device");
+ var services = device.getServiceAllUuids();
+ console.log("Services length " + services.length);
}
function onerror(e)
{
- console.log("Error occurred: " + e.message);
+ console.log("Error occurred: " + e.message);
}
function onDeviceFound(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- device.connect(onconnected.bind(null, device), onerror);
- }
+ if (device.address == remoteAddress)
+ {
+ device.connect(onconnected.bind(null, device), onerror);
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(onDeviceFound, onerror);
</pre>
</div>
+<div class="output">
+<span class="title"><p>Output example:</p></span><pre> Connected to device
+ Services length 2
+ </pre>
+</div>
</dd>
<dt class="method" id="BluetoothLEDevice::addConnectStateChangeListener">
<a class="backward-compatibility-anchor" name="::Bluetooth::BluetoothLEDevice::addConnectStateChangeListener"></a><code><b><span class="methodName">addConnectStateChangeListener</span></b></code>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Error occurred: " + e.message);
+ console.log("Error occurred: " + e.message);
}
function onDeviceFound(device)
{
- var onConnectionStateChange =
- {
- onconnected: function(device)
- {
- console.log("Device " + device.name + " connected");
- },
- ondisconnected: function(device)
- {
- console.log("Device " + device.name + " disconnected");
- }
- }
-
- if (device.address === "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- device.addConnectStateChangeListener(onConnectionStateChange);
- device.connect();
- }
+ var onConnectionStateChange =
+ {
+ onconnected: function(device)
+ {
+ console.log("Device " + device.name + " connected");
+ },
+ ondisconnected: function(device)
+ {
+ console.log("Device " + device.name + " disconnected");
+ }
+ }
+
+ if (device.address === "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ device.addConnectStateChangeListener(onConnectionStateChange);
+ device.connect();
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Error occurred: " + e.message);
+ console.log("Error occurred: " + e.message);
}
function onDeviceFound(device)
{
- var onConnectionStateChange =
- {
- onconnected: function(device)
- {
- console.log("Device " + device.name + " connected");
- },
- ondisconnected: function(device)
- {
- console.log("Device " + device.name + " disconnected");
- device.removeConnectStateChangeListener(listenerID);
- }
- }
-
- if (device.address === "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- listenerID = device.addConnectStateChangeListener(onConnectionStateChange);
- device.connect();
- }
+ var onConnectionStateChange =
+ {
+ onconnected: function(device)
+ {
+ console.log("Device " + device.name + " connected");
+ },
+ ondisconnected: function(device)
+ {
+ console.log("Device " + device.name + " disconnected");
+ device.removeConnectStateChangeListener(listenerID);
+ }
+ }
+
+ if (device.address === "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ listenerID = device.addConnectStateChangeListener(onConnectionStateChange);
+ device.connect();
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
function onSocketConnected(socket)
{
- console.log("Opened connection to remote device");
- socket.onmessage = function()
- {
- console.log("Message received: " + socket.readData());
- };
-
- socket.onclose = function()
- {
- console.log("Socket closed with " + socket.peer.name);
- };
-
- /* Sends data to peer */
- var textmsg = "Test";
- var sendtextmsg = new Array();
- for (var i = 0; i < textmsg.length; i++)
- {
- sendtextmsg[i] = textmsg.charCodeAt(i);
- }
- socket.writeData(sendtextmsg);
+ console.log("Opened connection to remote device");
+ socket.onmessage = function()
+ {
+ console.log("Message received: " + socket.readData());
+ };
+
+ socket.onclose = function()
+ {
+ console.log("Socket closed with " + socket.peer.name);
+ };
+
+ /* Sends data to peer */
+ var textmsg = "Test";
+ var sendtextmsg = new Array();
+ for (var i = 0; i < textmsg.length; i++)
+ {
+ sendtextmsg[i] = textmsg.charCodeAt(i);
+ }
+ socket.writeData(sendtextmsg);
}
function onSocketError(e)
{
- console.log("Error connecting to service. Reason: " + e.message);
+ console.log("Error connecting to service. Reason: " + e.message);
}
function onDeviceReady(device)
{
- /* Validates device and service uuid */
- if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
- {
- /* Opens socket */
- device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onSocketError);
- }
+ /* Validates device and service uuid */
+ if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
+ {
+ /* Opens socket */
+ device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onSocketError);
+ }
}
function onSetPowered()
{
- /* Gets the BluetoothDevice object */
- adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
+ /* Gets the BluetoothDevice object */
+ adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
}
adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message);});
function onError(e)
{
- console.log("Error connecting to service. Reason: " + e.message);
+ console.log("Error connecting to service. Reason: " + e.message);
}
function onSocketConnected(socket)
{
- console.log("Opening socket success!!!");
+ console.log("Opening socket success!!!");
- socket.onmessage = function()
- {
- /* Gets a message from peer, reads it */
- var data = socket.readData();
+ socket.onmessage = function()
+ {
+ /* Gets a message from peer, reads it */
+ var data = socket.readData();
- /* Code to evaluate message goes here */
- };
+ /* Code to evaluate message goes here */
+ };
- socket.onclose = function()
- {
- console.log("Socket closed with " + socket.peer.name);
- };
+ socket.onclose = function()
+ {
+ console.log("Socket closed with " + socket.peer.name);
+ };
}
function onDeviceReady(device)
{
- /* Validates device and service uuid */
- if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
- {
- /* Opens socket */
- device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onError);
- }
+ /* Validates device and service uuid */
+ if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
+ {
+ /* Opens socket */
+ device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onError);
+ }
}
function onSetPowered()
{
- /* Gets the BluetoothDevice object */
- adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
+ /* Gets the BluetoothDevice object */
+ adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
}
adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message);});
readonly attribute octet minor;
- readonly attribute unsigned short [] services ;
+ readonly attribute unsigned short [] services;
boolean hasService(unsigned short service) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
};</pre>
function evaluateDevice(address)
{
- adapter.getDevice(address, function(device)
- {
- if (device.deviceClass.major == tizen.bluetooth.deviceMajor.COMPUTER)
- {
- /* Shows computer icon for this device */
- console.log("Device is computer");
- }
- else if (device.deviceClass.major == tizen.bluetooth.deviceMajor.PHONE)
- {
- /* Shows phone icon */
- console.log("Device is a Phone");
- }
- }, function(e)
- {
- console.log("Couldn't get any device with the given address: " + e.message);
- });
+ adapter.getDevice(address, function(device)
+ {
+ if (device.deviceClass.major == tizen.bluetooth.deviceMajor.COMPUTER)
+ {
+ /* Shows computer icon for this device */
+ console.log("Device is computer");
+ }
+ else if (device.deviceClass.major == tizen.bluetooth.deviceMajor.PHONE)
+ {
+ /* Shows phone icon */
+ console.log("Device is a Phone");
+ }
+ }, function(e)
+ {
+ console.log("Couldn't get any device with the given address: " + e.message);
+ });
}
evaluateDevice("11:22:33:44:55:66");
</li>
</ul>
</div>
+<div class="returntype">
+<p><span class="return">Return value:</span></p>
+ boolean <em>true</em>, if given service exists in the <em>services</em>.
+ </div>
<div class="exceptionlist">
<p><span class="except">Exceptions:</span></p>
<ul class="exception"><li>WebAPIException<ul>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("12:34:56:78:9A:BC", function(device)
{
- if (device.deviceClass.hasService(tizen.bluetooth.deviceService.POSITIONING))
- {
- console.log("Device supports Positioning service");
- }
+ if (device.deviceClass.hasService(tizen.bluetooth.deviceService.POSITIONING))
+ {
+ console.log("Device supports Positioning service");
+ }
}, function(e)
{
- console.log("Couldn't get device for given address: " + e.message);
+ console.log("Couldn't get device for given address: " + e.message);
});
</pre>
</div>
<li class="attribute" id="BluetoothServiceHandler::uuid">
<span class="attrName"><span class="readonly"> readonly
</span><span class="type">BluetoothUUID </span><span class="name">uuid</span></span><div class="brief">
- The UUID of the service.
+ The UUID of the service. See <a href="#BluetoothServiceHandler::onconnect">example
+</a>.
</div>
<p><span class="version">
Since: </span>
<li class="attribute" id="BluetoothServiceHandler::name">
<span class="attrName"><span class="readonly"> readonly
</span><span class="type">DOMString </span><span class="name">name</span></span><div class="brief">
- The name of the service.
+ The name of the service. See <a href="#BluetoothServiceHandler::onconnect">example
+</a>.
</div>
<p><span class="version">
Since: </span>
<li class="attribute" id="BluetoothServiceHandler::isConnected">
<span class="attrName"><span class="readonly"> readonly
</span><span class="type">boolean </span><span class="name">isConnected</span></span><div class="brief">
- The flag indicating whether any remote devices is using this service.
+ The flag indicating whether any remote devices is using this service. See <a href="#BluetoothServiceHandler::onconnect">example</a>.
</div>
<p><span class="version">
Since: </span>
</p></li></ul>
</li></ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+var adapter = tizen.bluetooth.getDefaultAdapter();
+
+function chatServiceSuccessCb(handler)
+{
+ console.log("Chat service " + handler.name + " with UUID " + handler.uuid + " is successfully registered!");
+ console.log("There is " + (handler.isConnected ? "a" : "no") + " device using this service");
+
+ handler.onconnect = function(socket)
+ {
+ console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address);
+ socket.onmessage = function()
+ {
+ var data = socket.readData();
+ /* Handle message code goes here */
+ };
+
+ /* Expected close */
+ socket.onclose = function()
+ {
+ console.log("The socket is closed.");
+ };
+ };
+}
+
+function errorCb(e)
+{
+ console.log("Could not register service record, Error: " + e.message);
+}
+
+var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
+adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, errorCb);
+
+</pre>
+</div>
</li>
</ul>
</div>
function chatServiceSuccessCb(handler)
{
- console.log("Chat service registration was successful!");
+ console.log("Chat service registration was successful!");
- chatServiceHandler = handler;
- handler.onconnect = function(socket)
- {
- console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address);
- socket.onmessage = function()
- {
- var data = socket.readData();
- /* Handle message code here */
- };
+ chatServiceHandler = handler;
+ handler.onconnect = function(socket)
+ {
+ console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address);
+ socket.onmessage = function()
+ {
+ var data = socket.readData();
+ /* Handle message code goes here */
+ };
- /* Expected close */
- socket.onclose = function()
- {
- console.log('The socket is closed.');
- };
- };
+ /* Expected close */
+ socket.onclose = function()
+ {
+ console.log("The socket is closed.");
+ };
+ };
}
function publishChatService()
{
- var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
- adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb,
- /* Error handler: function(e) {console.log("Could not register service record, Error: " + e.message);} */);
+ var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
+ adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb,
+ /* Error handler */
+ function(e)
+ {
+ console.log("Could not register service record, Error: " + e.message);
+ });
}
function unRegisterChatService()
{
- if (chatServiceHandler != null)
- {
- chatServiceHandler.unregister(function()
- {
- chatServiceHandler = null;
- console.log("Chat service is unregistered.");
+ if (chatServiceHandler != null)
+ {
+ chatServiceHandler.unregister(function()
+ {
+ chatServiceHandler = null;
+ console.log("Chat service is unregistered.");
}, function(e)
- {
- console.log("Error: " + e.message);
- });
- }
+ {
+ console.log("Error: " + e.message);
+ });
+ }
}
</pre>
</div>
Since: </span>
2.2
</p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+var adapter = tizen.bluetooth.getDefaultAdapter();
+var healthCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/network.bluetooth.health");
+
+if (healthCapability)
+{
+ var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
+ console.log("Bluetooth profile type is " + healthProfileHandler.profileType);
+}
+else
+{
+ console.log("Bluetooth Health Profile is not supported on this device.");
+}
+</pre>
+</div>
</li></ul>
</div>
</div>
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
+ console.log("Registered application: " + app.name);
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
function healthConnectSuccess(channel)
{
- console.log("Health device is connected");
- var status = "Name of remote device: " + channel.peer.name +
- "channel type of device profile: " + channel.channelType +
- "health application name: " + channel.appication.name;
- console.log(status);
+ console.log("Health device is connected");
+ var status = "Name of remote device: " + channel.peer.name +
+ "channel type of device profile: " + channel.channelType +
+ "health application name: " + channel.appication.name;
+ console.log(status);
}
function healthConnectError(e)
{
- console.log("Failed to connect to source: " + e.message);
+ console.log("Failed to connect to source: " + e.message);
};
function gotDeviceInfo(device)
{
- healthProfileHandler.connectToSource(device, registerHealthApp, healthConnectSuccess, healthConnectError);
+ healthProfileHandler.connectToSource(device, registerHealthApp, healthConnectSuccess, healthConnectError);
}
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- registerHealthApp = app;
- adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo);
+ console.log("Registered application: " + app.name);
+ registerHealthApp = app;
+ adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo);
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
</div>
<div class="description">
<p>
-For example, pulse oximeter is 4100 and blood pressure monitor is 4103.
+For example, pulse oximeter is 4100 and blood pressure monitor is 4103. See <a href="#BluetoothHealthApplication::onconnect">example</a>.
</p>
</div>
<p><span class="version">
<li class="attribute" id="BluetoothHealthApplication::name">
<span class="attrName"><span class="readonly"> readonly
</span><span class="type">DOMString </span><span class="name">name</span></span><div class="brief">
- The friendly name associated with sink application.
+ The friendly name associated with sink application. See <a href="#BluetoothHealthApplication::onconnect">example</a>.
</div>
<p><span class="version">
Since: </span>
</p></li></ul>
</li></ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+var adapter = tizen.bluetooth.getDefaultAdapter();
+var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
+
+function healthRegisterSuccess(app)
+{
+ console.log("Registered application: " + app.name);
+ console.log("Data type used for communication is " + app.dataType);
+
+ app.onconnect = function(channel)
+ {
+ console.log("Health device is connected");
+ }
+}
+
+function healthRegisterError(e)
+{
+ console.log("Failed to register application: " + e.message);
+};
+
+healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
+</pre>
+</div>
</li>
</ul>
</div>
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- healthApp = app;
- healthApp.onconnect = function(channel)
- {
- console.log("Connected!!");
- };
+ console.log("Registered application: " + app.name);
+ healthApp = app;
+ healthApp.onconnect = function(channel)
+ {
+ console.log("Connected!!");
+ };
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
function startSink()
{
- try
- {
- healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
- }
- catch (e)
- {
- console.log("Error: " + e.message);
- }
+ try
+ {
+ healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
+ }
+ catch (e)
+ {
+ console.log("Error: " + e.message);
+ }
}
function stopSink()
{
- try
- {
- if (healthApp != null)
+ try
+ {
+ if (healthApp != null)
+ {
+ healthApp.unregister(function()
{
- healthApp.unregister(function()
- {
- healthApp = null;
- console.log("Health application is unregistered.");
- }, function(e)
- {
- console.log("Error: " + e.message);
- });
- }
- }
- catch (err)
- {
- console.log("Error: " + err.message);
- }
+ healthApp = null;
+ console.log("Health application is unregistered.");
+ }, function(e)
+ {
+ console.log("Error: " + e.message);
+ });
+ }
+ }
+ catch (err)
+ {
+ console.log("Error: " + err.message);
+ }
}
</pre>
</div>
<li class="attribute" id="BluetoothHealthChannel::peer">
<span class="attrName"><span class="readonly"> readonly
</span><span class="type">BluetoothDevice </span><span class="name">peer</span></span><div class="brief">
- The remote device to which this channel is connected.
+ The remote device to which this channel is connected. See <a href="#BluetoothHealthChannel::isConnected">example</a>.
</div>
<p><span class="version">
Since: </span>
<li class="attribute" id="BluetoothHealthChannel::channelType">
<span class="attrName"><span class="readonly"> readonly
</span><span class="type">BluetoothHealthChannelType </span><span class="name">channelType</span></span><div class="brief">
- The type of this channel.
+ The type of this channel. See <a href="#BluetoothHealthChannel::isConnected">example</a>.
</div>
<p><span class="version">
Since: </span>
<li class="attribute" id="BluetoothHealthChannel::application">
<span class="attrName"><span class="readonly"> readonly
</span><span class="type">BluetoothHealthApplication </span><span class="name">application</span></span><div class="brief">
- The health application which is used to communicate with the remote device.
+ The health application which is used to communicate with the remote device. See <a href="#BluetoothHealthChannel::isConnected">example</a>.
</div>
<p><span class="version">
Since: </span>
Since: </span>
2.2
</p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+var adapter = tizen.bluetooth.getDefaultAdapter();
+var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
+
+function healthRegisterSuccess(app)
+{
+ app.onconnect = function(channel)
+ {
+ console.log("Health device " + (channel.isConnected ? "is" : "is not") + " connected to " + channel.peer.name + " remote device");
+ console.log("Channel type is " + channel.channelType + " and health application name used for communication is " + channel.application.name);
+ }
+}
+
+function healthRegisterError(e)
+{
+ console.log("Failed to register application: " + e.message);
+};
+
+healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
+</pre>
+</div>
</li>
</ul>
</div>
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- app.onconnect = function(channel)
- {
- console.log("Health device is connected");
- channel.close();
- }
+ console.log("Registered application: " + app.name);
+ app.onconnect = function(channel)
+ {
+ console.log("Health device is connected");
+ channel.close();
+ }
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
var adapter = tizen.bluetooth.getDefaultAdapter();
var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
+/* Data to send */
+var textmsg = "Test";
+var dataToSend = new Array();
+for (var i = 0; i < textmsg.length; i++)
+{
+ dataToSend[i] = textmsg.charCodeAt(i);
+}
+
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- app.onconnect = function(channel)
- {
- console.log("Health device is connected");
- channel.sendData(dataToSend);
- }
+ console.log("Registered application: " + app.name);
+ app.onconnect = function(channel)
+ {
+ console.log("Health device is connected");
+ channel.sendData(dataToSend);
+ }
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
var channelCallback =
{
- onmessage: function(data)
- {
- console.log("data is received")
- },
- onclose: function()
- {
- console.log("channel is closed");
- }
+ onmessage: function(data)
+ {
+ console.log("data is received")
+ },
+ onclose: function()
+ {
+ console.log("channel is closed");
+ }
};
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- app.onconnect = function(channel)
- {
- console.log("Health device is connected");
- channel.setListener(channelCallback);
- }
+ console.log("Registered application: " + app.name);
+ app.onconnect = function(channel)
+ {
+ console.log("Health device is connected");
+ channel.setListener(channelCallback);
+ }
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
var channelCallback =
{
- onmessage: function(data)
- {
- console.log("data is received")
- },
- onclose: function()
- {
- console.log("channel is closed");
- connectedChannel.unsetListener();
- }
+ onmessage: function(data)
+ {
+ console.log("data is received")
+ },
+ onclose: function()
+ {
+ console.log("channel is closed");
+ connectedChannel.unsetListener();
+ }
};
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- app.onconnect = function(channel)
- {
- console.log("Health device is connected");
- connectedChannel = channel;
- connectedChannel.setListener(channelCallback);
- }
+ console.log("Registered application: " + app.name);
+ app.onconnect = function(channel)
+ {
+ console.log("Health device is connected");
+ connectedChannel = channel;
+ connectedChannel.setListener(channelCallback);
+ }
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback,
optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
- void setPowered(boolean state,
- optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback,
- optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
-
void setChangeListener(<a href="#BluetoothAdapterChangeCallback">BluetoothAdapterChangeCallback</a> listener) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
void unsetChangeListener() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
[NoInterfaceObject] interface BluetoothLEDevice {
readonly attribute <a href="#BluetoothAddress">BluetoothAddress</a> address;
readonly attribute DOMString? name;
- readonly attribute unsigned long? txpowerlevel;
+ readonly attribute long? txpowerlevel;
readonly attribute unsigned long? appearance;
readonly attribute <a href="#BluetoothUUID">BluetoothUUID</a>[]? uuids;
readonly attribute <a href="#BluetoothLESolicitationUUID">BluetoothLESolicitationUUID</a>[]? solicitationuuids;
readonly attribute <a href="#BluetoothLEServiceData">BluetoothLEServiceData</a>[]? serviceData;
readonly attribute <a href="#BluetoothLEManufacturerData">BluetoothLEManufacturerData</a>? manufacturerData;
+ readonly attribute long rssi;
void connect(optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback,
optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
readonly attribute octet minor;
- readonly attribute unsigned short [] services ;
+ readonly attribute unsigned short [] services;
boolean hasService(unsigned short service) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
};
<td><a href="#BluetoothAdapter">BluetoothAdapter</a></td>
<td>
<div>void <a href="#BluetoothAdapter::setName">setName</a> (DOMString name, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
-<div class="deprecated">void <a href="#BluetoothAdapter::setPowered">setPowered</a> (boolean state, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
<div>void <a href="#BluetoothAdapter::setChangeListener">setChangeListener</a> (<a href="#BluetoothAdapterChangeCallback">BluetoothAdapterChangeCallback</a> listener)</div>
<div>void <a href="#BluetoothAdapter::unsetChangeListener">unsetChangeListener</a> ()</div>
<div>void <a href="#BluetoothAdapter::discoverDevices">discoverDevices</a> (<a href="#BluetoothDiscoverDevicesSuccessCallback">BluetoothDiscoverDevicesSuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
var advertData =
{
- includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
- appearance: 192, includeTxPowerLevel: false
+ includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
+ appearance: 192, includeTxPowerLevel: false
}
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
var advertData =
{
- includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
- appearance: 192, includeTxPowerLevel: false
+ includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
+ appearance: 192, includeTxPowerLevel: false
}
var advertise = new tizen.BluetoothLEAdvertiseData(advertData);
</pre>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
try
{
- var adapter = tizen.bluetooth.getDefaultAdapter();
+ var adapter = tizen.bluetooth.getDefaultAdapter();
}
catch (err)
{
- console.log(err.name + ": " + err.message);
+ console.log(err.name + ": " + err.message);
}
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
try
{
- var adapter = tizen.bluetooth.getLEAdapter();
+ var adapter = tizen.bluetooth.getLEAdapter();
}
catch (err)
{
- console.log(err.name + ": " + err.message);
+ console.log(err.name + ": " + err.message);
}
</pre>
</div>
optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback,
optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
- void setPowered(boolean state,
- optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback,
- optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
-
void setChangeListener(<a href="#BluetoothAdapterChangeCallback">BluetoothAdapterChangeCallback</a> listener) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
void unsetChangeListener() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
function changeName(newName)
{
- if (adapter.name != newName)
- {
- /* Initiate change name */
- adapter.setName(newName, function()
- {
- console.log("Adapter name changed to " + adapter.name);
- }, function(e)
- {
- console.log("Failed to change name: " + e.message);
- });
- }
+ if (adapter.name != newName)
+ {
+ /* Initiate change name */
+ adapter.setName(newName, function()
+ {
+ console.log("Adapter name changed to " + adapter.name);
+ }, function(e)
+ {
+ console.log("Failed to change name: " + e.message);
+ });
+ }
}
if (bt_always_on === false)
{
- changeName("myDevice");
+ changeName("myDevice");
}
</pre>
</div>
For most Bluetooth actions, the Bluetooth adapter must be powered on.
</div>
<p class="deprecated"><b>Deprecated.</b>
- Deprecated since 2.3. Instead, let the user turn on/off Bluetooth through the Settings application. See <a href="https://developer.tizen.org/development/tutorials/web-application/tizen-features/network/bluetooth"">Managing Bluetooth Tutorial</a>.
+ Deprecated since 2.3. Instead, let the user turn on/off Bluetooth through the Settings application. See <a href="https://developer.tizen.org/development/guides/web-application/connectivity-and-wireless/bluetooth#Managing_BT_Adapter">Managing Bluetooth Tutorial</a>.
</p>
<div class="synopsis"><pre class="signature prettyprint">void setPowered(boolean state, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback);
</pre></div>
function powerOn()
{
- /* If adapter is not powered on */
- if (!adapter.powered)
- {
- /* Initiates power on */
- adapter.setPowered(true, function()
- {
- console.log("Bluetooth powered on success.");
- }, function(e)
- {
- console.log("Failed to power on Bluetooth: " + e.message);
- });
- }
+ /* If adapter is not powered on */
+ if (!adapter.powered)
+ {
+ /* Initiates power on */
+ adapter.setPowered(true, function()
+ {
+ console.log("Bluetooth powered on success.");
+ }, function(e)
+ {
+ console.log("Failed to power on Bluetooth: " + e.message);
+ });
+ }
}
function powerOff()
{
- /* If powered on */
- if (adapter.powered)
- {
- /* Initiates power off */
- adapter.setPowered(false, function()
- {
- console.log("Bluetooth powered off successfully.");
- }, function(e)
- {
- console.log("Failed to power off Bluetooth: " + e.message);
- });
- }
+ /* If powered on */
+ if (adapter.powered)
+ {
+ /* Initiates power off */
+ adapter.setPowered(false, function()
+ {
+ console.log("Bluetooth powered off successfully.");
+ }, function(e)
+ {
+ console.log("Failed to power off Bluetooth: " + e.message);
+ });
+ }
}
var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on");
if (bt_always_on === true)
{
- console.log("Bluetooth cannot be turn off or on because this device must be always enabled.");
+ console.log("Bluetooth cannot be turn off or on because this device must be always enabled.");
}
else
{
- powerOn();
+ powerOn();
}
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
var changeListener =
{
- onstatechanged: function(powered)
- {
- console.log("Power state is changed into: " + powered);
- },
- onnamechanged: function(name)
- {
- console.log("Name is changed to: " + name);
- },
- onvisibilitychanged: function(visible)
- {
- console.log("Visibility is changed into: " + visible);
- }
+ onstatechanged: function(powered)
+ {
+ console.log("Power state is changed into: " + powered);
+ },
+ onnamechanged: function(name)
+ {
+ console.log("Name is changed to: " + name);
+ },
+ onvisibilitychanged: function(visible)
+ {
+ console.log("Visibility is changed into: " + visible);
+ }
};
var adapter = tizen.bluetooth.getDefaultAdapter();
var changeListener =
{
- onstatechanged: function(powered)
- {
- console.log("Power state is changed into: " + powered);
- if (!powered)
- adapter.unsetChangeListener();
- },
- onnamechanged: function(name)
- {
- console.log("Name is changed to: " + name);
- },
- onvisibilitychanged: function(visible)
- {
- console.log("Visibility is changed into: " + visible);
- }
+ onstatechanged: function(powered)
+ {
+ console.log("Power state is changed into: " + powered);
+ if (!powered)
+ adapter.unsetChangeListener();
+ },
+ onnamechanged: function(name)
+ {
+ console.log("Name is changed to: " + name);
+ },
+ onvisibilitychanged: function(visible)
+ {
+ console.log("Visibility is changed into: " + visible);
+ }
};
adapter.setChangeListener(changeListener);
function startDiscovery()
{
- var discoverDevicesSuccessCallback =
- {
- onstarted: function()
- {
- console.log("Device discovery started...");
- },
- ondevicefound: function(device)
+ var discoverDevicesSuccessCallback =
+ {
+ onstarted: function()
+ {
+ console.log("Device discovery started...");
+ },
+ ondevicefound: function(device)
+ {
+ console.log("Found device - name: " + device.name + ", Address: "+ device.address);
+ },
+ ondevicedisappeared: function(address)
+ {
+ console.log("Device disappeared: " + address);
+ },
+ onfinished: function(devices)
+ {
+ console.log("Found Devices");
+ for (var i = 0; i < devices.length; i++)
{
- console.log("Found device - name: " + device.name + ", Address: " + device.address);
- },
- ondevicedisappeared: function(address)
- {
- console.log("Device disappeared: " + address);
- },
- onfinished: function(devices)
- {
- console.log("Found Devices");
- for (var i = 0; i < devices.length; i++)
- {
- console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
- }
- console.log("Total: " + devices.length);
+ console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
}
- };
-
- /* Starts searching for nearby devices, for about 12 sec */
- adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
- {
- console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
- });
+ console.log("Total: " + devices.length);
+ }
+ };
+
+ /* Starts searching for nearby devices, for about 12 sec */
+ adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
+ {
+ console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
+ });
}
function onSetPoweredError(e)
{
- console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
+ console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
}
adapter.setPowered(true, startDiscovery, onSetPoweredError);
/* Calls this method whenever user finds one of the device */
function cancelDiscovery()
{
- adapter.stopDiscovery(function()
- {
- console.log("Stop discovery success.");
- }, function(e)
- {
- console.log("Error while stopDiscovery:" + e.message);
- });
+ adapter.stopDiscovery(function()
+ {
+ console.log("Stop discovery success.");
+ }, function(e)
+ {
+ console.log("Error while stopDiscovery:" + e.message);
+ });
}
function startDiscovery()
{
- var discoverDevicesSuccessCallback =
- {
- onstarted: function()
- {
- console.log("Device discovery started...");
- },
- ondevicefound: function(device)
- {
- console.log("Found device - name: " + device.name + ", Address: " + device.address);
- /* Shows the device to user to check if this is the device user is looking for */
- /* For example, add this to list view */
-
- cancelDiscovery();
- },
- ondevicedisappeared: function(address)
- {
- console.log("Device disappeared: " + address);
- /* Removes from list, as it is no longer valid */
- },
- onfinished: function(devices)
+ var discoverDevicesSuccessCallback =
+ {
+ onstarted: function()
+ {
+ console.log("Device discovery started...");
+ },
+ ondevicefound: function(device)
+ {
+ console.log("Found device - name: " + device.name + ", Address: "+ device.address);
+ /* Shows the device to user to check if this is the device user is looking for */
+ /* For example, add this to list view */
+
+ cancelDiscovery();
+ },
+ ondevicedisappeared: function(address)
+ {
+ console.log("Device disappeared: " + address);
+ /* Removes from list, as it is no longer valid */
+ },
+ onfinished: function(devices)
+ {
+ console.log("Found Devices");
+ for (var i = 0; i < devices.length; i++)
{
- console.log("Found Devices");
- for (var i = 0; i < devices.length; i++)
- {
- console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
- }
- console.log("Total: " + devices.length);
+ console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
}
- };
-
- /* Starts searching for nearby devices, for about 12 sec */
- adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
- {
- console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
- });
+ console.log("Total: " + devices.length);
+ }
+ };
+
+ /* Starts searching for nearby devices, for about 12 sec */
+ adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
+ {
+ console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
+ });
}
function onSetPoweredError(e)
{
- console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
+ console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
}
adapter.setPowered(true, startDiscovery, onSetPoweredError);
function onGotDevices(devices)
{
- console.log("Devices");
- for (var i = 0; i < devices.length; i++)
- {
- console.log(" Name: " + devices[i].name + ", Address: " + devices[i].address);
- }
- console.log("Total: " + devices.length);
+ console.log("Devices");
+ for (var i = 0; i < devices.length; i++)
+ {
+ console.log(" Name: " + devices[i].name + ", Address: " + devices[i].address);
+ }
+ console.log("Total: " + devices.length);
}
function onError(e)
{
- console.log("Error: " + e.message);
+ console.log("Error: " + e.message);
}
function onBluetoothsetPowered()
{
- adapter.getKnownDevices(onGotDevices, onError);
+ adapter.getKnownDevices(onGotDevices, onError);
}
/* Turns on Bluetooth */
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function gotDeviceInfo(device)
{
- console.log("Device Name: " + device.name);
- console.log("Device Address: " + device.address);
- console.log("Device Class: " + device.deviceClass.major);
- console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No"));
+ console.log("Device Name: " + device.name);
+ console.log("Device Address: " + device.address);
+ console.log("Device Class: " + device.deviceClass.major);
+ console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No"));
}
function onError(e)
{
- console.log("Could not get device info:" + e.message);
+ console.log("Could not get device info:" + e.message);
}
var adapter = tizen.bluetooth.getDefaultAdapter();
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onBondingSuccess(device)
{
- console.log("Device Name:" + device.name);
- console.log("Device Address:" + device.address);
- console.log("Device Service UUIDs:" + device.uuids.join("\n"));
+ console.log("Device Name:" + device.name);
+ console.log("Device Address:" + device.address);
+ console.log("Device Service UUIDs:" + device.uuids.join("\n"));
}
function onError(e)
{
- console.log("Could not create bonding, reason:" + e.message);
+ console.log("Could not create bonding, reason:" + e.message);
}
var adapter = tizen.bluetooth.getDefaultAdapter();
function gotDevice(device)
{
- if (device.isBonded)
- {
- /* Initiates destroying bonding */
- adapter.destroyBonding(device.address, function()
- {
- console.log("Succeeded to destroy the bond success with:" + device.address);
- }, function(e)
- {
- console.log("Failed to destroy the bond with " + device.address + ", reason: " + e.message);
- });
- }
+ if (device.isBonded)
+ {
+ /* Initiates destroying bonding */
+ adapter.destroyBonding(device.address, function()
+ {
+ console.log("Succeeded to destroy the bond success with:" + device.address);
+ }, function(e)
+ {
+ console.log("Failed to destroy the bond with " + device.address + ", reason: " + e.message);
+ });
+ }
}
var deviceAddress = "35:F4:59:D1:7A:03";
adapter.getDevice(deviceAddress, gotDevice, function(e)
{
- console.log("Failed to get device info for " + deviceAddress + ", reason: " + e.message);
+ console.log("Failed to get device info for " + deviceAddress + ", reason: " + e.message);
});
</pre>
</div>
function chatServiceSuccessCb(recordHandler)
{
- console.log("Chat service registration succeeds!");
- chatServiceHandler = recordHandler;
- recordHandler.onconnect = function(socket)
- {
- console.log("Client connected: " + socket.peer.name + "," + socket.peer.address);
- serviceSocket = socket;
- /* Messages received from remote device */
- socket.onmessage = function()
- {
- var data = socket.readData();
- /* Handles message code goes here */
- };
+ console.log("Chat service registration succeeds!");
+ chatServiceHandler = recordHandler;
+ recordHandler.onconnect = function(socket)
+ {
+ console.log("Client connected: " + socket.peer.name + "," + socket.peer.address);
+ serviceSocket = socket;
+ /* Messages received from remote device */
+ socket.onmessage = function()
+ {
+ var data = socket.readData();
+ /* Handles message code goes here */
+ };
- socket.onclose = function()
- {
- console.log('The socket is closed.');
- serviceSocket = null;
- };
- };
+ socket.onclose = function()
+ {
+ console.log("The socket is closed.");
+ serviceSocket = null;
+ };
+ };
};
function publishChatService()
{
- var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
- adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb,
- /* Error handler: function(e) {console.log("Could not register service record, Error: " + e.message);} */);
+ var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
+ adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb,
+ /* Error handler */
+ function(e)
+ {
+ console.log( "Could not register service record, Error: " + e.message);
+ });
}
function unregisterChatService()
{
- if (chatServiceHandler != null)
- {
- chatServiceHandler.unregister(function()
- {
- console.log("Chat service is unregistered");
- chatServiceHandler = null;
- }, function(e)
- {
- console.log("Failed to unregister service: " + e.message);
- });
- }
+ if (chatServiceHandler != null)
+ {
+ chatServiceHandler.unregister(function()
+ {
+ console.log("Chat service is unregistered");
+ chatServiceHandler = null;
+ }, function(e)
+ {
+ console.log("Failed to unregister service: " + e.message);
+ });
+ }
}
</pre>
</div>
if (healthCapability)
{
- healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
+ healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
}
else
{
- console.log("Bluetooth Health Profile is not supported on this device.");
+ console.log("Bluetooth Health Profile is not supported on this device.");
}
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("[Found device] address: " + device.address);
+ console.log("[Found device] address: " + device.address);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- adapter.stopScan();
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ adapter.stopScan();
+ }
});
</pre>
</div>
var heart_rate_svc_uuid_16 = "180d"; /* Service solicitation UUID, 16-bit UUID is supported (e.g. 180d) */
var advertiseOptions =
{
- includeName: true, /* Whether the device name should be included */
- includeTxPowerLevel: true, /* Whether the transmission power level should be included */
- appearance: 192, /* External appearance of device, 192 - Generic Watch */
- uuids: [battery_svc_uuid_16],
- solicitationuuids: [heart_rate_svc_uuid_16]
+ includeName: true, /* Whether the device name should be included */
+ includeTxPowerLevel: true, /* Whether the transmission power level should be included */
+ appearance: 192, /* External appearance of device, 192 - Generic Watch */
+ uuids: [battery_svc_uuid_16],
+ solicitationuuids: [heart_rate_svc_uuid_16]
};
var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions);
adapter.startAdvertise(advertiseData, "ADVERTISE", function onstate(state)
{
- console.log("Advertiser state: " + state);
+ console.log("Advertiser state: " + state);
}, function(e)
{
- console.log("Failed to startAdvertise: " + e.message);
+ console.log("Failed to startAdvertise: " + e.message);
}, "LOW_LATENCY", connectable);
</pre>
</div>
var heart_rate_svc_uuid_16 = "180d"; /* Service solicitation UUID, 16-bit UUID is supported (e.g. 180d) */
var advertiseOptions =
{
- includeName: true, /* Whether the device name should be included */
- includeTxPowerLevel: true, /* Whether the transmission power level should be included */
- appearance: 192, /* External appearance of device, 192 - Generic Watch */
- uuids: [battery_svc_uuid_16],
- solicitationuuids: [heart_rate_svc_uuid_16]
+ includeName: true, /* Whether the device name should be included */
+ includeTxPowerLevel: true, /* Whether the transmission power level should be included */
+ appearance: 192, /* External appearance of device, 192 - Generic Watch */
+ uuids: [battery_svc_uuid_16],
+ solicitationuuids: [heart_rate_svc_uuid_16]
};
var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions);
adapter.startAdvertise(advertiseData, "ADVERTISE", function onstate(state)
{
- console.log("Advertiser state: " + state);
+ console.log("Advertiser state: " + state);
});
adapter.stopAdvertise();
</pre>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onconnected(device)
{
- console.log("Connected to device");
- var service = device.getService(device.uuids[0]);
- console.log("Service got");
+ console.log("Connected to device");
+ var service = device.getService(device.uuids[0]);
+ console.log("Service got");
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("[Found device] address: " + device.address);
- device.connect(onconnected.bind(null, device), onerror);
+ console.log("[Found device] address: " + device.address);
+ device.connect(onconnected.bind(null, device), onerror);
});
</pre>
</div>
var service = device.getService(device.uuids[0]);
for (var i = 0; i service.services.length; ++i)
{
- console.log("Subservices UUID " + service.services[i].uuid);
+ console.log("Subservices UUID " + service.services[i].uuid);
}
</pre>
</div>
var service = device.getService(device.uuids[0]);
for (var i = 0; i service.characteristics.length; ++i)
{
- console.log("Subservices UUID " + service.characteristics[i].isWritable);
+ console.log("Subservices UUID " + service.characteristics[i].isWritable);
}
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Failed to connect to device: " + e.message);
+ console.log("Failed to connect to device: " + e.message);
}
function proccessDevice(device)
{
- device.connect(onConnected, onerror);
- function onConnected()
- {
- var service = device.getService(device.uuids[0]);
- if (service.characteristics.length > 0)
+ device.connect(onConnected, onerror);
+ function onConnected()
+ {
+ var service = device.getService(device.uuids[0]);
+ if (service.characteristics.length > 0)
+ {
+ var characteristic = service.characteristics[0];
+ characteristic.readValue(function(val)
{
- var characteristic = service.characteristics[0];
- characteristic.readValue(function(val)
- {
- console.log("Value read: " + val);
- device.disconnect();
- });
- }
- }
+ console.log("Value read: " + val);
+ device.disconnect();
+ });
+ }
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- proccessDevice(device);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ proccessDevice(device);
+ }
});
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Failed to connect to device: " + e.message);
+ console.log("Failed to connect to device: " + e.message);
}
function proccessDevice(device)
{
- device.connect(onConnected, onerror);
- function onConnected()
- {
- var service = device.getService(device.uuids[0]);
- if (service.characteristics.length > 0)
+ device.connect(onConnected, onerror);
+ function onConnected()
+ {
+ var service = device.getService(device.uuids[0]);
+ if (service.characteristics.length > 0)
+ {
+ var characteristic = service.characteristics[0];
+ var data = new Array(1, 2, 3, 4, 5, 6);
+ characteristic.writeValue(data, function()
{
- var characteristic = service.characteristics[0];
- var data = new Array(1, 2, 3, 4, 5, 6);
- characteristic.writeValue(data, function()
- {
- console.log("Value written");
- device.disconnect();
- }, function(e)
- {
- console.log("Failed to write: " + e.message);
- });
- }
- }
+ console.log("Value written");
+ device.disconnect();
+ }, function(e)
+ {
+ console.log("Failed to write: " + e.message);
+ });
+ }
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- proccessDevice(device);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ proccessDevice(device);
+ }
});
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function proccessDevice(device)
{
- function onConnected()
- {
- var service = device.getService("5BCE9431-6C75-32AB-AFE0-2EC108A30860");
- if (service.characteristics.length > 0)
- {
- var characteristic = service.characteristics[0];
- var watchID;
-
- watchID = characteristic.addValueChangeListener(function(value)
- {
- console.log("Characteristic value changed: " + value);
- characteristic.removeValueChangeListener(watchID);
- device.disconnect();
- });
- }
- }
+ function onConnected()
+ {
+ var service = device.getService("5BCE9431-6C75-32AB-AFE0-2EC108A30860");
+ if (service.characteristics.length > 0)
+ {
+ var characteristic = service.characteristics[0];
+ var watchID;
- device.connect(onConnected);
+ watchID = characteristic.addValueChangeListener(function(value)
+ {
+ console.log("Characteristic value changed: " + value);
+ characteristic.removeValueChangeListener(watchID);
+ device.disconnect();
+ });
+ }
+ }
+ device.connect(onConnected);
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- adapter.stopScan();
- proccessDevice(device);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ adapter.stopScan();
+ proccessDevice(device);
+ }
});
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Failed to connect to device: " + e.message);
+ console.log("Failed to connect to device: " + e.message);
}
function proccessDevice(device)
{
- device.connect(onConnected, onerror);
- function onConnected()
- {
- var service = device.getService(device.uuids[0]);
- if (service.characteristics.length > 0)
+ device.connect(onConnected, onerror);
+ function onConnected()
+ {
+ var service = device.getService(device.uuids[0]);
+ if (service.characteristics.length > 0)
+ {
+ var characteristic = service.characteristics[0];
+ var descriptor = characteristic.descriptors[0];
+ descriptor.readValue(function(val)
{
- var characteristic = service.characteristics[0];
- var descriptor = characteristic.descriptors[0];
- descriptor.readValue(function(val)
- {
- console.log("Value read: " + val);
- device.disconnect();
- });
- }
- }
+ console.log("Value read: " + val);
+ device.disconnect();
+ });
+ }
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- proccessDevice(device);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ proccessDevice(device);
+ }
});
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Failed to connect to device: " + e.message);
+ console.log("Failed to connect to device: " + e.message);
}
function proccessDevice(device)
{
- device.connect(onConnected, onerror);
- function onConnected()
- {
- var service = device.getService(device.uuids[0]);
- if (service.characteristics.length > 0)
+ device.connect(onConnected, onerror);
+ function onConnected()
+ {
+ var service = device.getService(device.uuids[0]);
+ if (service.characteristics.length > 0)
+ {
+ var characteristic = service.characteristics[0];
+ var data = new Array(1, 2, 3, 4, 5, 6);
+ var descriptor = characteristic.descriptors[0];
+ descriptor.writeValue(data, function()
{
- var characteristic = service.characteristics[0];
- var data = new Array(1, 2, 3, 4, 5, 6);
- var descriptor = characteristic.descriptors[0];
- descriptor.writeValue(data, function()
- {
- console.log("Value written");
- device.disconnect();
- }, function(e)
- {
- console.log("Failed to write: " + e.message);
- });
- }
- }
+ console.log("Value written");
+ device.disconnect();
+ }, function(e)
+ {
+ console.log("Failed to write: " + e.message);
+ });
+ }
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- proccessDevice(device);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ proccessDevice(device);
+ }
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Device Name: " + device.name);
+ console.log("Device Name: " + device.name);
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Device Address: " + device.address);
+ console.log("Device Address: " + device.address);
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Device Major Class: " + device.deviceClass.major);
+ console.log("Device Major Class: " + device.deviceClass.major);
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Is bonded: " + (device.isBonded ? "Yes" : "No"));
+ console.log("Is bonded: " + (device.isBonded ? "Yes" : "No"));
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Is trusted: " + (device.isTrusted ? "Yes" : "No"));
+ console.log("Is trusted: " + (device.isTrusted ? "Yes" : "No"));
});
</pre>
</div>
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- console.log("Is connected: " + (device.isConnected ? "Yes" : "No"));
+ console.log("Is connected: " + (device.isConnected ? "Yes" : "No"));
});
</pre>
</div>
var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
adapter.getDevice("11:22:33:44:55:66", function(device)
{
- var uuids = device.uuids;
- var services = "";
- for (var i = 0; i < uuids.length; i++)
- {
- services += uuids[i] + "\n";
- }
- console.log("Services found: " + services);
- if (uuids.indexOf(CHAT_SERVICE_UUID) != -1)
- {
- /* Connects to service */
- device.connectToServiceByUUID(CHAT_SERVICE_UUID, function(socket)
- {
- /* Connected to service, handle socket */
- }, function(e)
- {
- console.log("Could not connect to chat service !!!. Error: " + e.message);
- });
- }
+ var uuids = device.uuids;
+ var services = "";
+ for (var i = 0; i < uuids.length; i++)
+ {
+ services += uuids[i] + "\n";
+ }
+ console.log("Services found: " + services);
+ if (uuids.indexOf(CHAT_SERVICE_UUID) != -1)
+ {
+ /* Connects to service */
+ device.connectToServiceByUUID(CHAT_SERVICE_UUID, function(socket)
+ {
+ /* Connected to service, handle socket */
+ }, function(e)
+ {
+ console.log("Could not connect to chat service !!!. Error: " + e.message);
+ });
+ }
});
</pre>
</div>
/* Calls a method that is invoked when user wants to send a message to a remote device */
function sendMessage(msg)
{
- /* Validates socket state, if everything is ok */
- if (clientSocket != null && clientSocket.state == "OPEN")
- {
- /* Sends the message */
- clientSocket.writeData(msg);
- }
+ /* Validates socket state, if everything is ok */
+ if (clientSocket != null && clientSocket.state == "OPEN")
+ {
+ /* Sends the message */
+ clientSocket.writeData(msg);
+ }
}
/* Calls a method that is invoked when a socket is open */
function onSocketConnected(socket)
{
- clientSocket = socket;
- console.log("Opening a socket successfully!!!");
- socket.onmessage = function()
- {
- var data = socket.readData();
- var recvmsg = "";
- for (var i = 0; i < data.length; i++)
- {
- recvmsg += String.fromCharCode(data[i]);
- }
- console.log("server msg >> " + recvmsg);
- };
-
- socket.onclose = function()
- {
- console.log("socket disconnected.");
- };
+ clientSocket = socket;
+ console.log("Opening a socket successfully!!!");
+ socket.onmessage = function()
+ {
+ var data = socket.readData();
+ var recvmsg = "";
+ for (var i = 0; i < data.length; i++)
+ {
+ recvmsg += String.fromCharCode(data[i]);
+ }
+ console.log("server msg >> " + recvmsg);
+ };
+
+ socket.onclose = function()
+ {
+ console.log("socket disconnected.");
+ };
}
function onDeviceReady(device)
{
- /* Validates device and service uuid */
- if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
- {
- /* Opens socket */
- device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, function(e)
- {
- console.log("Error connecting to service. Reason: " + e.message);
- });
- }
- else
- {
- console.log("Chat service is not supported by this device");
- }
+ /* Validates device and service uuid */
+ if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
+ {
+ /* Opens socket */
+ device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, function(e)
+ {
+ console.log("Error connecting to service. Reason: " + e.message);
+ });
+ }
+ else
+ {
+ console.log("Chat service is not supported by this device");
+ }
}
function onSetPowered()
{
- /* Gets the BluetoothDevice object */
- adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
+ /* Gets the BluetoothDevice object */
+ adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message); });
}
adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message); });
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("Found device: " + device.address);
+ console.log("Found device: " + device.address);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("Found device: " + device.name);
+ console.log("Found device: " + device.name);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("Found device: " + device.txpowerlevel);
+ console.log("Found device: " + device.txpowerlevel);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("Found device: " + device.appearance);
+ console.log("Found device: " + device.appearance);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- var uuids = device.uuids;
- var services = "";
- for (var i = 0; i < uuids.length; i++)
- {
- services += uuids[i] + "\n";
- }
- console.log("Service found: " + services);
+ var uuids = device.uuids;
+ var services = "";
+ for (var i = 0; i < uuids.length; i++)
+ {
+ services += uuids[i] + "\n";
+ }
+ console.log("Service found: " + services);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- var uuids = device.solicitationuuids;
- var services = "";
- for (var i = 0; i < uuids.length; i++)
- {
- services += uuids[i] + "\n";
- }
- console.log("Service solicitations found: " + services);
+ var uuids = device.solicitationuuids;
+ var services = "";
+ for (var i = 0; i < uuids.length; i++)
+ {
+ services += uuids[i] + "\n";
+ }
+ console.log("Service solicitations found: " + services);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- var serviceData = device.serviceData;
- var data = "";
- for (var i = 0; i < serviceData.length; i++)
- {
- data += serviceData[i].id + serviceData[i].data + "\n";
- }
- console.log("Service data found: " + data);
+ var serviceData = device.serviceData;
+ var data = "";
+ for (var i = 0; i < serviceData.length; i++)
+ {
+ data += serviceData[i].id + serviceData[i].data + "\n";
+ }
+ console.log("Service data found: " + data);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- var manufacturerData = device.manufacturerData;
- console.log("Manufacture id: " + manufacturerData.id);
- console.log("Manufacture data: " + manufacturerData.data);
+ var manufacturerData = device.manufacturerData;
+ console.log("Manufacture id: " + manufacturerData.id);
+ console.log("Manufacture data: " + manufacturerData.data);
});
</pre>
</div>
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- console.log("Found device: " + device.name);
- console.log("RSSI: " + device.rssi);
+ console.log("Found device: " + device.name);
+ console.log("RSSI: " + device.rssi);
});
</pre>
</div>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Failed to connect to device: " + e.message);
+ console.log("Failed to connect to device: " + e.message);
}
function onconnected()
{
- console.log("Connected to device");
+ console.log("Connected to device");
}
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function onsuccess(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- device.connect(onconnected, onerror);
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ device.connect(onconnected, onerror);
}
});
</pre>
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Error occurred: " + e.message);
+ console.log("Error occurred: " + e.message);
}
function onDeviceFound(device)
{
- function ondisconnect()
- {
- console.log("Disconnected");
- }
-
- function onconnected()
- {
- console.log("Connected to device");
- device.disconnect(ondisconnect, onerror);
- }
-
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- device.connect(onconnected, onerror);
- }
+ function ondisconnect()
+ {
+ console.log("Disconnected");
+ }
+
+ function onconnected()
+ {
+ console.log("Connected to device");
+ device.disconnect(ondisconnect, onerror);
+ }
+
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ device.connect(onconnected, onerror);
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onconnected(device)
{
- console.log("Connected to device");
- var service = device.getService(device.uuids[0]);
- console.log("Service got");
+ console.log("Connected to device");
+ var service = device.getService(device.uuids[0]);
+ console.log("Service got");
}
function onerror(e)
{
- console.log("Error occurred: " + e.message);
+ console.log("Error occurred: " + e.message);
}
function onDeviceFound(device)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- device.connect(onconnected.bind(null, device), onerror);
- }
+ if (device.address == "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ device.connect(onconnected.bind(null, device), onerror);
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
</div>
<div class="example">
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
-/* Below variable should represent valid address of discoverable bluetooth low energy device */
+/*Below variable should represent valid address of discoverable bluetooth low energy device */
var remoteAddress = "11:22:33:44:55:66";
function onconnected(device)
{
- console.log("Connected to device");
- var services = device.getServiceAllUuids();
- console.log("Services length " + services.length);
+ console.log("Connected to device");
+ var services = device.getServiceAllUuids();
+ console.log("Services length " + services.length);
}
function onerror(e)
{
- console.log("Error occurred: " + e.message);
+ console.log("Error occurred: " + e.message);
}
function onDeviceFound(device)
{
- if (device.address == remoteAddress)
- {
- device.connect(onconnected.bind(null, device), onerror);
- }
+ if (device.address == remoteAddress)
+ {
+ device.connect(onconnected.bind(null, device), onerror);
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Error occurred: " + e.message);
+ console.log("Error occurred: " + e.message);
}
function onDeviceFound(device)
{
- var onConnectionStateChange =
- {
- onconnected: function(device)
- {
- console.log("Device " + device.name + " connected");
- },
- ondisconnected: function(device)
- {
- console.log("Device " + device.name + " disconnected");
- }
- }
-
- if (device.address === "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- device.addConnectStateChangeListener(onConnectionStateChange);
- device.connect();
- }
+ var onConnectionStateChange =
+ {
+ onconnected: function(device)
+ {
+ console.log("Device " + device.name + " connected");
+ },
+ ondisconnected: function(device)
+ {
+ console.log("Device " + device.name + " disconnected");
+ }
+ }
+
+ if (device.address === "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ device.addConnectStateChangeListener(onConnectionStateChange);
+ device.connect();
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
function onerror(e)
{
- console.log("Error occurred: " + e.message);
+ console.log("Error occurred: " + e.message);
}
function onDeviceFound(device)
{
- var onConnectionStateChange =
- {
- onconnected: function(device)
- {
- console.log("Device " + device.name + " connected");
- },
- ondisconnected: function(device)
- {
- console.log("Device " + device.name + " disconnected");
- device.removeConnectStateChangeListener(listenerID);
- }
- }
-
- if (device.address === "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- listenerID = device.addConnectStateChangeListener(onConnectionStateChange);
- device.connect();
- }
+ var onConnectionStateChange =
+ {
+ onconnected: function(device)
+ {
+ console.log("Device " + device.name + " connected");
+ },
+ ondisconnected: function(device)
+ {
+ console.log("Device " + device.name + " disconnected");
+ device.removeConnectStateChangeListener(listenerID);
+ }
+ }
+
+ if (device.address === "11:22:33:44:55:66")
+ {
+ console.log("Found device: " + device.name);
+ listenerID = device.addConnectStateChangeListener(onConnectionStateChange);
+ device.connect();
+ }
}
var adapter = tizen.bluetooth.getLEAdapter();
function onSocketConnected(socket)
{
- console.log("Opened connection to remote device");
- socket.onmessage = function()
- {
- console.log("Message received: " + socket.readData());
- };
-
- socket.onclose = function()
- {
- console.log("Socket closed with " + socket.peer.name);
- };
-
- /* Sends data to peer */
- var textmsg = "Test";
- var sendtextmsg = new Array();
- for (var i = 0; i < textmsg.length; i++)
- {
- sendtextmsg[i] = textmsg.charCodeAt(i);
- }
- socket.writeData(sendtextmsg);
+ console.log("Opened connection to remote device");
+ socket.onmessage = function()
+ {
+ console.log("Message received: " + socket.readData());
+ };
+
+ socket.onclose = function()
+ {
+ console.log("Socket closed with " + socket.peer.name);
+ };
+
+ /* Sends data to peer */
+ var textmsg = "Test";
+ var sendtextmsg = new Array();
+ for (var i = 0; i < textmsg.length; i++)
+ {
+ sendtextmsg[i] = textmsg.charCodeAt(i);
+ }
+ socket.writeData(sendtextmsg);
}
function onSocketError(e)
{
- console.log("Error connecting to service. Reason: " + e.message);
+ console.log("Error connecting to service. Reason: " + e.message);
}
function onDeviceReady(device)
{
- /* Validates device and service uuid */
- if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
- {
- /* Opens socket */
- device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onSocketError);
- }
+ /* Validates device and service uuid */
+ if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
+ {
+ /* Opens socket */
+ device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onSocketError);
+ }
}
function onSetPowered()
{
- /* Gets the BluetoothDevice object */
- adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
+ /* Gets the BluetoothDevice object */
+ adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
}
adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message);});
function onError(e)
{
- console.log("Error connecting to service. Reason: " + e.message);
+ console.log("Error connecting to service. Reason: " + e.message);
}
function onSocketConnected(socket)
{
- console.log("Opening socket success!!!");
+ console.log("Opening socket success!!!");
- socket.onmessage = function()
- {
- /* Gets a message from peer, reads it */
- var data = socket.readData();
+ socket.onmessage = function()
+ {
+ /* Gets a message from peer, reads it */
+ var data = socket.readData();
- /* Code to evaluate message goes here */
- };
+ /* Code to evaluate message goes here */
+ };
- socket.onclose = function()
- {
- console.log("Socket closed with " + socket.peer.name);
- };
+ socket.onclose = function()
+ {
+ console.log("Socket closed with " + socket.peer.name);
+ };
}
function onDeviceReady(device)
{
- /* Validates device and service uuid */
- if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
- {
- /* Opens socket */
- device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onError);
- }
+ /* Validates device and service uuid */
+ if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
+ {
+ /* Opens socket */
+ device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onError);
+ }
}
function onSetPowered()
{
- /* Gets the BluetoothDevice object */
- adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
+ /* Gets the BluetoothDevice object */
+ adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
}
adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message);});
readonly attribute octet minor;
- readonly attribute unsigned short [] services ;
+ readonly attribute unsigned short [] services;
boolean hasService(unsigned short service) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
};</pre>
function evaluateDevice(address)
{
- adapter.getDevice(address, function(device)
- {
- if (device.deviceClass.major == tizen.bluetooth.deviceMajor.COMPUTER)
- {
- /* Shows computer icon for this device */
- console.log("Device is computer");
- }
- else if (device.deviceClass.major == tizen.bluetooth.deviceMajor.PHONE)
- {
- /* Shows phone icon */
- console.log("Device is a Phone");
- }
- }, function(e)
- {
- console.log("Couldn't get any device with the given address: " + e.message);
- });
+ adapter.getDevice(address, function(device)
+ {
+ if (device.deviceClass.major == tizen.bluetooth.deviceMajor.COMPUTER)
+ {
+ /* Shows computer icon for this device */
+ console.log("Device is computer");
+ }
+ else if (device.deviceClass.major == tizen.bluetooth.deviceMajor.PHONE)
+ {
+ /* Shows phone icon */
+ console.log("Device is a Phone");
+ }
+ }, function(e)
+ {
+ console.log("Couldn't get any device with the given address: " + e.message);
+ });
}
evaluateDevice("11:22:33:44:55:66");
var adapter = tizen.bluetooth.getDefaultAdapter();
adapter.getDevice("12:34:56:78:9A:BC", function(device)
{
- if (device.deviceClass.hasService(tizen.bluetooth.deviceService.POSITIONING))
- {
- console.log("Device supports Positioning service");
- }
+ if (device.deviceClass.hasService(tizen.bluetooth.deviceService.POSITIONING))
+ {
+ console.log("Device supports Positioning service");
+ }
}, function(e)
{
- console.log("Couldn't get device for given address: " + e.message);
+ console.log("Couldn't get device for given address: " + e.message);
});
</pre>
</div>
<li class="attribute" id="BluetoothServiceHandler::uuid">
<span class="attrName"><span class="readonly"> readonly
</span><span class="type">BluetoothUUID </span><span class="name">uuid</span></span><div class="brief">
- The UUID of the service. See <a href="#BluetoothServiceHandler::onconnect">example</a>.
+ The UUID of the service. See <a href="#BluetoothServiceHandler::onconnect">example
+</a>.
</div>
<p><span class="version">
Since: </span>
<li class="attribute" id="BluetoothServiceHandler::name">
<span class="attrName"><span class="readonly"> readonly
</span><span class="type">DOMString </span><span class="name">name</span></span><div class="brief">
- The name of the service. See <a href="#BluetoothServiceHandler::onconnect">example</a>.
+ The name of the service. See <a href="#BluetoothServiceHandler::onconnect">example
+</a>.
</div>
<p><span class="version">
Since: </span>
function chatServiceSuccessCb(handler)
{
- console.log("Chat service " + handler.name + " with UUID " + handler.uuid + " is successfully registered!");
- console.log("There is " + (handler.isConnected ? "a" : "no") + " device using this service");
+ console.log("Chat service " + handler.name + " with UUID " + handler.uuid + " is successfully registered!");
+ console.log("There is " + (handler.isConnected ? "a" : "no") + " device using this service");
- handler.onconnect = function(socket)
- {
- console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address);
- socket.onmessage = function()
- {
- var data = socket.readData();
- /* Handle message code here */
- };
+ handler.onconnect = function(socket)
+ {
+ console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address);
+ socket.onmessage = function()
+ {
+ var data = socket.readData();
+ /* Handle message code goes here */
+ };
- /* Expected close */
- socket.onclose = function()
- {
- console.log('The socket is closed.');
- };
- };
+ /* Expected close */
+ socket.onclose = function()
+ {
+ console.log("The socket is closed.");
+ };
+ };
}
function errorCb(e)
{
- console.log("Could not register service record, Error: " + e.message);
+ console.log("Could not register service record, Error: " + e.message);
}
var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
function chatServiceSuccessCb(handler)
{
- console.log("Chat service registration was successful!");
+ console.log("Chat service registration was successful!");
- chatServiceHandler = handler;
- handler.onconnect = function(socket)
- {
- console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address);
- socket.onmessage = function()
- {
- var data = socket.readData();
- /* Handle message code here */
- };
+ chatServiceHandler = handler;
+ handler.onconnect = function(socket)
+ {
+ console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address);
+ socket.onmessage = function()
+ {
+ var data = socket.readData();
+ /* Handle message code goes here */
+ };
- /* Expected close */
- socket.onclose = function()
- {
- console.log('The socket is closed.');
- };
- };
+ /* Expected close */
+ socket.onclose = function()
+ {
+ console.log("The socket is closed.");
+ };
+ };
}
function publishChatService()
{
- var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
- adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb,
- /* Error handler: function(e) {console.log("Could not register service record, Error: " + e.message);} */);
+ var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
+ adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb,
+ /* Error handler */
+ function(e)
+ {
+ console.log("Could not register service record, Error: " + e.message);
+ });
}
function unRegisterChatService()
{
- if (chatServiceHandler != null)
- {
- chatServiceHandler.unregister(function()
- {
- chatServiceHandler = null;
- console.log("Chat service is unregistered.");
+ if (chatServiceHandler != null)
+ {
+ chatServiceHandler.unregister(function()
+ {
+ chatServiceHandler = null;
+ console.log("Chat service is unregistered.");
}, function(e)
- {
- console.log("Error: " + e.message);
- });
- }
+ {
+ console.log("Error: " + e.message);
+ });
+ }
}
</pre>
</div>
if (healthCapability)
{
- var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
- console.log("Bluetooth profile type is " + healthProfileHandler.profileType);
+ var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
+ console.log("Bluetooth profile type is " + healthProfileHandler.profileType);
}
else
{
- console.log("Bluetooth Health Profile is not supported on this device.");
+ console.log("Bluetooth Health Profile is not supported on this device.");
}
</pre>
</div>
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
+ console.log("Registered application: " + app.name);
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
function healthConnectSuccess(channel)
{
- console.log("Health device is connected");
- var status = "Name of remote device: " + channel.peer.name +
- "channel type of device profile: " + channel.channelType +
- "health application name: " + channel.appication.name;
- console.log(status);
+ console.log("Health device is connected");
+ var status = "Name of remote device: " + channel.peer.name +
+ "channel type of device profile: " + channel.channelType +
+ "health application name: " + channel.appication.name;
+ console.log(status);
}
function healthConnectError(e)
{
- console.log("Failed to connect to source: " + e.message);
+ console.log("Failed to connect to source: " + e.message);
};
function gotDeviceInfo(device)
{
- healthProfileHandler.connectToSource(device, registerHealthApp, healthConnectSuccess, healthConnectError);
+ healthProfileHandler.connectToSource(device, registerHealthApp, healthConnectSuccess, healthConnectError);
}
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- registerHealthApp = app;
- adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo);
+ console.log("Registered application: " + app.name);
+ registerHealthApp = app;
+ adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo);
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- console.log("Data type used for communication is " + app.dataType);
+ console.log("Registered application: " + app.name);
+ console.log("Data type used for communication is " + app.dataType);
- app.onconnect = function(channel)
- {
- console.log("Health device is connected");
- }
+ app.onconnect = function(channel)
+ {
+ console.log("Health device is connected");
+ }
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- healthApp = app;
- healthApp.onconnect = function(channel)
- {
- console.log("Connected!!");
- };
+ console.log("Registered application: " + app.name);
+ healthApp = app;
+ healthApp.onconnect = function(channel)
+ {
+ console.log("Connected!!");
+ };
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
function startSink()
{
- try
- {
- healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
- }
- catch (e)
- {
- console.log("Error: " + e.message);
- }
+ try
+ {
+ healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
+ }
+ catch (e)
+ {
+ console.log("Error: " + e.message);
+ }
}
function stopSink()
{
- try
- {
- if (healthApp != null)
+ try
+ {
+ if (healthApp != null)
+ {
+ healthApp.unregister(function()
{
- healthApp.unregister(function()
- {
- healthApp = null;
- console.log("Health application is unregistered.");
- }, function(e)
- {
- console.log("Error: " + e.message);
- });
- }
- }
- catch (err)
- {
- console.log("Error: " + err.message);
- }
+ healthApp = null;
+ console.log("Health application is unregistered.");
+ }, function(e)
+ {
+ console.log("Error: " + e.message);
+ });
+ }
+ }
+ catch (err)
+ {
+ console.log("Error: " + err.message);
+ }
}
</pre>
</div>
function healthRegisterSuccess(app)
{
- app.onconnect = function(channel)
- {
- console.log("Health device " + (channel.isConnected ? "is" : "is not") + " connected to " + channel.peer.name + " remote device");
- console.log("Channel type is " + channel.channelType + " and health application name used for communication is " + channel.application.name);
- }
+ app.onconnect = function(channel)
+ {
+ console.log("Health device " + (channel.isConnected ? "is" : "is not") + " connected to " + channel.peer.name + " remote device");
+ console.log("Channel type is " + channel.channelType + " and health application name used for communication is " + channel.application.name);
+ }
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- app.onconnect = function(channel)
- {
- console.log("Health device is connected");
- channel.close();
- }
+ console.log("Registered application: " + app.name);
+ app.onconnect = function(channel)
+ {
+ console.log("Health device is connected");
+ channel.close();
+ }
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
var dataToSend = new Array();
for (var i = 0; i < textmsg.length; i++)
{
- dataToSend[i] = textmsg.charCodeAt(i);
+ dataToSend[i] = textmsg.charCodeAt(i);
}
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- app.onconnect = function(channel)
- {
- console.log("Health device is connected");
- channel.sendData(dataToSend);
- }
+ console.log("Registered application: " + app.name);
+ app.onconnect = function(channel)
+ {
+ console.log("Health device is connected");
+ channel.sendData(dataToSend);
+ }
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
var channelCallback =
{
- onmessage: function(data)
- {
- console.log("data is received")
- },
- onclose: function()
- {
- console.log("channel is closed");
- }
+ onmessage: function(data)
+ {
+ console.log("data is received")
+ },
+ onclose: function()
+ {
+ console.log("channel is closed");
+ }
};
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- app.onconnect = function(channel)
- {
- console.log("Health device is connected");
- channel.setListener(channelCallback);
- }
+ console.log("Registered application: " + app.name);
+ app.onconnect = function(channel)
+ {
+ console.log("Health device is connected");
+ channel.setListener(channelCallback);
+ }
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
var channelCallback =
{
- onmessage: function(data)
- {
- console.log("data is received")
- },
- onclose: function()
- {
- console.log("channel is closed");
- connectedChannel.unsetListener();
- }
+ onmessage: function(data)
+ {
+ console.log("data is received")
+ },
+ onclose: function()
+ {
+ console.log("channel is closed");
+ connectedChannel.unsetListener();
+ }
};
function healthRegisterSuccess(app)
{
- console.log("Registered application: " + app.name);
- app.onconnect = function(channel)
- {
- console.log("Health device is connected");
- connectedChannel = channel;
- connectedChannel.setListener(channelCallback);
- }
+ console.log("Registered application: " + app.name);
+ app.onconnect = function(channel)
+ {
+ console.log("Health device is connected");
+ connectedChannel = channel;
+ connectedChannel.setListener(channelCallback);
+ }
}
function healthRegisterError(e)
{
- console.log("Failed to register application: " + e.message);
+ console.log("Failed to register application: " + e.message);
};
healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback,
optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
- void setPowered(boolean state,
- optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback,
- optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
-
void setChangeListener(<a href="#BluetoothAdapterChangeCallback">BluetoothAdapterChangeCallback</a> listener) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
void unsetChangeListener() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
readonly attribute <a href="#BluetoothLESolicitationUUID">BluetoothLESolicitationUUID</a>[]? solicitationuuids;
readonly attribute <a href="#BluetoothLEServiceData">BluetoothLEServiceData</a>[]? serviceData;
readonly attribute <a href="#BluetoothLEManufacturerData">BluetoothLEManufacturerData</a>? manufacturerData;
+ readonly attribute long rssi;
void connect(optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback,
optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
readonly attribute octet minor;
- readonly attribute unsigned short [] services ;
+ readonly attribute unsigned short [] services;
boolean hasService(unsigned short service) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
};