add enable/disable function

This commit is contained in:
Fanani M. Ihsan 2016-05-24 21:49:04 +07:00
parent c0da6b715d
commit 411b2679ef
2 changed files with 22 additions and 0 deletions

View File

@ -9,6 +9,7 @@ print 'Connecting to device ...'
conn = zk.connect()
if conn.get('status'):
print conn
print zk.disable_device()
print 'Firmware Version: : {}'.format(zk.get_firmware_version())
# print 'Restarting device'
# print zk.restart()
@ -23,6 +24,7 @@ if conn.get('status'):
# # level = 'User'
# # print "[UID %d]: ID: %s, Name: %s, Level: %s, Password: %s" % ( uid, users[uid][0], users[uid][1], level, users[uid][3] )
print zk.enable_device()
print 'Disconnecting to device ...'
print zk.disconnect()
# if status:

View File

@ -172,6 +172,26 @@ class ZK(object):
else:
return cmd_response
def disable_device(self):
command = const.CMD_DISABLEDEVICE
cmd_response = self.__send_command(command)
cmd_response['data'] = ''
if cmd_response.get('status'):
cmd_response['message'] = 'device disabled'
return cmd_response
else:
return cmd_response
def enable_device(self):
command = const.CMD_ENABLEDEVICE
cmd_response = self.__send_command(command)
cmd_response['data'] = ''
if cmd_response.get('status'):
cmd_response['message'] = 'device enabled'
return cmd_response
else:
return cmd_response
# def __get_size_user(self):
# """Checks a returned packet to see if it returned CMD_PREPARE_DATA,
# indicating that data packets are to be sent