Denon DN500BD Network Control

Again, a good bit of #techbodgery that solved a problem for me that might help someone else stumbling on this page from Google.

I have a Denon DN500BD BluRay Player with no remote (no idea what happened to it), the following simple NodeJS script emulates the remote;

#!/usr/bin/node
const readline = require('readline');
var net = require('net');

var ipAddr = '192.168.10.150'; // insert the IP of your player here

var client = new net.Socket();
client.connect(9030, ipAddr, function() {
	console.log('Connected');
});

client.on('data', function(data) {
	console.log('Received: ' + data);
});

client.on('close', function() {
	console.log('Connection Lost');
	process.exit();
});

// mapping
var kmap = new Map([
   ['\x1B[A', '0PCCUSR3'],
   ['\x1B[B', '0PCCUSR4'],
   ['\x1B[D', '0PCCUSR1'],
   ['\x1B[C', '0PCCUSR2'],
   ['\r', '0PCENTR'], // enter
   ['c', '0PCDTRYOP'], // close
   ['o', '0PCDTRYCL'], // open
   ['1', '0PW00'], // on
   ['0', '0PW01'], // off
   ['p', '02353'], // play
   ['s', '02354'], // stop
   ['f', '02348'], // pause
   ['m', '0mt00'], // mute
   ['M', '0mt01'], // un mute
   ['.', '02333'], // << prev
   [',', '02332'], // >> next
   ['<', '0PCSLSR'], // << rew
   ['>', '0PCGPPV'], // >> ff
   ['z', '0DVHOSD00'], // hide OSD
   ['Z', '0DVHOSD01'], // enable OSD
   ['h', '0PCHM'], // home menu
   ['r', '0PCRTN'], // return
   ['\x1B', '0PCRTN'], // escape return
   ['\x13', '0PCSU'], // CTRL+S Setup
   ['\x14', '0DVTP'], // CTRL+t Top
   ['u', '0DVPU'], // Popup
]);

readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
process.stdin.on('keypress', (str, key) => {
  if (key.ctrl && key.name === 'c') {
    process.exit();
  } else {
  	if (kmap.has(key.sequence)) {
  		var cmd = kmap.get(key.sequence);
		client.write('@'+cmd+"\r");
  	} else {
	    	// nothing, it's not mapped...
	}
  }
});

console.log('Ready');