Skip to content

Commit

Permalink
Renamed set-super-passwords to set-door-passcodes (cf. uhppoted/uhppo…
Browse files Browse the repository at this point in the history
  • Loading branch information
twystd committed Sep 18, 2023
1 parent 6bc8ae4 commit 60e0c9a
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Unreleased

### Added
1. `uhppoted-set-super-passwords` node.
1. `uhppoted-set-door-passcodes` node.

### Updated
1. Fixed input/output labels for renamed nodes.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ _Please see:_
| `set-pc-control` | Delegates access control to an offboard application |
| `set-interlock` | Sets the controller door interlock mode |
| `activate-keypads` | Activates/deactivates the reader access keypads |
| `set-super-passwords` | Sets the supervisor keypad passwords for a door |
| `set-door-passcodes` | Sets the supervisor keypad passcodes for a door |
| `listen` | Establishes a listening connection for controller events |

All nodes take a message with JSON object payload as input and send a message with a JSON object payload as output.
Expand Down
4 changes: 2 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### IN PROGRESS

- [x] set-super-passwords (cf. https://github.com/uhppoted/uhppoted/issues/40)
- [x] `set-super-passwords` node
- [x] set-door-passcodes (cf. https://github.com/uhppoted/uhppoted/issues/40)
- [x] `set-door-passcodes` node
- [x] example
- [x] integration test
- [x] CHANGELOG
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/7-doors.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@
},
{
"id": "d642fe8a140a7ba2",
"type": "uhppoted-set-super-passwords",
"type": "uhppoted-set-door-passcodes",
"z": "86bbf50e.a7f188",
"name": "",
"topic": "",
Expand Down
4 changes: 2 additions & 2 deletions examples/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,7 @@
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"deviceId\":405419896,\"door\":3,\"passwords\":[12345,999999,54321]}",
"payload": "{\"deviceId\":405419896,\"door\":3,\"passcodes\":[12345,999999,54321]}",
"payloadType": "json",
"x": 130,
"y": 700,
Expand Down Expand Up @@ -1877,7 +1877,7 @@
},
{
"id": "d642fe8a140a7ba2",
"type": "uhppoted-set-super-passwords",
"type": "uhppoted-set-door-passcodes",
"z": "86bbf50e.a7f188",
"name": "",
"topic": "",
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/integration-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2892,20 +2892,20 @@
"id": "72aeeecb90ad24f4",
"type": "change",
"z": "de85fbbc.953fc8",
"name": "set-super-passwords",
"name": "set-door-passcodes",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "set-super-passwords",
"to": "set-door-passcodes",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"deviceId\":405419896,\"door\":3,\"passwords\":[12345,999999,54321]}",
"to": "{\"deviceId\":405419896,\"door\":3,\"passcodes\":[12345,999999,54321]}",
"tot": "json"
}
],
Expand All @@ -2924,7 +2924,7 @@
},
{
"id": "343b60a053b57df9",
"type": "uhppoted-set-super-passwords",
"type": "uhppoted-set-door-passcodes",
"z": "de85fbbc.953fc8",
"name": "",
"topic": "",
Expand All @@ -2942,7 +2942,7 @@
"id": "252b172a8418a0f4",
"type": "link out",
"z": "de85fbbc.953fc8",
"name": "set-super-passwords",
"name": "set-door-passcodes",
"mode": "link",
"links": [
"ee75260d.e57f48"
Expand Down
4 changes: 2 additions & 2 deletions nodes/codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const enc = new Map([
[opcodes.SetPCControl, encoder.SetPCControl],
[opcodes.SetInterlock, encoder.SetInterlock],
[opcodes.ActivateKeypads, encoder.ActivateKeypads],
[opcodes.SetSuperPasswords, encoder.SetSuperPasswords]
[opcodes.SetDoorPasscodes, encoder.SetDoorPasscodes]
])

/**
Expand All @@ -60,7 +60,7 @@ const dec = new Map([
[0x98, decoder.GetTimeProfile],
[0x88, decoder.SetTimeProfile],
[0x8a, decoder.ClearTimeProfiles],
[opcodes.SetSuperPasswords, decoder.SetSuperPasswords],
[opcodes.SetDoorPasscodes, decoder.SetDoorPasscodes],
[0x8e, decoder.RecordSpecialEvents],
[0xa0, decoder.SetPCControl],
[0xa2, decoder.SetInterlock],
Expand Down
6 changes: 3 additions & 3 deletions nodes/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,15 +614,15 @@ module.exports = {
},

/**
* Decodes the response to a set-super-passwords request (function code 0x8c).
* Decodes the response to a set-door-passcodes request (function code 0x8c).
*
* @param {buffer} buffer 64 byte NodeJS buffer
* @param {function} translator (optional) function to internationalise the text in a
* decoded object
*
* @param {object} Decoded set-super-passwords response object
* @param {object} Decoded set-door-passcodes response object
*/
SetSuperPasswords: function (bytes, translator) {
SetDoorPasscodes: function (bytes, translator) {
return {
deviceId: uint32(bytes, 4),
ok: bool(bytes, 8)
Expand Down
10 changes: 5 additions & 5 deletions nodes/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,15 +750,15 @@ module.exports = {
},

/**
* Encodes a set-super-passwords request.
* Encodes a set-door-passcodes request.
*
* @param {number} deviceId Controller serial number
* @param {number} door Controller door ID (in the range [1..4])
* @param {array} passwords Array of passwords (in the range [0..999999])
* @param {array} passcodes Array of passcodes (in the range [0..999999])
*
* @return {buffer} 64 byte NodeJS buffer with encoded activate-keypads request.
*/
SetSuperPasswords: function (deviceId, { door, passwords } = {}) {
SetDoorPasscodes: function (deviceId, { door, passcodes } = {}) {
const request = Buffer.alloc(64)

request.writeUInt8(0x17, 0)
Expand All @@ -767,8 +767,8 @@ module.exports = {
request.writeUInt8(door, 8)

for (let i = 0; i < 4; i++) {
if (passwords && passwords.length > i) {
const passcode = passwords[i] > 0 && passwords[i] < 1000000 ? passwords[i] : 0
if (passcodes && passcodes.length > i) {
const passcode = passcodes[i] > 0 && passcodes[i] < 1000000 ? passcodes[i] : 0

request.writeUInt32LE(passcode, 12 + 4 * i)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script type="text/html" data-template-name="uhppoted-set-super-passwords">
<script type="text/html" data-template-name="uhppoted-set-door-passcodes">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i>Name</label>
<input type="text" id="node-input-name" placeholder="Name" />
Expand All @@ -13,13 +13,13 @@
</div>
</script>

<script type="text/html" data-help-name="uhppoted-set-super-passwords">
<p>Sets the supervisor passwords assigned to a door.</p>
<script type="text/html" data-help-name="uhppoted-set-door-passcodes">
<p>Sets the supervisor passcodes assigned to a door.</p>

<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload<span class="property-type">object</span></dt>
<dd>JSON object with the device ID, door and supervisor passwords for 'uhppoted-set-super-password'</dd>
<dd>JSON object with the device ID, door and supervisor passcodes for 'uhppoted-set-door-passcodes'</dd>
<dt class="optional">topic<span class="property-type">string</span></dt>
<dd>identifying message topic for output</dd>
</dl>
Expand All @@ -35,29 +35,29 @@ <h3>Outputs</h3>
<h3>Details</h3>
<p>The input <code>msg.payload</code> is a JSON object containing the access
controller serial number, the door ID and an array of up to four supervisor
passwords to be assigned to the door.</p>
passcodes to be assigned to the door.</p>
<dl class="message-properties">
<dt>deviceId<span class="property-type">uint32</span></dt>
<dd>controller serial number</dd>
<dt>door<span class="property-type">uint8</span></dt>
<dd>door number [1..4]</dd>
<dt>passwords<span class="property-type">array</span></dt>
<dd>array of passwords in the range [1..999999]</dd>
<dt>passcodes<span class="property-type">array</span></dt>
<dd>array of passcodes in the range [1..999999]</dd>
</dl>
<h4>Example:</h4>
<pre>
{
"deviceId": 405419896,
"door": 4,
"passwords": [ 12345, 999999, 54321 ]
"passcodes": [ 12345, 999999, 54321 ]
}</pre>

<p>The output is a JSON object containing the success/failure result.</p>
<dl class="message-properties">
<dt>deviceId<span class="property-type">uint32</span></dt>
<dd>controller serial number</dd>
<dt>ok<span class="property-type">boolean</span></dt>
<dd>true if the supervisor passwords were assigned to the door</dd>
<dd>true if the supervisor passcodes were assigned to the door</dd>
</dl>
<h4>Example:</h4>
<pre>
Expand Down
6 changes: 6 additions & 0 deletions nodes/locales/en-US/uhppoted-set-door-passcodes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"uhppoted-set-door-passcodes": {
"inputLabel": "controller ID\ndoor\passcodes",
"outputLabel": "passcodes updated"
}
}
6 changes: 0 additions & 6 deletions nodes/locales/en-US/uhppoted-set-super-passwords.json

This file was deleted.

2 changes: 1 addition & 1 deletion nodes/opcodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
GetTimeProfile: 0x98,
SetTimeProfile: 0x88,
ClearTimeProfiles: 0x8a,
SetSuperPasswords: 0x8c,
SetDoorPasscodes: 0x8c,
SetPCControl: 0xa0,
SetInterlock: 0xa2,
ActivateKeypads: 0xa4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script type="text/javascript">
RED.nodes.registerType('uhppoted-set-super-passwords', {
RED.nodes.registerType('uhppoted-set-door-passcodes', {
category: 'uhppoted',
color: '#A6BBCF',
defaults: {
Expand All @@ -18,10 +18,10 @@
outputs: 1,
icon: 'icons/uhppoted.svg',
label: function() {
return this.name || 'set-super-passwords';
return this.name || 'set-door-passcodes';
},
paletteLabel: 'set-super-passwords',
inputLabels: function(index) { return this._('uhppoted-set-super-passwords.inputLabel') },
outputLabels: function(index) { return this._('uhppoted-set-super-passwords.outputLabel') }
paletteLabel: 'set-door-passcodes',
inputLabels: function(index) { return this._('uhppoted-set-door-passcodes.inputLabel') },
outputLabels: function(index) { return this._('uhppoted-set-door-passcodes.outputLabel') }
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = function (RED) {
const uhppoted = require('./uhppoted.js')
const opcodes = require('../nodes/opcodes.js')

function SetSuperPasswordsNode (config) {
function SetDoorPasscodesNode (config) {
RED.nodes.createNode(this, config)

const node = this
Expand All @@ -18,10 +18,10 @@ module.exports = function (RED) {
const door = msg.payload.door
const passcodes = [0, 0, 0, 0]

if (msg.payload.passwords) {
for (const [ix, password] of msg.payload.passwords.entries()) {
if (ix < 4 && password > 0 && password < 1000000) {
passcodes[ix] = password
if (msg.payload.passcodes) {
for (const [ix, code] of msg.payload.passcodes.entries()) {
if (ix < 4 && code > 0 && code < 1000000) {
passcodes[ix] = code
}
}
}
Expand All @@ -37,13 +37,13 @@ module.exports = function (RED) {
try {
const context = {
config: uhppote,
translator: (k) => { return RED._('put-card.' + k) },
translator: (k) => { return RED._('set-door-passcodes.' + k) },
logger: (m) => { node.log(m) }
}

uhppoted.set(context, deviceId, opcodes.SetSuperPasswords, {
uhppoted.set(context, deviceId, opcodes.SetDoorPasscodes, {
door,
passwords: passcodes
passcodes
})
.then(object => { emit(object) })
.then(done())
Expand All @@ -52,5 +52,5 @@ module.exports = function (RED) {
})
}

RED.nodes.registerType('uhppoted-set-super-passwords', SetSuperPasswordsNode)
RED.nodes.registerType('uhppoted-set-door-passcodes', SetDoorPasscodesNode)
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"uhppoted-set-pc-control": "nodes/uhppoted-set-pc-control.js",
"uhppoted-set-interlock": "nodes/uhppoted-set-interlock.js",
"uhppoted-activate-keypads": "nodes/uhppoted-activate-keypads.js",
"uhppoted-set-super-passwords": "nodes/uhppoted-set-super-passwords.js",
"uhppoted-set-door-passcodes": "nodes/uhppoted-set-door-passcodes.js",
"uhppoted-listen": "nodes/uhppoted-listen.js"
}
},
Expand Down
6 changes: 3 additions & 3 deletions test/codec_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,15 @@ describe('codec', function () {
expect(bytes).to.deep.equal(msg)
})

it('should encode set-super-passwords request', function () {
it('should encode set-door-passcodes request', function () {
const msg = Buffer.from([
0x17, 0x8c, 0x00, 0x00, 0x78, 0x37, 0x2a, 0x18, 0x03, 0x00, 0x00, 0x00, 0x39, 0x30, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3f, 0x42, 0x0f, 0x00, 0x31, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
])

const bytes = codec.encode(opcodes.SetSuperPasswords, 405419896, { door: 3, passwords: [12345, 0, 999999, 54321] })
const bytes = codec.encode(opcodes.SetDoorPasscodes, 405419896, { door: 3, passcodes: [12345, 0, 999999, 54321] })

expect(bytes).to.deep.equal(msg)
})
Expand Down Expand Up @@ -1646,7 +1646,7 @@ describe('codec', function () {
expect(object).to.deep.equal(expected)
})

it('should decode set-super-passwords response', function () {
it('should decode set-door-passcodes response', function () {
const expected = {
deviceId: 405419896,
ok: true
Expand Down

0 comments on commit 60e0c9a

Please sign in to comment.