Module 5
Module 5
• turning any Thing into a Web Thing that can be interacted with using
HTTP requests just like any other resource on the Web.
• a Web Thing is a REST API that allows to interact with something in
the real world, like opening a door or reading a temperature sensor
located across the planet.
• Illustration http://devices.webofthings.io/pi/sensors/
• but many IoT scenarios are real-time and/or event-driven (get
notified when something happens in the real world).
• Web protocol can help: WebSocket.
Layer 2: Find
• Marking things accessible via an HTTP and WebSocket API is great but
it doesn’t mean applications can really “understand” what the Thing
is, what data or services it offers, and so on.
• This layer ensures that your Thing can not only be easily used by
other HTTP clients but can also be findable and automatically usable
by other WoT applications.
Layer 3: Share
• once Things are on the Web (layer 1) where they can be found by
humans and machines (layer 2) and their resources can be shared
securely with others (layer 3), it’s time to look at how to build large-
scale, meaningful applications for the Web of Things.
• integration of data and services from heterogeneous Things into an
immense ecosystem of web tools such as analytics software
Example
• First step when Web-enabling a smart thing is to design its resource
network. Identification of resources and their relationships are the
two important aspects of this step
• On the Web, the identification of resources relies on Uniform Resource
Identifiers (URIs), and representations retrieved through resource interactions
contain links to other resources, so that applications can follow links through
an interconnected web of resources.
• Clients of RESTful services are supposed to follow these links, must like one
browses Web pages, in order to find resources to interact with.
• This allows clients to “explore” a service simply by browsing it, and in many
cases, services will use a variety of link types to establish different
relationships between resources.
• Each node has a few sensors (light, temperature, accelerometer, etc.),
actuators (digital outputs, LEDs, etc.), and a number of internal
components (radio, battery).
• Each of these components is modeled as a resource and assigned a
URI.
• For instance, typing a URI such as
http://.../sunspots/spot1/sensors/light
• In a browser requests a representation of the resource light of the
resource sensors of spot1. Resources are primarily structured
hierarchically and each resource also provides links back to its parent
and forward to its children
• Representing Resources
• Resources are abstract entities and are not bound to any particular
representation.
• Thus, several formats can be used to represent a single resource.
However, agreed upon resource representation formats make it
much easier for a decentralised system of clients and servers to
interact without the need for individual negotiations.
• On the Web, media type support in HTTP and the Hypertext
Markup Language (HTML) allow peers to cooperate without
individual agreements.
• It further allows clients to navigate amongst the resources using
hyperlinks.
• For machine-to-machine communication, other media types, such as the XML
and the JSON have gained widespread support across services and client
platforms.
• JSON is a lightweight alternative to XML that is widely used in Web 2.0
applications.
JSON Representation of the Temperature Resource
• The uniform interface is based on the identification (and thus interaction) of
resources, and in case of the Web, this interface is defined by the HTTP.
• HTTP provides four main methods to interact with resources - GET, PUT, POST,
and DELETE. GET is used to retrieve the representation of a resource
• In the Web of Things, these operations map rather naturally, since smart things
usually offer quite simple and atomic operations. As an example, a GET on,
http://.../spot1/sensors/temperature
• returns the temperature observed by spot1, i.e., it retrieves the current
representation of the temperature resource.
• A PUT on, http://.../sunspots/spot1/actuators/leds/1, with the updated JSON
representation {“status”:“on”} (which was first retrieved with a GET on /leds/1)
switches on the first LED of the Sun SPOT, i.e., it updates the state of the LED
resource.
Resource-oriented Architectures
• REST is based on the concept of a resource.
• A resource can be defined as any relevant entity in an application’s domain
that is exposed on the network.
• A webpage, a video, and an order on an e-commerce website can all be
considered web resources.
• A resource is any thing with which a user interacts while progressing
toward some goal.
• Anything can be mapped as a resource, as long as it is meaningful for the
application.
• Resources are characterized by some data, such as the title of the page or
the items in an order.
• Thank you