bulentv / js_zklib

Attendance Machine Library for NodeJS with a connection to the network using the UDP protocol and port 4370
GNU General Public License v2.0
56 stars 46 forks source link

setUser with rfid card_number #57

Closed ykptke closed 5 years ago

ykptke commented 5 years ago

I didn't find how to set card number.

ykptke commented 5 years ago

I tried this solution and successed. https://github.com/bulentv/js_zklib/blob/master/zklib/zkuser.js#L76-L88

  setUser(uid, password = '', name = '', card_number, user_id, cb) {
    const command_string = Buffer.alloc(72);

    command_string.writeUInt16LE(uid, 0);
    command_string[2] = 0;
    command_string.write(password, 3, 11);
    command_string.write(name, 11, 35);
    command_string.writeUInt32LE(card_number, 35, 39);
    command_string[39] = 1;
    command_string.writeUInt32LE(0, 40);
    command_string.write(user_id ? user_id.toString(10) : '', 48);

    this.executeCmd(Commands.USER_WRQ, command_string, cb);
  }
derit commented 4 years ago

@ykptke if this code works, u can create a pull request for it

csulit commented 4 years ago

@ykptke cardno is the field for card number.