Skip to content

Instantly share code, notes, and snippets.

@electricimp
Created January 27, 2015 15:56
Show Gist options
  • Save electricimp/8df501a16ad8167bf8b4 to your computer and use it in GitHub Desktop.
Save electricimp/8df501a16ad8167bf8b4 to your computer and use it in GitHub Desktop.
Persistent Storage Example
function sendPrefs(value)
{
// Clock has requested the current set-up data
device.send("clock.set.prefs", clockPrefs)
}
. . .
// Register device-sent request for settings
device.on("clock.get.prefs", sendPrefs)
function setPrefs(prefsTable)
{
// Parse the set-up data table provided by the agent
hr24_flag = prefsTable.hr24mode
bst_flag = prefsTable.dst
utc_flag = prefsTable.utc
utc_offset = prefsTable.utcOffset
led_brightness = prefsTable.brightness
}
. . .
// Register callback for incoming settings data
agent.on("clock.set.prefs", setPrefs)
// Issue a request for settings
agent.send("clock.get.prefs", 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment