コード例 #1
0
ファイル: dpr.py プロジェクト: AlexKano/pmax
def enroll(long_id, dev_type, customer_mid=0, customer_did=0):

    serial_num = prutils.convert_longid(long_id)
    rssi = "\x32"
    tx_power = "\x01"
    association_request_data = "\x00"
    # TODO: Get device type
    if dev_type.upper() in _DeviceType:
        dev_type = _DeviceType[dev_type.upper()]
    else:
        raise Exception("Incorrect device type specified")
        return None

    attached_device_information = "\x00" + dev_type + "\x01\x14\x03\x00\x00"
    # Counting customer id
    manufacturing_information = chr(customer_mid) + prutils.num_to_chars(customer_did, 2, 0)
    rf_module_information = "\x00\x70\x09\x28\x03\x08\x01"
    packet = (
        serial_num
        + rssi
        + tx_power
        + association_request_data
        + "\x00"
        + prutils.str_l(attached_device_information)
        + "\x01"
        + prutils.str_l(manufacturing_information)
        + "\x02"
        + prutils.str_l(rf_module_information)
    )
    host_protocol_message = prutils.make_host_packet(0x41, packet, False)
    enroll_packet = "\x01" + host_protocol_message
    enroll_packet = prutils._make_f2_packet(enroll_packet, 13)
    return enroll_packet
コード例 #2
0
def enroll(long_id, dev_type, customer_mid=0, customer_did=0):

    serial_num = prutils.convert_longid(long_id)
    rssi = '\x32'
    tx_power = '\x01'
    association_request_data = '\x00'
    #TODO: Get device type
    if (dev_type.upper() in _DeviceType):
        dev_type = _DeviceType[dev_type.upper()]
    else:
        raise Exception("Incorrect device type specified")
        return None

    attached_device_information = '\x00' + dev_type + '\x01\x14\x03\x00\x00'
    #Counting customer id
    manufacturing_information = chr(customer_mid) + prutils.num_to_chars(
        customer_did, 2, 0)
    rf_module_information = '\x00\x70\x09\x28\x03\x08\x01'
    packet = serial_num + rssi + tx_power + association_request_data + '\x00' + prutils.str_l(
        attached_device_information) + '\x01' + prutils.str_l(
            manufacturing_information) + '\x02' + prutils.str_l(
                rf_module_information)
    host_protocol_message = prutils.make_host_packet(0x41, packet, False)
    enroll_packet = '\x01' + host_protocol_message
    enroll_packet = prutils._make_f2_packet(enroll_packet, 13)
    return enroll_packet
コード例 #3
0
ファイル: hpr.py プロジェクト: goldmar5/BFASS
def send_unicast_message(enable_retries, short_id, message_data_hex):
    # enable_retries:
    #   0 - MAC ACK and Retries Disabled
    #   1 - MAC ACK and  Retries Enabled
    packet = prutils.make_host_packet(
        0x01,
        chr(enable_retries) + chr(short_id) +
        chr(len(message_data_hex) + message_data_hex))
    return packet
コード例 #4
0
ファイル: hpr.py プロジェクト: AlexKano/pmax
def send_diagnostics(short_id, long_id, seq):
    #22 3F 0A 01 30 00 08 B5 0C 95 28 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 53 06 00 00 81 0A
    #53 06 00 00 - Supervision message (06 00 - Long ID)
    #Long is 13 bits of the real Long ID: [LSB] [MSB], 2100 = [0x34] [0x08]
    #long_id_packed = chr(long_id % 256) + chr(long_id &0xff00)/ 256
    
    long_id_packed = prutils.num_to_chars(long_id, 0, 0)[:2]
    data = chr(short_id) + chr(seq) +'\x30\x00\x08\xB5\x0C\x95\x28\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x53' + long_id_packed + '\x00'
    packet = prutils.make_host_packet(0x3F, data)
    return packet
コード例 #5
0
ファイル: hpr.py プロジェクト: goldmar5/BFASS
def send_diagnostics(short_id, long_id, seq):
    #22 3F 0A 01 30 00 08 B5 0C 95 28 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 53 06 00 00 81 0A
    #53 06 00 00 - Supervision message (06 00 - Long ID)
    #Long is 13 bits of the real Long ID: [LSB] [MSB], 2100 = [0x34] [0x08]
    #long_id_packed = chr(long_id % 256) + chr(long_id &0xff00)/ 256

    long_id_packed = prutils.num_to_chars(long_id, 0, 0)[:2]
    data = chr(short_id) + chr(
        seq
    ) + '\x30\x00\x08\xB5\x0C\x95\x28\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x53' + long_id_packed + '\x00'
    packet = prutils.make_host_packet(0x3F, data)
    return packet
コード例 #6
0
ファイル: hpr.py プロジェクト: goldmar5/BFASS
def association_request(long_id):
    # Real packet: 20 40 06 00 00 00 13 00 00 00 08 01 03 29 03 14 03 00 08 01 01 00 02 07 00 70 09 28 03 08 01 88 0A
    long_id = prutils.convert_longid(long_id)
    rssi = '\x13'
    tx_power = '\x00'
    request_data = '\x00'
    attached_device_information = '\x00\x08\x01\x03\x29\x03\x14\x03\x00\x08'
    manufacturing_information = '\x01\x01\x00'
    rf_module_information = '\x02\x07\x00\x70\x09\x28\x03\x08\x01'

    data = long_id + rssi + tx_power + request_data + attached_device_information + manufacturing_information + rf_module_information
    packet = prutils.make_host_packet(0x40, data)
    return packet
