OCF for resource-constrained environments

Similar documents
OCF Specification Overview Core Technology Specification. OCF 2.0 Release June 2018

IoTivity: The Open Connectivity Foundation and the IoT Challenge

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

IoTivity Big Picture. MyeongGi Jeong Software R&D Center

Tizen/Artik IoT Lecture Chapter 7. IoTivity Connectivity Abstraction

ARCHITECTURING AND SECURING IOT PLATFORMS JANKO ISIDOROVIC MAINFLUX

IOTIVITY INTRODUCTION

IOTIVITY AND EMBEDDED LINUX SUPPORT. Kishen Maloor Intel Open Source Technology Center

System Architecture Directions for Networked Sensors[1]

IoTivity Provisioning Manager Design Specification v0.1d

OCF Fundamentals. Ravi Subramaniam Principal Engineer, Intel Corporation

Soletta. Closing the IoT Development Gap. OpenIoT & ELC Europe 2016

DALI 2 Framework Design Document Introduction System Requirements Hardware Requirements Software Requirements...

ARM IoT Tutorial. CoAP: The Web of Things Protocol Zach Shelby. April 30 th, 2014

Assessing interoperability in Internet of Things ecosystems

Interoperability Frameworks for RIOT-OS

IP Based Architecture for the Internet of Things. IPV6 and Related Standards for IoT Interoperability November 20, 2014

MetaWatch Firmware Design Guide

IoTivity. Sungkyunkwan University. Presenter: Dzung Tien Nguyen Networking Laboratory,

OCF 2.0 Semantic Tagging ATG CR1970. Legal Disclaimer

Dotstack Porting Guide.

ARM mbed with us Hands On Getting to the Cloud

Bluetooth low energy Protocol Stack

Embedded Web Services

Tizen/Artik IoT Lecture Chapter 10. IoTivity Resource Encapsulation

AUTOBEST: A United AUTOSAR-OS And ARINC 653 Kernel. Alexander Züpke, Marc Bommert, Daniel Lohmann

RF Networking With MSP430 & the ez430-rf2500 Session 2 Miguel Morales, MSP430 Applications 6/5/2008 1

Provisioning IoT with Web NFC. Zoltan Kis Intel

Lab Assignment: Interrupt + Lookup Tables + Binary

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals

Internet of Things: An Introduction

Constrained Application Protocol (CoAP) Vilen Looga, M.Sc. Doctoral

s132_nrf52 release notes

Implementation work on open source web of things servers and gateways. Dave Raggett, W3C

#include <tobii/tobii.h> char const* tobii_error_message( tobii_error_t error );

Towards a Zero-Configuration Wireless Sensor Network Architecture for Smart Buildings

SpiNNaker Application Programming Interface (API)

PS Telematik-Projekt: Wireless Embedded Systems

Multitasking. Embedded Systems

PusleIR Multitouch Screen Software SDK Specification. Revision 4.0

Linux SDK for UPnP Devices v1.4

Real-Time Systems Hermann Härtig Real-Time Operating Systems Brief Overview

Constrained Application Protocol (CoAP) Vilen Looga, M.Sc. Doctoral

Chapter 13: I/O Systems. Operating System Concepts 9 th Edition

Developer manual. (Onvif Client Library) Happytimesoft Technology Co.,LTD

RM0327 Reference manual

int fnvgetconfig(handle h, UINT32 id, const void *cfg, size_t sz);... 4

OpenAMP Discussion - Linaro2018HK. Copyright 2018 Xilinx

Programming Guide. WISE-PaaS/RMM 3.2. Wireless IoT Sensing Embedded Agent WISE-Agent Programming Guide

MaRTE OS Misc utilities

Implementation work on open source web of things servers and gateways. Dave Raggett, W3C

Zilog Real-Time Kernel

Chapter 5.6 Network and Multiplayer

Jonas Green, Björn Otterdahl HMS Industrial Networks AB. February 22, 2017

This Document describes the API provided by the DVB-Multicast-Client library

Embedded Systems. 5. Operating Systems. Lothar Thiele. Computer Engineering and Networks Laboratory

Resilient IoT Security: The end of flat security models

FreeRTOS. A Brief Overview. Christopher Kenna. October 1, Avionics. FreeRTOS 1 / 34

An Architecture for Underwater Networks

Embedded Software TI2726 B. 7. Embedded software design. Koen Langendoen. Embedded Software Group

Vinod Koul, Sanyog Kale Intel Corp. MIPI SoundWire Linux Subsystem: An introduction to Protocol and Linux Subsystem

An Implementation of Fog Computing Attributes in an IoT Environment

VD Interfaces V0.1. Draft 2

Lithe: Lightweight Secure CoAP for the Internet of Things

Lecture 3. Introduction to Real-Time kernels. Real-Time Systems

