def send_init_packet(self, init_packet):
        super(DfuTransportBle, self).send_init_packet(init_packet)
        init_packet_start = chr(0x00)
        init_packet_end = chr(0x01)

        logger.debug("Sending 'INIT DFU' command")
        self.send_control_data(DfuOpcodesBle.INITIALIZE_DFU, init_packet_start)

        logger.debug("Sending init data")
        for i in range(0, len(init_packet), DATA_PACKET_SIZE):
            data_to_send = init_packet[i:i + DATA_PACKET_SIZE]
            self.send_packet_data(data_to_send)

        logger.debug("Sending 'Init Packet Complete' command")
        self.send_control_data(DfuOpcodesBle.INITIALIZE_DFU, init_packet_end)
        self._wait_for_condition(self.get_received_response,
                                 timeout=60,
                                 waiting_for="response for INITIALIZE DFU")
        self.clear_received_response()

        if NUM_OF_PACKETS_BETWEEN_NOTIF:
            packet = int16_to_bytes(NUM_OF_PACKETS_BETWEEN_NOTIF)
            logger.debug(
                "Send number of packets before device sends notification")
            self.send_control_data(DfuOpcodesBle.REQ_PKT_RCPT_NOTIFICATION,
                                   packet)
예제 #2
0
    def send_init_packet(self, init_packet):
        super(DfuTransportSerial, self).send_init_packet(init_packet)

        frame = [x for x in int32_to_bytes(DFU_INIT_PACKET)]
        frame += [chr(x) for x in bytes(init_packet)]
        frame += [x for x in int16_to_bytes(0x0000)]  # Padding required

        packet = HciPacket(frame)
        self.send_packet(packet)
예제 #3
0
    def send_init_packet(self, init_packet):
        super(DfuTransportSerial, self).send_init_packet(init_packet)

        frame = int32_to_bytes(DFU_INIT_PACKET)
        frame += init_packet
        frame += int16_to_bytes(0x0000)  # Padding required

        packet = HciPacket(frame)
        self.send_packet(packet)
        time.sleep(DfuTransportSerial.SEND_INIT_PACKET_WAIT_TIME)
예제 #4
0
    def send_init_packet(self, init_packet):
        super(DfuTransportSerial, self).send_init_packet(init_packet)

        frame = int32_to_bytes(DFU_INIT_PACKET)
        frame += init_packet
        frame += int16_to_bytes(0x0000)  # Padding required

        packet = HciPacket(frame)
        self.send_packet(packet)
        time.sleep(DfuTransportSerial.SEND_INIT_PACKET_WAIT_TIME)
예제 #5
0
    def send_init_packet(self, init_packet):
        super(DfuTransportBle, self).send_init_packet(init_packet)
        init_packet_start = chr(0x00)
        init_packet_end = chr(0x01)

        logging.debug("Sending 'INIT DFU' command")
        self.send_control_data(DfuOpcodesBle.INITIALIZE_DFU, init_packet_start)

        logging.debug("Sending init data")
        for i in range(0, len(init_packet), DATA_PACKET_SIZE):
            data_to_send = init_packet[i:i + DATA_PACKET_SIZE]
            self.send_packet_data(data_to_send)

        logging.debug("Sending 'Init Packet Complete' command")
        self.send_control_data(DfuOpcodesBle.INITIALIZE_DFU, init_packet_end)
        self._wait_for_response(DfuOpcodesBle.INITIALIZE_DFU)

        if NUM_OF_PACKETS_BETWEEN_NOTIF:
            packet = int16_to_bytes(NUM_OF_PACKETS_BETWEEN_NOTIF)
            logging.debug("Send number of packets before device sends notification")
            self.send_control_data(DfuOpcodesBle.REQ_PKT_RCPT_NOTIFICATION, packet)