diff --git a/examples/platform/esp32/ota/OTAHelper.cpp b/examples/platform/esp32/ota/OTAHelper.cpp index 83b65776928104..b2be750db337c9 100644 --- a/examples/platform/esp32/ota/OTAHelper.cpp +++ b/examples/platform/esp32/ota/OTAHelper.cpp @@ -118,6 +118,14 @@ CHIP_ERROR RequestorCanConsentHandler(int argc, char ** argv) return CHIP_NO_ERROR; } +CHIP_ERROR SetPeriodicQueryTimeoutHandler(int argc, char ** argv) +{ + VerifyOrReturnError(argc == 1, CHIP_ERROR_INVALID_ARGUMENT); + gRequestorUser.SetPeriodicQueryTimeout(strtoul(argv[0], NULL, 0)); + gRequestorUser.RekickPeriodicQueryTimer(); + return CHIP_NO_ERROR; +} + CHIP_ERROR OTARequestorHandler(int argc, char ** argv) { if (argc == 0) @@ -147,6 +155,9 @@ void OTARequestorCommands::Register() { &RequestorCanConsentHandler, "requestorCanConsent", "Set requestorCanConsent for QueryImageCommand\n" "Usage: OTARequestor requestorCanConsent " }, + { &SetPeriodicQueryTimeoutHandler, "PeriodicQueryTimeout", + "Set timeout for querying the OTA provider for an update\n" + "Usage: OTARequestor PeriodicQueryTimeout " }, }; diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp index 5183026932c927..f2e4f6870c4db4 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp +++ b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp @@ -388,6 +388,13 @@ void DefaultOTARequestorDriver::StopPeriodicQueryTimer() CancelDelayedAction(PeriodicQueryTimerHandler, this); } +void DefaultOTARequestorDriver::RekickPeriodicQueryTimer(void) +{ + ChipLogProgress(SoftwareUpdate, "Rekicking the Periodic Query timer"); + StopPeriodicQueryTimer(); + StartPeriodicQueryTimer(); +} + void DefaultOTARequestorDriver::WatchdogTimerHandler(System::Layer * systemLayer, void * appState) { DefaultOTARequestorDriver * driver = ToDriver(appState); diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h index 0d76af626d6dc6..4a643da36e1251 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h +++ b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h @@ -52,6 +52,9 @@ class DefaultOTARequestorDriver : public OTARequestorDriver } } + // Restart the periodic query timer + void RekickPeriodicQueryTimer(void); + // Set the timeout (in seconds) for the watchdog timer; must be non-zero void SetWatchdogTimeout(uint32_t timeout) {