Skip to content

Commit 474362b

Browse files
author
Thomas McRoberts
committed
Key set command
1 parent 8a9a9d4 commit 474362b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

osdp/_command.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,31 @@ def data(self) -> bytes:
366366

367367
def custom_command_update(self, command_buffer: bytearray):
368368
pass
369+
370+
class KeySetCommand(Command):
371+
372+
def __init__(self, address: int, scbk: bytes):
373+
self.address = address
374+
self.scbk = scbk
375+
376+
@property
377+
def command_code(self) -> int:
378+
return 0x75
379+
380+
def security_control_block(self) -> bytes:
381+
return bytes([0x02, 0x17])
382+
383+
def data(self) -> bytes:
384+
return self.keyset_data()
385+
386+
def custom_command_update(self, command_buffer: bytearray):
387+
pass
388+
389+
def keyset_data(self):
390+
header = []
391+
type = 0x01
392+
len = 0x10
393+
scbk = [0x41, 0x02, 0x31, 0x84, 0xF1, 0xA2, 0xDE, 0x7C, 0x32, 0x98, 0x01, 0xB8, 0x7B, 0x56, 0xB3, 0x60]
394+
header.append(type)
395+
header.append(len)
396+
return bytes(header + scbk)

osdp/_control_panel.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from ._connection import OsdpConnection
1010
from ._command import (
1111
Command, IdReportCommand, DeviceCapabilitiesCommand, LocalStatusReportCommand, InputStatusReportCommand,
12-
OutputStatusReportCommand, ReaderStatusReportCommand, OutputControlCommand, ReaderLedControlCommand
12+
OutputStatusReportCommand, ReaderStatusReportCommand, OutputControlCommand, ReaderLedControlCommand,
13+
KeySetCommand
1314
)
1415
from ._reply import Reply
1516
from ._bus import Bus
@@ -63,6 +64,11 @@ def reader_led_control(self, connection_id: UUID, address: int, reader_led_contr
6364
reply = self.send_command(connection_id, ReaderLedControlCommand(address, reader_led_controls))
6465
return reply.type == ReplyType.Ack
6566

67+
def keyset(self, connection_id: UUID, address: int) -> bool:
68+
reply = self.send_command(connection_id, KeySetCommand(address, bytes([])))
69+
return reply.type == ReplyType.Ack
70+
71+
6672
def is_online(self, connection_id: UUID, address: int) -> bool:
6773
bus = self._buses.get(connection_id)
6874
if bus is None:

0 commit comments

Comments
 (0)