Quadros. RTXC Kernel Services Reference, Volume 1. Levels, Threads, Exceptions, Pipes, Event Sources, Counters, and Alarms. Systems Inc.

Asynchronous Events on Linux

EVE2 BLE Datasheet. The EVE Platform features standardized IO, common OS and drivers and ultra-low power consumption.

ECEN 449 Microprocessor System Design. Hardware-Software Communication. Texas A&M University

The Big Picture So Far. Chapter 4: Processes

HLD For SMP node affinity

RFC: connectionless Data Link Metalanguage Burkhard Daniel

Like select() and poll(), epoll can monitor multiple FDs epoll returns readiness information in similar manner to poll() Two main advantages:

OCF 2.0 Constrained Device Support OIC 1.1 Core Technology WG CR Legal Disclaimer

Operating Systems 2010/2011

IoT on Fedora Using Fedora as a base for the IoT Revolution

Operating Systems. Introduction & Overview. Outline for today s lecture. Administrivia. ITS 225: Operating Systems. Lecture 1

Triangle MicroWorks IEC Library Evaluation Kit

Homework. Reading. Machine Projects. Labs. Intel 8254 Programmable Interval Timer (PIT) Data Sheet. Continue on MP3

AN HONORS UNIVERSITY IN MARYLAND UMBC. AvrX. Yousef Ebrahimi Professor Ryan Robucci

Process Scheduling Queues

Security Monitoring of LwM2M Protocol

Model Based Development of Embedded Control Software

Tizen/Artik IoT Lecture Chapter 11. IoTivity Resource Hosting & Resource Directory

Bluetooth Mesh. Johan Hedberg

OCF Core Specifiation

An Incubator Project in the Apache Software Foundation. 13 July 2016

Multicast Dissemination Protocol (MDP) Developer's Guide

Embedded Programming for IoT. John Light, Intel OTC OpenIoT Summit, San Diego 6 April 2016

OS: An Overview. ICS332 Operating Systems

Real-Time Concepts for Embedded Systems Author: Qing Li with Caroline Yao

Major Components of the Internet of Things Systems

IoT OSes: Contiki-NG Part 1. Luca Mottola

5/11/2012 CMSIS-RTOS. Niall Cooling Feabhas Limited CMSIS. Cortex Microcontroller Software Interface Standard.

The Big Picture So Far. Chapter 4: Processes

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Zymkey App Utils: C++

Real-Time Systems. Real-Time Operating Systems

Resilient IoT Security: The end of flat security models. Milosch Meriac IoT Security Engineer

Transcription:

October 11 13, 2016 Berlin, Germany OCF for resource-constrained environments Kishen Maloor, Intel 1

Outline Introduction Brief background in OCF Core Constrained environment charactertics IoTivity-Constrained architecture Building applications Porting to new environments 2

Introduction What is OCF? Industry consortium with several member companies Publish open IoT standards Standards supported by open-source reference code 3

Introduction What is this talk about? IoTivity-Constrained New open source stack Reference Implementation of OCF standards for resource-constrained devices Easily customizable to any constrained platform configuration 4

Introduction RFC 7228: Classes of Constrained Devices Name data size (e.g., RAM) code size (e.g., Flash) Class 0, C0 << 10 KiB << 100 KiB Class 1, C1 ~ 10 KiB ~ 100 KiB Class 2, C2 ~ 50 KiB ~ 250 KiB Challenge: Must accommodate (at a minimum) OS + Network stack + drivers + OCF protocol + OCF application 5

IoTivity-Constrained vs IoTivity IoTivity-Constrained For resource-constrained devices Battery-powered door locks, tiny wireless sensors embedded in ceiling etc. Devices run small OS Zephyr, Contiki, RIOT OS etc. IoTivity For multi-function devices PCs, smartphones, gateways etc Devices run full-featured OS Linux, Android, Tizen, Windows etc. Both implementations are protocol compatible 6

Brief background in OCF Core OCF resource model RESTful design: Things modeled as resources with properties and methods CRUDN operations on resources (GET / OBSERVE, POST, PUT, DELETE) OCF roles Server role: Exposes hosted resources Client role: Accesses resources on a server Properties Resource URI rt: Resource Type if: Resource Interface p: Policy n: Resource Name 7

Brief background in OCF Core OCF Protocols Messaging protocol CoAP (RFC 7252) Resource discovery and reliability CBOR (RFC 7049) encoding of OCF payloads DTLS-based authentication, encryption and access control lists* Uses UDP/IP transport; being adapted to Bluetooth *Refer to the OCF Security spec at https://openconnectivity.org/resources/specifications 8

