Skip to content

Instantly share code, notes, and snippets.

@kioku-systemk
Created November 29, 2013 19:44
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kioku-systemk/7710990 to your computer and use it in GitHub Desktop.
Save kioku-systemk/7710990 to your computer and use it in GitHub Desktop.
RICOH THETAでシャッターを切るサンプル(node.js版)
/*
RICOH THETA remote shutter for node.js
coded by @kioku_systemk
code license is public domain.
this code is referenced from @MobileHackerz and @GOROman
https://gist.github.com/GOROman/7596186
*/
var net = require('net');
var bp = require('bufferpack');
var host = '192.168.1.1';
var port = 15740;
var Init_Command_Request = 1;
var Cmd_Request = 6;
var OpenSession = 0x1002;
var InitiateCapture = 0x100E;
function thetaShot() {
var client = new net.Socket();
client.connect(port, host, function() {
console.log('CONNECTED TO: ' + host + ':' + port);
var cnt = 0;
client.on('data', function(data) {
if (cnt == 0){
var s = bp.pack("<LLLLLL", [0,Cmd_Request, 1, OpenSession, 0, 1]);
s.writeUInt32LE(s.length,0);
client.write(s);
cnt = 1;
} else if (cnt == 1) {
var s = bp.pack("<LLLLLLL", [0,Cmd_Request, 1, InitiateCapture, 0, 0, 0]);
s.writeUInt32LE(s.length,0);
client.write(s);
cnt = 2;
client.end();
}
});
client.on('close', function() {
console.log('Connection closed');
});
var s = bp.pack("<LLB16L",[0,Init_Command_Request,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 1]);
s.writeUInt32LE(s.length,0);
client.write(s);
});
client.on('error', function(e) {
console.error(e.message);
});
}
thetaShot();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment