我目前正在开发一个带有考勤管理系统的项目,使用局域网连接的考勤设备,我拥有ZKTeco公司的SC700型号 . 不幸的是,该设备不是't implemented with a web server, so the only way to interact is using the UDP Port 4370. That also means that i can'吨使用这个精彩的图书馆https://github.com/cobisja/tad-php

该项目是自定义的,用PHP编写(Codeigniter 3),我使用github(https://github.com/dnaextrim/php_zklib)的dnaextrim库与设备进行交互 . 到目前为止一切顺利,除了SetUser功能外,一切都很好 . 我可以设置一个新用户,其ID,名称,密码,角色从我的应用程序到设备,但我无法设置他将要使用的卡的RFID .

该函数构建一个74个字符长的字符串,并将其发送到设备,如下所示

function zksetuser($self, $uid, $userid, $name, $password, $role, $card) {
    $command = CMD_SET_USER;
    //$command_string = str_pad(chr( $uid ), 2, chr(0)).chr($role).str_pad($password, 8, chr(0)).str_pad($name, 28, chr(0)).str_pad(chr(1), 9, chr(0)).str_pad($userid, 8, chr(0)).str_repeat(chr(0),16);
    $byte1 = chr((int) ($uid % 256));
    $byte2 = chr((int) ($uid >> 8));

    $command_string = $byte1 . $byte2 . chr($role) . str_pad($password, 8, chr(0)) . str_pad($name, 24, chr(0)) . str_pad($card, 13, chr(0)) . str_pad($userid, 8, chr(0)) . str_repeat(chr(0), 16);

    $chksum = 0;
    $session_id = $self->session_id;

    $u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6/H2h7/H2h8', substr($self->data_recv, 0, 8));
    $reply_id = hexdec($u['h8'] . $u['h7']);

    $buf = $self->createHeader($command, $chksum, $session_id, $reply_id, $command_string);

    socket_sendto($self->zkclient, $buf, strlen($buf), 0, $self->ip, $self->port);

    try {
        @socket_recvfrom($self->zkclient, $self->data_recv, 1024, 0, $self->ip, $self->port);

        $u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6', substr($self->data_recv, 0, 8));

        $self->session_id = hexdec($u['h6'] . $u['h5']);
        return substr($self->data_recv, 8);
    } catch (ErrorException $e) {
        return FALSE;
    } catch (exception $e) {
        return False;
    }
}

参数$ card由我实现,所以我可以传递卡的RFID号码,但问题是设备“转换”我发送的RFID到另一个号码!我无法弄清楚它对这种转换做了什么操作,或者我应该怎么做才能将用户映射到他的RFID卡上 .

有没有人用ZKTeco SC700使用PHP解决了这个问题?