Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

IoT: From Arduino Microcontrollers to Tizen Products using IoTivity

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Cargando en…3
×

Eche un vistazo a continuación

1 de 42 Anuncio

Más Contenido Relacionado

Presentaciones para usted (20)

A los espectadores también les gustó (13)

Anuncio

Similares a IoT: From Arduino Microcontrollers to Tizen Products using IoTivity (20)

Más reciente (20)

Anuncio

IoT: From Arduino Microcontrollers to Tizen Products using IoTivity

  1. 1. Samsung Open Source Group 1 IoT: From micro controllers to products using Philippe Coval Samsung Open Source Group / SRUK philippe.coval@osg.samsung.com “IoT with the Best” Online conference #IOTWTB <2016-10-29>
  2. 2. Samsung Open Source Group 2 Hello World ! ● Philippe Coval – Software engineer for Samsung OSG ● Belongs to SRUK team, based in Rennes, France ● Ask me for IoTivity support on Tizen platform and others – Interests ● Libre Soft/Hard/ware, Communities, Interoperability – DIY, Embedded, Mobile, Wearables, Automotive... – Find me online ● https://wiki.tizen.org/wiki/User:Pcoval
  3. 3. Samsung Open Source Group 3 Agenda ● What is IoT ? ● IoTivity framework for connected devices ● Example ● Deployed on Arduino and Tizen Mobile Wearable devices ● More ● Q&A
  4. 4. Samsung Open Source Group 4 Internet of Things is: A complex equation ● Where all parameters are correlated : – Connectivity: not only Internet, probably IP, but not only ● Personal (<1m), Local (<10m - 10km), Metropolitan (<10km), Wide Area (<1000Km) – Security matters ! (during all expected life span) ● Several surfaces of attacks: service, monitoring, upgrade – Cost of materials and cost of usage: ● Computing capability (CPU or MCU?), consumption, if 24x7 ● Development, maintenance: FLOSS or Closed source ?
  5. 5. Samsung Open Source Group 5 ● Many Silos / Many implementations : – One app per device (better than many remote controls) – Dependence on centralized models (hub/cloud) ● Many concerns or issues: – Security/Privacy concerns? – Long term support and maintenance? – Do we want critical devices exposed to the Internet ? ● Few Interoperability/Interconnection of today's things. IoT: Internet of Today or Internet of Troubles ?
  6. 6. Samsung Open Source Group 6 IoT: Internet of Tomorrow? Internet of Trust? ● “I” like Interoperability – <blink>Local connectivity between devices</blink> – Interconnect any protocols or on line services ● “O” like Openness – Open standards, protocol, implementations ● “T” like Trustworthy – Security is sine qua non condition for IoT – Today, gateway is a reasonable answer
  7. 7. Samsung Open Source Group 7 “Talk is cheap. Show me the code.” ~ Linus Torvalds
  8. 8. Samsung Open Source Group 8 “I” like framework ● Seamless device to device connectivity for IoT – Core: Discovery, Secure Transmission, Data/Device – Plus profile services : SmartHome, Automotive, Health... ● C/C++ library (Apache 2.0) – RESTfull design : CoAP and CBOR ● Backed by Open Connectivity Foundation – Establishes standard, certifies of products, propose models – With industry support (Samsung, Intel, Cisco, GE, +190)
  9. 9. Samsung Open Source Group 9 OCF is standard / IoTivity is implementation ● Based on existing standards or solutions – Interacts with other standards: uPnP, AllSeen ● Current features: – Discovery (IETF RFC7252 / IP Multicast) – Communication (RESTfull API on CoAP) w/ Security (DTLS) – Transports (IP, WiFi, BT, BLE, Zigbee...) – Data/Device management, web services, cloud, plugins... ● Today I explain only discovery and notification mechanism
  10. 10. Samsung Open Source Group 10 “The secret of getting ahead is getting started.” ~ Mark Twain
  11. 11. Samsung Open Source Group 11 Challenge yourself ! ● No limit: sensors, robotics, from cat feeder to autonomous vehicles ● Start with simplest example: – Led blinking is the “hello word” for embedded developer ● Using GPIO – Then we can replace LED by a relay ● And make is visible by several connected clients – And notify them on each change ● Today mission: multi controlled binary switch (Flip/Flop) ● Shared resource is boolean (on/off) as READ and WRITE mode
  12. 12. Samsung Open Source Group 12 Typical flow ● Resource is identified by an URI and composed of properties – To be Created, Read, Updated, Deleted, + Notified (CRUD+N) IoTivity Server IoTivity Client(s) Network Registration of resource Handling new requests Set/Get/ing properties values Initialization as server Initialization as client Handling new clients Discovery of resource ( POST/PUT GET ) (CoAP Multicast)
  13. 13. Samsung Open Source Group 13 Let's develop a client/server ● You can start an Arduino project – IoTivity CSDK code is cross platform – Suggestion: Try to make a portable project too ● Or on a friendly GNU/Linux environment: – Debian/Ubuntu, Tizen, Yocto (meta-oic), OpenWRT – Try to Isolate platform code (syscalls, POSIX, GPIO) – Use your favorites tools, IDE, debug, log, trace, QA
  14. 14. Samsung Open Source Group 14 Get your hands on IoTivity! ● Get and build libraries: https://wiki.iotivity.org/build – Download sources and dependencies ● Build current version 1.1.1 using scons – Or if OS shipping IoTivity ● Tizen, Yocto based Automotive Grade Linux GENIVI ... ● Use it a regular library (CPPFLAGS & LDFLAGS) ● Look at tree: https://wiki.iotivity.org/sources – Samples apps: resource/examples – C SDK: resource/csdk or C++ SDK: resource/resource/src
  15. 15. Samsung Open Source Group 15 IoTivity CSDK flow : Create Resource OCInit(... OC_SERVER); OCCreateResource( …, onOCEntity); { OCProcess(); } OCInit(... OC_CLIENT); IoTivity Server IoTivity Client(s) IP NetworkIP Network ● Initialization is trivial ● Then server create a new resource – and registers a callback to serve client – and waits for new client(s) requests
  16. 16. Samsung Open Source Group 16 IoTivity CSDK flow: Discovery of resource OCInit(NULL, 0, OC_SERVER); OCCreateResource( …, onOCEntity); { OCProcess(); } OCInit(NULL, 0, OC_CLIENT); OCDoResource(...,OC_REST_DISCOVER, ...) onDiscover(... OCClientResponse ...) IoTivity Server IoTivity Client(s) IP NetworkIP Network ● Client attempts to discover server's resources – and finds registered ones
  17. 17. Samsung Open Source Group 17 IoTivity CSDK flow: GET Request OCInit(..., OC_SERVER); OCCreateResource( …, onOCEntity); { OCProcess(); } onOCEntity(entityHandlerRequest) { switch entityHandlerRequest->method { case 'GET' : // READ current value ... OCDoResponse(&response); }} OCInit(..., OC_CLIENT); OCDoResource(...,OC_REST_DISCOVER, ...) onDiscover(... OCClientResponse ...) OCDoResource(...OC_REST_GET …) onGet(... OCClientResponse ...) IoTivity Server IoTivity Client(s) IP NetworkIP Network ● Client is asking – for resource's value ● Server is responding
  18. 18. Samsung Open Source Group 18 OCDoResource(...OC_REST_PUT …) onPut(... OCClientResponse ...) IoTivity CSDK flow: PUT request OCInit(..., OC_SERVER); OCCreateResource( …, onOCEntity); { OCProcess(); } onOCEntity(entityHandlerRequest) { switch entityHandlerRequest->method { case 'POST: // Create value case 'PUT' : // Update new resource // handling the change case 'GET' : // READ current value ... OCDoResponse(&response); }} OCInit(..., OC_CLIENT); OCDoResource(...,OC_REST_DISCOVER, ...) onDiscover(... OCClientResponse ...) IoTivity Server IoTivity Client(s) IP NetworkIP Network ● Client sets resource's value ● Server is handling it – and responding
  19. 19. Samsung Open Source Group 19 OCDoResource(...OC_REST_PUT …) onPut(... OCClientResponse ...) IoTivity CSDK flow: Notification/Observation OCInit(..., OC_SERVER); OCCreateResource( …, onOCEntity); { OCProcess(); } onOCEntity(entityHandlerRequest) { switch entityHandlerRequest->method { case 'POST: // Create value case 'PUT' : // Update new resource OCNotifyAllObservers(); case 'GET' : // READ current value ... OCDoResponse(&response); }} OCInit(..., OC_CLIENT); OCDoResource(...,OC_REST_DISCOVER, ...) onDiscover(... OCClientResponse ...) IoTivity Server IoTivity Client(s) IP NetworkIP Network onObserve(... OCClientResponse ...) ● All subscribed clients – are notified of the change
  20. 20. Samsung Open Source Group 20 “I'm not crazy. My reality is just different from yours.” ~ Lewis Carroll
  21. 21. Samsung Open Source Group 21 Microcontrollers (MCU) ● A microcontroller is a System on Chip (SoC) – Digital I/O, A/D & D/A Conversion, Serial Interface, Timers – Flash Memory, Static RAM ● Arduino : OSHW Electronic prototyping platform – Huge community, OOP libraries, education purposes – Supports daughter boards called shields, ie: Ethernet, WiFi, etc ● Baremetal development – main loop program have direct access to hardware ● Note that many operating system for MCU are existing
  22. 22. Samsung Open Source Group 22 IoTivity is supporting Arduino atmega256 ● IoTivity CSDK use atmega256 as reference target – Based on Atmel ATmega2560 MCU (8KiB RAM, 256KiB of Flash, 16Mhz) ● Class 2 Constrained device (RFC7228 ~ 50 KiB data ~ 250 KiB code) – Build it using scons tool: scons resource TARGET_OS=arduino TARGET_ARCH=avr BOARD=mega SHIELD=ETH – It will download toolchain, and build using avr-gcc & avr-g++ – And produce a set of static libs (~100KiB) to be linked with any program: ● libcoap.a, liboctbstack.a, libconnectivity_abstraction,a ...
  23. 23. Samsung Open Source Group 23 Port server code to Arduino API ● Adapt/rewrite platform code: sleep(sec) vs delay(ms) – Initialize Ethernet, GPIO (pinMode, digitalWrite) ● Update build scripts (tip: use Arduino-Makefile/Arduino.mk) – Note Arduino API are using C++ POO while ours in plain C – Trick: symlink or echo “#include “$file.c” “ > “$file.c.tmp.cpp” – LOCAL_CPP_SRCS += src/server.c.tmp.cpp ● Deploy server using Arduino's avrdure: (117056 bytes of flash) ● Use client(s) on GNU/Linux or port code for other devices
  24. 24. Samsung Open Source Group 24 Hardware integration : DIY or Modules? ● High voltage relay (0-220V) – Signal = Base of NPN Transistor ● Simples modules, to wire on headers – Ie: Single channel Relay (HXJ-36) : 0V, +5V, GPIO SBC Relay 5V Finder F34 30.22.7.005.0010 Vcc 2 ? GND 2 Vcc 1 + 5V GND 1 Transistor NPN P2N 2222A Resistor * (*) ARTIK10 | MinnowMax 47 OHM (yellow, purple, black) C B E o o o o GPIO (*) RaspberryPI 180 OHM (brown, grey, brown) GND1GND1 GPIOGPIO PinPin 1313 Vcc1Vcc1 (5v)(5v) Vcc2Vcc2 GND2GND2
  25. 25. Samsung Open Source Group 25 What is a friend? A single soul dwelling in two bodies ~ Aristotle
  26. 26. Samsung Open Source Group 26 Interaction with products ● Tizen is an Operating System based on FLOSS ● Shipped into consumer electronics products ● Tizen IoTivity – Tizen:3 contains as platform package (.rpm) – Tizen:2 can ship shared lib into native app (.tpk) ● For Samsung Z{1,2,3} (Tizen:2.4:Mobile) ● Samsung GearS2 (Tizen:2.3.1:Wearable)
  27. 27. Samsung Open Source Group 27 Build Tizen clients 1/2: build library ● Setup and configure GBS for : – Tizen:2.4:Mobile for Z1 – Tizen:2.3.1:Wearable for Gear S2 – Tizen:3.0 for x86 or ARM ● Build dependencies 1st : (scons, boost...) – git clone $URL -b ${branch} # (ie: tizen, tizen_2.4) – gbs build -p ${profile} # (ie: tizen_mobile-armv7l) ● In the end : iotivity-*.rpm
  28. 28. Samsung Open Source Group 28 Build Tizen clients 2/2: create App ● Using Tizen SDK, create native tizen project – Unpack lib and headers from: iotivity-*.rpm iotivity-devel*.rpm – Update build and link flags (see wiki) – cp usr/lib/*.so lib and make deploy package (.tpk) ● Adapt EFL gui and integrate IoTivity – Create UI using elementary widgets toolkit – Use previous CSDK client (or write it again using C++) ● Start IoTivity client in a separate thread – Update UI on IoTivity events (main loop)
  29. 29. Samsung Open Source Group 29 IoTivity hardware to hack on: ● Single Board Computers with daughters boards – ARTIK 5,10,7 are also compatible with Arduino Shields – Raspberry Pi + hats (RabbitMax Flex, CoPiino) – Minnowboard + lures (Calamari, Tadpole), Edison ● Other micro controllers: – ESP8266, Arduino 101, Galileo ● Yours? Tell us: https://wiki.iotivity.org/hardware ● IoTivity is also supported outside GNU/Linux or Tizen
  30. 30. Samsung Open Source Group 30 You can even create your own Tizen device ● Since Tizen 3, Tizen:Common was introduced ● A profile to create new profiles on: – 90% Tizen:IVI (cars) is Tizen Common – IoTivity is part of Tizen:Common ● Like “your Tizen gateway” profile – Start by installing OS for supported devices (ARM or Intel) ● Or port to new architecture hardware using GBS or Yocto
  31. 31. Samsung Open Source Group 31 “Any sufficiently advanced technology is indistinguishable from magic.” ~ Arthur C. Clarke
  32. 32. Samsung Open Source Group 32 iotivity-arduino-20161006rzr https://vimeo.com/185851073#iotivity-arduino-20161006rzr
  33. 33. Samsung Open Source Group 33 Want More ? ● More constrained: – Iotivity-constrained: RIOT, Contiki, Zephyr... – Tizen Micro (RTOS + JerryScript + IoT.js), Tizen Nano... ● More connectivity: BT, BLE, Zigbee, LTE, NFC... ● Security & scale: Deploy an OCF network of sensors – For Smart (Home | Car | City | $profile)
  34. 34. Samsung Open Source Group 34 Summary ● IoT is not only about apps or cloud but new connections between things ● Open Connectivity Foundation – establishes a standard for interconnecting things – Open Source IoTivity project implements it ● Devices can be connected using IoTivity: – Micro controllers are part of IoT – Arduino are great development platforms for prototyping – Tizen OS is shipped into today products or into your own design ● And many more OS or hardware
  35. 35. Samsung Open Source Group 35 References ● Entry point: – https://wiki.iotivity.org/examples – git clone iotivity-example -b sandbox/pcoval/arduino ● Technical references – https://openconnectivity.org/resources/iotivity ● OIC_1.1_Candidate_Specification.zip – http://www.atmel.com/Images/ ● Atmel-2549-8-bit-AVR-Microcontroller-ATmega640-1280-1281-2560-2561_datasheet.pdf – https://tools.ietf.org/html/rfc7228 – https://www.tizen.org/sites/default/files/event/gb1_tdc15_tizen_micro_profile_for_low-end_iot_device.pdf ● Keep in touch online: – https://wiki.iotivity.org/community – https://wiki.tizen.org/wiki/Meeting – https://blogs.s-osg.org/author/pcoval/
  36. 36. Samsung Open Source Group 36 Q&A or/and Annexes ?
  37. 37. Samsung Open Source Group 37 Thank you Merci / 고맙습니다 Samung OSG, SSI, Open Connectivity Foundation, LinuxFoundation, BeMyApp, FLOSS Communities: Tizen, Yocto, EFL, AGL, GENIVI FlatIcons (CC BY 3.0) : Freepik, xkcd.com (CC BY NC 2.5), Libreoffice, openshot, SRUK,SEF, Intel, Rabbitmax, LabFabFr,Chao@TelecomBretagne, IOTWTF attendees, YOU ! Contact: https://wiki.tizen.org/wiki/User:Pcoval
  38. 38. Samsung Open Source Group 38 iotivity-genivi-demo-platform-20160210rzr https://vimeo.com/154879264#iotivity-genivi-demo-platform-20160210rzr
  39. 39. Samsung Open Source Group 39 tizen-artik-20161010rzr https://vimeo.com/186286428#tizen-artik-20161010rzr

×