Last active
November 14, 2019 15:56
-
-
Save cmdr2/3d8796b0c96ac99073522b28406cf5ac to your computer and use it in GitHub Desktop.
Access to the full power of a smartphone to a javascript file, with the simplest (least-verbose) possible API of what a "smartphone" is. Probably scary, and some parts might not be possible yet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var acc = require('imu'); | |
var camera = require('camera'); | |
var file = require('file'); | |
var notification = require('notification'); | |
var vibrate = require('vibrate'); | |
var led = require('led'); | |
var location = require('location'); | |
var sms = require('sms'); | |
var contacts = require('contacts'); | |
var phone = require('phone'); | |
var bluetooth = require('bluetooth'); | |
var wifi = require('wifi'); | |
var mobileData = require('mobiledata'); | |
// touch, alarms, ambient, magnetometer, speaker, headphone, battery, compass, screen (brightness), unlock/lock events, ? | |
acc.angularVelocity; // {x, y, z} | |
acc.orientation; // {x, y, z, w} | |
camera.front.getImageSync({opts}); | |
camera.back.getImage({opts}, callback).then(); | |
camera.front.on('data', (frame) => { | |
}); | |
camera.get(3).getImageSync({opts}); // 3 is cameraId | |
file.readSync('/sdcard/data/something'); // standard NodeJS-like file module | |
file.writeSync('relativePath.txt', 'foo'); | |
notification.notify('title', 'msg', {opts}); | |
notification.notify('title', imageByteBuffer, {opts}); | |
vibrate.vibrate(20); // ms | |
led.front.set('red'); | |
led.front.set('#e4f2d2'); | |
led.flash.set(true); // or false | |
led.get(3).set(); // 3 is LED ID | |
location.latitude; | |
location.longitude; | |
location.lastUpdated; // epoch time | |
location.enabled; // true/false | |
location.enable({opts}); | |
location.disable(); | |
sms.readSync(msgGuid); | |
sms.read(msgGiud, callback).then(); | |
sms.listSync(filter, {opts}); | |
sms.list(filter, {opts}, callback).then(); | |
sms.sendSync(contactGuid, 'hello'); | |
sms.send('+1 1234561231', 'foo', callback).then(); | |
contacts.readSync(contactGuid); | |
contacts.list(filter, {opts}); | |
contacts.set({data}); | |
contacts.set(contactGuid, {data}); | |
contacts.delete(contactGuid); | |
phone.call(contactGuid); | |
phone.call('+1 123456789'); | |
phone.callSync(..); | |
phone.call(.., callback).then((call) => { | |
call.on('data', (byteBuffer) => { | |
call.send(waveformBytes); | |
call.close(); | |
}); | |
}); | |
phone.on('incoming', (call) => { | |
call.start(); | |
call.on('data', ..); // as earlier | |
call.close(); | |
}); | |
wifi.enable(); | |
wifi.disable(); | |
wifi.list(filter, callback).then(); | |
wifi.listSync(filter); | |
wifi.connect(ssid, {opts}); | |
wifi.disconnect(); | |
mobileData.enable(); | |
mobileData.disable(); | |
mobileData.set({opts}); // 2g, 3g, lte etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment