diff --git a/README.md b/README.md index 0bf92b8..54e9f00 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,10 @@ for my own convenience: 1. Clone project 2. Copy config.json.sample to config.json 3. Edit config.json for your setup +4. [Install Node.js](https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions) 4. `npm install` (node.js dependencies) -5. `make all` (Python dependencies, mpg321 dependency) +5. `virtualenv lib` # make a python virtualenv +6. `lib/bin/pip install -r requirements.txt` TODO: Can this be streamlined? Maybe move Makefile commands into `npm` commands. diff --git a/bin/tag-reader-nfc b/bin/tag-reader-nfc new file mode 100644 index 0000000..3025377 --- /dev/null +++ b/bin/tag-reader-nfc @@ -0,0 +1,17 @@ +import nxppy +import time +import sys + +mifare = nxppy.Mifare() + +# Print card UIDs as they are detected +while True: + try: + uid = mifare.select() + print(uid) + sys.stdout.flush() + except nxppy.SelectError: + # SelectError is raised if no card is in the field. + pass + + time.sleep(1) diff --git a/jukebox/child-process.js b/jukebox/child-process.js index b395af1..5de1431 100644 --- a/jukebox/child-process.js +++ b/jukebox/child-process.js @@ -12,6 +12,8 @@ module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmit var emitter = this; + this.transform_line = l => l; + this.logger = logger; this.stderrFilters = []; @@ -32,6 +34,7 @@ module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmit var lines = data.toString().split(/\n/g); lines.map(line => line.trim()) .filter(line => line.length) + .map(this.transform_line) .map(line => this.emit('message', line)); }); diff --git a/jukebox/library/file-backend.js b/jukebox/library/file-backend.js index a6d2c37..5f293ff 100644 --- a/jukebox/library/file-backend.js +++ b/jukebox/library/file-backend.js @@ -13,7 +13,9 @@ class FileBackend { } find(tag, callback) { - glob(this.config.media_path + '/**/' + tag + ' - *.mp3', (err, files) => { + // add extra * glob to the end of the file: old tag-reader got 10 + // character uids, new one gets 8 character for the same cards + glob(this.config.media_path + '/**/' + tag + '* - *.mp3', (err, files) => { if (files.length > 0) { return callback(pickRandom(files)); } diff --git a/jukebox/tag-reader.js b/jukebox/tag-reader.js index e87b91a..ee9327a 100644 --- a/jukebox/tag-reader.js +++ b/jukebox/tag-reader.js @@ -5,6 +5,8 @@ const ChildProcessEmitter = require('./child-process').ChildProcessEmitter; class TagReader extends ChildProcessEmitter { constructor(config, logger) { super(config.tag_reader, logger); + + this.transform_line = l => l.toLowerCase(); } } diff --git a/requirements.txt b/requirements.txt index f8a6d60..c76e0e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1 @@ -appdirs==1.4.3 -packaging==16.8 -pi-rc522==2.1.0 -pyparsing==2.2.0 -RPi.GPIO==0.6.3 -six==1.10.0 -spidev==3.2 +nxppy==1.6.0