Skip to content

Commit

Permalink
[ota-r] API to rekick the periodic query timer (#21991)
Browse files Browse the repository at this point in the history
* [ota-r] API to rekick the periodic query timer

* [ESP32]: cli option to set the periodic ota query timer
  • Loading branch information
shubhamdp authored and pull[bot] committed Sep 21, 2022
1 parent f06897e commit 5871224
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/platform/esp32/ota/OTAHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -147,6 +155,9 @@ void OTARequestorCommands::Register()
{ &RequestorCanConsentHandler, "requestorCanConsent",
"Set requestorCanConsent for QueryImageCommand\n"
"Usage: OTARequestor requestorCanConsent <true/false>" },
{ &SetPeriodicQueryTimeoutHandler, "PeriodicQueryTimeout",
"Set timeout for querying the OTA provider for an update\n"
"Usage: OTARequestor PeriodicQueryTimeout <seconds>" },

};

Expand Down
7 changes: 7 additions & 0 deletions src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 5871224

Please sign in to comment.