Using Eclipse and Lua for the Internet of Things with Eclipse Koneki, Mihini and Paho

Preview:

DESCRIPTION

The Internet of Things (IoT) or Machine to Machine (M2M), is a technological field that will radically change the global network by enabling the communication of virtually every single object with each other. Studies state that more than 50 billions objects may be connected to the Internet by 2020. In a near future, everything from a light bulb to a power plant, from a pacemaker to an hospital, from a car to a road network will be part of the Internet. While this revolution is already happening (your house or your car may be "connected" already!), there are still lots of barriers to its growth, especially since existing solutions are almost always proprietary, and cannot interoperate easily. There are several very active M2M initiatives at Eclipse aiming at lowering these barriers, all under the umbrella of the M2M Industry Working Group. Last year, projects Paho (communication protocols for M2M) and Koneki (tools for M2M developers, in particular a complete IDE for Lua development) were created, and in July 2012 project Mihini was proposed to establish Lua as a reference platform for building M2M and IoT solutions. The purpose of this talk is to give you a clear understanding of the afore mentioned Eclipse projects, as well as to show you that real M2M solutions can already be developed thanks to them. We will briefly introduce the Lua programming language, explain why it is a good fit for embedded M2M development, and then demonstrate the development of an actual working solution making use of the Mihini framework, a Paho MQTT client, and the Koneki tooling. The use case will also leverage Open Hardware such as Arduino and a RaspberryPi, therefore you can expect nice demos!

Citation preview

Using Eclipse & Lua for the Internet of Things

Benjamin Cabé – bcabe@sierrawireless.com Gaétan Morice – gmorice@sierrawireless.com

� IoT? M2M?

Technology that supports wired or wireless communication between devices

50

bill ion devices by 2020

50

bill ion devices by 2020

Communication Infrastructure

Smart Pill Box

Heartbeat Sensor

Weight Scale

Blood Pressure

Medical Services Gateway

Near field

Blood Sugar

Internet of Things

Patient

Clinical Trial

Doctor

Ready then?

…Not quite!!

M2M market = fragmented

M2M development = complex

M2M vendors = lock-in

?

Framework

Tools

3 projects

Protocols

M2M embedded programming

•  low-level C

•  memory management

•  multithreaded programming

•  read sensor values

•  control actuators

•  consolidate data

•  communicate

Example: Sending an SMS int main(){ unsigned char char1[10]; unsigned char char_buf[8]="AT+CSQ\n"; // 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 portstruct termios options;ttys5_fd = open("/dev/ttyS5", O_RDWR );if (ttys5_fd < 0){ printf("\nFail to open serial port 2\n"); return 0;}init_tty( ttys5_fd ,BAUD_RATE);return ttys5_fd;-----------------------------------//initializing baud rateint init_tty( int fd ,long wBaud){ long baud; switch (wBaud) {

sms.send( '+33612345678’, 'My SMS’, )

Simplify M2M programming

What is Lua?

•  High-level programming language

•  Scripting

•  Extensible

•  Simple

•  E!cient

•  Portable

You need an IDE! •  Project structure

•  Syntax coloring

•  Content assist

•  Code navigation

•  Code formatting

•  Documentation

•  Code templates

•  Debugger

•  Remote development

June 2012: first release (0.8)

Dec. 2012: 0.9 release

June 2013: graduate w/ Kepler

20,000+ installations already!

DEMO

Using Koneki LDT for remote Lua development

101

•  http://www.eclipse.org/koneki/ldt •  Download standalone IDE •  Or install in existing Eclipse

–  from Juno repository –  from nightly/milestones repositories

•  Execution environments: –  http://sierrawireless.github.com/lua-execution-

environments/

•  Contact the team –  http://eclipse.org/forums/eclipse.koneki

http://www.sxc.hu/photo/1036004

•  Low-bandwidth

•  Low-power

•  Payload agnostic

•  Adjustable QoS

•  Large ecosystem

broker broker

(optional) bridge

publishsubscribe

keepalivelast will & testamentusername/password

topic/subtopic

topic/#

101 •  http://eclipse.org/paho/ •  Eclipse Paho delivers clients for MQTT in C and

Java –  http://eclipse.org/paho/download.php

•  Lua client available soon –  https://github.com/geekscape/mqtt_lua

•  MQTT view in Eclipse –  http://git.eclipse.org/c/paho/org.eclipse.paho.esf.git/

•  Free broker hosted at Eclipse: m2m.eclipse.org

•  Contact the team –  paho-dev mailing-list

Lua VM + MQTT client to go?

Application framework for M2M

•  Set of libraries providing building blocks to develop user M2M applications: – Serial and I/O management, – Networking (FTP, HTTP, E-mail clients), – GPS, – Cryptography, – Modbus, – Local storage – etc. http://www.eclipse.org/mihini

Smart agent for M2M

•  M2M data queues

•  Network bearers

•  Device management

•  Application container

•  Application configuration

http://www.eclipse.org/mihini

101

•  http://www.eclipse.org/proposals/technology.mihini

•  http://eclipse.org/mihini

•  Code will be available on Github soon

•  Initial contribution planned for Q1

Let me show you!

Step 1 – Early prototyping

•  Greenhouse business – Connect gardening equipments to each

other – Remote monitoring of sensors – Remote control

•  M2M Gateway not selected yet, neither is the rest of the equipment (PLCs)

m2m.eclipse.org MQTT broker

Raspberry Pi Mobile phone

humidity temperature illuminance

light ON/OFF

Modbus RTU

Two Lua applications

Embedded

–  Uses Modbus library to talk to Arduino PLC

–  Collects sensor data/controls actuators

–  Publishes MQTT messages

–  Subscribe to commands

Mobile

Corona SDK

–  Subscribes to MQTT messages

–  Displays sensor data with a fancy UI

–  Publish command to switch on/o" the light

M2M Developer Kit

•  Actual hardware early in the dev. process is key

Affordable! Simple! Industrial!

•  http://wiki.eclipse.org/Mihini/Developer_Kit •  Arduino code & schematics available after the conference

Step 2 – Use an industrial gateway

•  Need for rugged, industrial-grade M2M gateway

•  Take the Mihini codebase and compile it against the gateway’s toolchain

•  Mihini porting layer – straightforward for Linux-based devices

with AT modem – porting layer for other solutions

m2m.eclipse.org MQTT broker

Rugged wireless gateway

Mobile phone

humidity temperature illuminance

light ON/OFF

Modbus RTU

Step 3 – Industrial deployment

•  Use a real PLC – Mihini dev. kit is replaced by a real PLC – Only the configuration of the application

(modbus registries #) will have to be updated

•  Use a reliable, multi-tenant, M2M server

M2M server

Rugged wireless gateway

humidity temperature illuminance

light ON/OFF

Modbus RTU

Telco!

Billing! etc…!

Mobile phone

Conclusion

•  Developing an M2M app with Mihini is simple – Demo app written in a couple hours

•  Mihini apps are portable

•  Mihini itself is easily portable – make install

•  Koneki provides support for editing, debugging and deploying M2M apps

M2M AT ECLIPSE IS ALSO…

A developer portal

An all-in-one IDE

•  June 2013 •  Ready-to-use •  Market Place

Join us!

•  BoF: tomorrow – 7 pm Schubartsaal

•  Industry Working Groups booth

Recommended