Added API: rfid_start_record, rfid_stop_record.
This commit is contained in:
parent
7e8979d41e
commit
98e690ec2c
28
handlers.js
28
handlers.js
@ -96,6 +96,8 @@ function homepage(res, req) {
|
|||||||
+ '<ul>'
|
+ '<ul>'
|
||||||
+ '<li><a target="results" href="/cgi-bin/rfid_list">rfid_list</a></li>'
|
+ '<li><a target="results" href="/cgi-bin/rfid_list">rfid_list</a></li>'
|
||||||
+ '<li><a target="results" href="/cgi-bin/rfid_list_ext">rfid_list_ext</a></li>'
|
+ '<li><a target="results" href="/cgi-bin/rfid_list_ext">rfid_list_ext</a></li>'
|
||||||
|
+ '<li><a target="results" href="/cgi-bin/rfid_start_record">rfid_start_record</a></li>'
|
||||||
|
+ '<li><a target="results" href="/cgi-bin/rfid_stop_record">rfid_stop_record</a></li>'
|
||||||
+ '</ul>'
|
+ '</ul>'
|
||||||
+ '<h2>Misc.</h2>'
|
+ '<h2>Misc.</h2>'
|
||||||
+ '<ul>'
|
+ '<ul>'
|
||||||
@ -356,11 +358,11 @@ function sound(res, req) {
|
|||||||
data = '{"return":"1","msg":"Unable to perform action, rabbit is sleeping."}';
|
data = '{"return":"1","msg":"Unable to perform action, rabbit is sleeping."}';
|
||||||
} else {
|
} else {
|
||||||
var id = getParameter(req, "id");
|
var id = getParameter(req, "id");
|
||||||
var url = getParameter(req, "url");
|
var uri = getParameter(req, "url");
|
||||||
|
|
||||||
if (id && url) {
|
if (id && uri) {
|
||||||
data = '{"return":"1","msg":"You cannot use ID and URL parameters at the same time."}';
|
data = '{"return":"1","msg":"You cannot use ID and URL parameters at the same time."}';
|
||||||
} else if ((id === undefined) && (url === undefined)) {
|
} else if ((id === undefined) && (uri === undefined)) {
|
||||||
data = '{"return":"1","msg":"No sound to play."}';
|
data = '{"return":"1","msg":"No sound to play."}';
|
||||||
} else if (id) {
|
} else if (id) {
|
||||||
data = '{"return":"0"}';
|
data = '{"return":"0"}';
|
||||||
@ -622,6 +624,26 @@ function rfid_list_ext(res, req) {
|
|||||||
}
|
}
|
||||||
exports.rfid_list_ext = rfid_list_ext;
|
exports.rfid_list_ext = rfid_list_ext;
|
||||||
|
|
||||||
|
function rfid_start_record(res, req) {
|
||||||
|
log.trace('rfid_start_record: begin');
|
||||||
|
|
||||||
|
var data = '{"return":"0"}';
|
||||||
|
|
||||||
|
sendResponse(res, data);
|
||||||
|
log.trace('rfid_start_record: end');
|
||||||
|
}
|
||||||
|
exports.rfid_start_record = rfid_start_record;
|
||||||
|
|
||||||
|
function rfid_stop_record(res, req) {
|
||||||
|
log.trace('rfid_stop_record: begin');
|
||||||
|
|
||||||
|
var data = '{"return":"0"}';
|
||||||
|
|
||||||
|
sendResponse(res, data);
|
||||||
|
log.trace('rfid_stop_record: end');
|
||||||
|
}
|
||||||
|
exports.rfid_stop_record = rfid_stop_record;
|
||||||
|
|
||||||
function clock(res, req) {
|
function clock(res, req) {
|
||||||
log.trace('clock: begin');
|
log.trace('clock: begin');
|
||||||
|
|
||||||
|
2
index.js
2
index.js
@ -53,6 +53,8 @@ handle['/cgi-bin/reboot'] = handlers.reboot;
|
|||||||
handle['/cgi-bin/reset_install_flag'] = handlers.reset_install_flag;
|
handle['/cgi-bin/reset_install_flag'] = handlers.reset_install_flag;
|
||||||
handle['/cgi-bin/rfid_list'] = handlers.rfid_list;
|
handle['/cgi-bin/rfid_list'] = handlers.rfid_list;
|
||||||
handle['/cgi-bin/rfid_list_ext'] = handlers.rfid_list_ext;
|
handle['/cgi-bin/rfid_list_ext'] = handlers.rfid_list_ext;
|
||||||
|
handle['/cgi-bin/rfid_start_record'] = handlers.rfid_start_record;
|
||||||
|
handle['/cgi-bin/rfid_stop_record'] = handlers.rfid_stop_record;
|
||||||
handle['/cgi-bin/sleep'] = handlers.sleep;
|
handle['/cgi-bin/sleep'] = handlers.sleep;
|
||||||
handle['/cgi-bin/snapshot'] = handlers.snapshot;
|
handle['/cgi-bin/snapshot'] = handlers.snapshot;
|
||||||
handle['/cgi-bin/snapshot_ftp'] = handlers.snapshot_ftp;
|
handle['/cgi-bin/snapshot_ftp'] = handlers.snapshot_ftp;
|
||||||
|
@ -87,7 +87,7 @@ function sleep() {
|
|||||||
sleeping = true;
|
sleeping = true;
|
||||||
sleepTime = Math.floor(new Date().getTime() / 1000);
|
sleepTime = Math.floor(new Date().getTime() / 1000);
|
||||||
return sleeping;
|
return sleeping;
|
||||||
};
|
}
|
||||||
exports.sleep = sleep;
|
exports.sleep = sleep;
|
||||||
|
|
||||||
function wakeup() {
|
function wakeup() {
|
||||||
@ -95,14 +95,14 @@ function wakeup() {
|
|||||||
sleeping = false;
|
sleeping = false;
|
||||||
sleepTime = 0;
|
sleepTime = 0;
|
||||||
return sleeping;
|
return sleeping;
|
||||||
};
|
}
|
||||||
exports.wakeup = wakeup;
|
exports.wakeup = wakeup;
|
||||||
|
|
||||||
function reboot() {
|
function reboot() {
|
||||||
log.info("Karotz reboot");
|
log.info("Karotz reboot");
|
||||||
wakeup();
|
wakeup();
|
||||||
return sleeping;
|
return sleeping;
|
||||||
};
|
}
|
||||||
exports.reboot = reboot;
|
exports.reboot = reboot;
|
||||||
|
|
||||||
function leds(color1, color2, pulse, speed) {
|
function leds(color1, color2, pulse, speed) {
|
||||||
|
@ -35,14 +35,14 @@ function route(pathname, handle, res, req) {
|
|||||||
|
|
||||||
if (typeof handle[pathname] === 'function') {
|
if (typeof handle[pathname] === 'function') {
|
||||||
return handle[pathname](res, req);
|
return handle[pathname](res, req);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
log.failure('No request handler found for ' + pathname);
|
log.failure('No request handler found for ' + pathname);
|
||||||
res.writeHead(404, {
|
res.writeHead(404, {
|
||||||
'Content-Type' : 'text/plain'
|
'Content-Type' : 'text/plain'
|
||||||
});
|
});
|
||||||
res.write('404 Not Found');
|
res.write('404 Not Found');
|
||||||
res.end();
|
res.end();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.route = route;
|
exports.route = route;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user