Created
November 29, 2013 19:44
-
-
Save kioku-systemk/7710990 to your computer and use it in GitHub Desktop.
RICOH THETAでシャッターを切るサンプル(node.js版)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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