Created
February 15, 2016 16:08
-
-
Save jploh/3bb5c5466bf33e2fc0ff to your computer and use it in GitHub Desktop.
Test RFID Server
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
var net = require('net'); | |
var x = ''; | |
net.createServer(function(sock) { | |
console.log('CONNECTED: ' + sock.remoteAddress +':'+ sock.remotePort); | |
sock.on('data', function(data) { | |
x = new Buffer(data, 'binary').toString('hex'); | |
if(x == '04ff211995' || x == '040021d96a') { | |
var b = new Buffer(14); | |
b[0] = 0x0d; | |
b[1] = 0x00; | |
b[2] = 0x21; | |
b[3] = 0x00; | |
b[4] = 0x03; | |
b[5] = 0x3f; | |
b[6] = 0x09; | |
b[7] = 0x03; | |
b[8] = 0x00; | |
b[9] = 0x00; | |
b[10] = 0x1e; | |
b[11] = 0x0a; | |
b[12] = 0x76; | |
b[13] = 0x48; | |
sock.write(b); | |
} | |
console.log(new Buffer(data, 'binary').toString('hex') + "\n"); | |
}); | |
sock.on('close', function(data) { | |
console.log('CLOSED: ' + sock.remoteAddress +' '+ sock.remotePort); | |
}); | |
}).listen(6000, '192.168.1.109'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment