Upload
jan-jongboom
View
262
Download
1
Tags:
Embed Size (px)
Citation preview
abusing phones
Wix UA R&D 23 April 2015
to make the internet of things
@janjongboom
Telenor R&D
@janjongboomMozilla things
I hate JavaScript!
VBScript <3 <3 <3
PrerequisitesRaspberry Pi B+ (v1)
Breadboard Some LEDs
Jan's awesome Firefox OS Build
1 navigator.gpio.setPinMode(2, 'output') 2 .then(pin => { 3 pin.writeDigital(true); 4 5 setTimeout(() => pin.writeDigital(false), 500); 6 });
1 navigator.gpio.setPinMode(26, 'input') 2 .then(pin26 => { 3 4 setInterval(() => { 5 pin26.readDigital().then(v => { 6 // do something 7 }); 8 }, 50); 9 10 });
DownsideConnectivity? Camera? Accelerometer?
JanOSTurn your smartphone into an IoT board
JanOSAlternative OS for smartphones
Based on Firefox OS Runs on mobile phones
Runs without a screen
UAH 484
UAH 727
GSM ShieldOnly 2G
Antenna not included
UAH 1700
Firefox OS without UI, with extra low level APIs
So what is JanOS?
(and some kernel changes)
Extra APIsFilesystem access
Running native code IoT functionality like GPIO
Linux Kernel
Gecko HTML5 UI
Has all phone APIs in JS
Similar to node.jsBut...
Made for embeddedLaunched in 30 countries, on tens of handsets, tablets, TVs, etc.
First class comm with RILHardest part of the phone
Power efficientRPi battery shield 45 S$ Firefox OS phone
22 mAh idle 6 mAh idle
Still has the webWebRTC / WebAudio / DOM etc.
Getting startedFlashing JanOS on a phone
www.janos.io
First screwdriver ever!
Booting / flashing
Hello world
1. Clone repo
2. Create JS file with some code
3. Add the JS file to index.html
https://github.com/jan-os/janos
1 var conn = navigator.mozMobileConnections[0]; 2 conn.addEventListener('voicechange', function vc() { 3 if (conn.voice.connected) { 4 conn.removeEventListener('voicechange', vc); 5 6 var req = navigator.mozMobileMessage 7 .send('+31612345678', 'Hello from JanOS!'); 8 req.onsuccess = function() { 9 console.log('Message sent successfully'); 10 }; 11 req.onerror = function() { 12 console.error('Could not send SMS', req.error); 13 }; 14 } 15 });
DoorbellProximity sensor
Ring over bluetooth
Live video stream
Bluetooth doorbell 1 enableBluetoothAudio('00:0C:8A:75:EF:30').then(function() { 2 window.onuserproximity = function(e) { 3 if (e.near) { 4 var audio = new Audio('/sounds/doorbell.ogg'); 5 audio.play(); 6 } 7 }; 8 });
Brian
BrianTracker™2G connection
Connected to push server
Geolocation on request
Rethink applicationsConnectivity & sensors on hand
Accelerometer?
Proximity Accelerometer Ambient Light Magnetometer Gyroscope Humidity Ambient Temperature Pressure Battery Cameras
Bend sensor
Weight scale
Device LightReal purpose: adjust brightness
MusicTheremin is instrument
Use device light as tone frequency
Wave your hands and magic!
1 var context = new AudioContext(); 2 var oscillator = context.createOscillator(); 3 oscillator.connect(context.destination); 4 oscillator.start(0); 5 6 window.addEventListener('devicelight', function(e) { 7 oscillator.frequency.value = e.value * 10; 8 });
Music
AccelerometerReal purpose: Turn to mute
Juggling visualizerMeasure z-forces on device
Plot it in graph over time
Juggle with multiple devices
Juggling visualizer
1 window.addEventListener('devicemotion', function(e) { 2 var serie = getGraphSerieForDevice(e.data.deviceId); 3 serie.addPoint([ e.data.timestamp, Math.abs(e.data.z) ]); 4 });
BeaconsReal purpose: ads
BeaconsTag everyone with a beacon
Cross-reference facebook Phone alerts you who to talk to
Beacons 1 var Bleacon = require('bleacon'); 2 3 Bleacon.startScanning(); 4 5 Bleacon.on('discover', function(b) { 6 console.log('found', b.major, b.minor, b.distance); 7 });
Work in progress in Firefox OS & Firefox for Android (https://bugzilla.mozilla.org/show_bug.cgi?id=1063444)
Get hacking!
Grab a phone that has latest Chrome / Firefox
Use that sensor data
Think outside the box
Thank you!www.janos.io
@janjongboom