SlideShare a Scribd company logo
1 of 51
Building it
From mock-up to prototype to
production
• Rapid prototyping is important
• Mock-up vs prototype
– Start with a mock-up, or
– Start working on the target hardware

• Using the same components when
prototyping as in production is good
– Makes production easier
Mock-up: Raspberry Pi
Mock-up: Arduino Yun
Prototyping: CC2538
IoT hardware – closer look
IoT hardware
• Sensors and actuators
– Connectors to the physical world

• Microprocessor
– To be able to do something with the
sensors/actuators

• Communication device
– To communicate with the world

• Power source
Typical IoT hardware properties
• Microcontroller
– Memory
• Flash ROM on the order of 64-512 kilobytes
• RAM on the order of 8-32 kilobytes

– I/O to connect sensors and actuators
• Serial ports, ADCs, SPI, etc

• Radio
– External transceivers
– Systems-on-a-Chip
• Radio integrated with microcontroller
Typical IoT hardware properties
• Power source
– Battery
– Energy harvesting
•
•
•
•

Solar cells
Ambient RF (like RFID)
Piezo electric
Temperature differences
Radio hardware
• Microcontroller + transceiver
–
–
–
–

CC1120 – sub-GHz
CC2520 – IEEE 802.15.4
nRF8001 – Bluetooth Smart
CC3300 – WiFi

• Connected via SPI
• System-on-a-Chip
– CC2538 – IEEE 802.15.4 + ARM Cortex M3
– Broadcom Wiced – WiFi + ARM Cortex M3
Power
• Power consumers
– Sensors, actuators
– Microprocessor
– Communication

• Radio must be completely off
– Consumes power even when idle

• Radio duty cycling mechanisms
OS vs rolling your own
• Rolling your own non-OS firmware
– Write everything, flash the chip

• An OS helps you with
– Network stacks
– Memory managament
– Drivers
– Power management
– ... and much, much more
IoT software challenges
• Severe limitations in every dimension
– Memory
– Processing power
– Communication bandwidth
– Energy, power consumption

• The number of different platforms is large
– Different microcontrollers, different radios,
different compilers
IoT system challenges
• Communication-bound, distributed
systems
– Exceptionally low visibility
• Hard to understand what is going on

– Application development difficult
– Debugging difficult

• Large-scale
• Wireless communication
Wireless connectivity
• Counter-intuitive
• Not a simple replacement to cables
The magic behind it all: Contiki
Contiki: an IoT OS
• Runs on tiny microcontrollers and SoCs
• Handles communication over a number of
different radios
• Provides processes, timers, libraries,
memory allocation, network stacks, etc
Contiki
• Dealing with limited memory
– Memory block allocation strategies
– Protothreads

• Portability
– Fully written in C

• Application development and debugging
– The Cooja network simulator
The Cooja network simulator
A Brief History of Contiki
Contiki: 10+ years old
• Based on the uIP TCP/IP stack
• First release March 10, 2003
– Ports to a range of odd lovely platforms
• Most 6502-based (Apple II, Atari 2600)
• Commodore C64

• The Contiki idea: put things on the Internet
– First system to do IP-based wireless sensor
networks
2008: IPv6 for Contiki
• uIPv6 was contributed by Cisco in 2008
• World’s smallest fully certified IPv6 stack
TIME magazine award
Recent history
• July 2012: Thingsquare founded, Contiki 2.6 released

• October 2012: Moved to github
• November 2012: automated regression tests with Travis
• November 2012: IPv6/RPL updates
• December 2012: New testing framework
• July 2013: Significant RPL updates
• November 2013: Contiki 2.7
Next steps: Contiki 3.x
• Push the Thingsquare firmware features
towards Contiki
• UDP, TCP socket APIs
• HTTP socket API
• Websocket API
Contiki features
• Three network stacks
– IPv4/IPv6 stacks
• RPL, 6lowpan, CoAP, HTTP, ...

– Rime stack

•
•
•
•
•
•
•
•
•
•

Instant Contiki development environment
The Cooja network simulator
Sleepy meshing (ContikiMAC)
Interactive shell
Flash-based file system
Powertracing
Protothreads
Multithreading
Event timers, real-time timers
Libraries: linked list, ringbuf, crc16, etc
Additional Thingsquare features:
Contiki 3.x
• IPv4/IPv6 routing
– NAT64 and DNS64

•
•
•
•
•
•
•

AES encryption
Network sniffer
Frequency hopping protocol
Portable duty cycling (Drowsie, CSL)
WebSocket protocol
UDP, TCP, HTTP socket APIs
More hardware platforms
Back to the Big Red Button
What the Big Red Button did
• When the button switch went from 1 to 0
– Do HTTP POST request to http://requestb.in

• Several steps:
– Ask the DNS server for requestb.in
– Get the answer, but converted to an IPv6 address
– converted by the router
– Set up a TCP connection to the IPv6 address
– The router translates to IPv4
– Send the HTTP POST request
HTTP POST request
POST /abcdefghij HTTP/1.1
Host: requestb.in
Content-Type: application/x-www-form-urlencoded
Content-Length: 15
button=big%20red
The Contiki code
#define URL "http://requestb.in/abcdefghij"
#define DATA "button=big%20red"
static struct http_socket s;
http_socket_post(&s, URL, DATA, strlen(DATA),
"application/x-www-form-urlencoded", callback,
NULL);
RESTful APIs
•
•
•
•
•
•

Leverage the way that HTTP works
Representational state transfer
Coined by Roy Fielding in 2000
Resources, representation
State
Actions, requests
Example RESTful API
• Collection resource
– http://api.example.com/devices

• Element resource
– http://api.example.com/device/23

• Typical actions:
– GET collection
• Return a list of devices

– POST collection
• Create a new device

– GET element
• Return the device

– PUT/POST element
• Update the device information
Representation: JSON
• JavaScript Object Notation
• Very simple
– Compared to stuff like XML

• A representation of a Javascript object
– Can easily be converted back and forth
– var str = JSON.stringify(obj);
– var obj = JSON.parse(str);
JSON Example
{
"id": "12345acb",
"name": "Adam",
"age": 392131145,
"sensors": [ "light", "button" ]
}
Lab 2: Build our own cloud
service
• Device connect to the cloud server with a
websocket
• Server receives message from device,
broadcasts to all connected devices
Material
• Cloud software
– Node.js
– Running on our laptop

• The Thingsquare kit
• Device software
– websocket-example.c
Cloud software: node.js
• Javascript framework for scalable highconcurrency servers
• Non-blocking, event-driven programming
style
• Lots of libraries
• npm – the node package manager
Node.js crash course
• Javascript programs are run from the
command prompt
– node program.js

• Unlike server software like Apache, node.js is
extremely raw
– You program everything from the ground up
– Libraries help you do almost everything

• Use HTTP library to build web server
• Use Websocket library to build web socket
server
Install node
• http://nodejs.org/
• Unzip websocket-server.zip
• Open a command prompt, go to the
websocket-server directory
• In the websocket-server directory, install
the websocket module
– npm install websocket

• node example-server.js
The cloud server code
var serverPort = 8080;
var http = require('http');
var server = http.createServer(function(request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.write('This is a websocket-only servern');
response.end();
});
server.listen(serverPort, function() {
console.log('Server is listening on port ' + serverPort);
});
The cloud server code
var websocket = require('websocket').server;
var wsServer = new websocket({
httpServer: server
});
var connections = [];
function broadcastMessage(message) {
for (var i = 0; i < connections.length; i++) {
connections[i].sendUTF(message);
}
}
The cloud server code
wsServer.on('request', function(request) {
var connection = request.accept(null, request.origin);
var connectionIndex = connections.push(connection) - 1;
console.log('Connection from ' + connection.remoteAddress + '.');
connection.on('message', function(message) {
if (message.type === 'utf8') {
console.log('Message: ' + message.utf8Data);
broadcastMessage(message.utf8Data);
}
});

connection.on('close', function(connection) {
connections.splice(connectionIndex, 1);
});
});
The device code
PROCESS_THREAD(websocket_example_process, ev, data)
{
static struct etimer et;
PROCESS_EXITHANDLER(websocket_close(&s));
PROCESS_BEGIN();
websocket_open(&s, "ws://192.168.1.65:8080/",
"thingsquare", callback);
while(1) {
etimer_set(&et, CLOCK_SECOND * 10);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
websocket_send_str(&s, "hello");
}
PROCESS_END();
}
The device code
static void
callback(struct websocket *s, websocket_result r,
uint8_t *data, uint16_t datalen)
{
if(r == WEBSOCKET_CONNECTED) {
websocket_send_str(s, "Connected");
} else if(r == WEBSOCKET_DATA) {
char buf[100];
snprintf(buf, sizeof(buf), "%.*s", datalen, data);
thsq_client_set_str("data", buf);
}
thsq_client_push();
}
Update the code
• Obtain the IPv4 address of your laptop
– On Windows, run “ipconfig” command
– On Linux, run “ifconfig” command
– On Mac, run “ifconfig” command

• Insert your own IPv4 address in the
websocket_open() call
Running the code
• Run the websocket server on your laptop
– node websocket-server.js

• Compile and upload the code to your device
• Enter “data” in the variable inspection field
• You should see
– The server should say something like
• Connection from 192.168.1.98

– The device should say “Connected” then “hello” in
the variable inspection field
What we have done
• We have built our own IoT cloud service
– On our laptop

• We have connected an IoT device to our
cloud service
• We have seen two-way communication,
from the device to the cloud and back
More like this

http://thingsquare.com

More Related Content

What's hot

Simplifying the OpenStack and Kubernetes network stack with Romana
Simplifying the OpenStack and Kubernetes network stack with RomanaSimplifying the OpenStack and Kubernetes network stack with Romana
Simplifying the OpenStack and Kubernetes network stack with RomanaJuergen Brendel
 
Zigbee intro v5
Zigbee intro v5Zigbee intro v5
Zigbee intro v5rajrayala
 
ONUG Tutorial: Bridges and Tunnels Drive Through OpenStack Networking
ONUG Tutorial: Bridges and Tunnels Drive Through OpenStack NetworkingONUG Tutorial: Bridges and Tunnels Drive Through OpenStack Networking
ONUG Tutorial: Bridges and Tunnels Drive Through OpenStack Networkingmarkmcclain
 
Openstack Neutron Insights
Openstack Neutron InsightsOpenstack Neutron Insights
Openstack Neutron InsightsAtul Pandey
 
OpenStack Neutron's Distributed Virtual Router
OpenStack Neutron's Distributed Virtual RouterOpenStack Neutron's Distributed Virtual Router
OpenStack Neutron's Distributed Virtual Routercarlbaldwin
 
Tech Talk by John Casey (CTO) CPLANE_NETWORKS : High Performance OpenStack Ne...
Tech Talk by John Casey (CTO) CPLANE_NETWORKS : High Performance OpenStack Ne...Tech Talk by John Casey (CTO) CPLANE_NETWORKS : High Performance OpenStack Ne...
Tech Talk by John Casey (CTO) CPLANE_NETWORKS : High Performance OpenStack Ne...nvirters
 
Node-RED and getting started on the Internet of Things
Node-RED and getting started on the Internet of ThingsNode-RED and getting started on the Internet of Things
Node-RED and getting started on the Internet of ThingsBoris Adryan
 
OCP Summit 2016 - Transforming Networks to All-IT Network with OCP and Open N...
OCP Summit 2016 - Transforming Networks to All-IT Network with OCP and Open N...OCP Summit 2016 - Transforming Networks to All-IT Network with OCP and Open N...
OCP Summit 2016 - Transforming Networks to All-IT Network with OCP and Open N...Junho Suh
 
Network address translation
Network address translationNetwork address translation
Network address translationMohak Kaushik
 
OpenStack in Action 4! Emilien Macchi & Sylvain Afchain - What's new in neutr...
OpenStack in Action 4! Emilien Macchi & Sylvain Afchain - What's new in neutr...OpenStack in Action 4! Emilien Macchi & Sylvain Afchain - What's new in neutr...
OpenStack in Action 4! Emilien Macchi & Sylvain Afchain - What's new in neutr...eNovance
 
