node-red-contrib-periph-rfid 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/examples/st25dv/demo.json +113 -0
- package/nodes/st25dv/st25dv.html +94 -0
- package/nodes/st25dv/st25dv.js +72 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# node-red-contrib-periph-rfid
|
|
2
2
|
|
|
3
|
-
Node-RED nodes for RFID and NFC peripheral chips: MFRC522, PN532 — part of the [Periph](https://github.com/tuhde/Periph) library.
|
|
3
|
+
Node-RED nodes for RFID and NFC peripheral chips: MFRC522, PN532, ST25DV — part of the [Periph](https://github.com/tuhde/Periph) library.
|
|
4
4
|
|
|
5
|
-
**Supported chips (
|
|
5
|
+
**Supported chips (3):** MFRC522, PN532, ST25DV.
|
|
6
6
|
|
|
7
7
|
Each chip has a sensor/actuator node plus a shared `-device` config node that holds the bus settings. Importable example flows are in [`examples/`](https://github.com/tuhde/Periph/tree/main/nodejs/packages/node-red-contrib-periph-rfid/examples).
|
|
8
8
|
|
|
@@ -24,6 +24,8 @@ npm install node-red-contrib-periph-rfid
|
|
|
24
24
|
| `mfrc522` | input | Detects ISO/IEC 14443 Type A cards in the field of an NXP MFRC522 13.56 MHz RFID/NFC reader and reads their UID. The node polls the chip on the configured interval and only emits a message when the card state changes (card inserted, removed, or a different card presented). |
|
|
25
25
|
| `pn532-device` | config | Bus configuration for a PN532 |
|
|
26
26
|
| `pn532` | input | Detects an ISO/IEC 14443 A card or tag (MIFARE, NTAG) with an NXP PN532 NFC controller over I²C (address 0x24) and outputs its UID, one detection per message. |
|
|
27
|
+
| `st25dv-device` | config | I²C bus and address for a ST25DV |
|
|
28
|
+
| `st25dv` | input | Reads and writes the user EEPROM of an ST25DV04K/16K/64K dynamic NFC tag over I²C, and stores an NDEF message that an NFC phone can read. The tag stays readable by RF readers while the host uses it. |
|
|
27
29
|
|
|
28
30
|
## Links
|
|
29
31
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-st25dv-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "ST25DV NFC Memory",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Shares data between Node-RED and an NFC phone through an ST25DV dynamic tag. The first inject writes the text \"Hello NFC\" (hex string 48656C6C6F204E4643) to user memory at address 0x0100; the debug node shows the address and the number of bytes written. The second inject reads the 9 bytes back. The third inject stores the same text as an NDEF text record, which a phone reads when held to the antenna. Adjust the bus and the two addresses (0x53 memory, 0x57 system) in the st25dv-device config node."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "cfg-st25dv",
|
|
11
|
+
"type": "st25dv-device",
|
|
12
|
+
"name": "ST25DV",
|
|
13
|
+
"bus": "1",
|
|
14
|
+
"address": "53",
|
|
15
|
+
"systemAddress": "57"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "inj-write",
|
|
19
|
+
"type": "inject",
|
|
20
|
+
"name": "write \"Hello NFC\"",
|
|
21
|
+
"props": [{ "p": "payload" }],
|
|
22
|
+
"repeat": "",
|
|
23
|
+
"crontab": "",
|
|
24
|
+
"once": false,
|
|
25
|
+
"onceDelay": 0.1,
|
|
26
|
+
"topic": "",
|
|
27
|
+
"payload": "{\"address\":256,\"data\":\"48656C6C6F204E4643\"}",
|
|
28
|
+
"payloadType": "json",
|
|
29
|
+
"z": "tab-st25dv-demo",
|
|
30
|
+
"x": 150,
|
|
31
|
+
"y": 100,
|
|
32
|
+
"wires": [["st-write"]]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "st-write",
|
|
36
|
+
"type": "st25dv",
|
|
37
|
+
"name": "Write memory",
|
|
38
|
+
"device": "cfg-st25dv",
|
|
39
|
+
"z": "tab-st25dv-demo",
|
|
40
|
+
"x": 360,
|
|
41
|
+
"y": 100,
|
|
42
|
+
"wires": [["dbg"]]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "inj-read",
|
|
46
|
+
"type": "inject",
|
|
47
|
+
"name": "read 9 bytes",
|
|
48
|
+
"props": [{ "p": "payload" }],
|
|
49
|
+
"repeat": "",
|
|
50
|
+
"crontab": "",
|
|
51
|
+
"once": false,
|
|
52
|
+
"onceDelay": 0.1,
|
|
53
|
+
"topic": "",
|
|
54
|
+
"payload": "{\"address\":256,\"length\":9}",
|
|
55
|
+
"payloadType": "json",
|
|
56
|
+
"z": "tab-st25dv-demo",
|
|
57
|
+
"x": 140,
|
|
58
|
+
"y": 160,
|
|
59
|
+
"wires": [["st-read"]]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"id": "st-read",
|
|
63
|
+
"type": "st25dv",
|
|
64
|
+
"name": "Read memory",
|
|
65
|
+
"device": "cfg-st25dv",
|
|
66
|
+
"z": "tab-st25dv-demo",
|
|
67
|
+
"x": 360,
|
|
68
|
+
"y": 160,
|
|
69
|
+
"wires": [["dbg"]]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "inj-ndef",
|
|
73
|
+
"type": "inject",
|
|
74
|
+
"name": "NDEF text \"Hello NFC\"",
|
|
75
|
+
"props": [{ "p": "payload" }],
|
|
76
|
+
"repeat": "",
|
|
77
|
+
"crontab": "",
|
|
78
|
+
"once": false,
|
|
79
|
+
"onceDelay": 0.1,
|
|
80
|
+
"topic": "",
|
|
81
|
+
"payload": "{\"ndef\":\"D1010C5402656E48656C6C6F204E4643\"}",
|
|
82
|
+
"payloadType": "json",
|
|
83
|
+
"z": "tab-st25dv-demo",
|
|
84
|
+
"x": 160,
|
|
85
|
+
"y": 220,
|
|
86
|
+
"wires": [["st-ndef"]]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "st-ndef",
|
|
90
|
+
"type": "st25dv",
|
|
91
|
+
"name": "Write NDEF",
|
|
92
|
+
"device": "cfg-st25dv",
|
|
93
|
+
"z": "tab-st25dv-demo",
|
|
94
|
+
"x": 360,
|
|
95
|
+
"y": 220,
|
|
96
|
+
"wires": [["dbg"]]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"id": "dbg",
|
|
100
|
+
"type": "debug",
|
|
101
|
+
"name": "ST25DV result",
|
|
102
|
+
"active": true,
|
|
103
|
+
"tosidebar": true,
|
|
104
|
+
"console": false,
|
|
105
|
+
"tostatus": false,
|
|
106
|
+
"complete": "payload",
|
|
107
|
+
"targetType": "msg",
|
|
108
|
+
"z": "tab-st25dv-demo",
|
|
109
|
+
"x": 580,
|
|
110
|
+
"y": 160,
|
|
111
|
+
"wires": []
|
|
112
|
+
}
|
|
113
|
+
]
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('st25dv-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '53', required: true },
|
|
9
|
+
systemAddress: { value: '57', required: true }
|
|
10
|
+
},
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || ('ST25DV @ 0x' + this.address + '/0x' + this.systemAddress + ' (bus ' + this.bus + ')');
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="st25dv-device">
|
|
18
|
+
<div class="form-row">
|
|
19
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
20
|
+
<input type="text" id="node-config-input-name" placeholder="ST25DV">
|
|
21
|
+
</div>
|
|
22
|
+
<div class="form-row">
|
|
23
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
24
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
25
|
+
</div>
|
|
26
|
+
<div class="form-row">
|
|
27
|
+
<label for="node-config-input-address"><i class="fa fa-hashtag"></i> Memory address (hex)</label>
|
|
28
|
+
<input type="text" id="node-config-input-address" style="width:80px"> (user memory, default 53)
|
|
29
|
+
</div>
|
|
30
|
+
<div class="form-row">
|
|
31
|
+
<label for="node-config-input-systemAddress"><i class="fa fa-hashtag"></i> System address (hex)</label>
|
|
32
|
+
<input type="text" id="node-config-input-systemAddress" style="width:80px"> (system area, default 57)
|
|
33
|
+
</div>
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<!-- Flow node -->
|
|
37
|
+
<script type="text/javascript">
|
|
38
|
+
RED.nodes.registerType('st25dv', {
|
|
39
|
+
category: 'Peripheral',
|
|
40
|
+
color: '#C084FC',
|
|
41
|
+
defaults: {
|
|
42
|
+
name: { value: '' },
|
|
43
|
+
device: { value: '', type: 'st25dv-device', required: true }
|
|
44
|
+
},
|
|
45
|
+
inputs: 1,
|
|
46
|
+
outputs: 1,
|
|
47
|
+
icon: 'bridge.svg',
|
|
48
|
+
label: function() { return this.name || 'ST25DV'; },
|
|
49
|
+
paletteLabel: 'ST25DV'
|
|
50
|
+
});
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<script type="text/html" data-template-name="st25dv">
|
|
54
|
+
<div class="form-row">
|
|
55
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
56
|
+
<input type="text" id="node-input-name" placeholder="ST25DV">
|
|
57
|
+
</div>
|
|
58
|
+
<div class="form-row">
|
|
59
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
60
|
+
<input type="text" id="node-input-device">
|
|
61
|
+
</div>
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<script type="text/html" data-help-name="st25dv">
|
|
65
|
+
<p>Reads and writes the user EEPROM of an ST25DV04K/16K/64K dynamic NFC tag over I²C, and
|
|
66
|
+
stores an NDEF message that an NFC phone can read. The tag stays readable by RF readers while the
|
|
67
|
+
host uses it.</p>
|
|
68
|
+
<h3>Inputs</h3>
|
|
69
|
+
<dl class="message-properties">
|
|
70
|
+
<dt>payload.address <span class="property-type">number</span></dt>
|
|
71
|
+
<dd>Start byte address in user memory (default 0).</dd>
|
|
72
|
+
<dt class="optional">payload.length <span class="property-type">number</span></dt>
|
|
73
|
+
<dd>Without <code>data</code> or <code>ndef</code>: read this many bytes (default 16).</dd>
|
|
74
|
+
<dt class="optional">payload.data <span class="property-type">array | string</span></dt>
|
|
75
|
+
<dd>Write these bytes (byte array or hex string) starting at <code>address</code>.</dd>
|
|
76
|
+
<dt class="optional">payload.ndef <span class="property-type">array | string | boolean</span></dt>
|
|
77
|
+
<dd>Write this NDEF message (byte array or hex string) with a Type 5 capability container;
|
|
78
|
+
<code>true</code> only reads the stored message.</dd>
|
|
79
|
+
</dl>
|
|
80
|
+
<h3>Outputs</h3>
|
|
81
|
+
<dl class="message-properties">
|
|
82
|
+
<dt>payload.data <span class="property-type">array</span></dt>
|
|
83
|
+
<dd>Read: the bytes, with <code>payload.address</code>.</dd>
|
|
84
|
+
<dt>payload.written <span class="property-type">number</span></dt>
|
|
85
|
+
<dd>Write: number of bytes written, with <code>payload.address</code>.</dd>
|
|
86
|
+
<dt>payload.ndef <span class="property-type">array</span></dt>
|
|
87
|
+
<dd>NDEF: the message stored on the tag (empty if none).</dd>
|
|
88
|
+
</dl>
|
|
89
|
+
<h3>Configuration</h3>
|
|
90
|
+
<p>The <b>st25dv-device</b> config node sets the I²C bus number and the chip's two addresses: the
|
|
91
|
+
user memory / dynamic register address (default <code>0x53</code>) and the system area address
|
|
92
|
+
(default <code>0x57</code>). Writes are split into 16-byte-aligned pieces and wait for each
|
|
93
|
+
EEPROM write cycle.</p>
|
|
94
|
+
</script>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { ST25DVFull } = require('periph/src/chips/rfid/st25dv');
|
|
6
|
+
|
|
7
|
+
function toBytes(data) {
|
|
8
|
+
if (typeof data === 'string') return Buffer.from(data.replace(/\s+/g, ''), 'hex');
|
|
9
|
+
return Buffer.from(data || []);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function ST25DVDeviceNode(config) {
|
|
13
|
+
RED.nodes.createNode(this, config);
|
|
14
|
+
const node = this;
|
|
15
|
+
try {
|
|
16
|
+
const bus = parseInt(config.bus);
|
|
17
|
+
const user = new I2CConnection(bus, parseInt(config.address, 16) || 0x53, null, null, 2);
|
|
18
|
+
const system = new I2CConnection(bus, parseInt(config.systemAddress, 16) || 0x57, null, null, 2);
|
|
19
|
+
node.connections = [user, system];
|
|
20
|
+
node.driver = new ST25DVFull(user, system);
|
|
21
|
+
node.ready = node.driver.init();
|
|
22
|
+
node.ready.catch((e) => {
|
|
23
|
+
node.error('ST25DV init failed: ' + e.message);
|
|
24
|
+
});
|
|
25
|
+
} catch (e) {
|
|
26
|
+
node.error('ST25DV init failed: ' + e.message);
|
|
27
|
+
}
|
|
28
|
+
node.on('close', function() {
|
|
29
|
+
if (node.connections) node.connections.forEach((c) => c.close());
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
RED.nodes.registerType('st25dv-device', ST25DVDeviceNode);
|
|
33
|
+
|
|
34
|
+
function ST25DVNode(config) {
|
|
35
|
+
RED.nodes.createNode(this, config);
|
|
36
|
+
const node = this;
|
|
37
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
38
|
+
|
|
39
|
+
node.on('input', async function(msg, send, done) {
|
|
40
|
+
if (!deviceNode.driver) {
|
|
41
|
+
node.error('No ST25DV device configured', msg);
|
|
42
|
+
done();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
await deviceNode.ready;
|
|
47
|
+
const d = deviceNode.driver;
|
|
48
|
+
const p = (msg.payload && typeof msg.payload === 'object' && !Array.isArray(msg.payload)) ? msg.payload : {};
|
|
49
|
+
if ('ndef' in p) {
|
|
50
|
+
if (p.ndef !== true && p.ndef != null && toBytes(p.ndef).length) {
|
|
51
|
+
await d.writeNdef(toBytes(p.ndef));
|
|
52
|
+
}
|
|
53
|
+
msg.payload = { ndef: Array.from(await d.readNdef()) };
|
|
54
|
+
} else if (p.data != null) {
|
|
55
|
+
const address = p.address || 0;
|
|
56
|
+
const data = toBytes(p.data);
|
|
57
|
+
await d.write(address, data);
|
|
58
|
+
msg.payload = { address, written: data.length };
|
|
59
|
+
} else {
|
|
60
|
+
const address = p.address || 0;
|
|
61
|
+
const length = p.length != null ? p.length : 16;
|
|
62
|
+
msg.payload = { address, data: Array.from(await d.read(address, length)) };
|
|
63
|
+
}
|
|
64
|
+
send(msg);
|
|
65
|
+
done();
|
|
66
|
+
} catch (e) {
|
|
67
|
+
done(e);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
RED.nodes.registerType('st25dv', ST25DVNode);
|
|
72
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-periph-rfid",
|
|
3
|
-
"version": "1.6.
|
|
4
|
-
"description": "Node-RED nodes for RFID and NFC peripheral chips: MFRC522, PN532",
|
|
3
|
+
"version": "1.6.1",
|
|
4
|
+
"description": "Node-RED nodes for RFID and NFC peripheral chips: MFRC522, PN532, ST25DV",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
7
7
|
"rfid",
|
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
"peripheral",
|
|
12
12
|
"node-red-contrib",
|
|
13
13
|
"mfrc522",
|
|
14
|
-
"pn532"
|
|
14
|
+
"pn532",
|
|
15
|
+
"st25dv"
|
|
15
16
|
],
|
|
16
17
|
"node-red": {
|
|
17
18
|
"version": ">=3.0.0",
|
|
18
19
|
"nodes": {
|
|
19
20
|
"mfrc522": "nodes/mfrc522/mfrc522.js",
|
|
20
|
-
"pn532": "nodes/pn532/pn532.js"
|
|
21
|
+
"pn532": "nodes/pn532/pn532.js",
|
|
22
|
+
"st25dv": "nodes/st25dv/st25dv.js"
|
|
21
23
|
}
|
|
22
24
|
},
|
|
23
25
|
"dependencies": {
|