[Bluetooth] - improving examples
authorPiotr Czaja <p.czaja@samsung.com>
Fri, 29 Jan 2016 11:19:42 +0000 (12:19 +0100)
committerPiotr Czaja <p.czaja@samsung.com>
Mon, 1 Feb 2016 08:05:36 +0000 (09:05 +0100)
Change-Id: I6d08a2a1186d71c914250065490e4b20d65c9edd
Signed-off-by: Piotr Czaja <p.czaja@samsung.com>
org.tizen.web.apireference/html/device_api/mobile/tizen/bluetooth.html

index 5f94932..4667b48 100644 (file)
@@ -503,7 +503,12 @@ The <em>tizen.bluetooth</em> object allows access to the Bluetooth API.
           </p>
 <div class="constructors">
 <h4 id="BluetoothLEServiceData::constructor">Constructors</h4>
-<dl><pre class="webidl prettyprint">BluetoothLEServiceData(DOMString uuid, DOMString data);</pre></dl>
+<dl>
+<pre class="webidl prettyprint">BluetoothLEServiceData(DOMString uuid, DOMString data);</pre>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> // Creates a serviceData.
+ var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811");
+ </pre>
 </div>
 <div class="attributes">
 <h4>Attributes</h4>
@@ -516,6 +521,12 @@ The <em>tizen.bluetooth</em> object allows access to the Bluetooth API.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> // Creates a serviceData.
+ var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811");
+ service.uuid = "f236-41a4";
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothLEServiceData::data">
 <span class="attrName"><span class="type">DOMString </span><span class="name">data</span></span><div class="brief">
@@ -525,6 +536,12 @@ The <em>tizen.bluetooth</em> object allows access to the Bluetooth API.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> // Creates a serviceData.
+ var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811");
+ service.data = "0x1815";
+ </pre>
+</div>
 </li>
 </ul>
 </div>
@@ -565,6 +582,12 @@ The <em>tizen.bluetooth</em> object allows access to the Bluetooth API.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> // Creates a manufacturerData.
+ var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057");
+ manufacturer.id = "129";
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothLEManufacturerData::data">
 <span class="attrName"><span class="type">DOMString </span><span class="name">data</span></span><div class="brief">
@@ -574,6 +597,12 @@ The <em>tizen.bluetooth</em> object allows access to the Bluetooth API.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> // Creates a manufacturerData.
+ var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057");
+ manufacturer.data = "0x0059"
+ </pre>
+</div>
 </li>
 </ul>
 </div>
@@ -601,6 +630,11 @@ The <em>tizen.bluetooth</em> object allows access to the Bluetooth API.
 This dictionary is used as an input parameter of the BluetoothLEAdvertiseData constructor.
           </p>
          </div>
+<div class="example">
+<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  }
+ </pre>
+</div>
 </div>
 <div class="interface" id="BluetoothLEAdvertiseData">
 <a class="backward-compatibility-anchor" name="::Bluetooth::BluetoothLEAdvertiseData"></a><h3>2.5. BluetoothLEAdvertiseData</h3>
@@ -627,6 +661,12 @@ The BluetoothLEAdvertiseData container for Bluetooth LE advertising.
 This represents the data to be advertised as well as the scan response data for active scans.
           </p>
          </div>
+<div class="example">
+<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 }
+ var advertise = new tizen.BluetoothLEAdvertiseData(advertData);
+ </pre>
+</div>
 <div class="constructors">
 <h4 id="BluetoothLEAdvertiseData::constructor">Constructors</h4>
 <dl><pre class="webidl prettyprint">BluetoothLEAdvertiseData(optional <a href="#BluetoothLEAdvertiseDataInit">BluetoothLEAdvertiseDataInit</a>? init);</pre></dl>
@@ -643,6 +683,11 @@ If attribute is set to null, The default value is set to a false.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var advertise = new tizen.BluetoothLEAdvertiseData();
+ advertise.includeName = true;
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothLEAdvertiseData::uuids">
 <span class="attrName"><span class="type">BluetoothUUID[]
