SlideShare a Scribd company logo
1 of 27
Download to read offline
TITLE TEXT 
CONNECTING PEBBLE TO THE WORLD 
THOMAS SARLANDIE 
OCT. 17TH 2014 - WEARABLE+THINGS
I connect Pebble to the world! 
@sarfata 
Developer, Hardware tinkerer, 
Passionate Geek 
Developer Evangelist @Pebble
Wearable Service - Device
API API 
Wearable Service - Device
1 - Identify the APIs available 
2 - Prototype 
3 - Connect
0 - Know your tools 
Sensors 
Accel. Buttons Compass 
Phone 
Native Apps JavaScript 
HTTP/ 
JSON 
Bluetooth LE 
GPS
1 - Identify the APIs available
2 - Prototype 
http://api.openweathermap.org/data/2.1/find 
/city?lat=38.89&lon=-77.07=&cnt=1
3 - Connect 
var UI = require('ui'); 
var ajax = require('ajax'); 
var main = new UI.Card({ 
title: 'WX Station', 
body: 'Loading ...' 
}); 
main.show(); 
var url = “http://api.openweathermap.org/data/2.1/find/city?" 
+ "cnt=1&lat=38.89&lon=-77.07"; 
ajax( 
{ url: url, type: 'json' }, 
function(weather) { 
var temp = (weather.list[0].main.temp - 273.15) 
temp = (temp* 1.8 + 32).toFixed(1); 
main.body('Temperature: ' + temp + " F"); 
}, 
function (err) { console.log("AJAX Error: " + err); } 
);
var UI = require('ui'); 
var ajax = require('ajax'); 
var main = new UI.Card({ 
title: 'WX Station', 
body: 'Loading ...' 
}); 
main.show(); 
var url = "http://api.openweathermap.org/data/2.1/find/city? 
cnt=1&lat=38.89&lon=-77.07"; 
ajax( 
{ url: url, type: 'json' }, 
function(weather) { 
var temp = ((weather.list[0].main.temp - 273.15) * 1.8 + 32).toFixed(1); 
main.body('Temperature: ' + temp + " F"); 
}, 
function (err) { console.log("AJAX Error: " + err); } 
);
navigator.geolocation.getCurrentPosition( 
function(pos) { 
var url = "http://api.openweathermap.org/data/2.1/find/city?cnt=1" + 
"&lat=" + pos.coords.latitude + 
"&lon=" + pos.coords.longitude; 
ajax( 
{ url: url, type: 'json' }, 
function(weather) { 
var temp = (weather.list[0].main.temp - 273.15); 
temp = (temp * 1.8 + 32).toFixed(1); 
main.body('Temperature: ' + temp + " F"); 
}, 
function (err) { console.log("Error: " + err); } 
); 
}, 
function (err) { console.log("Gps error: " + JSON.stringify(err)); }, 
{ timeout: 10000 } 
);
1 - Identify the APIs available
2 - Prototype 
$ curl --request PUT --data '{"on":true}'  
http://url/api/username/lights/1/state
3 - Connect
var setHueState = function(id, state) { 
ajax( 
{ 
url: 'http://192.168.0.42/api/newdeveloper/lights/' 
+ id + '/state', 
type: 'json', 
method: 'PUT', 
data: state 
}, 
function(data) { 
console.log('Success: ' + JSON.stringify(data)); 
}, 
function(error) { 
console.log('The ajax request failed: ' + error); 
} 
); 
console.log("Request sent! New state: " + JSON.stringify(state)); 
};
console.log("Request sent! New state: " + JSON.stringify(state)); 
}; 
var ambiances = [ 
{ title: 'Warm', bri: 255, ct: 500 }, 
{ title: 'Cold', bri: 255, ct: 153 }, 
{ title: 'Red', bri: 255, sat: 255, hue: 0 }, 
{ title: 'Yellow', bri: 255, sat: 255, hue: 12750 }, 
{ title: 'Green', bri: 255, sat: 255, hue: 25500 }, 
{ title: 'Blue', bri: 255, sat: 255,hue: 46920 }, 
{ title: 'Purple', bri: 255, sat: 255,hue: 56100 } 
]; 
var menu = new UI.Menu({ 
sections: [{ 
items: ambiances 
}] 
}); 
menu.on('select', function(e) { 
setHueState(3, e.item); 
}); 
menu.show();
1 - Identify the APIs available
1 - Identify the APIs available 
Pebble BLE Robot 
“PebbleBot” Service 
UUID 
Characteristic 
UUID / Properties (R/W/…) 
Left Motor Speed 
Characteristic 
UUID / Properties (R/W/…) 
Right Motor Speed
static void handle_up_button_up(ClickRecognizerRef recognizer, void *context) { 
ble_client_write_without_response(s_ctx.scratch1_characteristic, 
(const uint8_t *) &SERVO_STILL, sizeof(SERVO_STILL)); 
printf("UP=0"); 
} 
static void handle_up_button_down(ClickRecognizerRef recognizer, void *context) { 
ble_client_write_without_response(s_ctx.scratch1_characteristic, 
(const uint8_t *) &SERVO_BACK, sizeof(SERVO_BACK)); 
printf("UP=1"); 
} 
static void handle_down_button_up(ClickRecognizerRef recognizer, void *context) { 
ble_client_write_without_response(s_ctx.scratch2_characteristic, 
(const uint8_t *) &SERVO_STILL, sizeof(SERVO_STILL)); 
printf("DOWN=0"); 
} 
static void handle_down_button_down(ClickRecognizerRef recognizer, void *context) { 
ble_client_write_without_response(s_ctx.scratch2_characteristic, 
(const uint8_t *) &SERVO_FWD, sizeof(SERVO_FWD)); 
printf("DOWN=1"); 
}
1 - Identify the APIs available 
2 - Prototype 
3 - Connect 
4 - Have fun! 
Thomas Sarlandie 
@sarfata / @pebbledev 
Illustrations by sam brown, explodingdog
Connecting Pebble to the World