コード例 #7
0
ファイル: hpr.py プロジェクト: AlexKano/pmax
def association_request(long_id):
    # Real packet: 20 40 06 00 00 00 13 00 00 00 08 01 03 29 03 14 03 00 08 01 01 00 02 07 00 70 09 28 03 08 01 88 0A
    long_id = prutils.convert_longid(long_id)
    rssi = '\x13'
    tx_power = '\x00'
    request_data = '\x00'
    attached_device_information = '\x00\x08\x01\x03\x29\x03\x14\x03\x00\x08'
    manufacturing_information = '\x01\x01\x00'
    rf_module_information = '\x02\x07\x00\x70\x09\x28\x03\x08\x01'

    data = long_id + rssi + tx_power + request_data + attached_device_information + manufacturing_information + rf_module_information
    packet = prutils.make_host_packet(0x40, data)
    return packet
コード例 #8
0
ファイル: procedures.py プロジェクト: AlexKano/pmax
    def request_configuration_data(self, short_id, long_id, parameter):
        if (not self.is_AUTO_port_ready()): return
        final_hop_info = '\x00\x00\x00\x00\x80\x00\x84\x00\x00\x00\x00'
        repeater_hop_info = '\x00' * 12
        dpr_seq = prutils.generate_seq('dpr')
        hpr_seq = prutils.generate_seq('hpr')
        if parameter == 0x46:
            data = chr(short_id) + chr(hpr_seq) + chr(0xF8) + final_hop_info  + repeater_hop_info\
                + prutils.str_l('\x64\x00' + chr(dpr_seq) + prutils.num_to_chars(long_id, 3, 0) + "\x02\x02" + chr(parameter) + '\x00')
        else:    
            data = chr(short_id) + chr(hpr_seq) + chr(0x30) + final_hop_info  + repeater_hop_info\
                + prutils.str_l('\x64\x00' + chr(dpr_seq) + prutils.num_to_chars(long_id, 3, 0) + "\x02\x02" + chr(parameter) + '\x00')

        packet = prutils.make_host_packet(0x30, data) 
        self._Communicator.send(packet)
コード例 #9
0
ファイル: hpr.py プロジェクト: goldmar5/BFASS
def ack(status):
    # status:
    #   0x00: Message Legal
    #   0x01: Message not Recognized
    #   0x02: Message Data Invalid
    #   0x03: -unused-
    #   0x04: Buffer Full
    #   0x05: -unused-
    #   0x06: Notification Error
    #   0x07: One-Way Network
    #   0x08: Message Length Error
    #   0x09: Network Unavailable
    #   0x0A: Node Busy
    packet = prutils.make_host_packet(0x01, chr(status) + chr(0x00))
    return packet
コード例 #10
0
    def request_configuration_data(self, short_id, long_id, parameter):
        if (not self.is_AUTO_port_ready()): return
        final_hop_info = '\x00\x00\x00\x00\x80\x00\x84\x00\x00\x00\x00'
        repeater_hop_info = '\x00' * 12
        dpr_seq = prutils.generate_seq('dpr')
        hpr_seq = prutils.generate_seq('hpr')
        if parameter == 0x46:
            data = chr(short_id) + chr(hpr_seq) + chr(0xF8) + final_hop_info  + repeater_hop_info\
                + prutils.str_l('\x64\x00' + chr(dpr_seq) + prutils.num_to_chars(long_id, 3, 0) + "\x02\x02" + chr(parameter) + '\x00')
        else:
            data = chr(short_id) + chr(hpr_seq) + chr(0x30) + final_hop_info  + repeater_hop_info\
                + prutils.str_l('\x64\x00' + chr(dpr_seq) + prutils.num_to_chars(long_id, 3, 0) + "\x02\x02" + chr(parameter) + '\x00')

        packet = prutils.make_host_packet(0x30, data)
        self._Communicator.send(packet)
コード例 #11
0
ファイル: hpr.py プロジェクト: AlexKano/pmax
def ack(status):
    # status:
    #   0x00: Message Legal
    #   0x01: Message not Recognized
    #   0x02: Message Data Invalid
    #   0x03: -unused-
    #   0x04: Buffer Full
    #   0x05: -unused-
    #   0x06: Notification Error
    #   0x07: One-Way Network
    #   0x08: Message Length Error
    #   0x09: Network Unavailable
    #   0x0A: Node Busy
    packet = prutils.make_host_packet(0x01, chr(status) + chr(0x00))
    return packet
コード例 #12
0
ファイル: hpr.py プロジェクト: goldmar5/BFASS
def send_response_to_get_system_time():
    time = '\x89\xB8'
    packet = prutils.make_host_packet(0x43, time + '\x20')
    return packet
コード例 #13
0
ファイル: hpr.py プロジェクト: AlexKano/pmax
def send_response_to_get_system_time():
    time = '\x89\xB8'
    packet = prutils.make_host_packet(0x43, time + '\x20')
    return packet
コード例 #14
0
ファイル: hpr.py プロジェクト: AlexKano/pmax
def send_unicast_message(enable_retries, short_id, message_data_hex):
    # enable_retries:
    #   0 - MAC ACK and Retries Disabled
    #   1 - MAC ACK and  Retries Enabled
    packet = prutils.make_host_packet(0x01, chr(enable_retries) + chr(short_id) + chr(len(message_data_hex) + message_data_hex))
    return packet