Brief background in OCF Core Well-known OCF resources Functionality Discovery Device Platform Security Fixed URI /oic/res /oic/d /oic/p /oic/sec/* Refer to the OCF Core spec at https://openconnectivity.org/resources/specifications 9

Brief background in OCF Core OCF request/response examples Resource discovery Multicast GET coap://224.0.1.187:5683/oic/res Unicast response [URI: /a/light; rt = [ oic.r.light ], if = [ oic.if.rw ], p= discoverable, observable] 10

Brief background in OCF Core OCF request/response examples GET and PUT requests Unicast GET coap://192.168.1.1:9000/a/light Unicast response [URI: /a/light; state = 0, dim = 0] Unicast PUT coap://192.168.1.1:9000/a/light PayLoad: [state=1;dim=50] Unicast response Status = Success 11

Brief background in OCF Core OCF request/response examples OBSERVE / Notify Unicast GET coap://192.168.1.1:9000/a/light; Observe_option= 0 Unicast response [URI: /a/light; state = 1, dim = 50] Notify Observers [URI: /a/light; state = 0, dim = 0, sequence #: 1] 12

Working in constrained environments Hardware related Low RAM and flash capacity Low power CPU with low clock cycle Execution efficiency Allow selection of feature subset to fulfill application s purpose 13

Working in constrained environments Software related Lightweight OS No dynamic memory management Multiplicity of OS, network stack, hardware platform and peripheral options Varying execution context design and scheduling strategy 14

IoTivity-Constrained architectural goals At a high level Cross-platform core Abstract interfaces to system clock, connectivity, PRNG, persistent storage Rapid porting to new environments Static memory allocation Modular design 15

IoTivity-Constrained architecture Ports Zephyr Abstract Interfaces Clock RIOT Embedded IoT Application On {Zephyr, Contiki, RIOT, Mynewt, Linux, } APIs IoTivity- Constrained Core PRNG Connectivity Persistent Storage Contiki Linux Concrete Implementations of Interfaces IoTivity-Constrained Framework 16

IoTivity-Constrained core Application APIs OCF Client Role OCF Server Role Memory Management Event Queue Resource Model Messaging Security Interact uniformly with Interface implementations for all ports 17

IoTivity-Constrained event loop Event loop execution Embedded IoT Application while( ) { oc_main_poll() } Callbacks Resource Layer Interrupt events Messaging Security CoAP Connectivity 18

IoTivity-Constrained event loop Enter tickless idle mode during periods of inactivity... // Initialize a semaphore while (1) { oc_clock_time_t next_event = oc_main_poll(); // next_event is the absolute time of the next scheduled event in clock ticks // Meanwhile, do other tasks or sleep (e.g., wait on semaphore)... // Framework invokes a callback when there is new work static void signal_event_loop(void) { // Wake up the event loop (e.g., signal the semaphore) } 19

Building applications Application structure Incorporate OCF s client or server roles or both Implement a set of callbacks Initialization (Client / Server) Defining and registering OCF resources (Server) Resource handlers for all supported methods (Server) Response handlers for all requests (Client) Entry point for issuing requests (Client) Framework configuration at build-time (config.h) 20

Building applications Setting the callbacks Main task in application main() { static const oc_handler_t handler = {.init = app_init,.signal_event_loop = signal_event_loop,.register_resources = register_resources };... oc_main_init(&handler);... while (1) { oc_clock_time_t next_event = oc_main_poll();... 21

Building applications Initialization Client / Server void app_init(void) { oc_init_platform("intel", NULL, NULL); oc_add_device("/oic/d", "oic.d.light", "Lamp", "1.0", "1.0", NULL, NULL); oc_storage_config(./creds ); } Populate standard OCF resources (platform / device) oc_storage_config is defined in the implementation of the storage interface for a target 22

Building applications Defining a resource Server-side... void register_resources(void) { oc_resource_t *res = oc_new_resource("/a/light", 1, 0); oc_resource_bind_resource_type(res, "core.light"); oc_resource_bind_resource_interface(res, OC_IF_R); oc_resource_set_default_interface(res, OC_IF_R); oc_resource_set_discoverable(res, true); oc_resource_set_observable(res, true); oc_resource_set_request_handler(res, OC_GET, get_light, NULL); oc_add_resource(res); } 23

Building applications Defining a resource handler Server-side... bool light_state; int brightness;... static void get_light(oc_request_t *request, oc_interface_mask_t interface,...) { oc_rep_start_root_object(); // Call oc_get_query_value() to access any uri-query oc_rep_set_boolean(root, state, light_state); oc_rep_set_int(root, brightness_level, brightness); oc_rep_end_root_object(); oc_send_response(request, OC_STATUS_OK); } 24

Building applications Resource discovery Client-side oc_do_ip_discovery("oic.r.light", &discovery, NULL);... oc_server_handle_t light_server; char light_uri[64];... oc_discovery_flags_t discovery(..., const char *uri,..., oc_server_handle_t *server,,...) { strncpy(light_uri, uri, strlen(uri)); memcpy(&light_server, server, sizeof(oc_server_handle_t)); return OC_STOP_DISCOVERY; // return OC_CONTINUE_DISCOVERY to review other resources } 25

Building applications Issuing a request Client-side oc_server_handle_t light_server; // Populated in the discovery callback char light_uri[64];... oc_do_get(light_uri, &light_server, unit=cd, &get_light, LOW_QOS, NULL);... 26

Building applications Handling a response Client-side void get_light(oc_client_response_t *data) { oc_rep_t *rep = data->payload; while (rep!= NULL) { // rep->name contains the key of the key-value pair switch (rep->type) { case BOOL: light_state = rep->value_boolean; break; case INT: brightness = rep->value_int; break; } rep = rep->next; } } 27

Building applications Separate response: For slow resources Server-side oc_separate_response_t temp_response; // Separate response handle for a request... static void get_temp(oc_request_t *request, oc_interface_mask_t interface) { oc_indicate_separate_response(request, &temp_response); }... void response_ready( ) {... oc_set_separate_response_buffer(&temp_response); oc_rep_start_root_object(); oc_rep_set_int(root, temp, temperature); oc_rep_end_root_object(); oc_send_separate_response(&temp_response, OC_STATUS_OK); 28

Building applications Scheduling events Client / Server Trigger callback after a period of time... oc_event_callback_retval_t run_after_a_sec(void *user_data) {... return DONE; // Tears down the callback // return CONTINUE instead to be called back once more after the preset interval }... oc_set_delayed_callback(null, &run_after_a_sec, 1);... May be used for scheduling one-off or periodic request issuances 29

Building applications Handling Interrupts Server-side Applications can define and signal a callback from an external context (eg. ISR) Callback executed on task that runs the event loop oc_define_interrupt_handler(temp_sensor) { // Callback definition... }... static void app_init(void){ oc_activate_interrupt_handler(temp_sensor); // Callback registration... void temp_sensor_isr() {... oc_signal_interrupt_handler(temp_sensor); // Callback Signaling 30

Building applications Framework configuration Set at build-time in a file config.h Number of application resources Number of request/response buffers Maximum payload sizes Memory pool sizes Max # of DTLS peers DTLS connection timeout 31

Porting to new environments Abstract Interfaces Clock IoTivity- Constrained Core PRNG Connectivity Persistent Storage IoTivity-Constrained Framework 32

Porting to new environments Clock interface // Set clock resolution in IoTivity-Constrained s configuration file: config.h #define OC_CLOCK_CONF_TICKS_PER_SECOND (...) typedef uint64_t oc_clock_time_t; // timestamp field width // Declared in port/oc_clock.h // Implement the following functions using the platform/os s APIs, For eg. on Linux // using clock_gettime() void oc_clock_init(void); oc_clock_time_t oc_clock_time(void); unsigned long oc_clock_seconds(void); void oc_clock_wait(oc_clock_time_t t); 33

Porting to new environments Connectivity interface // Declared in port/oc_connectivity.h // Implement the following functions using the platform s network stack. int oc_connectivity_init(void); void oc_connectivity_shutdown(void); void oc_send_buffer(oc_message_t *message); void oc_send_multicast_message(oc_message_t *message); uint16_t oc_connectivity_get_dtls_port(void); oc_message_t contains remote endpoint information (IP/Bluetooth address), and a data buffer 34

Porting to new environments Connectivity interface: network event synchronization Capture incoming messages by polling or with blocking wait in a separate context and construct an oc_message_t object Message injected into framework for processing via oc_network_event() call Based on nature of OS or implementation, might require synchronization void oc_network_event_handler_mutex_init(void); void oc_network_event_handler_mutex_lock(void); void oc_network_event_handler_mutex_unlock(void); 35

Porting to new environments PRNG interface // Declared in port/oc_random.h // Implement the following functions to interact with the platform s PRNG void oc_random_init(void); unsigned int oc_random_value(void); void oc_random_destroy(void); 36

Porting to new environments Persistent storage interface // Declared in port/oc_storage.h // Implement the following functions to interact with the platform s persistent storage // oc_storage_read/write must implement access to a key-value store int oc_storage_config(const char *store_ref); long oc_storage_read(const char *key, uint8_t *buf, size_t size); long oc_storage_write(const char *key, uint8_t *buf, size_t size); 37

Conclusion Pointers to code Source code: https://gerrit.iotivity.org/gerrit/gitweb?p=iotivity-constrained.git IoTivity mailing list: iotivity-dev@lists.iotivity.org Project actively developed Ports for RIOT OS, Zephyr, Contiki and Linux Feature gaps, enhancements, pass OCF certification tests Project, code and API documentation Your involvement and contributions are welcome! 38

Q & A