The JS of things

Firefox OS

Mobile platforms, wearable devices, IoT

Valentin Goșu

about:me

Open Source enthusiast

C++ developer by day

Firefox OS hacker by night

Mozilla Rep in Bucharest

 

http://google.com/+ValentinGosu

valentin@mozilla.ro

 

Firefox OS

Gaia        (collection of web apps that make up the UI)

Gecko     (JS Runtime, APIs for hardware access)

Gonk       (Linux Kernel, Drivers, HAL)

WebAPI

Battery

Orientation

Vibration

Alarm

Notification

Camera

SMS

Telephony

Bluetooth

Wifi

TcpSocket

Contacts

Storage

Apps

WebPayment

DEMO

Simple Firefox OS app

WebIDE

Apps

Normal/Web

Privileged

Certified

Firefox as a runtime for your apps

https://marketplace.firefox.com/

Kickstart your IoT project

1 - low cost

2 - easy development

This part of the presentation is based on  http://janos.io/ by Jan Jongboom

Cost

Raspberry Pi - 35$

Wifi - 10$

Flash - 5$

Battery - 20$

Wires & Cables - 5$

Screen - 30$

3G?

Camera?

Bluetooth?

Speaker?

Sensors?

Cost

https://firefoxosdevices.org

25$

dual sim (GSM) ✓

bluetooth 4.0 ✓

Wi-Fi ✓

camera ✓

battery ✓

touchscreen ✓

Easy development

1 - Flash JanOS (Stripped down FirefoxOS)

2 - Buy a screwdriver

3 -

JanOS DEMO

Included:

- doorbell

- motion

- security camera

- GPS tracker

 

How easy is it?

function start() {
    // Call the phone number
    navigator.mozTelephony.dial('07XXXXXXXX');
    // Stop the call in 63 seconds
    setTimeout(stop, 63*1000);
}

function stop() {
    // Hang up
    navigator.mozTelephony.calls[0].hangUp();
    // Call back again in another 3 seconds
    setTimeout(start, 3*1000);
}

start();

How easy is it?

window.camera.takePicture('back').then(function(ev) {
  var blob = ev.blob;
  // Store blob in storage 
}

// WebRTC

navigator.geolocation.getCurrentPosition(
  function(position) {
  // position.coords.latitude
  // position.coords.longitude
});

var request = navigator.mozAlarms.add(
  new Date("May 21, 2015 16:20:00"));
navigator.mozSetMessageHandler("alarm", 
  function (mozAlarm) { alert("alarm fired"); });

Extra goodies

navigator.mozOs.exec('ls', [ '-al', '/data/local' ])
  .then(res => console.log('exec', res.exitCode, res.stdout, res.stderr))
  .catch(err => console.error('exec failed', err));

http://janos.io/api-reference/exec.html

navigator.mozOs.readFile('/data/local/user.js', 'utf-8')
  .then(content => console.log('readFile', content))
  .catch(err => console.error('readFile', err));

http://janos.io/api-reference/fs.html

Powered by Firefox OS

Monohm Runcible

matchstick.tv

Panasonic 4K TV

Questions?

Performance

ASM.js

Advantages

Completely open source (in real time)

Not a walled garden (self  hosting of apps)

Everything is the web

VERY easy to get started

Very small memory footprint (128 Mb of RAM?)

Cost $$$

Disadvantages

Not enough users

Performance*

Lack of dedicated apps*

You can ONLY use JavaScript**

* Can be mitigated

** For wearables we can make an exception

Should I port?

Is user count your only priority?

Do you only have native apps for Android/iOS

Does your app use closed-source/platform dependent libraries?

 

Not yet!

Should I port?

Do you have a hybrid app (PhoneGap, Apache Cordova)?

Do you have a usable web app?

Do you want to quickly build something new?

Do you just love JavaScript?

 

YES!

References

This presentation