Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/components/ble/DfuService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
bootloaderSize,
applicationSize);

// From here until the response below, this task blocks and cannot service BLE:
// first the unbounded wait for SystemTask to disable sleeping, then the image-slot
// erase, which can approach or exceed the 10s inactivity timeout (116 sectors at a
// datasheet-max 300ms each). The timer runs on the FreeRTOS timer task, so it fires
// while this task is blocked; its Reset() zeroes applicationSize, the erase then
// completes and the transfer carries on with a zero-length image. Hold the timeout
// off until this handler can react to packets again.
xTimerStop(timeoutTimer, 0);

// Wait until SystemTask has disabled sleeping
// This isn't quite correct, as we don't actually know
// if BleFirmwareUpdateStarted has been received yet
Expand All @@ -146,6 +155,7 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
}

dfuImage.Erase();
xTimerStart(timeoutTimer, 0);

uint8_t data[] {16, 1, 1};
notificationManager.Send(connectionHandle, controlPointCharacteristicHandle, data, 3);
Expand Down
Loading