--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta http-equiv="X-UA-Compatible" content="IE=9" />
+ <link rel="stylesheet" type="text/css" href="../../css/styles.css" />
+ <link rel="stylesheet" type="text/css" href="../../css/snippet.css" />
+ <script type="text/javascript" src="../../scripts/snippet.js"></script>
+ <script type="text/javascript" src="../../scripts/jquery.util.js" charset="utf-8"></script>
+ <script type="text/javascript" src="../../scripts/common.js" charset="utf-8"></script>
+ <script type="text/javascript" src="../../scripts/core.js" charset="utf-8"></script>
+ <script type="text/javascript" src="../../scripts/search.js" charset="utf-8"></script>
+ <title>IoTivity</title>
+</head>
+
+<body onload="prettyPrint()" style="overflow: auto;">
+
+ <div id="toc-navigation">
+ <div id="profile">
+ <p><img alt="Mobile Web" src="../../images/mobile_s_w_optional.png" /> <img alt="Wearable Web" src="../../images/wearable_s_w_optional.png"
+ /> <img alt="TV Web" src="../../images/tv_s_w.png" /></p>
+ </div>
+
+ <div id="toc_border">
+ <div id="toc">
+ <p class="toc-title">Dependencies</p>
+ <ul class="toc">
+ <li>Tizen 3.0 and Higher for Mobile</li>
+ <li>Tizen 3.0 and Higher for Wearable</li>
+ <li>Tizen 3.0 and Higher for TV</li>
+ </ul>
+ <p class="toc-title">Content</p>
+ <ul class="toc">
+ <li><a href="#prerequisites">Prerequisites</a></li>
+ <li><a href="#create-resource">Creating a New Resource</a></li>
+ <li><a href="#find-resources">Finding Remote Resources</a></li>
+ <li><a href="#find-device-infos">Retrieving Device and Platform Information</a></li>
+ <li><a href="#remote-get">Sending GET Requests</a></li>
+ <li><a href="#remote-put">Sending PUT Requests</a></li>
+ <li><a href="#remote-state-change">Observing Resource Changes</a></li>
+ </ul>
+ <p class="toc-title">Related Info</p>
+ <ul class="toc">
+ <li><a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html">Iotcon API for Mobile Web</a></li>
+ <li><a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html">Iotcon API for Wearable Web</a></li>
+ <li><a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html">Iotcon API for TV Web</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+
+<div id="container"><div id="contents"><div class="content">
+
+<h1>IoTivity</h1>
+
+<p><a href="https://www.iotivity.org/" target="_blank">IoTivity</a> offers seamless device-to-device connectivity to address the emerging needs of the Internet of Things (IoT) through the open source reference implementation of the OIC (Open Interconnect Consortium) standard specifications. IoT connectivity (Iotcon) provides the means of using IoTivity in Tizen.</p>
+
+<p>The Iotcon API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices. The Iotcon API is supported on the Tizen Emulators.</p>
+
+<p>IoT connectivity is usually handled with a server and client. The server is responsible for creating and providing resources, and the client can access those resources through requests.</p>
+
+
+<p>The main features of the Iotcon API include:</p>
+<ul>
+ <li>Creating a server
+ <p>You can <a href="#create-resource">create a resource</a> and send a presence event to the client when it becomes online.</p>
+ </li>
+ <li>Managing resources
+ <p>You can add types and interfaces to an existing resource.</p>
+ </li>
+ <li>Creating a client
+ <p>You can <a href="#find-resources">find remote resources</a>, <a href="#find-device-infos">retrieve device and platform information</a>, and listen for server presence events.</p>
+ </li>
+ <li>Remotely managing resources
+ <p>You can <a href="#remote-get">retrieve</a> and <a href="#remote-put">modify</a> the remote resource attributes with GET and PUT methods. You can also use POST and DELETE methods to modify the resources on a remote server. You can <a href="#remote-state-change">monitor the resource attribute changes and the <span style="font-family: Courier New,Courier,monospace">isAlive</span> state</a>.</p>
+ <p>For more information on all available remote resource management methods, see the native <a href="../../native/connectivity/iotivity_n.htm">IoTivity</a> guide.</p>
+ </li>
+</ul>
+
+<p>Before you start, remember to <a href="#prerequisites">prepare your application to use the IoT functionality</a>.</p>
+
+<h2>Warm-up</h2>
+<p>Become familiar with the Iotcon API basics by learning about:</p>
+<ul>
+ <li><a href="#prerequisites">Prerequisites</a>
+ <p>Prepare your application to use the IoT functionality.</p>
+ </li>
+ <li><a href="#create-resource">Creating a New Resource</a>
+ <p>Create a server, create a resource, and register a request handler.</p>
+ </li>
+ <li><a href="#find-resources">Finding Remote Resources</a>
+ <p>Create a client and find the resources.</p>
+ </li>
+ <li><a href="#find-device-infos">Retrieving Device and Platform Information</a>
+ <p>Get device and platform information from the server.</p>
+ </li>
+ <li><a href="#remote-get">Sending GET Requests</a>
+ <p>Get information from the resources.</p>
+ </li>
+ <li><a href="#remote-put">Sending PUT Requests</a>
+ <p>Update the resource information.</p>
+ </li>
+ <li><a href="#remote-state-change">Observing Resource Changes</a>
+ <p>Monitor attribute and state changes in a remote resource.</p>
+ </li>
+</ul>
+
+<h2 id="prerequisites">Prerequisites</h2>
+
+<p>To enable your application to use the IoT functionality:</p>
+
+<ol>
+<li>To use the Iotcon API (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html">mobile</a>, <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html">wearable</a>, and <a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html">TV</a> applications), the application has to request permission by adding the following privilege to the <span style="font-family: Courier New,Courier,monospace">config.xml</span> file:
+<pre class="prettyprint">
+<tizen:privilege name="http://tizen.org/privilege/internet"/>
+</pre>
+</li>
+<li>To make your application visible only for devices that support Iotcon, the application must specify the following feature in the <span style="font-family: Courier New,Courier,monospace">config.xml</span> file:
+
+<pre class="prettyprint">
+<feature name="http://tizen.org/feature/iot.ocf"/>
+</pre>
+
+<p>You can also check whether a device supports the API by using the <span style="font-family: Courier New,Courier,monospace">tizen.systeminfo.getCapability()</span> method and accordingly enabling or disabling the code requiring the API:</p>
+
+<pre class="prettyprint">
+try
+{
+ /* Checks whether a device supports the Iotcon API */
+ var iotcon_feature = tizen.systeminfo.getCapability("http://tizen.org/feature/iot.ocf");
+ console.log("Iotcon = " + iotcon_feature);
+}
+catch (error)
+{
+ console.log("Error name: " + error.name + ", message: " + error.message);
+}
+</pre>
+</li>
+</ol>
+
+<p>For details on OIC IoT standard specifications, see the <a href="https://openconnectivity.org/" target="_blank">Open Connectivity Foundation (OCF) Web site</a>.</p>
+
+
+<h2 id="create-resource">Creating a New Resource</h2>
+
+<p>To create a new resource:</p>
+
+<ol>
+<li>Initialize a server and set the device name:
+<ol type="a">
+<li>
+ <p>For managing secure virtual resources, a CBOR format file (Concise Binary Object Representation) must be
+ available, preferably in the application local storage. For more information on security, see <a href="https://wiki.iotivity.org/iotivity_security" target="_blank">Iotivity Security</a>.</p>
+<pre class="prettyprint">
+var cborPath = "path_to_my_app_storage/iotcon-server-test.dat";
+</pre>
+</li>
+<li>
+ <p>Initialize Iotcon and set a human friendly name:</p>
+<pre class="prettyprint">
+tizen.iotcon.initialize(cborPath);
+tizen.iotcon.deviceName = "Device 1";
+</pre>
+</li>
+<li>
+ <p>Get the Iotcon server object:</p>
+<pre class="prettyprint">
+var iotServer = tizen.iotcon.getServer();
+</pre>
+</li>
+</ol>
+</li>
+<li>Prepare a resource:
+<ol type="a">
+<li>
+ <p>On the server side, prepare a variable for storing the resource object and its attributes. The following example shows a door resource:</p>
+<pre class="prettyprint">
+var doorResource;
+var doorAttributes = {openstate: "open"};
+</pre>
+</li>
+<li>
+ <p>Prepare handlers for the get, put, post, delete, and observing requests from the client.</p>
+<p>The exact list of required handlers depends on the resource interfaces. The following example uses the "oic.if.b" interface.</p>
+<pre class="prettyprint">
+var requestCallbacks =
+{
+ onget: function(request) {/* Handler code */},
+ onput: function(request) {/* Handler code */},
+ onpost: function(request) {/* Handler code */},
+ ondelete: function(request) {/* Handler code */},
+ onobserving: function(request, observeType, observeId) {/* Handler code */}
+}
+</pre>
+</li>
+<li>
+ <p>Fill the <span style="font-family: Courier New,Courier,monospace">onget</span> handler with a code that sends a response to the client. Other handlers remain empty in this example (you can modify attributes in them).</p>
+ <p>To send a response to the client:</p>
+ <ol type="a">
+ <li>Create a new <span style="font-family: Courier New,Courier,monospace">Response</span> object (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html#Response">mobile</a>, <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html#Response">wearable</a>, and <a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html#Response">TV</a> applications) from the <span style="font-family: Courier New,Courier,monospace">Request</span> object (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html#Request">mobile</a>, <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html#Request">wearable</a>, and <a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html#Request">TV</a> applications): <span style="font-family: Courier New,Courier,monospace">new tizen.Response(request)</span></li>
+ <li>Create a new <span style="font-family: Courier New,Courier,monospace">Representation</span> object (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html#Representation">mobile</a>, <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html#Representation">wearable</a>, and <a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html#Representation">TV</a> applications), to be sent inside the response: <span style="font-family: Courier New,Courier,monospace">new tizen.Representation(doorResource.uriPath)</span></li>
+ <li>Fill the <span style="font-family: Courier New,Courier,monospace">Representation</span> object with values from the resource object.</li>
+ <li>Send the response: <span style="font-family: Courier New,Courier,monospace">response.send()</span></li>
+ </ol>
+
+<pre class="prettyprint">
+var requestCallbacks =
+{
+ onget: function(request)
+ {
+ console.log("onget");
+ var response = new tizen.Response(request);
+ try
+ {
+ var representation = new tizen.Representation(doorResource.uriPath);
+ representation.resourceTypes = doorResource.resourceTypes;
+ representation.resourceInterfaces = doorResource.resourceInterfaces;
+ representation.attributes = doorAttributes;
+ response.representation = representation;
+ response.result = "SUCCESS";
+ }
+ catch (err)
+ {
+ console.log(err.name + ": " + err.message);
+ response.result = "ERROR";
+ }
+ response.send();
+ },
+}
+</pre>
+</li>
+<li>
+ <p>Create a resource using the prepared handlers, chosen resource path, types, and interfaces:</p>
+<pre class="prettyprint">
+var uriPath = "/door";
+var resourceTypes = ["core.door"];
+var resourceInterfaces = ["oic.if.b"];
+var policy =
+{
+ isObservable: true,
+ isDiscoverable: true
+};
+
+doorResource = iotServer.createResource(uriPath, resourceTypes, resourceInterfaces, requestCallbacks, policy);
+</pre>
+</li>
+</ol>
+</li></ol>
+
+<h2 id="find-resources">Finding Remote Resources</h2>
+
+<p>To find remote resources:</p>
+
+<ol>
+<li>Initialize a client and set the device name:
+<ol type="a">
+<li>
+ <p>For managing secure virtual resources, a CBOR format file (Concise Binary Object Representation) must be
+ available, preferably in the application local storage. For more information on security, see <a href="https://wiki.iotivity.org/iotivity_security" target="_blank">Iotivity Security</a>.</p>
+<pre class="prettyprint">
+var cborPath = "path_to_my_app_storage/iotcon-client-test.dat";
+</pre>
+</li>
+<li>
+ <p>Initialize Iotcon and set a human friendly name:</p>
+<pre class="prettyprint">
+tizen.iotcon.initialize(cborPath);
+tizen.iotcon.deviceName = "Device 2";
+</pre>
+</li>
+<li>
+ <p>Get the Iotcon client object:</p>
+<pre class="prettyprint">
+var iotClient = tizen.iotcon.getClient();
+</pre>
+</li>
+</ol>
+<p>Now you can use the <span style="font-family: Courier New,Courier,monospace">iotClient</span> methods for IoT connectivity with the server.</p>
+</li>
+<li>On the client side, search for resources on servers:
+<ol type="a">
+<li>
+ <p>Get the client object:</p>
+<pre class="prettyprint">
+var client = tizen.iotcon.getClient();
+</pre>
+</li>
+<li>
+ <p>Set the remote server address and connectivity type.</p>
+ <p>The <span style="font-family: Courier New,Courier,monospace">hostAddress</span> value must be in the Constrained Application Protocol (CoAP) format (<span style="font-family: Courier New,Courier,monospace">coap(s)://address:port</span>), for example, <span style="font-family: Courier New,Courier,monospace">coaps://[fe80::ae5a:14ff:fe24:b8fe]:12345</span> or <span style="font-family: Courier New,Courier,monospace">coaps://192.168.1.10:12345</span>. The <span style="font-family: Courier New,Courier,monospace">null</span> value indicates that the client communicates with all nodes (multicast).</p>
+<pre class="prettyprint">
+var hostAddress = null;
+var connectivityType = "IP";
+</pre>
+</li>
+<li>
+ <p>Prepare a query. You can search for specific <span style="font-family: Courier New,Courier,monospace">resourceType</span> and <span style="font-family: Courier New,Courier,monospace">resourceInterface</span> values, and add an attribute filter:</p>
+<pre class="prettyprint">
+var query = {resourceType: "core.door"};
+</pre>
+ <p>For more information, see the Query interface (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html#Query">mobile</a>, <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html#Query">wearable</a>, and <a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html#Query">TV</a> applications).</p>
+</li>
+<li>
+ <p>Find a resource:</p>
+<pre class="prettyprint">
+client.findResource(hostAddress, query, connectivityType, foundSuccess, onerror);
+</pre>
+<p>The <span style="font-family: Courier New,Courier,monospace">foundSuccess</span> and <span style="font-family: Courier New,Courier,monospace">onerror</span> parameters are success and error callbacks for an async operation:</p>
+<pre class="prettyprint">
+function onerror(err)
+{
+ console.log("Failed to find resource: " + err.message);
+}
+</pre>
+ <p>The success callback lists information, types, and interfaces for every found remote resource:</p>
+<pre class="prettyprint">
+function foundSuccess(resource)
+{
+ if (resource)
+ {
+ console.log(resource.uriPath);
+ console.log(resource.hostAddress);
+ console.log(resource.deviceId);
+ var resourceTypes = resource.resourceTypes;
+ for (var i in resourceTypes)
+ {
+ console.log(resourceTypes[i]);
+ }
+ var resourceInterfaces = resource.resourceInterfaces;
+ for (var i in resourceInterfaces)
+ {
+ console.log(resourceInterfaces[i]);
+ }
+ }
+}
+</pre>
+</li>
+</ol>
+</li></ol>
+
+<h2 id="find-device-infos">Retrieving Device and Platform Information</h2>
+
+<p>On the client side, you can get device and platform information from the server for a given remote resource:</p>
+<ol>
+<li>
+ <p>Prepare the error and success callbacks:</p>
+<pre class="prettyprint">
+function onerror(err)
+{
+ console.log("Failed to find resource: " + err.message);
+}
+
+function foundSuccess(platformInfo)
+{
+ console.log(platformInfo.platformId);
+ console.log(platformInfo.modelNumber);
+ console.log(platformInfo.platformVersion);
+ console.log(platformInfo.operatingSystemVersion);
+ console.log(platformInfo.systemTime);
+ /* Other PlatformInfo object attributes; see the API Reference for details */
+}
+</pre>
+</li>
+<li>
+ <p>Get the client object:</p>
+<pre class="prettyprint">
+var client = tizen.iotcon.getClient();
+</pre>
+</li>
+<li>
+ <p>Prepare the server address, connectivity type, and query (with optional filters):</p>
+<pre class="prettyprint">
+/* hostAddress must be a valid IP address, or null for all nodes (multicast) */
+var hostAddress = "coaps://192.168.0.10:12345";
+var connectivityType = "IP";
+/* null means no filter */
+var query = null;
+</pre>
+</li>
+<li>Retrieve the information:
+<ul>
+<li>
+ <p>Get the platform information from the remote server:</p>
+<pre class="prettyprint">
+client.findPlatformInfo(hostAddress, query, connectivityType, foundSuccess, onerror);
+</pre>
+<p>The success callback is called with the <span style="font-family: Courier New,Courier,monospace">PlatformInfo</span> object (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html#PlatformInfo">mobile</a>, <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html#PlatformInfo">wearable</a>, and <a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html#PlatformInfo">TV</a> applications) as a parameter. You can access the platform information in the object attributes.</p>
+</li>
+<li>
+ <p>Get the device information from the remote server:</p>
+<pre class="prettyprint">
+client.findDeviceInfo(hostDeviceIpAddress, query, connectivityType, foundSuccess, onerror);
+</pre>
+ <p>The success callback is called with the <span style="font-family: Courier New,Courier,monospace">DeviceInfo</span> object (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html#DeviceInfo">mobile</a>, <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html#DeviceInfo">wearable</a>, and <a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html#DeviceInfo">TV</a> applications) as a parameter. You can access the device information in the object attributes.</p>
+</li>
+</ul></li>
+</ol>
+
+<h2 id="remote-get">Sending GET Requests</h2>
+<p>On the client side, you can read resource attributes:</p>
+<ol>
+<li>
+ <p>Prepare a callback for reading the attributes:</p>
+<pre class="prettyprint">
+function onresponse(remoteResponse)
+{
+ if (remoteResponse.result != "SUCCESS")
+ {
+ console.log("the result is not SUCCESS");
+
+ return;
+ }
+
+ var repr = remoteResponse.representation;
+
+ /* You can retrieve attributes from Representation object in RemoteResponse */
+ for (var key in repr.attributes)
+ {
+ console.log(key + ": " + repr.attributes[key]);
+ }
+}
+</pre>
+</li>
+<li>
+ <p><a href="#find-resources">Find a remote resource</a>.</p>
+</li>
+<li>
+ <p>Once you have a <span style="font-family: Courier New,Courier,monospace">RemoteResource</span> object, use the <span style="font-family: Courier New,Courier,monospace">methodGet()</span> method to send a request to the server. For a list of resource attributes you can request, see the API Reference (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html#RemoteResource">mobile</a>, <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html#RemoteResource">wearable</a>, and <a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html#RemoteResource">TV</a> applications).</p>
+<pre class="prettyprint">
+/* filter results, query = null means no filter */
+query["filter"] = {openstate: "open"};
+resource.methodGet(onresponse, query, onerror);
+</pre>
+ <p>As a result, the <span style="font-family: Courier New,Courier,monospace">onresponse</span> or (optional) <span style="font-family: Courier New,Courier,monospace">onerror</span> callback is called.</p>
+</li>
+</ol>
+
+<h2 id="remote-put">Sending PUT Requests</h2>
+<p>On the client side, you can modify remote resource attributes using the PUT method:</p>
+<ol>
+<li>
+ <p>Prepare a callback that is called after the PUT request:</p>
+<pre class="prettyprint">
+function onresponse(remoteResponse)
+{
+ console.log("result is " + remoteResponse.result);
+ /* remoteResponse.result is expected to be "RESOURCE_CHANGED" */
+}
+</pre>
+</li>
+<li>
+ <p><a href="#find-resources">Find a remote resource</a>.</p>
+</li>
+<li>
+ <p>Once you have a <span style="font-family: Courier New,Courier,monospace">RemoteResource</span> object (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html#RemoteResource">mobile</a>, <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html#RemoteResource">wearable</a>, and <a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html#RemoteResource">TV</a> applications), use the success callback to create a <span style="font-family: Courier New,Courier,monospace">Representation</span> object (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html#Representation">mobile</a>, <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html#Representation">wearable</a>, and <a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html#Representation">TV</a> applications). This object represents the changes in attributes, types, and interfaces.</p>
+<pre class="prettyprint">
+representation = new tizen.Representation(uriPath);
+representation.resourceTypes = ["core.door"];
+representation.attributes = {openstate: "closed"};
+</pre>
+</li>
+<li>
+ <p>Call the <span style="font-family: Courier New,Courier,monospace">methodPut()</span> method on the <span style="font-family: Courier New,Courier,monospace">RemoteResource</span> object:</p>
+<pre class="prettyprint">
+/* Optional filter, query = null means no filter */
+query["filter"] = {openstate: "open"}
+resource.methodPut(representation, onresponse, query, onerror);
+</pre>
+<p>After a successful request, the <span style="font-family: Courier New,Courier,monospace">onresponse</span> callback is called with the result and updated resource representation. In case of a failure, the (optional) <span style="font-family: Courier New,Courier,monospace">onerror</span> callback is called.</p>
+</li>
+</ol>
+
+
+<h2 id="remote-state-change">Observing Resource Changes</h2>
+
+<p>On the client side, you can observe remote resource attribute changes with the <span style="font-family: Courier New,Courier,monospace">startObserving()</span> method, and the <span style="font-family: Courier New,Courier,monospace">isAlive</span> state with the <span style="font-family: Courier New,Courier,monospace">setResourceStateChangeListener()</span> method:</p>
+<ol>
+<li>
+ <p><a href="#find-resources">Find a remote resource</a>.</p>
+</li>
+<li>
+ <p>Prepare a callback for state change events:</p>
+<pre class="prettyprint">
+function onchanged(isAlive)
+{
+ if (isAlive == true)
+ {
+ console.log("Remote resource is alive");
+ }
+ else
+ {
+ console.log("Remote resource is lost");
+ }
+}
+</pre>
+</li>
+<li>
+ <p>Register a listener on the <span style="font-family: Courier New,Courier,monospace">RemoteResource</span> object (in <a href="../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/iotcon.html#RemoteResource">mobile</a>, <a href="../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/iotcon.html#RemoteResource">wearable</a>, and <a href="../../../../org.tizen.web.apireference/html/device_api/tv/tizen/iotcon.html#RemoteResource">TV</a> applications):</p>
+<pre class="prettyprint">
+resource.setResourceStateChangeListener(onchanged);
+</pre>
+</li>
+<li>
+ <p>When the notifications are no longer needed, deregister the listener:</p>
+<pre class="prettyprint">
+resource.unsetResourceStateChangeListener();
+</pre>
+</li>
+</ol>
+<p>You can monitor attribute changes in a remote resource similarly using the <span style="font-family: Courier New,Courier,monospace">startObserving()</span> method on the <span style="font-family: Courier New,Courier,monospace">RemoteResource</span> object.</p>
+
+<script type="text/javascript" src="../../scripts/jquery.zclip.min.js"></script>
+<script type="text/javascript" src="../../scripts/showhide.js"></script>
+</div></div></div>
+
+<a class="top sms" href="#"><img src="../../images/btn_top.gif" alt="Go to top" /></a>
+
+<div id="footer">
+<p class="footer">Except as noted, this content - excluding the Code Examples - is licensed under <a href="http://creativecommons.org/licenses/by/3.0/legalcode" target="_blank">Creative Commons Attribution 3.0</a> and all of the Code Examples contained herein are licensed under <a href="https://www.tizen.org/bsd-3-clause-license" target="_blank">BSD-3-Clause</a>.<br/>For details, see the <a href="https://www.tizen.org/content-license" target="_blank">Content License</a>.</p>
+</div>
+
+<script type="text/javascript">
+var _gaq = _gaq || [];
+_gaq.push(['_setAccount', 'UA-25976949-1']);
+_gaq.push(['_trackPageview']);
+(function() {
+var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+})();
+</script>
+
+</body>
+
+</html>
\ No newline at end of file