transferFirmware
Drives the full upload sequence (START, init-packet brackets, PRN setup, firmware stream, validate, activate).
Sequence details:
START_DFU [0x04](APP image only).Image sizes payload on Packet char:
[0u32, 0u32, firmware.size_u32].Await START response.
INIT_PARAMS_START, init bytes on Packet,INIT_PARAMS_COMPLETE. Await init response.PRN_REQ [PRN_LE16]. (No response.)RECEIVE_FIRMWARE_IMAGE. (No response.)Stream firmware in MTU-sized chunks. Every PRN packets, await
PacketReceipt(bytesReceived)and verify count.After last byte, await final response for
RECEIVE_FIRMWARE_IMAGE.VALIDATE, await response.ACTIVATE_AND_RESET— an ordinary disconnect/write Exception may occur because the device resets before the acknowledgement; treat that operational Exception as expected success (structured cancellation and Error subtypes still propagate).
As transferFirmware, additionally reporting coarse DfuUploadPhase transitions so the UI can explain a wait that produces no progress (Legacy DFU erases the whole application region before it accepts a single byte). Transports without a meaningful prepare step keep the default, which never reports a phase.