From 0961020cea6f030852ae5c59969d7c94a07df0d3 Mon Sep 17 00:00:00 2001 From: Sergei Lissianoi <54454955+selissia@users.noreply.github.com> Date: Thu, 3 Mar 2022 15:32:33 -0500 Subject: [PATCH] Implement periodic timer for querying OTA providers, refactor OTARequestor and OTARequestorDriver (#15433) * Add quasi-state machine for the Requestor * Use the RequestorDriver scheduling method instead of the platform timer The Linux OTA scenario works with this change * Add a commissioning callback * Add periodic timer for querying the default OTA provider * Add calls to StartDefaultProvidersTimer() * Move all calls to StartDefaultProvidersTimer() to RecordNewUpdateState() * Move some of the Requestor logic to the GenericOTARequestorDriver class * Update comments * Fix StartDelayTimerHandler() call * Add DriverTriggerQuery() method * Remove obsolet methods from OTARequestor * Rearrange error logic flow * Use TriggerImmediateQuery() API when processing AnnounceOTAProviders * Use DetermineProviderLocation() to pick the provider location * Introduce mLastUsedProvider * Rename functions and add comments * Rework StartDelayTimerHandler * Cleanup unused parameter, comments * Clean up spelling * Fix override compile error * Restyled by whitespace * Restyled by clang-format * Remove unused enum * Rename variable, fix comments, change private back to protected (merge artifact) * Restyled by clang-format * Make periodic query timeout configurable on Linux * Update examples/ota-requestor-app/linux/main.cpp Co-authored-by: Carol Yang * Update examples/ota-requestor-app/linux/README.md Co-authored-by: Carol Yang * Update wording Co-authored-by: Carol Yang * Use seconds for the delay, don't set the state prematurely, use lambda * Rework enums, query retry logic * Restyled by whitespace * Restyled by clang-format * Restyled by prettier-markdown * Add word to disctionary * Delay initial query after commissioning * Restyled by whitespace * Restyled by clang-format * Udate comment * Introduce GenericOTARequestorDriver::OTACommissioningCallback * Restyled by whitespace * Restyled by clang-format * Rename and move around various OTARequestor and Driver APIs * Restyled by whitespace * Restyled by clang-format * Resolve merge conflicts from the latest merge from master * Rename variables and update comments * Restyled by whitespace * Remove leftover code block * When connecting to the Provider change the state to kUnknown * Remove unused function * Check for kCommissioningComplete; clear current provider * Set the kQuerying state in TriggerImmediateQueryInternal * Restyled by clang-format * Restyled by prettier-markdown * Clean up missed merge conflicts * Restyled by prettier-markdown Co-authored-by: Restyled.io Co-authored-by: Carol Yang --- .github/.wordlist.txt | 1 + examples/ota-requestor-app/efr32/README.md | 3 +- examples/ota-requestor-app/linux/README.md | 27 +- examples/ota-requestor-app/linux/main.cpp | 38 +-- .../clusters/ota-requestor/OTARequestor.cpp | 227 +++++++++------- src/app/clusters/ota-requestor/OTARequestor.h | 79 +++--- src/include/platform/OTARequestorDriver.h | 29 +- src/include/platform/OTARequestorInterface.h | 34 ++- src/platform/GenericOTARequestorDriver.cpp | 249 ++++++++++++++++-- src/platform/GenericOTARequestorDriver.h | 32 ++- src/platform/mbed/OTARequestorDriverImpl.cpp | 4 +- 11 files changed, 531 insertions(+), 192 deletions(-) diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index 1ffec017b94a1a..c4acd491940e9d 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -903,6 +903,7 @@ peerNodeId peerSessionId pem percentageLiftValue +periodicQueryTimeout pexpect pickString PID diff --git a/examples/ota-requestor-app/efr32/README.md b/examples/ota-requestor-app/efr32/README.md index 2db645c03fcf9b..a16a357319fb80 100644 --- a/examples/ota-requestor-app/efr32/README.md +++ b/examples/ota-requestor-app/efr32/README.md @@ -95,12 +95,13 @@ See `examples/lighting-app/efr32/README.md` - In a terminal start the provider app passing to it the path to the bootable image file created in the previous step: + rm -r /tmp/chip_* ./out/debug/chip-ota-provider-app -f chip-efr32-ota-requestor-example.gbl - In a separate terminal run the chip-tool commands to provision the Provider: - rm -r /tmp/chip_* ./out/chip-tool pairing onnetwork 1 20202021 + ./out/chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' 1 0 - If the Requestor had been previously commissioned hold Button 0 for six seconds to factory-reset the device. diff --git a/examples/ota-requestor-app/linux/README.md b/examples/ota-requestor-app/linux/README.md index e99594e23e7025..88b1ae729d5d3f 100644 --- a/examples/ota-requestor-app/linux/README.md +++ b/examples/ota-requestor-app/linux/README.md @@ -17,11 +17,11 @@ scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux out/debug In addition to the general options available to all Linux applications, the following command line options are available for the OTA Requestor application. -| Directory | Description | -| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| -q/--delayQuery