More Related Content

What's hot

Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perl
typester
 

What's hot (20)

Gogo shell
Gogo shellGogo shell
Gogo shell
 
A different thought angular js part-3
A different thought   angular js part-3A different thought   angular js part-3
A different thought angular js part-3
 
fabfile.py
fabfile.pyfabfile.py
fabfile.py
 
Kayac Lightning-Talk | Interaction Design with Web Audio API
Kayac Lightning-Talk | Interaction Design with Web Audio APIKayac Lightning-Talk | Interaction Design with Web Audio API
Kayac Lightning-Talk | Interaction Design with Web Audio API
 
Dion Almaer & Ben Galbraith - Build Once, Deploy Everywhere
Dion Almaer & Ben Galbraith - Build Once, Deploy EverywhereDion Almaer & Ben Galbraith - Build Once, Deploy Everywhere
Dion Almaer & Ben Galbraith - Build Once, Deploy Everywhere
 
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
 
Gaelyk
GaelykGaelyk
Gaelyk
 
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js
 
Hacking the Internet of Things for Fun & Profit
Hacking the Internet of Things for Fun & ProfitHacking the Internet of Things for Fun & Profit
Hacking the Internet of Things for Fun & Profit
 
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"JSLab. Домников Виталий. "ES6 генераторы и Koa.js"
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"
 
10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language
 
Intro to Systems Orchestration with MCollective
Intro to Systems Orchestration with MCollectiveIntro to Systems Orchestration with MCollective
Intro to Systems Orchestration with MCollective
 
G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~
 
20151224-games
20151224-games20151224-games
20151224-games
 
«Работа с базами данных с использованием Sequel»
«Работа с базами данных с использованием Sequel»«Работа с базами данных с использованием Sequel»
«Работа с базами данных с использованием Sequel»
 
Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perl
 
RabbitMQ
RabbitMQRabbitMQ
RabbitMQ
 
Angular promises and http
Angular promises and httpAngular promises and http
Angular promises and http
 
Break through the serverless barriers with Durable Functions
Break through the serverless barriers with Durable FunctionsBreak through the serverless barriers with Durable Functions
Break through the serverless barriers with Durable Functions
 
Locarise,reagent and JavaScript Libraries
Locarise,reagent and JavaScript LibrariesLocarise,reagent and JavaScript Libraries
Locarise,reagent and JavaScript Libraries
 

Similar to Connecting Pebble to the World

CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 
Do you want a SDK with that API? (Nordic APIS April 2014)
Do you want a SDK with that API? (Nordic APIS April 2014)Do you want a SDK with that API? (Nordic APIS April 2014)
Do you want a SDK with that API? (Nordic APIS April 2014)
Nordic APIs
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
app.js.docx
app.js.docxapp.js.docx
app.js.docx
armitageclaire49
 

Similar to Connecting Pebble to the World (20)

Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
huhu
huhuhuhu
huhu
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
mobl
moblmobl
mobl
 
Angular 1.5 & ES6
Angular 1.5  & ES6Angular 1.5  & ES6
Angular 1.5 & ES6
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
YAP / Open Mail Overview
YAP / Open Mail OverviewYAP / Open Mail Overview
YAP / Open Mail Overview
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
 
CARTO ENGINE
CARTO ENGINECARTO ENGINE
CARTO ENGINE
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
Do you want a SDK with that API? (Nordic APIS April 2014)
Do you want a SDK with that API? (Nordic APIS April 2014)Do you want a SDK with that API? (Nordic APIS April 2014)
Do you want a SDK with that API? (Nordic APIS April 2014)
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 
Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09
Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09
Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
app.js.docx
app.js.docxapp.js.docx
app.js.docx
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
API Days Paris - Automatic Testing of (RESTful) API Documentation
API Days Paris - Automatic Testing of (RESTful) API DocumentationAPI Days Paris - Automatic Testing of (RESTful) API Documentation
API Days Paris - Automatic Testing of (RESTful) API Documentation
 
AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】
AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】
AWS IoTで家庭内IoTをやってみた【JAWS DAYS 2016】
 

More from Pebble Technology

Overlay & Libraries | Pebble Meetup Oct. 2014
Overlay & Libraries | Pebble Meetup Oct. 2014Overlay & Libraries | Pebble Meetup Oct. 2014
Overlay & Libraries | Pebble Meetup Oct. 2014
Pebble Technology
 

More from Pebble Technology (20)

#PDR15 - Awesome Appstore Assets
#PDR15 - Awesome Appstore Assets#PDR15 - Awesome Appstore Assets
#PDR15 - Awesome Appstore Assets
 
#PDR15 - Smartstrap Workshop
#PDR15 - Smartstrap Workshop#PDR15 - Smartstrap Workshop
#PDR15 - Smartstrap Workshop
 
#PDR15 - Data Analytics and Pebble
#PDR15 - Data Analytics and Pebble#PDR15 - Data Analytics and Pebble
#PDR15 - Data Analytics and Pebble
 
#PDR15 - Best Use Cases For Timeline
#PDR15 - Best Use Cases For Timeline#PDR15 - Best Use Cases For Timeline
#PDR15 - Best Use Cases For Timeline
 
#PDR15 - waf, wscript and Your Pebble App
#PDR15 - waf, wscript and Your Pebble App#PDR15 - waf, wscript and Your Pebble App
#PDR15 - waf, wscript and Your Pebble App
 
#PDR15 - PebbleKit iOS 3.0
#PDR15 - PebbleKit iOS 3.0#PDR15 - PebbleKit iOS 3.0
#PDR15 - PebbleKit iOS 3.0
 
#PDR15 - Voice API
#PDR15 - Voice API#PDR15 - Voice API
#PDR15 - Voice API
 
#PDR15 - Pebble Graphics
#PDR15 - Pebble Graphics#PDR15 - Pebble Graphics
#PDR15 - Pebble Graphics
 
#PDR15 Creating Pebble Apps for Aplite, Basalt, and Chalk
#PDR15 Creating Pebble Apps for Aplite, Basalt, and Chalk#PDR15 Creating Pebble Apps for Aplite, Basalt, and Chalk
#PDR15 Creating Pebble Apps for Aplite, Basalt, and Chalk
 