@@ -653,6 +698,11 @@ If attribute is set to null, The default value is set to a false.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var advertise = new tizen.BluetoothLEAdvertiseData();
+ advertise.uuids = ["180d"];
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothLEAdvertiseData::solicitationuuids">
 <span class="attrName"><span class="type">BluetoothLESolicitationUUID[]
@@ -663,6 +713,11 @@ If attribute is set to null, The default value is set to a false.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var advertise = new tizen.BluetoothLEAdvertiseData();
+ advertise.solicitationuuids = ["180f"];
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothLEAdvertiseData::appearance">
 <span class="attrName"><span class="type">unsigned long </span><span class="name">appearance</span><span class="optional"> [nullable]</span></span><div class="brief">
@@ -677,6 +732,11 @@ See the <a href="https://developer.bluetooth.org/gatt/characteristics/Pages/Char
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var advertise = new tizen.BluetoothLEAdvertiseData();
+ advertise.appearance = 192;
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothLEAdvertiseData::includeTxPowerLevel">
 <span class="attrName"><span class="type">boolean </span><span class="name">includeTxPowerLevel</span><span class="optional"> [nullable]</span></span><div class="brief">
@@ -687,6 +747,11 @@ If attribute is set to null, The default value is set to a false.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var advertise = new tizen.BluetoothLEAdvertiseData();
+ advertise.includeTxPowerLevel = true;
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothLEAdvertiseData::serviceData">
 <span class="attrName"><span class="type">BluetoothLEServiceData </span><span class="name">serviceData</span><span class="optional"> [nullable]</span></span><div class="brief">
@@ -696,6 +761,12 @@ If attribute is set to null, The default value is set to a false.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var advertise = new tizen.BluetoothLEAdvertiseData();
+ var service = new tizen.BluetoothLEServiceData("c500-11e5", "0x1811");
+ advertise.serviceData = service;
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothLEAdvertiseData::manufacturerData">
 <span class="attrName"><span class="type">BluetoothLEManufacturerData </span><span class="name">manufacturerData</span><span class="optional"> [nullable]</span></span><div class="brief">
@@ -705,6 +776,12 @@ If attribute is set to null, The default value is set to a false.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var advertise = new tizen.BluetoothLEAdvertiseData();
+ var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057");
+ advertise.manufacturerData = manufacture;
+ </pre>
+</div>
 </li>
 </ul>
 </div>
@@ -738,6 +815,10 @@ If attribute is set to null, The default value is set to a false.
             Since: </span>
  1.0
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> console.log(tizen.bluetooth.deviceMajor);
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothManager::deviceMinor">
 <span class="attrName"><span class="readonly">                readonly
@@ -748,6 +829,10 @@ If attribute is set to null, The default value is set to a false.
             Since: </span>
  1.0
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> console.log(tizen.bluetooth.deviceMinor);
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothManager::deviceService">
 <span class="attrName"><span class="readonly">                readonly
@@ -758,6 +843,10 @@ If attribute is set to null, The default value is set to a false.
             Since: </span>
  1.0
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> console.log(tizen.bluetooth.deviceService);
+ </pre>
+</div>
 </li>
 </ul>
 </div>
@@ -806,9 +895,8 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
 </li></ul>
         </div>
 <div class="example">
-<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var adapter = null;
- try {
-     adapter = tizen.bluetooth.getDefaultAdapter() ;
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+     var adapter = tizen.bluetooth.getDefaultAdapter() ;
  } catch (err) {
      console.log (err.name +": " + err.message);
  }
@@ -863,9 +951,8 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
 </li></ul>
         </div>
 <div class="example">
-<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var adapter = null;
- try {
-     adapter = tizen.bluetooth.getLEAdapter();
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+     var adapter = tizen.bluetooth.getLEAdapter();
  } catch (err) {
      console.log(err.name +": " + err.message);
  }
@@ -2469,6 +2556,22 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  2.3.1
           </p>
