"channel_device": '/tmp/osdp_mq', } ] key = '01020304050607080910111213141516' commands = [output_cmd, buzzer_cmd, text_cmd, led_cmd, comset_cmd, mfg_cmd] def event_handler(address, event): print("Address: ", address, " Event: ", event) # Print LibOSDP version and source info print("pyosdp", "Version:", osdp.get_version(), "Info:", osdp.get_source_info()) osdp.set_loglevel(6) cp = osdp.ControlPanel(pd_info, master_key=key) cp.set_event_callback(event_handler) count = 0 # loop counter PD_0 = 0 # PD offset number while True: cp.refresh() if (count % 100) == 99 and cp.sc_active(PD_0): # send a random command to the PD_0 r = random.randint(PD_0, len(commands) - 1) cp.send_command(PD_0, commands[r])
# For MFG commands, repply wth MFGREP. Notice that the "command" # is still set be osdp.CMD_MFG. This is because the structure for both # MFG and MFGREP are the same. return { "return_code": 1, "command": osdp.CMD_MFG, "vendor_code": 0x00030201, "mfg_command": 14, "data": bytes([1,2,3,4,5,6,7,8]) } return { "return_code": 0 } # Print LibOSDP version and source info print("pyosdp", "Version:", osdp.get_version(), "Info:", osdp.get_source_info()) osdp.set_loglevel(6) pd = osdp.PeripheralDevice(pd_info, capabilities=pd_cap, scbk=load_scbk()) pd.set_command_callback(handle_command) card_read_event = { "event": osdp.EVENT_CARDREAD, "reader_no": 1, "format": osdp.CARD_FMT_ASCII, "direction": 1, "data": bytes([ord('p'),ord('y'),ord('o'),ord('s'),ord('d'),ord('p')]) } keypress_event = { "event": osdp.EVENT_KEYPRESS,