Skip to content

Commit

Permalink
Ensure that the OTA commissioning callback timer is started with the …
Browse files Browse the repository at this point in the history
…correct function-pointer and object data (#16888)
  • Loading branch information
harsha-rajendran authored and pull[bot] committed Feb 23, 2024
1 parent 6ff1448 commit 2078193
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ bool OTAProviderExample::ParseOTAHeader(const char * otaFilePath, OTAImageHeader
}

otaFile.read(reinterpret_cast<char *>(otaFileContent), kOtaHeaderMaxSize);
if (!otaFile.good())
if (otaFile.bad())
{
ChipLogError(SoftwareUpdate, "Error reading OTA image file: %s", otaFilePath);
return false;
Expand Down
4 changes: 3 additions & 1 deletion scripts/tests/ota_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/app/clusters/ota-requestor/BDXDownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 1 addition & 3 deletions src/app/clusters/ota-requestor/GenericOTARequestorDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<OTARequestorDriver *>(context)->SendQueryImage(); }, this);
ScheduleDelayedAction(System::Clock::Seconds32(kDelayQueryUponCommissioningSec), StartDelayTimerHandler, this);
}

void GenericOTARequestorDriver::ProcessAnnounceOTAProviders(
Expand Down

0 comments on commit 2078193

Please sign in to comment.