esp32_ble_ota icon indicating copy to clipboard operation
esp32_ble_ota copied to clipboard

Python script not working

Open arpitsahu0740 opened this issue 2 years ago • 2 comments

I am trying to test this but the python code doesn't write the characteristics of the esp. And the execution is stuck at this - Searching for ESP32... ESP32 found! Sending packet size: 253. Sending OTA request.

arpitsahu0740 avatar Jun 22 '23 10:06 arpitsahu0740

You need to add "response=True" when writing to the control characteristic too.

        # write the request OP code to OTA Control
        print("Sending OTA request.")
        await client.write_gatt_char(
            OTA_CONTROL_UUID,
            SVR_CHR_OTA_CONTROL_REQUEST,
            response=True
        )

        # wait for the response
        await asyncio.sleep(1)
        if await queue.get() == "ack":

            # sequentially write all packets to OTA data
            for i, pkg in enumerate(firmware):
                print(f"Sending packet {i+1}/{len(firmware)}.")
                await client.write_gatt_char(
                    OTA_DATA_UUID,
                    pkg,
                    response=True
                )

            # write done OP code to OTA Control
            print("Sending OTA done.")
            await client.write_gatt_char(
                OTA_CONTROL_UUID,
                SVR_CHR_OTA_CONTROL_DONE,
                response=True
            )

magicmicros avatar Aug 26 '23 05:08 magicmicros