Kodi Play/Pause with an NFC Ring and USB NFC Device

In this example I use a keyduino but you can use any Arduino device that has the PN532 or NFC module loaded on. The Arduino has to just push out the ID of the Ring (or tag) via Serial print. This arrives at ttyACM0 and we then parse it and do some xbmc events..

var fs = require('fs');
var inp = fs.createReadStream("/dev/ttyACM0");
inp.setEncoding('utf8');
var inptext = "";
var XBMCEventClient = require('xbmc-event-client').XBMCEventClient;
var xbmc = new XBMCEventClient('node.js app');

xbmc.connect(function(errors, bytes) {
  inp.on('data', function (data) {
    console.log(data);
    // inptext += data;

    if (errors.length){
      throw errors[0];
    }

    if(data.indexOf("yourringUIDhere") !== -1){
      xbmc.notification('Resuming playback', 'Resuming playback');
      xbmc.keyPress('space');
    };

  });
});

Leave a Reply

Your email address will not be published. Required fields are marked *