28
OIC/IoTivity Base Framework Sashi Penta Senior Software Engineer

OIC/IoTivity Base Framework

Embed Size (px)

Citation preview

OIC/IoTivity Base Framework

Sashi Penta

Senior Software Engineer

IoTivity & OIC

Open Source

Open Standard

OIC Architecture

• Discovery and Connectivity

• Interoperability

• Security and Identification

• Different device capabilities

IP CoAP

IoTivity Structure

iotivity/

├── android

├── service

│ ├── notification-manager

│ ├── protocol-plugin

│ │ ├── plugin-manager

│ │ ├── plugins

│ ├── soft-sensor-manager

│ └── things-manager

iotivity/

├── resource

│ ├── csdk

│ │ ├── connectivity

│ │ ├── security

│ │ └── stack

│ │ ├── include

│ │ ├── samples

│ │ │ ├── arduino

│ │ │ └── linux

│ │ ├── src

│ │ └── test

│ ├── src

│ ├── include

│ ├── examples

│ └── unittests

OIC Resource Model

• Server hosts resources – Entity

• Light bulb, Actuator, Sensor

• Plugin – to operate non OIC devices

– Entity Handler

– Resource Attribute • State, Color, Brightness

– Resource Interface

– Resource Type

– Resource Property

OIC Resource Model

• Client can access resources

– Discovery

– RESTful API

• GET/PUT/POST/DELETE

• OBSERVE

• PRESENCE (Active Discovery)

Modes

• SERVER

– Provides resource state information.

– Allows remote control of its resources.

• CLIENT

– Accesses a resource provided by an OIC Server.

• BOTH

– Acts both like both Server and Client.

Proxy Resources / Plugins

IoTivity Server

IoTivity Client

Hue Plugin

Collection

• OCBindResource

Room

Fan Light AC

C Stack API (0.9 Release)

Create Resource

• OCCreateResource

– In

• Resource Type : “core.light”

• Resource Interface : “def”

• Resource URI : “/a/light”

• Entity handler (like callback)

• ResourceProperties: OC_DISCOVERABLE | OC_OBSERVABLE

– Out

• Resource handle

Entity Handler Function that handles the client requests EntityHandler() { if(method == GET) { // Process Get Request & prepare response } else if(method == PUT) { // Process Put Request & prepare response } . . . OCDoResponse(response); }

Discover Resources

• OCDoResource – In

• Method : GET

• Query: – “/oc/core” <- Search on all adapters & Multicast search for IP

– “192.168.1.36:port/oc/core” <- Unicast

• Payload: NULL

• Callback Data:

– Out • handle

DISCOVERY Flow Client App Client Stack Server Stack Server App

OCCreateResource

OCDoResource

Discovery Response

Callback provided in OCDoResource will be called with the

response

GET

“/oc/core”

GET

• OCDoResource

– In

• Method : GET

• Query: “192.168.1.5:29389/a/light”

• Payload: NULL

• Callback Data:

– Out

• handle

GET Flow Client App Client Stack Server Stack Server App

OCCreateResource

OCDoResource

GET Response CallBack

Entity Handler

OCDoResponse

GET

“/a/light”

PUT

• OCDoResource

– In

• Method : PUT

• Query: “192.168.1.5:29389/a/light”

• Payload: {"oc":[{"rep":{“bri":100,"state":true}}]}

• Callback Data:

– Out

• handle

OBSERVE

• OCDoResource

– In

• Method : OBSERVE

• Query: “192.168.1.5:29389/a/light”

• Payload: NULL

• Callback Data:

– Out

• handle

OBSERVE Flow Client App Client Stack Server Stack Server App

OCNotify*Observers

OCDoResource

Observe Response

Callback

OBSERVE “/a/light”

Entity Handler

GET with Obs Flag

PRESENCE

• OCDoResource

– In

• Method : PRESENCE

• Query: “192.168.1.5/oc/presence”

• Payload: NULL

• Callback Data:

– Out

• handle

PRESENCE Flow Client App Client Stack Server Stack Server App

OCCreateResource

OCDoResource

Presence Notification Callback

PRESENCE

“/oc/presence”

OCStartPresence

Presence Notification

Observe Vs Presence

• Observe: – At Resource level

– Server Application decides when to send the observe notification • E.g. Temperature change in the room.

• Presence: – At Device / Server level

– Stack sends the notification (Although application triggers)

– Any kind of resources changes

C++ API

• Richer API

• Object Oriented Design

• JSON Parsing

• Multi threading

OIC Resource Model

• Server hosts resources

– Entity

• Actuator, Sensor

– Entity Handler

• Client accesses the resources

– RESTful API

– GET/PUT/PRESENCE/..

References

• http://openinterconnect.org/

• https://www.iotivity.org/

[email protected]

• http://www.intel.com/content/www/us/en/internet-of-things/overview.html

Thank you

Back up slides

C++ : Flow C++ Client

Stack Client Stack Server Stack C++ Server

Stack

OCCreateResource

OCDoResource

GET Response

Call Back Wrapper

Entity Handler

Wrapper

OCDoResponse

GET

“/a/light”

C++ Server App

C++ Client App

findResource

registerResource

Call Back

Entity Handler

sendResponse