Created
October 8, 2012 04:01
-
-
Save error454/3850656 to your computer and use it in GitHub Desktop.
on{X} Disable/Enable WiFI when leaving/entering home
This file contains hidden or 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 home = { | |
name : "home", | |
latitude : "0", | |
longitude : "0", | |
location : "Home" | |
}; | |
function createRegion(location, enterFunction, exitFunction){ | |
var region = device.regions.createRegion({ | |
latitude: parseFloat(location.latitude, 10), | |
longitude: parseFloat(location.longitude, 10), | |
name: location.name, | |
radius: 500 | |
}); | |
region.on("enter", enterFunction); | |
region.on("exit", exitFunction); | |
device.regions.startMonitoring(region); | |
return region; | |
} | |
function DisableWifi() { | |
console.log("Disabling wifi"); | |
device.network.wifiEnabled = false; | |
} | |
function EnableWifi() { | |
console.log("Enabling wifi"); | |
device.network.wifiEnabled = true; | |
} | |
device.regions.stopMonitoringAll(); | |
createRegion(home, EnableWifi, DisableWifi); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment