Top Banner
Embedded Software Lab. @ SKKU 15 1 Sungkyunkwan University Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and Simple Client
15

Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Apr 18, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

1

Sungkyunkwan University

Tizen/Artik IoT Practice Part 5IoTivity Simple Server and Simple Client

Page 2: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

2

• In IoTivity, an entity (e.g. Sensor, Actuator) is being handled as a resource (OCF Resource Model)

– Each resource contains resource and device types, CRUDN Operations, URI information

– Users can access the Resource via URI and RESTful interface

IoTivity Resource

Page 3: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

3

• Simple IoTivity Server & Client– Using Iotivity base API (CRUDN), making a simple server (Service Provider

[e.g. sensors, actuators]) and simple client (e.g. Android Application)

• OCF Server– In IoTivity network topology, OCF Server handles the CRUDN requests– E.g Temperature Sensors, Lights, Humidity Sensors, Air conditional etc..

• OCF Client– In IoTivity network topology, OCF Client typically finds resources and sends

CRUDN requests – Android, Linux, Tizen, Windows, etc..

IoTivity Simple Server & Client

Page 4: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

4RESTful Resource Model

CRUDN

RESTful API

• RESTful API– Http request interface such as GET, PUT, POST, DELETE

• Using RESTful API, users can control the OCF server device in remote

Page 5: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

5

• Using IoTivity base API set, making a simple server (Temperature, Humidity sensors) and Android simple client App

Simple Client & Server Scenario

Temperature Sensor

URi : /a/temperatureType : core.temperatureAPI : RUND

CRUDN

Source Repository : https://github.com/gudbooy/IoTivity_Sample_Things.git

Page 6: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

6

• Resource Class contains Basic Operation of IoTivity & CRUDN virtual functions (interface set)

Resource Class

IoTivity/resource/examples/IoTivity_Sample_Server/resource.h File

User-defined Virtual Interface

Common Interface for Entity Handler

<User Define Virtual Function>put : Set the data sent from the clineget : Get the data requested from the ClientSensorValueRead : Sensor Acquisition Read Thread ChangeResourceRepresentation : Observe Thread Logic

<Common Interface Function>Resource Creation Logic :Resource Creation and Registering the URI resourceEntityHandler Logic : Request Handling Parsing Logic

Page 7: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

7

• Common IoTivity Resource API

– Resource Creation, Resource Handler (CRUDN Request Parser)

Resource Class Implementation

IoTivity/resource/examples/IoTivity_Sample_Server/resourceImpl.cpp File

Resource Creation Function

Initialization Uri & Resource Type

Registering CRUDN APIParsing Handler Callback

Resource RegisteringRequest Parsing Logic

CRUDN API Handler Unit

Page 8: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

8

• Entity Handler refers to a CRUDN request parsing callback function– GET : get the sensor data, then send data with response to the clients

– PUT : receive the status value (e.g. Turn On, Off) from the client, and set the status

– Observe : Periodically, observer thread publishing the sensor data to registered clients

Entity Handler - CRUDN Request Handler

GET

Put

Delete

Observe

Page 9: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

9

• E.g., Light, Humidity, Temp

Server (Thing Device) Interface

<Temperature Things>

Things Meta-Data

URI, Resource Type

< Get Logic >

IoTivity/resource/examples/IoTivity_Sample_Server/simple_server_temp.h / .cpp File

Page 10: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

10Server (Thing Device) Interface (2/2)

<Put Logic> <Observation Logic>

Get the data from the Representation

Notify the current message to observers

<Sensor Logic>Sensor Thread Creation

Page 11: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

11

• IoTivityWrapper.java

Simple Client (Android)

Listener Callback

Operation

Page 12: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

12findResource() - Resource Find Logic

Platform Configuration

Find Resource API

<Find Resource Listener Callback>

Found resource info

Page 13: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

13GET & PUT Function

<GET Function>

<GET Listener Callback>

<PUT Function>

<Observe Function>

Page 14: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

14Client Resource Description

To get the value from Representation for GET, OBSERVE

To set the value to Representation for PUT

Page 15: Tizen/Artik IoT Practice Part 5 IoTivity Simple Server and ...

Embedded Software Lab. @ SKKU

15

15IoTivity Communication Demo

1

1

2

/a/temp - PUT Status ON

/a/humidity - PUT Status ON2

3 4

3 4

Temperature Humidity

/a/temp - Get /a/humidity - Get