This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Support code python librairie nrfutil

Hi,

I am working on the port of the nrfutil library of python -> C and I am looking for a support to understand the python code of the nrfutil library please.

Can you help me please.

Best Regards.

Parents Reply Children
  • I am working on a communication project ble, is among the objectives of the project is the portage of the function ble in the main.py C is a project a little critical that requires less space of the memory c is why I am carrying a C or assembler

    that's the function I need

    github.com/.../dfu_transport_ble.py

    def send_init_packet(self, init_packet):
    def try_to_recover():
    if response['offset'] == 0 or response['offset'] > len(init_packet):
    # There is no init packet or present init packet is too long.
    return False

    expected_crc = (binascii.crc32(init_packet[:response['offset']]) & 0xFFFFFFFF)

    if expected_crc != response['crc']:
    # Present init packet is invalid.
    return False

    if len(init_packet) > response['offset']:
    # Send missing part.
    try:
    self.__stream_data(data = init_packet[response['offset']:],
    crc = expected_crc,
    offset = response['offset'])
    except ValidationException:
    return False

    self.__execute()
    return True

    response = self.__select_command()
    assert len(init_packet) <= response['max_size'], 'Init command is too long'

    if try_to_recover():
    return

    for r in range(DfuTransportBle.RETRIES_NUMBER):
    try:
    self.__create_command(len(init_packet))
    self.__stream_data(data=init_packet)
    self.__execute()
    except ValidationException:
    pass
    break
    else:
    raise NordicSemiException("Failed to send init packet")

Related