Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Using Eclipse and Lua for the Internet of Things - JAX2013


Published on

Published in: Technology
  • Be the first to comment

Using Eclipse and Lua for the Internet of Things - JAX2013

  1. 1. Using Eclipse & Lua for theInternet of ThingsBenjamin Cabé
  2. 2. Who I am•  Benjamin Cabé•  Open Source M2MEvangelist at Sierra Wireless•  Long-time Eclipse lover
  3. 3. ❝M2M? IoT?Technology that supportswired or wirelesscommunicationbetween devices
  4. 4. SmartPillBoxHeartbeatSensorWeightScaleBloodPressureMedicalServicesGatewayNear fieldBloodSugarInternetof ThingsPatientClinical TrialDoctor
  5. 5. FrameworkTools3 projectsProtocols
  6. 6. M2M embeddedprogramming•  low-level C•  memorymanagement•  multithreadedprogramming•  read sensor values•  control actuators•  consolidate data•  communicate
  7. 7. Example: Sending an SMSint main() { unsigned char char1[10]; unsigned char char_buf[8]="AT+CSQn"; // unsigned char sms_buf[20] = "AT+CMGS="xxxxxxxxx"; int wc_fd; /********* Init of serial port ************/ wc_fd = init_wc(wc_fd); sleep(3); //writing to serial port write(wc_fd,char_buf,sizeof(char_buf)); usleep(40000); //reading from serial port read(wc_fd,char1,sizeof(char1)); sleep(2); close(wc_fd); return 0; } // end of main // initialization of serial port struct termios options; ttys5_fd = open("/dev/ttyS5", O_RDWR ); if (ttys5_fd < 0) sms.send(
  8. 8. Simplify M2M programming
  9. 9. What is Lua?•  High-level programming language•  Scripting•  Simple•  Extensible•  Portable
  10. 10. Extensible by design•  Small– Trivial syntax and reduced keyword set•  Simple but not stupid– Simple enough for new users, powerful enoughfor advanced users (first-class functions,garbage collection, closures, tail calls, coercion,coroutines, metatables)•  Lua core is tiny– Compiled size is ~150kB– Lua uses libraries for its extensions
  11. 11. Lua vs. other high-level languages•  Same core features as Python, Ruby,Javascript •  Better concurrency management– Built-in – doesn’t rely on the OS•  Cutting-edge execution technology &performances
  12. 12. Lua vs. other high-level languages•  Restricted set of libraries– Stay simple, the developer brings his own •  Designed for C integration– Performance– Legacy
  13. 13. Lua for embedded and M2M?•  High-level languages usually tradehardware resources for development &maintenance resourcesLua allows to reconcile high-levellanguages accomplishmentswith embedded constraints
  14. 14. You need an IDE!•  Project structure•  Syntax coloring•  Content assist•  Code navigation•  Code formatting•  Documentation•  Code templates•  Debugger•  Remote development•  Embedded interpreterJune 2012: first release (0.8)Dec. 2012: 0.9 releaseJune 2013: graduate w/ Kepler60,000+ installations already! (Apr. 2013)
  15. 15. DEMOUsing Koneki LDT forremote Lua development
  16. 16. 101••  Download standalone IDE•  Or install in existing Eclipse–  from Juno repository (0.8.2)–  from nightly/milestones repositories (1.0M1)•  Execution environments on Koneki wiki– •  Contact the team–
  17. 17.
  18. 18. •  Messaging protocol•  Low-bandwidth / Low-power•  Payload agnostic•  Adjustable QoS•  Large ecosystem
  19. 19. broker broker(optional) bridgepublishsubscribekeepalivelast will & testamentusername/passwordtopic/subtopictopic/#
  20. 20. M3DA OverviewCompact … because in the wireless world, data overhead costs money–  Efficient in the transport of binary M2M dataInteroperable … because the M2M communication chain is heterogeneous–  Language-independent–  Tolerant to data schema changes–  Agnostic to transport layer (TCP, HTTP, SMS, …)Secure … because security is #1 concern for M2M adopters–  Ensure integrity and confidentiality of customer data–  Message ticket-id to enable acknowledgementOpen … because vendor lock-in hinders M2M adoption–  Open specification–  Open-source, royalty-free, implementations
  21. 21. 101••  Free brokers hosted at•  Contact the team– paho-dev mailing-list
  22. 22. Lua VM + a Paho client to go?
  23. 23. Application framework for M2M•  Set of libraries providing building blocksto develop M2M applications:– Serial and I/O management, – Networking (FTP, HTTP, e-mail, …),– GPS, – Cryptography, – Modbus, – Local storage– etc.
  24. 24. Smart agent for M2M•  M2M data queues•  Network bearers•  Device management•  Application container•  Application configuration
  25. 25. Overall architecture
  26. 26. Asset management•  User applications use an API tocommunicate with Mihini– Send data or events– Register listeners to handle data writing orcommands•  The Mihini agent takes care of networkconnection, buffering and reliablestorage of unsent data, etc.
  27. 27. Asset managementlocal gh_asset = asset_mgt.newAsset("greenhouse")gh_asset:start()gh_asset:pushdata("sensors.temperature", 22, "now")gh_asset:pushdata("sensors.humidity", 89, "hourly")
  28. 28. Device management•  A Tree Manager presents devices dataas– variables,– organized in a hierarchical tree,– that can be read, written, and monitored forchanges by user applications.
  29. 29. Device managementlocal devicetree = require devicetreelocal APN = system.cellular.apn.apnlocal RSSI = apn = devicetree.get (APN)log(LOG_NAME, "INFO", "Configure APN: %s", apn)local function print_callback (values)for name, value in pairs(values) dolog (LOG_NAME, "INFO"," - Variable %s changed: %s",name, value)endenddevicetree.register(RSSI, print_callback)devicetree.set(APN, foo)
  30. 30. Application Management•  Language-agnostic applicationcontainer– install/uninstall– start/stop, auto-start on boot– restart on failure•  Agent handles over-the-air softwaredownload and update mechanism•  Remote script execution
  31. 31. 101•••  Code will be available (very) soon– Initial contribution is pending IP review at Eclipse
  32. 32. Let meshow you!
  33. 33. Roadmap•  Protocols– CoAP, LWM2M •  REST API– Ease the communication of 3rd party apps with theAgent– Provide better tooling•  Polyglot framework– C and Java on their way
  34. 34. Wrapping up•  Developing an M2M app in Lua withMihini is simple– Demo app written in a couple of hours•  Mihini apps are portable•  Mihini itself is easily portable– make install J•  Koneki provides support for editing,debugging and deploying M2M apps
  35. 35. Join the party!
  36. 36. Thank you!