I was poking around the controlPanel found some code that may be useful to most flash developers
Here's the chumby's basic init sequence...
function setupHeartbeat() {
this.createEmptyMovieClip("heartbeat", 1);
heartbeat.g_nextHeartbeat = 0;
heartbeat.onEnterFrame = function () {
var timeNow = getTimer();
if (timeNow >= g_nextHeartbeat) {
trace ("(Master heartbeat)");
Object._chumby.putFile("/tmp/movieheartbeat", "1");
g_nextHeartBeat = timeNow + 15000;
}
};
}
function fetchChumbyGUID() {
trace ("Fetching Chumby GUID");
panel.setLabel("Identifying chumby...");
getChumbyGUIDXML = new XML ();
getChumbyGUIDXML.target = this;
getChumbyGUIDXML.onData = function (data) {
if (data.length) {
this.target.gotChumbyGUID(data);
} else {
trace ("- can\'t load Chumby GUID");
this.target.fetchNetworkStatus();
}
};
if (_root.test) {
getChumbyGUIDXML.load("chumbyguid.xml");
} else {
getChumbyGUIDXML.load("exec://guidgen.sh");
}
}
function gotChumbyGUID(guid) {
Object._chumby.g_guid = Object.chomp(guid.toUpperCase());
trace (("- GUID=\"" + Object._chumby.g_guid) + "\"");
delete getChumbyGUIDXML;
fetchMacAddress();
}
function fetchMacAddress() {
panel.setLabel("Checking network devices");
if (_root.test) {
Object._chumby.macAddress = "00:00:00:00:00:00";
fetchNetworkStatus();
} else {
trace ("Fetching MAC address");
getMacAddressXML = new XML ();
getMacAddressXML.target = this;
getMacAddressXML.onData = function (data) {
if (data.length) {
this.target.gotMacAddress(data);
} else {
trace ("- can\'t load MAC address");
this.target.fetchNetworkStatus();
}
};
getMacAddressXML.load("exec://macgen.sh");
}
}
function gotMacAddress(address) {
Object._chumby.macAddress = Object.chomp(address);
trace ("- MAC: " + Object._chumby.macAddress);
delete getMacAddressXML;
fetchNetworkStatus();
}
function fetchNetworkStatus() {
panel.setLabel("Checking network status");
trace ("Fetching network status");
if (_root.test) {
Object._chumby.hasNetwork = hasLocalNetwork;
dispatch();
} else {
Object._chumby.hasNetwork = false;
networkXML = new XML ();
networkXML.target = this;
networkXML.onLoad = function (success) {
if (success) {
this.target.gotNetworkStatus(this.firstChildOfType("network"));
} else {
trace ("- failed to get network status");
this.target.dispatch();
}
};
networkXML.load("exec://network_status.sh");
}
}
function gotNetworkStatus(network) {
if (network != undefined) {
var interface = network.firstChildOfType("interface");
if (interface != undefined) {
var errors = interface.childrenOfType("error");
Object._chumby.hasNetwork = !(errors && (errors.length > 0));
if (Object._chumby.hasNetwork) {
Object._chumby.ip = interface.attributes.ip;
Object._chumby.netmask = interface.attributes.netmask;
Object._chumby.gateway = interface.attributes.gateway;
Object._chumby.nameserver1 = interface.attributes.nameserver1;
Object._chumby.nameserver2 = interface.attributes.nameserver2;
var config = network.firstChildOfType("configuration");
Object._chumby.ssid = config.attributes.ssid;
}
}
}
trace ("- network status: " + Object._chumby.hasNetwork);
dispatch();
}
function dispatch() {
if (safeMode != undefined) {
gotoAndStop (8);
} else if (builtin) {
gotoAndStop (10);
} else if (firstTime) {
gotoAndStop (3);
} else {
gotoAndStop (4);
}
}
function restoreSettings() {
trace ("Restoring settings");
if (!_root.test) {
Object._chumby._setOverlayVisibility(255);
Object._chumby._setOverlayBlendingEnabled(1);
Object._chumby._switchDisplay(1);
trace ("- restoring dimlevel");
var v = Object._chumby.getFile("/psp/dimlevel");
Object._chumby._setLCDMute(v);
}
}
Date.month_names = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
Date.month_names_short = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
Date.day_names = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
Date.day_names_short = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
Date.prototype.format = function (f) {
var result = new String ();
var i = 0;
while (i < f.length) {
var c = f.charAt(i++);
if (c == "%") {
c = f.charAt(i++);
if ((c == "E") || (c == "O")) {
c = f.charAt(i++);
}
if (c == "a") {
result = result + Date.day_names_short[this.getDay()];
} else if (c == "A") {
result = result + Date.day_names[this.getDay()];
} else if ((c == "b") || (c == "h")) {
result = result + Date.month_names_short[this.getMonth()];
} else if (c == "B") {
result = result + Date.month_names[this.getMonth()];
} else if (c == "C") {
var century = int (this.getFullYear() / 100);
result = result + (((century < 10) ? "0" : "") + century);
} else if (c == "d") {
var dom = this.getDate();
result = result + (((dom < 10) ? "0" : "") + dom);
} else if (c == "D") {
result = result + this.format("%m/%d/%y");
} else if (c == "e") {
var dom = this.getDate();
result = result + (((dom < 10) ? " " : "") + dom);
} else if (c == "F") {
result = result + this.format("%Y-%m-%d");
} else if (c == "G") {
result = result + this.getFullYear();
} else if (c == "g") {
result = result + (this.getFullYear() % 100);
} else if (c == "H") {
var hour = this.getHours();
result = result + (((hours < 10) ? "0" : "") + hours);
} else if (c == "I") {
hours = this.getHours();
if (hours > 12) {
hours = hours - 12;
}
if (hours == 0) {
hours = 12;
}
result = result + (((hours < 10) ? "0" : "") + hours);
} else if (c == "j") {
var d = (this.getTime() - new Date (this.getFullYear(), 0).getTime());
d = int (d / 86400000);
result = result + ((((d < 100) ? "0" : "") + ((d < 10) ? "0" : "")) + d);
} else if (c == "k") {
var hours = this.getHours();
result = result + (((hours < 10) ? " " : "") + hours);
} else if (c == "l") {
var hours = this.getHours();
if (hours > 12) {
hours = hours - 12;
}
if (hours == 0) {
hours = 12;
}
result = result + (((hours < 10) ? " " : "") + hours);
} else if (c == "m") {
var month = (this.getMonth() + 1);
result = result + (((month < 10) ? "0" : "") + month);
} else if (c == "M") {
var minutes = this.getMinutes();
result = result + (((minutes < 10) ? "0" : "") + minutes);
} else if (c == "n") {
result = result + newline;
} else if (c == "p") {
result = result + ((this.getHours() >= 12) ? "PM" : "AM");
} else if (c == "P") {
result = result + ((this.getHours() >= 12) ? "pm" : "am");
} else if (c == "r") {
result = result + this.format("%I:%M:%S %p");
} else if (c == "R") {
result = result + this.format("%H:%M");
} else if (c == "s") {
result = result + int (this.getTime() / 1000);
} else if (c == "S") {
var seconds = this.getSeconds();
result = result + (((seconds < 10) ? "0" : "") + seconds);
} else if (c == "t") {
result = result + "\t";
} else if (c == "T") {
result = result + this.format("%H:%M:%S");
} else if (c == "u") {
var dow = this.getDay();
if (dow == 0) {
dow = 7;
}
result = result + dow;
} else if (c == "w") {
result = result + this.getDay();
} else if (c == "x") {
result = result + this.format("%m/%d/%y");
} else if (c == "X") {
result = result + this.format("%H:%M:%S");
} else if (c == "y") {
year = this.getYear() % 100;
result = result + (((year < 10) ? "0" : "") + year);
} else if (c == "Y") {
result = result + this.getFullYear();
} else if (c == "z") {
result = result + (-int (this.getTimeZoneOffset() / 60));
} else if (c == "%") {
result = result + "%";
} else {
result = result + ("%" + c);
}
} else {
result = result + c;
}
}
return (result);
};
Date.isLeap = function (y) {
if ((y % 400) == 0) {
return (true);
}
if ((y % 100) == 0) {
return (false);
}
return ((y % 4) == 0);
};
Date.daysInMonth = function (m, y) {
if (m == 1) {
return (28 + (Date.isLeap(y) ? 1 : 0));
}
return ([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m]);
};
ASSetPropFlags(Date, "month_names,month_names_short,day_names,day_names_short", 7);
ASSetPropFlags(Date.prototype, "format,isLeap,daysInMonth", 7);
Object.prototype.xpath_string = function (path) {
if (this.nodeType != 1) {
trace ("Error in xpath_string");
return ("Error");
}
var root = this;
var s = new String (path);
var tokens = s.split("/");
while (tokens.length > 0) {
if (tokens[0].charAt(0) == "@") {
return (root.attributes[tokens[0].substring(1)]);
} else {
var nodes = root.childNodes;
var found = false;
var i = 0;
while (i < nodes.length) {
if (nodes[i].nodeName == tokens[0]) {
if (tokens.length == 1) {
return (nodes[i].firstChild.nodeValue);
} else {
root = nodes[i];
tokens.shift();
found = true;
break;
}
}
i++;
}
if (!found) {
return ("");
}
}
}
return ("");
};
Object.prototype.xpath_node = function (path) {
if (this.nodeType != 1) {
trace ("Error in xpath_string");
return ("Error");
}
var root = this;
var s = new String ();
s = path;
var tokens = s.split("/");
while (tokens.length > 0) {
var nodes = root.childNodes;
var found = false;
var i = 0;
while (i < nodes.length) {
if (nodes[i].nodeName == tokens[0]) {
if (tokens.length == 1) {
return (nodes[i]);
} else {
root = nodes[i];
tokens.shift();
found = true;
break;
}
}
i++;
}
if (!found) {
return (null);
}
}
return (null);
};
Object.prototype.childrenOfType = function (s, a) {
if (a == undefined) {
a = new Array ();
}
var n = this.firstChild;
while (n) {
if (n.nodeName == s) {
a.push(n);
}
n = n.nextSibling;
}
return (a);
};
Object.prototype.cloneChildrenOfType = function (s, a) {
if (a == undefined) {
a = new Array ();
}
var n = this.firstChild;
while (n) {
if (n.nodeName == s) {
a.push(n.cloneNode(true));
}
n = n.nextSibling;
}
return (a);
};
Object.prototype.childrenOfTypeAnd = function (s, f, a) {
if (a == undefined) {
a = new Array ();
}
var n = this.firstChild;
while (n) {
if ((n.nodeName == s) && (f(n))) {
a.push(n);
}
n = n.nextSibling;
}
return (a);
};
Object.prototype.childrenThat = function (f, a) {
if (a == undefined) {
a = new Array ();
}
var n = this.firstChild;
while (n) {
if (f(n)) {
a.push(n);
}
n = n.nextSibling;
}
return (a);
};
Object.prototype.firstChildOfType = function (s) {
var n = this.firstChild;
while (n) {
if (n.nodeName == s) {
return (n);
}
n = n.nextSibling;
}
return (null);
};
Object.prototype.firstChildThat = function (f) {
var n = this.firstChild;
while (n) {
if (f(n)) {
return (n);
}
n = n.nextSibling;
}
return (null);
};
Object.prototype.firstChildOfTypeAnd = function (s, f) {
var n = this.firstChild;
while (n) {
if ((n.nodeName == s) && (f(n))) {
return (n);
}
n = n.nextSibling;
}
return (null);
};
Object.prototype.nextSiblingOfType = function (s) {
var n = this.nextSibling;
while (n) {
if (n.nodeName == s) {
return (n);
}
n = n.nextSibling;
}
return (null);
};
Object.prototype.previousSiblingOfType = function (s) {
var n = this.previousSibling;
while (n) {
if (n.nodeName == s) {
return (n);
}
n = n.previousSibling;
}
return (null);
};
Object.prototype.firstDescendantOfType = function (s) {
var n = this.firstChildOfType(s);
if (n) {
return (n);
}
n = this.firstChild;
while (n) {
var k = n.firstDescendantOfType(s);
if (k) {
return (k);
}
n = n.nextSibling;
}
return (null);
};
Object.prototype.descendantsOfType = function (s, a) {
if (a == undefined) {
a = new Array ();
}
var n = this.firstChild;
while (n) {
if (n.nodeType == 1) {
if (n.nodeName == s) {
a.push(n);
}
a = n.descendantsOfType(s, a);
}
n = n.nextSibling;
}
return (a);
};
Object.prototype.firstValueOfType = function (s) {
var n = this.firstChild;
while (n) {
if (n.nodeName == s) {
return (n.firstChild.nodeValue);
}
n = n.nextSibling;
}
return (null);
};
ASSetPropFlags(Object.prototype, "xpath_string,xpath_node,childrenOfType,cloneChildrenOfType,childrenOfTypeAnd,childrenThat,firstChildOfType,firstChildOfTypeAnd,firstChildThat,nextSiblingOfType,previousSiblingOfType,firstDescendantOfType,descendantsOfType,firstValueOfType", 7);
Object.prototype.dumpFields = function () {
trace ((((("Fields of " + this) + " <") + typeof (this)) + "> path ") + targetPath (this));
for (var index in this) {
var obj = this[index];
trace (((((((" [" + index) + "]: ") + obj) + " <") + typeof (obj)) + "> path ") + targetPath (obj));
}
};
ASSetPropFlags(Object.prototype, "dumpFields", 7);
Array.prototype.sortshuffle = function () {
var shuffler = function (a, b) {
return ((random (2) * 2) - 1);
};
this.sort(shuffler);
};
Array.prototype.shuffle = function () {
var len = this.length;
var it = 0;
while (it < len) {
var rn = random (len);
var el = this[it];
this[it] = this[rn];
this[rn] = el;
it++;
}
};
Array.prototype.copy = function () {
return (this.slice(0));
};
Array.prototype.removeDuplicates = function () {
var inc0 = 0;
while (inc0 < (this.length - 1)) {
var inc1 = (inc0 + 1);
while (inc1 < this.length) {
if (this[inc0] == this[inc1]) {
this.splice(inc1--, 1);
}
inc1++;
}
inc0++;
}
};
ASSetPropFlags(Array.prototype, "sortshuffle,shuffle,copy,removeDuplicates", 7);
TextField.prototype.autoResize = function (minn, maxx) {
if (this.autosizeFormat == null) {
this.autosizeFormat = new TextFormat ();
this.autosizeFormat.size = 6;
}
if (minn == null) {
minn = 1;
}
if (maxx == null) {
maxx = 99;
}
if (minn >= maxx) {
this.autosizeFormat.size = minn;
this.setTextFormat(this.autosizeFormat);
} else if (this.text.length > 0) {
this.autosizeFormat.size = this.autosizeFormat.size - 5;
this.setTextFormat(this.autosizeFormat);
if ((this.textHeight > this._height) || (this.textWidth > this._width)) {
while ((this.textHeight > this._height) || (this.textWidth > this._width)) {
this.autosizeFormat.size--;
this.setTextFormat(this.autosizeFormat);
}
} else {
while ((this.textHeight < this._height) && (this.textWidth < this._width)) {
this.autosizeFormat.size++;
this.setTextFormat(this.autosizeFormat);
}
this.autosizeFormat.size = this.autosizeFormat.size - 2;
this.setTextFormat(this.autosizeFormat);
}
this.autosizeFormat.size = Math.min(Math.max(minn, this.autosizeFormat.size), maxx);
this.setTextFormat(this.autosizeFormat);
}
};
ASSetPropFlags(TextField.prototype, "autoResize", 7);
if (Object._chumby == undefined) {
Object._chumby = {};
ASSetPropFlags(Object, "_chumby", 7);
}
Object._chumby._getFile = ASnative(5, 50);
Object._chumby._putFile = ASNative(5, 51);
Object._chumby._backtick = ASNative(5, 52);
Object._chumby._fileExists = ASnative(5, 53);
Object._chumby._getSpeakerMute = ASnative(5, 17);
Object._chumby._setSpeakerMute = ASnative(5, 18);
Object._chumby._lightLevel = ASnative(5, 15);
Object._chumby._getLCDMute = ASnative(5, 19);
Object._chumby._setLCDMute = ASnative(5, 20);
Object._chumby._getBrightnessForRange = ASnative(5, 21);
Object._chumby._setBrightnessForRange = ASnative(5, 22);
Object._chumby._getBrightnessThresholdForRange = ASnative(5, 23);
Object._chumby._setBrightnessThresholdForRange = ASnative(5, 24);
Object._chumby._bendLevel = ASnative(5, 14);
Object._chumby._bent = ASnative(5, 25);
Object._chumby._bendAverage = ASnative(5, 28);
Object._chumby._getBendThreshold = ASnative(5, 26);
Object._chumby._setBendThreshold = ASnative(5, 27);
Object._chumby._dcPower = ASnative(5, 16);
Object._chumby._setOverlayVisibility = ASnative(5, 110);
Object._chumby._getOverlayVisibility = ASnative(5, 111);
Object._chumby._setOverlayBlendingEnabled = ASnative(5, 112);
Object._chumby._getOverlayBlendingEnabled = ASnative(5, 113);
Object._chumby._setOverlayChromaBlendingEnabled = ASnative(5, 114);
Object._chumby._getOverlayChromaBlendingEnabled = ASnative(5, 115);
Object._chumby._setOverlayChromaBlendColor = ASnative(5, 116);
Object._chumby._getOverlayChromaBlendColor = ASnative(5, 117);
Object._chumby._setSlaveVar = ASnative(5, 80);
Object._chumby._getSlaveVar = ASnative(5, 81);
Object._chumby._routeUIEvents = ASnative(5, 82);
Object._chumby._switchDisplay = ASnative(5, 83);
Object._chumby._getCurrentDisplay = ASnative(5, 88);
Object._chumby._startSlave = ASnative(5, 84);
Object._chumby._stopSlave = ASnative(5, 85);
Object._chumby._pauseResumeSlave = ASnative(5, 86);
Object._chumby._getDefaultSlaveInstance = ASnative(5, 87);
Object._chumby._expireCache = ASnative(5, 100);
Object._chumby._expireCacheFiltered = ASnative(5, 101);
Object._chumby._exitOpportunity = ASnative(5, 120);
Object.chomp = function (s) {
while (s.length && ((s.slice(-1) == newline) || (s.slice(-1) == " "))) {
s = s.slice(0, -1);
}
return (s);
};
Object._chumby.getFile = function (f) {
return (Object.chomp(Object._chumby._getFile(f)));
};
Object._chumby.putFile = function (f, d) {
Object._chumby._putFile(f, d + newline);
};
Object._chumby.backtick = function (c) {
return (Object.chomp(Object._chumby._backtick(c)));
};
Object._chumby._setTimeZone = ASnative(103, 321);
Object._chumby._getTimeZone = ASnative(103, 320);
Date.addProperty("_timezone", ASnative(103, 320), ASnative(103, 321));
var o = Date.prototype;
o.setSystemTime = ASnative(103, 322);
ASSetpropFlags(Object, "chomp", 7);
ASSetPropFlags(Date.prototype, "setSystemTime", 7);
ASSetPropFlags(Date, "_timezone", 7);
Object._chumby.controlPanelVersion = "2.5.44";
stop();
trace (((("Welcome to the Chumby Control Panel (version " + Object._chumby.controlpanelVersion) + " [") + _root.$version) + "])");
if (_root.test == undefined) {
platform = _root.$version.split(" ")[0];
_root.test = (platform == "MAC") || (platform == "WIN");
}
if (_root.test) {
local = 1;
hasLocalNetwork = true;
defaultProfileTime = 2;
defaultWidgetTime = 5;
Object._chumby.hardware_version = "0.9.2";
Object._chumby.software_version = "0.9.2";
Object._chumby.firmware_version = "100";
} else {
panel.setLabel("Checking hardware version");
Object._chumby.hardware_version = Object._chumby.backtick("chumby_version -h");
if (Object._chumby.hardware_version == "") {
Object._chumby.hardware_version = Object._chumby.getFile("/etc/hardware_version");
Object._chumby.software_version = Object._chumby.getFile("/etc/software_version");
Object._chumby.firmware_version = Object._chumby.getFile("/etc/firmware_build");
} else {
panel.setLabel("Checking software version");
Object._chumby.software_version = Object._chumby.backtick("chumby_version -s");
panel.setLabel("Checking firmware version");
Object._chumby.firmware_version = Object._chumby.backtick("chumby_version -f");
}
}
if (_root.baseURL == undefined) {
Object._chumby.baseURL = "http://xml.chumby.com";
if (_root.test && (_root.local)) {
Object._chumby.baseURL = "http://0.0.0.0:3000";
if (platform == "WIN") {
Object._chumby.baseURL = "http://127.0.0.1:3000";
}
}
} else {
Object._chumby.baseURL = _root.baseURL;
trace ("Base URL=" + Object._chumby.baseURL);
}
Object._chumby.makeURL = function (u) {
return (Object._chumby.baseURL + u);
};
if (_root.widgetsURL == undefined) {
Object._chumby.widgetsURL = "http://widgets.chumby.com";
if (_root.test && (_root.local)) {
Object._chumby.widgetsURL = "http://0.0.0.0:3000";
if (platform == "WIN") {
Object._chumby.baseURL = "http://127.0.0.1:3000";
}
}
} else {
Object._chumby.widgetsURL = _root.widgetsURL;
trace ("Widgets URL=" + Object._chumby.widgetsURL);
}
Object._chumby.makeWidgetsURL = function (u) {
return (Object._chumby.widgetsURL + u);
};
setupHeartbeat();
restoreSettings();
fetchChumbyGUID();