#PDR15 - Developing for Round
#PDR15 - Developing for Round#PDR15 - Developing for Round
#PDR15 - Developing for Round
 
#PDR15 - Designing for Pebble
#PDR15 - Designing for Pebble#PDR15 - Designing for Pebble
#PDR15 - Designing for Pebble
 
#PDR15 Kick-Off
#PDR15 Kick-Off#PDR15 Kick-Off
#PDR15 Kick-Off
 
Pebble Slate Workshop
Pebble Slate WorkshopPebble Slate Workshop
Pebble Slate Workshop
 
Overlay Technique | Pebble Developer Retreat 2014
Overlay Technique | Pebble Developer Retreat 2014Overlay Technique | Pebble Developer Retreat 2014
Overlay Technique | Pebble Developer Retreat 2014
 
Overlay & Libraries | Pebble Meetup Oct. 2014
Overlay & Libraries | Pebble Meetup Oct. 2014Overlay & Libraries | Pebble Meetup Oct. 2014
Overlay & Libraries | Pebble Meetup Oct. 2014
 
Guest Presentation - Strap | Pebble Developer Retreat 2014
Guest Presentation - Strap | Pebble Developer Retreat 2014Guest Presentation - Strap | Pebble Developer Retreat 2014
Guest Presentation - Strap | Pebble Developer Retreat 2014
 
Battery Life | Pebble Developer Retreat 2014
Battery Life | Pebble Developer Retreat 2014Battery Life | Pebble Developer Retreat 2014
Battery Life | Pebble Developer Retreat 2014
 
Thomas Sarlandie Kickoff Talk | Pebble Developer Retreat 2014
Thomas Sarlandie Kickoff Talk | Pebble Developer Retreat 2014Thomas Sarlandie Kickoff Talk | Pebble Developer Retreat 2014
Thomas Sarlandie Kickoff Talk | Pebble Developer Retreat 2014
 
Advanced Techniques: Size | Pebble Developer Retreat 2014
Advanced Techniques: Size | Pebble Developer Retreat 2014Advanced Techniques: Size | Pebble Developer Retreat 2014
Advanced Techniques: Size | Pebble Developer Retreat 2014
 
Advanced Techniques: Graphics | Pebble Developer Retreat 2014
Advanced Techniques: Graphics | Pebble Developer Retreat 2014Advanced Techniques: Graphics | Pebble Developer Retreat 2014
Advanced Techniques: Graphics | Pebble Developer Retreat 2014
 

Recently uploaded

CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
Wonjun Hwang
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 

Recently uploaded (20)

How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 

