Skip to content

Instantly share code, notes, and snippets.

@nsmith
Created August 23, 2013 22:34
Show Gist options
  • Save nsmith/6324655 to your computer and use it in GitHub Desktop.
Save nsmith/6324655 to your computer and use it in GitHub Desktop.
// =FACTORY=AGENT============================================================== //
const projectName = "Pivot Power Genius"
// Factory IMP Device Code
// ---------------------------------------------------------------------------- //
const MAJOR_VER = 0; // Major Version of this Release
const MINOR_VER = 1; // Minor Version of this Release
const RELEASE = 0; // Release Number of this Version
// ---------------------------------------------------------------------------- //
// Revision History
// V0.1.0 - <_G> Initial Release
// ============================================================================ //
mac <- false
impeeid <- false
device.on("register", function(params) {
mac = params.mac
impeeid = params.impeeid
});
function mywebserver(request,res)
{
server.log("Got HTTP Request.");
local request_body = http.jsondecode(request.body)
foreach(idx,param in request_body) {
if (param == "impee_id"){
res.send(200, http.jsonencode({impee_id = impeeid, mac = mac}));
}
}
res.send(200, "OK")
}
http.onrequest(mywebserver);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment