Exploring the Internet of Things Using Ruby
-
Upload
mike-hagedorn -
Category
Technology
-
view
1.301 -
download
0
description
Transcript of Exploring the Internet of Things Using Ruby
![Page 1: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/1.jpg)
Exploring the Internet of Things
with RubyLone Star Ruby Conf 2012
![Page 2: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/2.jpg)
![Page 3: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/3.jpg)
Man Versus Wild…
![Page 4: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/4.jpg)
The Great Adventure
![Page 5: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/5.jpg)
The Oh No Moment
(aka – I am going to have to drink my urine)
![Page 6: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/6.jpg)
Whoami
Mike Hagedorn@mwhagedorn
github.com/mwhagedorn
![Page 7: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/7.jpg)
Agenda
Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
![Page 8: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/8.jpg)
Agenda
Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
![Page 9: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/9.jpg)
Internet of Things?
“Listen to your world, talk to the Internet”
http://supermechanical.com/
Objects-> Internet -> Servers
![Page 10: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/10.jpg)
Things Talk back
![Page 11: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/11.jpg)
@MarsCuriosity
![Page 12: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/12.jpg)
Botanicalls
![Page 13: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/13.jpg)
IOT Devices
Arduino Rasberry Pi Twine
![Page 14: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/14.jpg)
Agenda
Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
![Page 15: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/15.jpg)
The USB Lamp Project
http://www.thekua.com
![Page 16: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/16.jpg)
The USB Lamp Project
libusb gem open a context browse for your
device open the device send message close device
Easy!
NOT
![Page 17: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/17.jpg)
The USB Lamp Project
Lots of Questions How do you send messages? What is the form of the messages?
![Page 18: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/18.jpg)
Use The Source Luke…
void USBLamp::init() { char data1[8] = { 0x1f, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x03 }; send(data1, sizeof(data1));
char data2[8] = { 0x00, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x04 }; send(data2, sizeof(data2));
char data3[8] = { 0x00, 0x02, 0x00, 0x2e, 0x00, 0x00, 0x2b, 0x05 }; send(data3, sizeof(data3));}
![Page 19: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/19.jpg)
Use The Source Luke…
void USBLamp::send(char *bytes, int size) { … CALL(usb_control_msg(…)) …}
![Page 20: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/20.jpg)
Array#pack & String#unpack pack
Array of numbers to a binary string[97,98,99].pack("c*")=> "abc“
unpack Binary string to array
"abc".unpack("c*")=> [97,98,99]
![Page 21: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/21.jpg)
Demo
![Page 22: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/22.jpg)
Agenda
Internet Of Things in General Ruby and USB The IOT Printer The IOT Display
![Page 23: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/23.jpg)
The IOT printer
![Page 24: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/24.jpg)
The IOT printer
![Page 25: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/25.jpg)
Arduino
![Page 26: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/26.jpg)
Ethernet Shield
![Page 27: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/27.jpg)
Arduino IDE
![Page 28: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/28.jpg)
To Rad or Not To Rad
![Page 29: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/29.jpg)
To Rad or Not To Rad
![Page 30: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/30.jpg)
Tools You Can Trust
![Page 31: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/31.jpg)
Use TextMate!
![Page 32: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/32.jpg)
Use Terminal!
You can monitor the serial port via Terminal
> ls /dev/tty.*> screen <dev> <baud-rate> End with cntrl-A, cntrl-\
![Page 33: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/33.jpg)
IOT-Assistantgithub.com/newsinternational/iot-assistant
![Page 34: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/34.jpg)
Architecture
OAuthCalendars
Tweets
![Page 35: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/35.jpg)
Suiting It To Me
Calendar Tasks News Twitter
(Oauth)
![Page 36: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/36.jpg)
Omnifocus Challenges
How can I get my tasks exported? How can I get them up to the server?
![Page 37: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/37.jpg)
Applescript
![Page 38: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/38.jpg)
Applescript Dictionary
![Page 39: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/39.jpg)
Exporting Omnifocus tasks
#!/usr/local/bin/macrubyframework 'Foundation'framework 'ScriptingBridge'
OFOC = "com.omnigroup.Omnifocus” @of = SBApplication.applicationWithBundleIdentifier(OFOC) load_bridge_support_file 'Omnifocus.bridgesupport' @doc = @of.defaultDocument tasks = [] @doc.flattenedTasks.get.each do |task| tasks << task end
![Page 40: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/40.jpg)
How can the server get this? Omnifocus tried to solve this Have to expose your desktop on
internet More work than most people want to
do
![Page 41: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/41.jpg)
Use HP Object Storage!
![Page 42: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/42.jpg)
HpObjectStore Helper
Uses Fog
def tasks_dir @connection.directories.get("omnifocus")end
def update_tasks_file(content) tasks_dir.files.create(:key => "tasks.json", :body => content)end
![Page 43: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/43.jpg)
Update Cloud Bucket
Run a chron job from my desktop server
All my omnifocus installs are already synced
Server gets a current task list
![Page 44: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/44.jpg)
Outlook
Need my calendar Don’t want to deal with corp security Use the same omnifocus technique
![Page 45: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/45.jpg)
The Printout
![Page 46: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/46.jpg)
The Arduino Code
![Page 47: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/47.jpg)
Demo
![Page 48: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/48.jpg)
Agenda
Internet Of Things in General Ruby and USB Ruby and RFID The IOT Printer The IOT Display
![Page 49: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/49.jpg)
The IOT Display
http://bit.ly/vlMMvr
Original Inspiration:
![Page 50: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/50.jpg)
Arduino
![Page 51: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/51.jpg)
32X8 Led Panel
http://bit.ly/wyuE5V
![Page 52: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/52.jpg)
WiFly
![Page 53: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/53.jpg)
Fritzing Sketch
![Page 54: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/54.jpg)
Using IOT-A
Already had an infrastructure Already had a datasource Format didn’t make sense for LED
Display
![Page 55: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/55.jpg)
User-Agent
Use two different User-Agent header values
User-Agent:IOTDisplay User-Agent:IOTPrinter JSON representation for display
![Page 56: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/56.jpg)
Memory and the Sad Panda
Standard JSON parser took up too much memory
Char strings storage Had to give up a key feature
![Page 57: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/57.jpg)
Demo
![Page 58: Exploring the Internet of Things Using Ruby](https://reader035.fdocuments.net/reader035/viewer/2022062702/554bda76b4c9058f6c8b5471/html5/thumbnails/58.jpg)
HP Cloud For Free!
https://www.hpcloud.com/free-trial
@mwhagedorn
Thanks!
https://github.com/mwhagedorn/IOTDisplay.git
https://github.com/mwhagedorn/iot_printer_remote.githttps://github.com/mwhagedorn/iot-assistant.git
https://github.com/mwhagedorn/thingspeak.git