IPv6 at Mythic Beasts - Networkshop44
IPv6 at Mythic Beasts - Networkshop44IPv6 at Mythic Beasts - Networkshop44
IPv6 at Mythic Beasts - Networkshop44Jisc
 
Open stackdaykorea2016 wedge
Open stackdaykorea2016 wedgeOpen stackdaykorea2016 wedge
Open stackdaykorea2016 wedgeJunho Suh
 
Tungsten Fabric Overview
Tungsten Fabric OverviewTungsten Fabric Overview
Tungsten Fabric OverviewMichelle Holley
 
Navigating OpenStack Networking
Navigating OpenStack NetworkingNavigating OpenStack Networking
Navigating OpenStack NetworkingPLUMgrid
 

What's hot (20)

Simplifying the OpenStack and Kubernetes network stack with Romana
Simplifying the OpenStack and Kubernetes network stack with RomanaSimplifying the OpenStack and Kubernetes network stack with Romana
Simplifying the OpenStack and Kubernetes network stack with Romana
 
Zigbee intro v5
Zigbee intro v5Zigbee intro v5
Zigbee intro v5
 
ONUG Tutorial: Bridges and Tunnels Drive Through OpenStack Networking
ONUG Tutorial: Bridges and Tunnels Drive Through OpenStack NetworkingONUG Tutorial: Bridges and Tunnels Drive Through OpenStack Networking
ONUG Tutorial: Bridges and Tunnels Drive Through OpenStack Networking
 
Ipx protocol slide share
Ipx protocol slide shareIpx protocol slide share
Ipx protocol slide share
 
Openstack Neutron Insights
Openstack Neutron InsightsOpenstack Neutron Insights
Openstack Neutron Insights
 
High Availability in Neutron
High Availability in NeutronHigh Availability in Neutron
High Availability in Neutron
 
OpenStack Neutron's Distributed Virtual Router
OpenStack Neutron's Distributed Virtual RouterOpenStack Neutron's Distributed Virtual Router
OpenStack Neutron's Distributed Virtual Router
 
Tech Talk by John Casey (CTO) CPLANE_NETWORKS : High Performance OpenStack Ne...
Tech Talk by John Casey (CTO) CPLANE_NETWORKS : High Performance OpenStack Ne...Tech Talk by John Casey (CTO) CPLANE_NETWORKS : High Performance OpenStack Ne...
Tech Talk by John Casey (CTO) CPLANE_NETWORKS : High Performance OpenStack Ne...
 
Node-RED and getting started on the Internet of Things
Node-RED and getting started on the Internet of ThingsNode-RED and getting started on the Internet of Things
Node-RED and getting started on the Internet of Things
 
OCP Summit 2016 - Transforming Networks to All-IT Network with OCP and Open N...
OCP Summit 2016 - Transforming Networks to All-IT Network with OCP and Open N...OCP Summit 2016 - Transforming Networks to All-IT Network with OCP and Open N...
OCP Summit 2016 - Transforming Networks to All-IT Network with OCP and Open N...
 
Neutron scaling
Neutron scalingNeutron scaling
Neutron scaling
 
Neutron scale
Neutron scaleNeutron scale
Neutron scale
 
Network address translation
Network address translationNetwork address translation
Network address translation
 
OpenStack in Action 4! Emilien Macchi & Sylvain Afchain - What's new in neutr...
OpenStack in Action 4! Emilien Macchi & Sylvain Afchain - What's new in neutr...OpenStack in Action 4! Emilien Macchi & Sylvain Afchain - What's new in neutr...
OpenStack in Action 4! Emilien Macchi & Sylvain Afchain - What's new in neutr...
 
IPv6 at Mythic Beasts - Networkshop44
IPv6 at Mythic Beasts - Networkshop44IPv6 at Mythic Beasts - Networkshop44
IPv6 at Mythic Beasts - Networkshop44
 
Open stackdaykorea2016 wedge
Open stackdaykorea2016 wedgeOpen stackdaykorea2016 wedge
Open stackdaykorea2016 wedge
 
Tungsten Fabric Overview
Tungsten Fabric OverviewTungsten Fabric Overview
Tungsten Fabric Overview
 
