Skip to content

Commit

Permalink
power off, restart and other method added
Browse files Browse the repository at this point in the history
  • Loading branch information
raihanafroz committed Nov 21, 2021
1 parent 92b2256 commit 9437cc4
Show file tree
Hide file tree
Showing 4 changed files with 627 additions and 408 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,46 @@ The package will automatically register itself.
$zk->osVersion();
```

* __Power Off__
```php
// turn off the device
// this return bool/mixed

$zk->shutdown();
```

* __Restart__
```php
// restart the device
// this return bool/mixed

$zk->restart();
```

* __Sleep__
```php
// sleep the device
// this return bool/mixed

$zk->sleep();
```

* __Resume__
```php
// resume the device from sleep
// this return bool/mixed

$zk->resume();
```

* __Voice Test__
```php
// voice test of the device "Thank you"
// this return bool/mixed

$zk->testVoice();
```

* __Platform__
```php
// get platform
Expand Down
183 changes: 142 additions & 41 deletions src/Lib/Helper/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,146 @@

class Device
{
/**
* @param ZKTeco $self
* @return bool|mixed
*/
static public function name(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_DEVICE;
$command_string = '~DeviceName';

return $self->_command($command, $command_string);
}

/**
* @param ZKTeco $self
* @return bool|mixed
*/
static public function enable(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_ENABLE_DEVICE;
$command_string = '';

return $self->_command($command, $command_string);
}

/**
* @param ZKTeco $self
* @return bool|mixed
*/
static public function disable(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_DISABLE_DEVICE;
$command_string = chr(0) . chr(0);

return $self->_command($command, $command_string);
}
/**
* @param ZKTeco $self
* @return bool|mixed
*/
static public function name(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_DEVICE;
$command_string = '~DeviceName';

return $self->_command($command, $command_string);
}

/**
* @param ZKTeco $self
* @return bool|mixed
*/
static public function enable(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_ENABLE_DEVICE;
$command_string = '';

return $self->_command($command, $command_string);
}

/**
* @param ZKTeco $self
* @return bool|mixed
*/
static public function disable(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_DISABLE_DEVICE;
$command_string = chr(0) . chr(0);

return $self->_command($command, $command_string);
}

/**
* @param ZKTeco $self
* @return bool|mixed *** this will turn off the device
*/
public static function powerOff(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_POWEROFF;
$command_string = chr(0) . chr(0);
return $self->_command($command, $command_string);
}


/**
* @param ZKTeco $self
* @return bool|mixed *** this will restart the device
*/
public static function restart(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_RESTART;
$command_string = chr(0) . chr(0);
return $self->_command($command, $command_string);
}


/**
* @param ZKTeco $self
* @return bool|mixed *** this will sleep the device
*/
public static function sleep(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_SLEEP;
$command_string = chr(0) . chr(0);
return $self->_command($command, $command_string);
}


/**
* @param ZKTeco $self
* @return bool|mixed *** this will resume the device from sleep
*/
public static function resume(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_RESUME;
$command_string = chr(0) . chr(0);
return $self->_command($command, $command_string);
}


/**
* @param ZKTeco $self
* @return bool|mixed *** this will play voice "Thank you"
*/
public static function testVoice(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_TESTVOICE;
$command_string = chr(0) . chr(0);
return $self->_command($command, $command_string);
}


/**
* @param ZKTeco $self
* @return bool|mixed *** this will clear the LCD screen
*/
public static function clearLCD(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_CLEAR_LCD;
return $self->_command($command, '');
}


/**
* @param ZKTeco $self
* @param $rank *** Line number of text
* @param $text *** Text which will display in the LCD screen
* @return bool|mixed *** this will write text into the LCD
*/
public static function writeLCD(ZKTeco $self, $rank, $text)
{
$self->_section = __METHOD__;

$command = Util::CMD_WRITE_LCD;
$byte1 = chr((int)($rank % 256));
$byte2 = chr((int)($rank >> 8));
$byte3 = chr(0);
$command_string = $byte1.$byte2.$byte3.' '.$text;
return $self->_command($command, $command_string);
}
}
Loading

0 comments on commit 9437cc4

Please sign in to comment.