300 likes | 329 Views
Introduction to the ARM mbed Platform– A Hands-on Course. Class 3: mbed Communications and Multitasking. January 11, 2017 Charles J. Lord, PE President, Consultant, Trainer Blue Ridge Advanced Design and Automation. This Week’s Agenda. 1/9 Peeking Under the mbed Hood 1/10 CMSIS, Hands-On
E N D
Introduction to the ARM mbed Platform– A Hands-on Course Class 3: mbed Communications and Multitasking January 11, 2017 Charles J. Lord, PEPresident, Consultant, TrainerBlue Ridge Advanced Design and Automation
This Week’s Agenda 1/9 Peeking Under the mbed Hood1/10 CMSIS, Hands-On 1/11 mbed Communications and Multitasking 1/12 The mbed Developer Network 1/13Porting mbed
This Week’s Agenda 1/9 Peeking Under the mbed Hood1/10 CMSIS, Hands-On 1/11 mbed Communications and Multitasking 1/12 The mbed Developer Network 1/13Porting mbed
More on Ethernet • Sockets • UDP vs TCP • HTTP • Websockets • MQTT
Berkeley Socket Interface 7 Protocol’s Application Layers 6 5 SocketInterface 4 Transport (ex. TCP/UDP) 3 Internet Data Transport Layers 2 Network 1
Berkeley Sockets • API for base layer connectivity • Build modular for wide compatibility Berkeley Socket API
UDP TCP recvfrom()
HTTP: Pros: • TCP based • Widely used • Stateless (open, grab, close) • Request and response Cons: • Bulky (1KB-1MB) • Implementation varies • Every resource requires a new connection
HTTP Contents Request Request line Get/Post, HTTP version Request headers Host, user agent, language, cookies, etc Payload Blob of data (form data, measurement etc) Receive Status line HTTP version, status number Response headers Server, content type and length, cookie update etc Payload Blob of data (binary, HTML etc)
Websockets ws:// Pros • TCP based, port 80 • Live connection • Server <-> client • Native support • Realtime Cons • Does not scale well • Inconsistent support • Requires dedicated server
Websocket connection lifecycle Server Client handshake (http upgrade) connection opened messages open and persistent connection one side closes channel connection closed
MQTT Pros Publish/Subscribe End of life will Small footprint Universal support Security (user/pass) Arbitrary packets Wild card topics Cons Requires server (broker) TCP based Security No formalized packet schema ISO/IEC PRF 20922
MQTT: Publish/Subscribe sub(topic,data) Publisher Broker Subscriber pub(topic,data) pub(topic,data)
MQTT: How Does It Work? Publish/Subscribe to topics Wildcard subscribe (+,#) Client ID LWT - living will Quality of Service (QoS) Three levels QoS L0) ==1 delivery, no confirm QoS L1) 1+ delivery, confirm QoS L2) ==1 delivery, confirm
MQTT Summary Works on mobile, embedded, web, desktop (Seriously, there are libraries for all the languages) Lightweight-ish Medium weight for embedded TCP based (MQTT-SN, but who cares?) LWT is awesome Great for one <-> many Has cordova and Evothings plugin
CMSIS-RTOS • Standard API for RTOS • The ‘official’ RTOS, RTX, is one option • Our next class in three weeks (note it is at an earlier time), we will look at using Micrium uC/OS with mbed
This Week’s Agenda 1/9 Peeking Under the mbed Hood1/10 CMSIS, Hands-On 1/11 mbed Communications and Multitasking 1/12 The mbed Developer Network 1/13Porting mbed
Please stick around as I answer your questions! • Please give me a moment to scroll back through the chat window to find your questions • I will stay on chat as long as it takes to answer! • I am available to answer simple questions or to consult (or offer in-house training for your company)c.j.lord@ieee.orghttp://www.blueridgetechnc.comhttp://www.linkedin.com/in/charleslordTwitter: @charleslordhttps://www.github.com/bradatraining