diff --git a/examples/ota-provider-app/ota-provider-common/OTAProviderExample.cpp b/examples/ota-provider-app/ota-provider-common/OTAProviderExample.cpp index 695a76fbb81526..1b3266fc42638f 100644 --- a/examples/ota-provider-app/ota-provider-common/OTAProviderExample.cpp +++ b/examples/ota-provider-app/ota-provider-common/OTAProviderExample.cpp @@ -192,7 +192,7 @@ bool OTAProviderExample::ParseOTAHeader(const char * otaFilePath, OTAImageHeader } otaFile.read(reinterpret_cast(otaFileContent), kOtaHeaderMaxSize); - if (!otaFile.good()) + if (otaFile.bad()) { ChipLogError(SoftwareUpdate, "Error reading OTA image file: %s", otaFilePath); return false; diff --git a/scripts/tests/ota_test.sh b/scripts/tests/ota_test.sh index eecded2912c86a..fc9a326547eef9 100755 --- a/scripts/tests/ota_test.sh +++ b/scripts/tests/ota_test.sh @@ -18,6 +18,8 @@ CHIP_TOOL_FOLDER="out" killall -e "$OTA_PROVIDER_APP" "$OTA_REQUESTOR_APP" rm -f "$FIRMWARE_OTA" "$FIRMWARE_BIN" "$OTA_DOWNLOAD_PATH" +set -e + scripts/examples/gn_build_example.sh examples/chip-tool "$CHIP_TOOL_FOLDER" scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux "$OTA_REQUESTOR_FOLDER" chip_config_network_layer_ble=false scripts/examples/gn_build_example.sh examples/ota-provider-app/linux "$OTA_PROVIDER_FOLDER" chip_config_network_layer_ble=false @@ -26,7 +28,7 @@ echo "Test" >"$FIRMWARE_BIN" rm /tmp/chip_* -./src/app/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 1 -vs "1.0" -da sha256 "$FIRMWARE_BIN" "$FIRMWARE_OTA" +./src/app/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 10 -vs "10.0" -da sha256 "$FIRMWARE_BIN" "$FIRMWARE_OTA" if [ ! -f "$FIRMWARE_OTA" ]; then exit 1 diff --git a/src/app/clusters/ota-requestor/BDXDownloader.cpp b/src/app/clusters/ota-requestor/BDXDownloader.cpp index d97b95fbb83a41..5453ed73b51a13 100644 --- a/src/app/clusters/ota-requestor/BDXDownloader.cpp +++ b/src/app/clusters/ota-requestor/BDXDownloader.cpp @@ -115,6 +115,9 @@ CHIP_ERROR BDXDownloader::BeginPrepareDownload() VerifyOrReturnError(mImageProcessor != nullptr, CHIP_ERROR_INCORRECT_STATE); mPrevBlockCounter = 0; + + // Note that due to the nature of this timer function, the actual time taken to detect a stalled BDX connection might be + // anywhere in the range of [mTimeout, 2*mTimeout) DeviceLayer::SystemLayer().StartTimer(mTimeout, TransferTimeoutCheckHandler, this); ReturnErrorOnFailure(mImageProcessor->PrepareDownload()); diff --git a/src/app/clusters/ota-requestor/GenericOTARequestorDriver.cpp b/src/app/clusters/ota-requestor/GenericOTARequestorDriver.cpp index a94a2aa2348fa2..1eced387733b88 100644 --- a/src/app/clusters/ota-requestor/GenericOTARequestorDriver.cpp +++ b/src/app/clusters/ota-requestor/GenericOTARequestorDriver.cpp @@ -275,9 +275,7 @@ void GenericOTARequestorDriver::CancelDelayedAction(System::TimerCompleteCallbac void GenericOTARequestorDriver::OTACommissioningCallback() { // Schedule a query. At the end of this query/update process the Default Provider timer is started - ScheduleDelayedAction( - System::Clock::Seconds32(kDelayQueryUponCommissioningSec), - [](System::Layer *, void * context) { static_cast(context)->SendQueryImage(); }, this); + ScheduleDelayedAction(System::Clock::Seconds32(kDelayQueryUponCommissioningSec), StartDelayTimerHandler, this); } void GenericOTARequestorDriver::ProcessAnnounceOTAProviders(