01 Node-RED Basic
01 Node-RED Basic01 Node-RED Basic
01 Node-RED Basic
 
VPNaaS in Neutron
VPNaaS in NeutronVPNaaS in Neutron
VPNaaS in Neutron
 
Navigating OpenStack Networking
Navigating OpenStack NetworkingNavigating OpenStack Networking
Navigating OpenStack Networking
 

Similar to Building the Internet of Things with Thingsquare and Contiki - day 1, part 3

Using Java Script and COMPOSE to build cool IoT applications, SenZations 2015
Using Java Script and COMPOSE to build cool IoT applications, SenZations 2015Using Java Script and COMPOSE to build cool IoT applications, SenZations 2015
Using Java Script and COMPOSE to build cool IoT applications, SenZations 2015SenZations Summer School
 
Master-Master Replication and Scaling of an Application Between Each of the I...
Master-Master Replication and Scaling of an Application Between Each of the I...Master-Master Replication and Scaling of an Application Between Each of the I...
Master-Master Replication and Scaling of an Application Between Each of the I...vsoshnikov
 
Null mumbai-iot-workshop
Null mumbai-iot-workshopNull mumbai-iot-workshop
Null mumbai-iot-workshopNitesh Malviya
 
Building the Internet of Things with Eclipse IoT - IoTBE meetup
Building the Internet of Things with Eclipse IoT - IoTBE meetupBuilding the Internet of Things with Eclipse IoT - IoTBE meetup
Building the Internet of Things with Eclipse IoT - IoTBE meetupBenjamin Cabé
 
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1Adam Dunkels
 
Securing IoT Applications
Securing IoT Applications Securing IoT Applications
Securing IoT Applications WSO2
 
Eclipse Kura Shoot a-pi
Eclipse Kura Shoot a-piEclipse Kura Shoot a-pi
Eclipse Kura Shoot a-piEclipse Kura
 
End-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoTEnd-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoTBenjamin Cabé
 
Tracking the International Space Station with Commodore Computers
Tracking the International Space Station with Commodore ComputersTracking the International Space Station with Commodore Computers
Tracking the International Space Station with Commodore ComputersLeif Bloomquist
 
IoT interoperability
IoT interoperabilityIoT interoperability
IoT interoperability1248 Ltd.
 
Metarhia: Node.js Macht Frei
Metarhia: Node.js Macht FreiMetarhia: Node.js Macht Frei
Metarhia: Node.js Macht FreiTimur Shemsedinov
 
Nodemcu and IOT.pptx
Nodemcu and IOT.pptxNodemcu and IOT.pptx
Nodemcu and IOT.pptxDixonSunny2
 
Securing the Internet of Things
Securing the Internet of ThingsSecuring the Internet of Things
Securing the Internet of ThingsPaul Fremantle
 
Witekio IoT presentation
Witekio IoT presentation Witekio IoT presentation
Witekio IoT presentation Witekio
 
DCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveDCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveMadhu Venugopal
 
Building Open Source IoT Cloud
Building Open Source IoT CloudBuilding Open Source IoT Cloud
Building Open Source IoT Clouddejanb
 
Scalable Open-Source IoT Solutions on Microsoft Azure
Scalable Open-Source IoT Solutions on Microsoft AzureScalable Open-Source IoT Solutions on Microsoft Azure
Scalable Open-Source IoT Solutions on Microsoft AzureMaxim Ivannikov
 
chapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjchapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjAmitDeshai
 
Tech Tutorial by Vikram Dham: Let's build MPLS router using SDN
Tech Tutorial by Vikram Dham: Let's build MPLS router using SDNTech Tutorial by Vikram Dham: Let's build MPLS router using SDN
Tech Tutorial by Vikram Dham: Let's build MPLS router using SDNnvirters
 

Similar to Building the Internet of Things with Thingsquare and Contiki - day 1, part 3 (20)

Using Java Script and COMPOSE to build cool IoT applications, SenZations 2015
Using Java Script and COMPOSE to build cool IoT applications, SenZations 2015Using Java Script and COMPOSE to build cool IoT applications, SenZations 2015
Using Java Script and COMPOSE to build cool IoT applications, SenZations 2015
 
Master-Master Replication and Scaling of an Application Between Each of the I...
Master-Master Replication and Scaling of an Application Between Each of the I...Master-Master Replication and Scaling of an Application Between Each of the I...
Master-Master Replication and Scaling of an Application Between Each of the I...
 
Null mumbai-iot-workshop
Null mumbai-iot-workshopNull mumbai-iot-workshop
Null mumbai-iot-workshop
 
Building the Internet of Things with Eclipse IoT - IoTBE meetup
Building the Internet of Things with Eclipse IoT - IoTBE meetupBuilding the Internet of Things with Eclipse IoT - IoTBE meetup
Building the Internet of Things with Eclipse IoT - IoTBE meetup
 
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
 
Securing IoT Applications
Securing IoT Applications Securing IoT Applications
Securing IoT Applications
 
Eclipse Kura Shoot a-pi
Eclipse Kura Shoot a-piEclipse Kura Shoot a-pi
Eclipse Kura Shoot a-pi
 
End-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoTEnd-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoT
 
Tracking the International Space Station with Commodore Computers
Tracking the International Space Station with Commodore ComputersTracking the International Space Station with Commodore Computers
Tracking the International Space Station with Commodore Computers
 
IoT interoperability
IoT interoperabilityIoT interoperability
IoT interoperability
 
Metarhia: Node.js Macht Frei
Metarhia: Node.js Macht FreiMetarhia: Node.js Macht Frei
Metarhia: Node.js Macht Frei
 
Nodemcu and IOT.pptx
Nodemcu and IOT.pptxNodemcu and IOT.pptx
Nodemcu and IOT.pptx
 
Securing the Internet of Things
Securing the Internet of ThingsSecuring the Internet of Things
Securing the Internet of Things
 
Witekio IoT presentation
Witekio IoT presentation Witekio IoT presentation
Witekio IoT presentation
 
DCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveDCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep dive
 
Building Open Source IoT Cloud
Building Open Source IoT CloudBuilding Open Source IoT Cloud
Building Open Source IoT Cloud
 
Chapter - 1 Introduction to networking (3).ppt
Chapter - 1 Introduction to networking (3).pptChapter - 1 Introduction to networking (3).ppt
Chapter - 1 Introduction to networking (3).ppt
 
Scalable Open-Source IoT Solutions on Microsoft Azure
Scalable Open-Source IoT Solutions on Microsoft AzureScalable Open-Source IoT Solutions on Microsoft Azure
Scalable Open-Source IoT Solutions on Microsoft Azure
 
chapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjchapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhj
 
Tech Tutorial by Vikram Dham: Let's build MPLS router using SDN
Tech Tutorial by Vikram Dham: Let's build MPLS router using SDNTech Tutorial by Vikram Dham: Let's build MPLS router using SDN
Tech Tutorial by Vikram Dham: Let's build MPLS router using SDN
 

Recently uploaded

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

