Last active
August 29, 2015 14:14
-
-
Save zbee/cb4f9637d4ebee2c2fae to your computer and use it in GitHub Desktop.
My on{x} scripts
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
//This logs a lot of information about your device throughout the day. | |
//I used it to help my parents understand why their phones died faster some days. | |
function reportData () { | |
var data = {}; | |
data.battery = "At " + device.battery.status.percentage + "% (" + device.battery.status.powerSource + ")"; | |
if (device.bluetooth.enabled === true) { | |
data.bluetooth = "On; Paired with " + device.bluetooth.pairedDevices.length + " devices"; | |
} else { | |
data.bluetooth = "Off"; | |
} | |
if (device.network.wifiEnabled === true) { | |
data.wifi = "On; Connected to " + device.network.status.ssid; | |
} else { | |
data.wifi = "Off"; | |
} | |
if (device.network.mobileDataEnabled === true) { | |
data.data = "On"; | |
} else { | |
data.data = "Off"; | |
} | |
if (device.nfc.enabled === true) { | |
data.nfc = "On"; | |
} else { | |
data.nfc = "Off"; | |
} | |
if (device.screen.isOn === true) { | |
data.screen = "Is on; "; | |
} else { | |
data.screen = "Is off; "; | |
} | |
data.screen = data.screen + "Brightness: " + device.screen.brightness + "; Timeout: " + device.screen.timeout + " milliseconds" | |
data.runningApps = device.applications.runningApps.length + " Apps running"; | |
data.audio = "Volume at: " + device.audio.ringerVolume + "; Setting: " + device.audio.ringerMode + "; Headset connected: " + device.audio.isHeadsetConnected | |
+ "; Playing: " + device.media.isPlaying; | |
console.info(JSON.stringify(data)); | |
} | |
device.scheduler.setTimer({ | |
name: "dataReporterTimer", | |
time: 0, | |
interval: 30*60*1000, //30 minutes | |
exact: false | |
}, | |
reportData | |
); | |
//Sample log: {"battery":"At 94% (Battery)","bluetooth":"Off","wifi":"On; Connected to \"Asimov\"","data":"On","nfc":"Off","screen":"Is off; Brightness: 255; Timeout: 120000 milliseconds","runningApps":"85 Apps running","audio":"Volume at: 100; Setting: normal; Headset connected: false; Playing: false"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment