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/ iotivity/ ├ ── resource ├ ── android │ ├ ── csdk ├ ── service │ │ ├ ── connectivity │ ├ ── notification -manager │ │ ├ ── security │ ├ ── protocol -plugin │ │ ├ ── plugin -manager │ │ └── stack │ │ ├ ── include │ │ ├ ── plugins │ │ ├ ── samples │ ├ ── soft -sensor-manager │ │ │ ├ ── arduino │ └── things -manager │ │ │ └── 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 Client IoTivity Server 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 Server Stack Client App Client Stack Server App OCCreateResource GET “/oc/core” OCDoResource Discovery Response Callback provided in OCDoResource will be called with the response
GET • OCDoResource – In • Method : GET • Query: “192.168.1.5:29389/a/light” • Payload: NULL • Callback Data: – Out • handle
GET Flow Server Stack Client App Client Stack Server App OCCreateResource GET “/a/light” OCDoResource Entity Handler OCDoResponse GET Response CallBack
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 Server Stack Client App Client Stack Server App OBSERVE GET with Obs Flag “/a/light” OCDoResource Entity Handler Callback OCNotify*Observers Observe Response
PRESENCE • OCDoResource – In • Method : PRESENCE • Query: “ 192.168.1.5/oc/presence ” • Payload: NULL • Callback Data: – Out • handle
PRESENCE Flow Server Stack Client App Client Stack Server App OCStartPresence Presence Notification PRESENCE “/ oc /presence” OCDoResource OCCreateResource Presence Notification Callback
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/ • iotivity-dev@lists.iotivity.org • http://www.intel.com/content/www/us/en/in ternet-of-things/overview.html
Thank you
Back up slides
C++ : Flow C++ Server C++ Client C++ Server C++ Client Server Stack Client Stack App App Stack Stack OCCreateResource registerResource GET findResource “/a/light” OCDoResource Entity Handler Entity Handler Wrapper GET Response OCDoResponse sendResponse Call Back Call Back Wrapper
Recommend
More recommend