Ensure that the OTA commissioning callback timer is started with the correct function-pointer and object data (#16888)
diff --git a/examples/ota-provider-app/ota-provider-common/OTAProviderExample.cpp b/examples/ota-provider-app/ota-provider-common/OTAProviderExample.cpp
index 695a76f..1b3266f 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 @@
}
otaFile.read(reinterpret_cast<char *>(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 eecded2..fc9a326 100755
--- a/scripts/tests/ota_test.sh
+++ b/scripts/tests/ota_test.sh
@@ -18,6 +18,8 @@
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 @@
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 d97b95f..5453ed7 100644
--- a/src/app/clusters/ota-requestor/BDXDownloader.cpp
+++ b/src/app/clusters/ota-requestor/BDXDownloader.cpp
@@ -115,6 +115,9 @@
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 a94a2aa..1eced38 100644
--- a/src/app/clusters/ota-requestor/GenericOTARequestorDriver.cpp
+++ b/src/app/clusters/ota-requestor/GenericOTARequestorDriver.cpp
@@ -275,9 +275,7 @@
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<OTARequestorDriver *>(context)->SendQueryImage(); }, this);
+ ScheduleDelayedAction(System::Clock::Seconds32(kDelayQueryUponCommissioningSec), StartDelayTimerHandler, this);
}
void GenericOTARequestorDriver::ProcessAnnounceOTAProviders(