Update project for new NFC-EXPLORE build
This commit is contained in:
parent
0ae8ec4612
commit
684eb1448b
@ -21,8 +21,10 @@ for my own convenience:
|
|||||||
1. Clone project
|
1. Clone project
|
||||||
2. Copy config.json.sample to config.json
|
2. Copy config.json.sample to config.json
|
||||||
3. Edit config.json for your setup
|
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)
|
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.
|
TODO: Can this be streamlined? Maybe move Makefile commands into `npm` commands.
|
||||||
|
|
||||||
|
17
bin/tag-reader-nfc
Normal file
17
bin/tag-reader-nfc
Normal file
@ -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)
|
@ -12,6 +12,8 @@ module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmit
|
|||||||
|
|
||||||
var emitter = this;
|
var emitter = this;
|
||||||
|
|
||||||
|
this.transform_line = l => l;
|
||||||
|
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.stderrFilters = [];
|
this.stderrFilters = [];
|
||||||
|
|
||||||
@ -32,6 +34,7 @@ module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmit
|
|||||||
var lines = data.toString().split(/\n/g);
|
var lines = data.toString().split(/\n/g);
|
||||||
lines.map(line => line.trim())
|
lines.map(line => line.trim())
|
||||||
.filter(line => line.length)
|
.filter(line => line.length)
|
||||||
|
.map(this.transform_line)
|
||||||
.map(line => this.emit('message', line));
|
.map(line => this.emit('message', line));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -13,7 +13,9 @@ class FileBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
find(tag, callback) {
|
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) {
|
if (files.length > 0) {
|
||||||
return callback(pickRandom(files));
|
return callback(pickRandom(files));
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ const ChildProcessEmitter = require('./child-process').ChildProcessEmitter;
|
|||||||
class TagReader extends ChildProcessEmitter {
|
class TagReader extends ChildProcessEmitter {
|
||||||
constructor(config, logger) {
|
constructor(config, logger) {
|
||||||
super(config.tag_reader, logger);
|
super(config.tag_reader, logger);
|
||||||
|
|
||||||
|
this.transform_line = l => l.toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1 @@
|
|||||||
appdirs==1.4.3
|
nxppy==1.6.0
|
||||||
packaging==16.8
|
|
||||||
pi-rc522==2.1.0
|
|
||||||
pyparsing==2.2.0
|
|
||||||
RPi.GPIO==0.6.3
|
|
||||||
six==1.10.0
|
|
||||||
spidev==3.2
|
|
||||||
|
Loading…
Reference in New Issue
Block a user