I am currently building a driver for one of my RFID keypads and I am having a bit of trouble understanding how the function userCodeSet
is handling the the userCode
parameter.
My device is expecting the userCode (RFID Identifier) to be sent over zwave as a 10 hex pairs string, but when using the HE function the userCode is getting converted incorrectly.
I have setup a small code snippet to try and debug / understand what is happening:
Raw ZWave Command:
def rx_rfid = [143, 182, 75, 40, 133, 80, 1, 4, 0, 0] as byte[] // Received RFID Identifier
def code = new BigInteger(rx_rfid, 16)
def raw_cmd = [ 0x63, // User Code Command Class
0x01, // User Code Set Command
3, // User Slot
1, // UserCodeSet.USER_ID_STATUS_OCCUPIED
code
]
raw_cmd = raw_cmd.collect { String.format("%02x", it).toUpperCase() }.join('')
println raw_cmd // 630103018FB64B28855001040000
HE ZWave Command:
def he_cmd = zwave.userCodeV1.userCodeSet(userIdentifier: 3, userIdStatus: UserCodeSet.USER_ID_STATUS_OCCUPIED, userCode: [143, 182, 75, 40, 133, 80, 1, 4, 0, 0] as byte[]).format()
log.info he_cmd
Execution #1: 630103015B42403435653130633233
Execution #2: 630103015B42403230383032653139
Now if we compare the Raw commands we see that they both start as expected with `63010301` but then the rest of the code just gets converted in a strange way. Another thing I also don't get is that at every execution the raw command is different even if I don't change the function input parameters.
Questions:
- What is the expected or possible types / formats of the
userCode
parameter? - Why is the raw command changing at every execution?
- Is it currently possible to make the function
userCodeSet
work as I described on the Raw ZWave Command section?
I would prefer to use internal CC instead of having to construction my own raw commands.
Thanks in advance for any help, Seb