Esempio n. 1
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 2
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 3
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 4
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 5
0
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
Esempio n. 6
0
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
Esempio n. 7
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 8
0
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
Esempio n. 9
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 10
0
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
Esempio n. 11
0
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
Esempio n. 12
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 13
0
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
Esempio n. 14
0
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
Esempio n. 15
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 16
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 17
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 18
0
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
Esempio n. 19
0
def fire_alarm(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 34,
                                        chr(open))
    return packet
Esempio n. 20
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 21
0
File: dpr.py Progetto: AlexKano/pmax
def jamming(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 48, chr(open))
    return packet
Esempio n. 22
0
File: dpr.py Progetto: AlexKano/pmax
def ac_fail(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 41, chr(open))
    return packet
Esempio n. 23
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 24
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 25
0
def supervision(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 116,
                                        chr(open))
    return packet
Esempio n. 26
0
def tamper(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 39,
                                        chr(open))
    return packet
Esempio n. 27
0
def aux_simple(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.SET, 74,
                                        chr(open))
    return packet
Esempio n. 28
0
def low_battery(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 40,
                                        chr(open))
    return packet
Esempio n. 29
0
def ac_fail(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 41,
                                        chr(open))
    return packet
Esempio n. 30
0
def smoke_trouble(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 46,
                                        chr(open))
    return packet
Esempio n. 31
0
def jamming(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 48,
                                        chr(open))
    return packet
Esempio n. 32
0
def flood(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 16,
                                        chr(open))
    return packet
Esempio n. 33
0
def heat_sensor(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 10,
                                        chr(open))
    return packet
Esempio n. 34
0
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
Esempio n. 35
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 36
0
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
Esempio n. 37
0
def probe_disconnected(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 50,
                                        chr(open))
    return packet
Esempio n. 38
0
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
Esempio n. 39
0
File: dpr.py Progetto: AlexKano/pmax
def smoke_trouble(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 46, chr(open))
    return packet
Esempio n. 40
0
def update(long_id, short_id):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 253,
                                        chr(Config.NO_VALUE))
    return packet
Esempio n. 41
0
File: dpr.py Progetto: AlexKano/pmax
def probe_disconnected(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 50, chr(open))
    return packet
Esempio n. 42
0
def glass_break(long_id, short_id):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 6,
                                        chr(Config.VIOLATED))
    return packet
Esempio n. 43
0
def emergency(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 35,
                                        chr(open))
    return packet
Esempio n. 44
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 45
0
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
Esempio n. 46
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 47
0
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
Esempio n. 48
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 49
0
File: dpr.py Progetto: AlexKano/pmax
def aux_simple(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.SET, 74, chr(open))
    return packet
Esempio n. 50
0
File: dpr.py Progetto: AlexKano/pmax
def fire_alarm(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 34, chr(open))
    return packet
Esempio n. 51
0
File: dpr.py Progetto: AlexKano/pmax
def supervision(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 116, chr(open))
    return packet
Esempio n. 52
0
File: dpr.py Progetto: AlexKano/pmax
def emergency(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 35, chr(open))
    return packet
Esempio n. 53
0
File: dpr.py Progetto: AlexKano/pmax
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
Esempio n. 54
0
File: dpr.py Progetto: AlexKano/pmax
def tamper(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 39, chr(open))
    return packet
Esempio n. 55
0
def switch_magnetic(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 8,
                                        chr(open))
    return packet
Esempio n. 56
0
File: dpr.py Progetto: AlexKano/pmax
def low_battery(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 40, chr(open))
    return packet
Esempio n. 57
0
File: dpr.py Progetto: AlexKano/pmax
def update(long_id, short_id):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 253, chr(Config.NO_VALUE))
    return packet
Esempio n. 58
0
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
Esempio n. 59
0
File: dpr.py Progetto: AlexKano/pmax
def flood(long_id, short_id, open):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 16, chr(open))
    return packet
Esempio n. 60
0
def active_barrier(long_id, short_id):
    packet = prutils.make_device_packet(long_id, short_id, Config.REPORT, 4,
                                        chr(Config.VIOLATED))
    return packet