def prox(long_id, short_id, tag_id=0, action=3, partition_bitmap=0): """action_id = 3 if action.lower() == "away": action_id = 3 elif action.lower() == "home": action_id = 2 elif action.lower() == "disarm": action_id = 1 elif action.lower() == "away_latchkey": action_id = 4 elif action.lower() == "arm_part": action_id = 5 elif action.lower() == "quick_away": action_id = 6 elif action.lower() == "quick_home": action_id = 7 elif action.lower() == "arm_instant": action_id = 8 elif action.lower() == "check_code": action_id = 9 else: print "Wrong event was specified for TAG" sys.exit(0) """ packet = prutils.make_device_packet( long_id, short_id, Config.SET, 73, chr(partition_bitmap) + chr(action) + "\x28\x00\x00\x00\x00" + chr(tag_id) + "\x00\x00\x00", ) return packet
def hello(long_id, short_id, command, notification_period): # command: # 0 - Ping # 1 - Check if enrolled packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 64, chr(command), notification_period) return packet
def volume(long_id, short_id, level): # level: # 1 - lowest level # 254 - highest level packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 96, chr(level)) return packet
def power_mode(long_id, short_id, mode): # mode: # 0 - Power Save # 1 - Active packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 238, chr(mode)) return packet
def change_transmission_privileges(long_id, short_id, restricted_bitmap, timeout_sec): # restricted_bitmap - bitmap of restricted slots (8 bytes): # 0 - not restricted # 1 - slot is restricted for transmission # timeout_sec need to be 2 bytes length timeout_sec = prutils.num_to_chars(timeout_sec, 2) packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 63, restricted_bitmap + timeout_sec) return packet
def file_info(long_id, short_id, film_id, row, file_status, prime_file_id, secondary_file_id, frame_number, file_type,\ film_type, time_stamp, crc, index, zone, file_size, sequence=-1): data = chr(film_id) + chr(row) + chr(file_status) + chr(prime_file_id) + chr(secondary_file_id) + chr(frame_number) + \ chr(file_type) + chr(film_type) + prutils.num_to_chars(time_stamp, 4, 0) + prutils.num_to_chars(crc, 2 ,0) + \ chr(index) + chr(zone) + prutils.num_to_chars(file_size, 2, 0) packet = prutils.make_device_packet(long_id, short_id, Config.REPLY, 181, data, 0, 0, 0, 0, 1, 4, sequence) return packet
def change_listen_mode(long_id, short_id, mode, timeout_sec): # mode: # 0 - Notification Only # 1 - Always Open # 255 - Default # timeout_sec need to be 2 bytes length timeout_sec = prutils.num_to_chars(timeout_sec, 2) packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 61, chr(mode) + timeout_sec) return packet
def change_notification_period(long_id, short_id, mode, timeout_sec): # mode: # 0 - 1 second # 1 - 2 seconds # 2 - 4 seconds # 3 - 8 seconds # 4 - 16 seconds # 5 - 32 seconds # 6 - 64 seconds # 255 - Default # timeout_sec need to be 2 bytes length timeout_sec = prutils.num_to_chars(timeout_sec, 2) packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 62, chr(mode) + timeout_sec) return packet
def change_panel_state(long_id, short_id, part_bitmap, action, user_code): # part_bitmap - Partition (bitmap): # 0 - no Partition # action: # 1 - Disarm # 2 - Arm Home # 3 - Arm Away # 4 - Arm Latchkey # 5 - Arm Part # 6 - Quick Away # 7 - Quick Home # 8 - Arm Instant # 9 - Check Code # user_code - 4 digits user code: # 1st digit sent 1st, example - user code 1234: code byte 0: 0x12, code byte 1: 0x34 # 0xAAAA - no user code user_code = prutils.str_to_bcd(str(user_code)) packet = prutils.make_device_packet( long_id, short_id, Config.REPORT, 69, chr(part_bitmap) + chr(action) + user_code) return packet
def change_panel_state(long_id, short_id, part_bitmap, action, user_code): # part_bitmap - Partition (bitmap): # 0 - no Partition # action: # 1 - Disarm # 2 - Arm Home # 3 - Arm Away # 4 - Arm Latchkey # 5 - Arm Part # 6 - Quick Away # 7 - Quick Home # 8 - Arm Instant # 9 - Check Code # user_code - 4 digits user code: # 1st digit sent 1st, example - user code 1234: code byte 0: 0x12, code byte 1: 0x34 # 0xAAAA - no user code user_code = prutils.str_to_bcd(str(user_code)) packet = prutils.make_device_packet( long_id, short_id, Config.REPORT, 69, chr(part_bitmap) + chr(action) + user_code ) return packet
def file_info( long_id, short_id, film_id, row, file_status, prime_file_id, secondary_file_id, frame_number, file_type, film_type, time_stamp, crc, index, zone, file_size, sequence=-1, ): data = ( chr(film_id) + chr(row) + chr(file_status) + chr(prime_file_id) + chr(secondary_file_id) + chr(frame_number) + chr(file_type) + chr(film_type) + prutils.num_to_chars(time_stamp, 4, 0) + prutils.num_to_chars(crc, 2, 0) + chr(index) + chr(zone) + prutils.num_to_chars(file_size, 2, 0) ) packet = prutils.make_device_packet(long_id, short_id, Config.REPLY, 181, data, 0, 0, 0, 0, 1, 4, sequence) return packet
def film_info( long_id, short_id, film_id, film_status, film_type, pre_alarm_length, post_alarm_length, frame_rate, time_stamp, index, zone, files_amount, ): # film_status: # 0 does not exist # 1 existing, closed and permitted for delete # 2 existing, opened film # 3 existing, closed film # 4 error # print long_id, short_id, film_id, film_status, film_type, pre_alarm_length, post_alarm_length,\ # frame_rate, time_stamp, index, zone, files_amount # return data = chr(film_id) data += chr(film_status) data += chr(film_type) data += chr(pre_alarm_length) data += chr(post_alarm_length) data += chr(frame_rate) data += prutils.num_to_chars(time_stamp, 4, 0) data += chr(index) data += chr(zone) data += chr(files_amount) packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 180, data, 0, 1, 1, 1, 0) return packet
def passive_motion_with_index(long_id, short_id, index): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 19, chr(Config.VIOLATED) + chr(index)) return packet
def fire_alarm(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 34, chr(open)) return packet
def gas_sensor_trouble(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 52, chr(open)) return packet
def jamming(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 48, chr(open)) return packet
def ac_fail(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 41, chr(open)) return packet
def clear_alarm_memory(long_id, short_id): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 239, chr(Config.NO_VALUE)) return packet
def partition(long_id, short_id, partition_bitmap=0): packet = prutils.make_device_packet(long_id, short_id, Config.SET, 118, chr(partition_bitmap)) return packet
def supervision(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 116, chr(open)) return packet
def tamper(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 39, chr(open)) return packet
def aux_simple(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.SET, 74, chr(open)) return packet
def low_battery(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 40, chr(open)) return packet
def smoke_trouble(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 46, chr(open)) return packet
def flood(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 16, chr(open)) return packet
def heat_sensor(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 10, chr(open)) return packet
def device_type(long_id, short_id, type, subtype): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 237, chr(type) + chr(subtype)) return packet
def probe_disconnected(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 50, chr(open)) return packet
def update(long_id, short_id): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 253, chr(Config.NO_VALUE)) return packet
def glass_break(long_id, short_id): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 6, chr(Config.VIOLATED)) return packet
def emergency(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 35, chr(open)) return packet
def aux(long_id, short_id, open): bMask = 0xFF * open # Open all 8 auxilary inputs, according to mask 0b11111111 = 0xFF packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 17, chr(bMask)) return packet
def temperature(long_id, short_id, temperature): temperature = int(((temperature + 40.0) * 2) + 1) packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 24, chr(temperature)) return packet
def aux(long_id, short_id, open): bMask = 0xFF * open #Open all 8 auxilary inputs, according to mask 0b11111111 = 0xFF packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 17, chr(bMask)) return packet
def show_locally_link_quality(long_id, short_id, enable): action = Config.ENABLE if enable == 0: action = Config.DISABLE packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 142, chr(action)) return packet
def switch_magnetic(long_id, short_id, open): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 8, chr(open)) return packet
def active_barrier(long_id, short_id): packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 4, chr(Config.VIOLATED)) return packet