34
Developing IoT devices with mbed OS 5 Jan Jongboom Liyou Zhou mbed Connect 2016 - Shenzhen

mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

  • Upload
    armmbed

  • View
    33

  • Download
    3

Embed Size (px)

Citation preview

Page 1: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

Developing IoT deviceswith mbed OS 5

Jan JongboomLiyou Zhoumbed Connect 2016 - Shenzhen

Page 2: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 20162

Your hosts

Liyou ZhouSoftware Engineer

Jan JongboomDeveloper Evangelist

Page 3: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 2016

“I buy at the beginning of paradigm shifts. We are at that moment now

with Internet-of-things.”

3

Masayoshi Son

Page 4: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 20164

mbed has changed

mbed State of the Union

Page 5: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 20165

Before mbed OS 5

Online compiler Hardware Abstraction Layer

+

Page 6: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 20166

HAL fueled growth, compiler brought people in

Page 7: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 20167

But... embedded development is changingMCUs get more powerful, communication cheaperWe want more from our devices

Run full IP stacksFirmware upgradesDevice management

Challenges galore!

Page 8: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 20168

Affects both professionals and hobbyists

Professionals HobbyistsBigger attack surfaceLarger chance of bugsAdd value, not plumbing

Require sane defaultsGet to 90% without much

effortNeed proper networking

Good battery life out of the box

Page 9: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 20169

Standardizing the ecosystemProfessionals Hobbyists

Bigger attack surfaceMemory isolation

Larger chance of bugsWell tested isolated middleware

Add value, not plumbingCloud features, RTOS, unified network stacks

Require sane defaultsGet to 90% without much

effortWell tested cloud middleware

Need proper networkingUnified networking stacks

Good battery life out of the boxOptional schedular

Page 10: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201610

mbed OS 5 is more...More than the online compilerMore than the library ecosystemWell-tested middleware for IoT

Not needed?Still runs in 8K of RAM...

Page 11: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201611

Developing for mbed OS 5Or... how to get away from the online

compiler

Page 12: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201612

Not just the online compiler

Page 13: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201613

Three development environments

Online compiler mbed CLI Offline IDE

Page 14: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201614

Proper online / offline story

Sync

mbed.orgGitHub

Private DVCS

Page 15: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201615

Full integration coming to uVision 5

mbed Library manager

mbed OS 5 as CMSIS-PACK

Reference for other IDEs

Page 16: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201616

Getting started - online compiler

Choose 'mbed OS Blinky'

Page 17: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201617

Getting started - mbed CLIInstall mbed CLI - https://github.com/ARMmbed/mbed-cli

$ mbed new my-awesome-project

Page 18: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201618

Full RTOS or event schedulerFull RTOS based on Keil RTXOptional event scheduler - mbed-events

Same concepts as minar in mbed OS 3Runs in an RTOS threadhttps://github.com/ARMmbed/mbed-os/blob/master/docs/

events.md

Page 19: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 2016

1 #include "mbed_events.h" 2 3 // Create an event queue 4 Queue queue(32 * EVENTS_EVENT_SIZE); 5 // Create a thread that'll run the event queue's dispatch function 6 Thread t; 7 8 int main () { 9 // Start the event queue's dispatch thread 10 t.start(callback(&queue, &EventQueue::dispatch_forever)); 11 12 // Use normal constructs (like tickers, interrupts) 13 // but wrap them in queue.event to go from ISR->event loop 14 Ticker t2; 15 t2.attach(queue.event(&doSomething), 1.0f); 16 }

19

mbed Events

Page 20: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201620

Wait... There's an outside world?!Adding networking

Page 21: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201621

Available networking libraries

WiFiEthernetCellularThread6LoWPANBluetooth Low EnergyLoRaWAN... many more by the community

Page 22: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201622

Available networking libraries

WiFiEthernetCellularThread6LoWPANBluetooth Low EnergyLoRaWAN... many more by the community

}Unified networking APIWrite once, run anywherePorting is fast for socket-based librariesuBlox C027 ported in one day

mbed TLS included

Page 23: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201623

Example - HTTP using ESP8266Add https://github.com/ARMmbed/esp8266-driver

1 #include "mbed.h" 2 #include "ESP8266Interface.h" 3 4 ESP8266Interface esp(D1 /* TX */, D0 /* RX */); 5 6 int main() { 7 NetworkInterface* network = esp.connect("SSID", "Password"); 8 9 if (network) { 10 const char *ip_addr = network_interface->get_ip_address(); 11 printf("IP address is %s\n", ip_addr); 12 }

Page 24: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201624

Example - HTTP using ESP8266 (2)

1 socket.open(network); 2 socket.connect("developer.mbed.org", 80); 3 4 char sbuffer[] = "GET / HTTP/1.1\r\nHost: developer.mbed.org\r\n\r\n"; 5 int scount = socket.send(sbuffer, sizeof sbuffer); 6 7 char rbuffer[64]; 8 int rcount = socket.recv(rbuffer, sizeof rbuffer); 9 printf("recv %d [%.*s]\r\n", rcount);

Page 25: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201625

Security is bigger than TLS

Page 26: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201626

Reducing attack area on microcontrollersNo MMUFlat address spaceNeed component isolation

Page 27: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201627

uVisorMemory isolationTrustzone on V8-M architecture (Cortex-M23, Cortex-M33)Secure boxesWill be integrated part of mbed OS 5.x

Critical parts will be provided as well-tested isolated blocks

Currently available on 3 targets

Page 28: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201628

uVisor Blocks

Exposed Critical

Secure StorageCrypto Keys

Secure ID

Firmware Update

Crypto API

PRNGApplication

ProtocolTLS Library

Diagnose

WiFi StackBLE Stack

Device Manageme

nt

Page 29: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201629

"Ceci n'est pas un nuage"

Adding mbed Client

Page 30: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201630

mbed ClientRaw TCP / UDP sockets - easy data streams

Device management through mbed Device Connector

mbed Client is cloud middleware

Page 31: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201631

Simple mbed Client

Library to easily bring variables into the cloudhttps://developer.mbed.org/teams/sandbox/code/simple-m

bed-client

Cloud variablesDefine a variableUse it as normal variable, magic!

Easy to re-use existing mbed libraries...(integrated in core mbed Client in next release)

Page 32: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

One more thing...

Page 33: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

© ARM 201633

http://mbed.com/js

Page 34: mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

Thank you!http://developer.mbed.orgThank you!