Connecting Pebble to the World

  • 1. TITLE TEXT CONNECTING PEBBLE TO THE WORLD THOMAS SARLANDIE OCT. 17TH 2014 - WEARABLE+THINGS
  • 2. I connect Pebble to the world! @sarfata Developer, Hardware tinkerer, Passionate Geek Developer Evangelist @Pebble
  • 3.
  • 5. API API Wearable Service - Device
  • 6. 1 - Identify the APIs available 2 - Prototype 3 - Connect
  • 7. 0 - Know your tools Sensors Accel. Buttons Compass Phone Native Apps JavaScript HTTP/ JSON Bluetooth LE GPS
  • 8.
  • 9. 1 - Identify the APIs available
  • 10. 2 - Prototype http://api.openweathermap.org/data/2.1/find /city?lat=38.89&lon=-77.07=&cnt=1
  • 11. 3 - Connect var UI = require('ui'); var ajax = require('ajax'); var main = new UI.Card({ title: 'WX Station', body: 'Loading ...' }); main.show(); var url = “http://api.openweathermap.org/data/2.1/find/city?" + "cnt=1&lat=38.89&lon=-77.07"; ajax( { url: url, type: 'json' }, function(weather) { var temp = (weather.list[0].main.temp - 273.15) temp = (temp* 1.8 + 32).toFixed(1); main.body('Temperature: ' + temp + " F"); }, function (err) { console.log("AJAX Error: " + err); } );
  • 12. var UI = require('ui'); var ajax = require('ajax'); var main = new UI.Card({ title: 'WX Station', body: 'Loading ...' }); main.show(); var url = "http://api.openweathermap.org/data/2.1/find/city? cnt=1&lat=38.89&lon=-77.07"; ajax( { url: url, type: 'json' }, function(weather) { var temp = ((weather.list[0].main.temp - 273.15) * 1.8 + 32).toFixed(1); main.body('Temperature: ' + temp + " F"); }, function (err) { console.log("AJAX Error: " + err); } );
  • 13. navigator.geolocation.getCurrentPosition( function(pos) { var url = "http://api.openweathermap.org/data/2.1/find/city?cnt=1" + "&lat=" + pos.coords.latitude + "&lon=" + pos.coords.longitude; ajax( { url: url, type: 'json' }, function(weather) { var temp = (weather.list[0].main.temp - 273.15); temp = (temp * 1.8 + 32).toFixed(1); main.body('Temperature: ' + temp + " F"); }, function (err) { console.log("Error: " + err); } ); }, function (err) { console.log("Gps error: " + JSON.stringify(err)); }, { timeout: 10000 } );
  • 14.
  • 15. 1 - Identify the APIs available
  • 16. 2 - Prototype $ curl --request PUT --data '{"on":true}' http://url/api/username/lights/1/state
  • 18. var setHueState = function(id, state) { ajax( { url: 'http://192.168.0.42/api/newdeveloper/lights/' + id + '/state', type: 'json', method: 'PUT', data: state }, function(data) { console.log('Success: ' + JSON.stringify(data)); }, function(error) { console.log('The ajax request failed: ' + error); } ); console.log("Request sent! New state: " + JSON.stringify(state)); };
  • 19. console.log("Request sent! New state: " + JSON.stringify(state)); }; var ambiances = [ { title: 'Warm', bri: 255, ct: 500 }, { title: 'Cold', bri: 255, ct: 153 }, { title: 'Red', bri: 255, sat: 255, hue: 0 }, { title: 'Yellow', bri: 255, sat: 255, hue: 12750 }, { title: 'Green', bri: 255, sat: 255, hue: 25500 }, { title: 'Blue', bri: 255, sat: 255,hue: 46920 }, { title: 'Purple', bri: 255, sat: 255,hue: 56100 } ]; var menu = new UI.Menu({ sections: [{ items: ambiances }] }); menu.on('select', function(e) { setHueState(3, e.item); }); menu.show();
  • 20.
  • 21.
  • 22. 1 - Identify the APIs available
  • 23. 1 - Identify the APIs available Pebble BLE Robot “PebbleBot” Service UUID Characteristic UUID / Properties (R/W/…) Left Motor Speed Characteristic UUID / Properties (R/W/…) Right Motor Speed
  • 24. static void handle_up_button_up(ClickRecognizerRef recognizer, void *context) { ble_client_write_without_response(s_ctx.scratch1_characteristic, (const uint8_t *) &SERVO_STILL, sizeof(SERVO_STILL)); printf("UP=0"); } static void handle_up_button_down(ClickRecognizerRef recognizer, void *context) { ble_client_write_without_response(s_ctx.scratch1_characteristic, (const uint8_t *) &SERVO_BACK, sizeof(SERVO_BACK)); printf("UP=1"); } static void handle_down_button_up(ClickRecognizerRef recognizer, void *context) { ble_client_write_without_response(s_ctx.scratch2_characteristic, (const uint8_t *) &SERVO_STILL, sizeof(SERVO_STILL)); printf("DOWN=0"); } static void handle_down_button_down(ClickRecognizerRef recognizer, void *context) { ble_client_write_without_response(s_ctx.scratch2_characteristic, (const uint8_t *) &SERVO_FWD, sizeof(SERVO_FWD)); printf("DOWN=1"); }
  • 25.
  • 26. 1 - Identify the APIs available 2 - Prototype 3 - Connect 4 - Have fun! Thomas Sarlandie @sarfata / @pebbledev Illustrations by sam brown, explodingdog