+<div class="example">
+<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");
+  }
+
+ var adapter = tizen.bluetooth.getLEAdapter();
+ adapter.startScan(
+  function onsuccess(device) {
+    console.log("[Found device] address: " + device.address);
+    device.connect(onconnected.bind(null, device), onerror);
+ });
+
+ </pre>
+</div>
 <div class="attributes">
 <h4>Attributes</h4>
 <ul>
@@ -2481,6 +2584,12 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var service = device.getService(device.uuids[0]);
+ console.log("Service UUID " + service.uuid);
+
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothGATTService::services">
 <span class="attrName"><span class="readonly">                readonly
@@ -2492,6 +2601,14 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var service = device.getService(device.uuids[0]);
+ for( var i = 0; i  service.services.length; ++i) {
+   console.log("Subservices UUID " + service.services[i].uuid);
+ }
+
+ </pre>
+</div>
 </li>
 <li class="attribute" id="BluetoothGATTService::characteristics">
 <span class="attrName"><span class="readonly">                readonly
@@ -2503,6 +2620,14 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  2.3.1
             </p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var service = device.getService(device.uuids[0]);
+ for( var i = 0; i  service.characteristics.length; ++i) {
+   console.log("Subservices UUID " + service.characteristics[i].isWritable);
+ }
+
+ </pre>
+</div>
 </li>
 </ul>
 </div>
@@ -2918,6 +3043,9 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  2.3.1
             </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothGATTCharacteristic::addValueChangeListener">addValueChangeListener</a> code example.
+            </p>
 <div class="parameters">
 <p><span class="param">Parameters:</span></p>
 <ul>
@@ -3158,6 +3286,9 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  2.3.1
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothLEAdapter::startScan">startScan</a> code example.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -3198,6 +3329,9 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  2.3.1
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothLEAdapter::startAdvertise">startAdvertise</a> code example.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -3240,6 +3374,9 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  2.3.1
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothLEDevice::addConnectStateChangeListener">addConnectStateChangeListener</a> code example.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -3300,6 +3437,9 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  2.3.1
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="#BluetoothGATTCharacteristic::readValue">BluetoothGATTCharacteristic.readValue()</a> and <a href="#BluetoothGATTDescriptor::readValue">BluetoothGATTDescriptor.readValue()</a> code examples.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -5245,6 +5385,10 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
 
  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);
  }
 
  function healthConnectError(e) {
@@ -5831,6 +5975,9 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  2.2
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothAdapter::setChangeListener">setChangeListener</a> code example.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -5918,6 +6065,9 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  1.0
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothAdapter::getDevice">getDevice</a> and <a href="bluetooth.html#BluetoothAdapter::createBonding">createBonding</a> code examples.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -5959,6 +6109,9 @@ Instead, use <em>http://tizen.org/privilege/bluetooth</em>.
             Since: </span>
  1.0
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothAdapter::getKnownDevices">getKnownDevices</a> code example.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -6004,6 +6157,9 @@ Each element is a BluetoothDevice.
             Since: </span>
  1.0
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothAdapter::discoverDevices">discoverDevices</a> code example.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -6106,6 +6262,9 @@ After that, this device is no longer visible.
             Since: </span>
  1.0
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothDevice::connectToServiceByUUID">connectToServiceByUUID</a> code example.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -6147,6 +6306,9 @@ After that, this device is no longer visible.
             Since: </span>
  1.0
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothAdapter::registerRFCOMMServiceByUUID">registerRFCOMMServiceByUUID</a> code example.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -6188,6 +6350,9 @@ After that, this device is no longer visible.
             Since: </span>
  2.2
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothHealthProfileHandler::registerSinkApplication">registerSinkApplication</a> code example.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -6229,6 +6394,9 @@ After that, this device is no longer visible.
             Since: </span>
  2.2
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothHealthProfileHandler::connectToSource">connectToSource</a> code example.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>
@@ -6272,6 +6440,9 @@ After that, this device is no longer visible.
             Since: </span>
  2.2
           </p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="bluetooth.html#BluetoothHealthChannel::setListener">setListener</a> code example.
+          </p>
 <div class="methods">
 <h4>Methods</h4>
 <dl>