Building the Internet of Things with Thingsquare and Contiki - day 1, part 3

  • 2. From mock-up to prototype to production • Rapid prototyping is important • Mock-up vs prototype – Start with a mock-up, or – Start working on the target hardware • Using the same components when prototyping as in production is good – Makes production easier
  • 6. IoT hardware – closer look
  • 7. IoT hardware • Sensors and actuators – Connectors to the physical world • Microprocessor – To be able to do something with the sensors/actuators • Communication device – To communicate with the world • Power source
  • 8. Typical IoT hardware properties • Microcontroller – Memory • Flash ROM on the order of 64-512 kilobytes • RAM on the order of 8-32 kilobytes – I/O to connect sensors and actuators • Serial ports, ADCs, SPI, etc • Radio – External transceivers – Systems-on-a-Chip • Radio integrated with microcontroller
  • 9. Typical IoT hardware properties • Power source – Battery – Energy harvesting • • • • Solar cells Ambient RF (like RFID) Piezo electric Temperature differences
  • 10. Radio hardware • Microcontroller + transceiver – – – – CC1120 – sub-GHz CC2520 – IEEE 802.15.4 nRF8001 – Bluetooth Smart CC3300 – WiFi • Connected via SPI • System-on-a-Chip – CC2538 – IEEE 802.15.4 + ARM Cortex M3 – Broadcom Wiced – WiFi + ARM Cortex M3
  • 11. Power • Power consumers – Sensors, actuators – Microprocessor – Communication • Radio must be completely off – Consumes power even when idle • Radio duty cycling mechanisms
  • 12. OS vs rolling your own • Rolling your own non-OS firmware – Write everything, flash the chip • An OS helps you with – Network stacks – Memory managament – Drivers – Power management – ... and much, much more
  • 13. IoT software challenges • Severe limitations in every dimension – Memory – Processing power – Communication bandwidth – Energy, power consumption • The number of different platforms is large – Different microcontrollers, different radios, different compilers
  • 14. IoT system challenges • Communication-bound, distributed systems – Exceptionally low visibility • Hard to understand what is going on – Application development difficult – Debugging difficult • Large-scale • Wireless communication
  • 15. Wireless connectivity • Counter-intuitive • Not a simple replacement to cables
  • 16. The magic behind it all: Contiki
  • 17. Contiki: an IoT OS • Runs on tiny microcontrollers and SoCs • Handles communication over a number of different radios • Provides processes, timers, libraries, memory allocation, network stacks, etc
  • 18. Contiki • Dealing with limited memory – Memory block allocation strategies – Protothreads • Portability – Fully written in C • Application development and debugging – The Cooja network simulator
  • 19. The Cooja network simulator
  • 20. A Brief History of Contiki
  • 21. Contiki: 10+ years old • Based on the uIP TCP/IP stack • First release March 10, 2003 – Ports to a range of odd lovely platforms • Most 6502-based (Apple II, Atari 2600) • Commodore C64 • The Contiki idea: put things on the Internet – First system to do IP-based wireless sensor networks
  • 22.
  • 23. 2008: IPv6 for Contiki • uIPv6 was contributed by Cisco in 2008 • World’s smallest fully certified IPv6 stack
  • 25. Recent history • July 2012: Thingsquare founded, Contiki 2.6 released • October 2012: Moved to github • November 2012: automated regression tests with Travis • November 2012: IPv6/RPL updates • December 2012: New testing framework • July 2013: Significant RPL updates • November 2013: Contiki 2.7
  • 26. Next steps: Contiki 3.x • Push the Thingsquare firmware features towards Contiki • UDP, TCP socket APIs • HTTP socket API • Websocket API
  • 27. Contiki features • Three network stacks – IPv4/IPv6 stacks • RPL, 6lowpan, CoAP, HTTP, ... – Rime stack • • • • • • • • • • Instant Contiki development environment The Cooja network simulator Sleepy meshing (ContikiMAC) Interactive shell Flash-based file system Powertracing Protothreads Multithreading Event timers, real-time timers Libraries: linked list, ringbuf, crc16, etc
  • 28. Additional Thingsquare features: Contiki 3.x • IPv4/IPv6 routing – NAT64 and DNS64 • • • • • • • AES encryption Network sniffer Frequency hopping protocol Portable duty cycling (Drowsie, CSL) WebSocket protocol UDP, TCP, HTTP socket APIs More hardware platforms
  • 29. Back to the Big Red Button
  • 30. What the Big Red Button did • When the button switch went from 1 to 0 – Do HTTP POST request to http://requestb.in • Several steps: – Ask the DNS server for requestb.in – Get the answer, but converted to an IPv6 address – converted by the router – Set up a TCP connection to the IPv6 address – The router translates to IPv4 – Send the HTTP POST request
  • 31. HTTP POST request POST /abcdefghij HTTP/1.1 Host: requestb.in Content-Type: application/x-www-form-urlencoded Content-Length: 15 button=big%20red
  • 32. The Contiki code #define URL "http://requestb.in/abcdefghij" #define DATA "button=big%20red" static struct http_socket s; http_socket_post(&s, URL, DATA, strlen(DATA), "application/x-www-form-urlencoded", callback, NULL);
  • 33. RESTful APIs • • • • • • Leverage the way that HTTP works Representational state transfer Coined by Roy Fielding in 2000 Resources, representation State Actions, requests
  • 34. Example RESTful API • Collection resource – http://api.example.com/devices • Element resource – http://api.example.com/device/23 • Typical actions: – GET collection • Return a list of devices – POST collection • Create a new device – GET element • Return the device – PUT/POST element • Update the device information
  • 35. Representation: JSON • JavaScript Object Notation • Very simple – Compared to stuff like XML • A representation of a Javascript object – Can easily be converted back and forth – var str = JSON.stringify(obj); – var obj = JSON.parse(str);
  • 36. JSON Example { "id": "12345acb", "name": "Adam", "age": 392131145, "sensors": [ "light", "button" ] }
  • 37. Lab 2: Build our own cloud service
  • 38. • Device connect to the cloud server with a websocket • Server receives message from device, broadcasts to all connected devices
  • 39. Material • Cloud software – Node.js – Running on our laptop • The Thingsquare kit • Device software – websocket-example.c
  • 40. Cloud software: node.js • Javascript framework for scalable highconcurrency servers • Non-blocking, event-driven programming style • Lots of libraries • npm – the node package manager
  • 41. Node.js crash course • Javascript programs are run from the command prompt – node program.js • Unlike server software like Apache, node.js is extremely raw – You program everything from the ground up – Libraries help you do almost everything • Use HTTP library to build web server • Use Websocket library to build web socket server
  • 42. Install node • http://nodejs.org/ • Unzip websocket-server.zip • Open a command prompt, go to the websocket-server directory • In the websocket-server directory, install the websocket module – npm install websocket • node example-server.js
  • 43. The cloud server code var serverPort = 8080; var http = require('http'); var server = http.createServer(function(request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.write('This is a websocket-only servern'); response.end(); }); server.listen(serverPort, function() { console.log('Server is listening on port ' + serverPort); });
  • 44. The cloud server code var websocket = require('websocket').server; var wsServer = new websocket({ httpServer: server }); var connections = []; function broadcastMessage(message) { for (var i = 0; i < connections.length; i++) { connections[i].sendUTF(message); } }
  • 45. The cloud server code wsServer.on('request', function(request) { var connection = request.accept(null, request.origin); var connectionIndex = connections.push(connection) - 1; console.log('Connection from ' + connection.remoteAddress + '.'); connection.on('message', function(message) { if (message.type === 'utf8') { console.log('Message: ' + message.utf8Data); broadcastMessage(message.utf8Data); } }); connection.on('close', function(connection) { connections.splice(connectionIndex, 1); }); });
  • 46. The device code PROCESS_THREAD(websocket_example_process, ev, data) { static struct etimer et; PROCESS_EXITHANDLER(websocket_close(&s)); PROCESS_BEGIN(); websocket_open(&s, "ws://192.168.1.65:8080/", "thingsquare", callback); while(1) { etimer_set(&et, CLOCK_SECOND * 10); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); websocket_send_str(&s, "hello"); } PROCESS_END(); }
  • 47. The device code static void callback(struct websocket *s, websocket_result r, uint8_t *data, uint16_t datalen) { if(r == WEBSOCKET_CONNECTED) { websocket_send_str(s, "Connected"); } else if(r == WEBSOCKET_DATA) { char buf[100]; snprintf(buf, sizeof(buf), "%.*s", datalen, data); thsq_client_set_str("data", buf); } thsq_client_push(); }
  • 48. Update the code • Obtain the IPv4 address of your laptop – On Windows, run “ipconfig” command – On Linux, run “ifconfig” command – On Mac, run “ifconfig” command • Insert your own IPv4 address in the websocket_open() call
  • 49. Running the code • Run the websocket server on your laptop – node websocket-server.js • Compile and upload the code to your device • Enter “data” in the variable inspection field • You should see – The server should say something like • Connection from 192.168.1.98 – The device should say “Connected” then “hello” in the variable inspection field
  • 50. What we have done • We have built our own IoT cloud service – On our laptop • We have connected an IoT device to our cloud service • We have seen two-way communication, from the device to the cloud and back

Editor's Notes

  1. 2.4 GHz Cortex-M3 SOCThe small boards contains the SOC with antenna etc, just connect to power and run. The big board is for JTAG programming and debugging.