Skip to content

Commit

Permalink
Align OTA Requestor Cluster with spec
Browse files Browse the repository at this point in the history
  • Loading branch information
carol-apple committed Dec 16, 2021
1 parent 59dd330 commit cbd2887
Show file tree
Hide file tree
Showing 48 changed files with 1,824 additions and 392 deletions.
113 changes: 106 additions & 7 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,36 @@
}
],
"attributes": [
{
"name": "AttributeList",
"code": 65531,
"mfgCode": null,
"side": "server",
"included": 0,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
"mfgCode": null,
"side": "server",
"included": 0,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
Expand All @@ -1452,7 +1482,16 @@
"define": "OTA_REQUESTOR_CLUSTER",
"side": "client",
"enabled": 0,
"commands": [],
"commands": [
{
"name": "AnnounceOtaProvider",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
}
],
"attributes": [
{
"name": "ClusterRevision",
Expand Down Expand Up @@ -1481,35 +1520,95 @@
"commands": [],
"attributes": [
{
"name": "default ota provider",
"name": "DefaultOtaProviders",
"code": 0,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "UpdatePossible",
"code": 1,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": "0",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "update possible",
"name": "UpdateState",
"code": 2,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": "0",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "UpdateStateProgress",
"code": 3,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
"mfgCode": null,
"side": "server",
"included": 0,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
"mfgCode": null,
"side": "server",
"included": 0,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <platform/OTARequestorInterface.h>

bool emberAfOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::DecodableType & commandData)
{
return false;
}
1 change: 1 addition & 0 deletions examples/all-clusters-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ list(
${chip_dir}/zzz_generated/all-clusters-app/zap-generated/CHIPClusters.cpp

${chip_dir}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp

${chip_dir}/examples/all-clusters-app/ameba/main/chipinterface.cpp
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import("//build_overrides/chip.gni")
executable("chip-all-clusters-app") {
sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
"include/tv-callbacks.cpp",
"main.cpp",
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ target_sources(${APP_TARGET} PRIVATE
${CHIP_ROOT}/src/app/server/CommissioningWindowManager.cpp

${CHIP_ROOT}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp
${CHIP_ROOT}/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp
${CHIP_ROOT}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp

${APP_UTIL}/DataModelHandler.cpp
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/p6/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ p6_executable("clusters_app") {

sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
"${examples_plat_dir}/LEDWidget.cpp",
"${examples_plat_dir}/init_p6Platform.cpp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1100,31 +1100,91 @@
"commands": [],
"attributes": [
{
"name": "default ota provider",
"name": "DefaultOtaProviders",
"code": 0,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "UpdatePossible",
"code": 1,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "update possible",
"name": "UpdateState",
"code": 2,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "UpdateStateProgress",
"code": 3,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
"mfgCode": null,
"side": "server",
"included": 0,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
"mfgCode": null,
"side": "server",
"included": 0,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
Expand Down
4 changes: 2 additions & 2 deletions src/app/clusters/ota-requestor/OTARequestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ EmberAfStatus OTARequestor::HandleAnnounceOTAProvider(app::CommandHandler * comm
const app::ConcreteCommandPath & commandPath,
const AnnounceOtaProvider::DecodableType & commandData)
{
auto & providerLocation = commandData.providerLocation;
auto & providerNodeId = commandData.providerNodeId;
auto & announcementReason = commandData.announcementReason;

if (commandObj == nullptr || commandObj->GetExchangeContext() == nullptr)
Expand All @@ -192,7 +192,7 @@ EmberAfStatus OTARequestor::HandleAnnounceOTAProvider(app::CommandHandler * comm
return EMBER_ZCL_STATUS_FAILURE;
}

mProviderNodeId = providerLocation;
mProviderNodeId = providerNodeId;
mProviderFabricIndex = commandObj->GetExchangeContext()->GetSessionHandle().GetFabricIndex();

ChipLogProgress(SoftwareUpdate, "OTA Requestor received AnnounceOTAProvider");
Expand Down
29 changes: 19 additions & 10 deletions src/app/zap-templates/zcl/data-model/chip/chip-ota.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ limitations under the License.
<cluster>
<name>OTA Software Update Provider</name>
<domain>CHIP</domain>
<description></description>
<description>Provides an interface for providing OTA software updates</description>
<code>0x0029</code>
<define>OTA_PROVIDER_CLUSTER</define>
<client tick="false" init="false">true</client>
Expand Down Expand Up @@ -107,23 +107,32 @@ limitations under the License.
<item name="Failure" value="0x2"/>
<item name="TimeOut" value="0x3"/>
<item name="DelayByProvider" value="0x4"/>
</enum>
</enum>
<struct name="ProviderLocation">
<cluster code="0x002a"/>
<item name="FabricIndex" type="fabric_idx"/>
<item name="ProviderNodeID" type="node_id"/>
<item name="Endpoint" type="endpoint_no"/>
</struct>
<cluster>
<name>OTA Software Update Requestor</name>
<domain>CHIP</domain>
<description>TODO</description>
<description>Provides an interface for downloading and applying OTA software updates</description>
<code>0x002a</code>
<define>OTA_REQUESTOR_CLUSTER</define>
<client tick="false" init="false">true</client>
<server tick="false" init="false">true</server>
<attribute side="server" code="0x0001" define="DEFAULT_OTA_PROVIDER" type="OCTET_STRING" length="16" writable="true" optional="false">default ota provider</attribute>
<attribute side="server" code="0x0002" define="UPDATE_POSSIBLE" type="BOOLEAN" writable="false" optional="false">update possible</attribute>
<command source="client" code="0" name="AnnounceOtaProvider" optional="true" cli="chip ota announceotaprovider">
<description>Notify OTA Provider that an update was applied</description>
<arg name="providerLocation" type="NODE_ID"/>
<arg name="vendorId" type="VENDOR_ID"/>
<attribute side="server" code="0x0000" define="DEFAULT_OTA_PROVIDERS" type="ARRAY" entryType="ProviderLocation" length="16" writable="true" optional="false">DefaultOtaProviders</attribute>
<attribute side="server" code="0x0001" define="UPDATE_POSSIBLE" type="BOOLEAN" default="true" writable="false" optional="false">UpdatePossible</attribute>
<attribute side="server" code="0x0002" define="UPDATE_STATE" type="UpdateStateEnum" default="Unknown" writable="false" optional="false">UpdateState</attribute>
<attribute side="server" code="0x0003" define="UPDATE_STATE_PROGRESS" type="INT8U" min="0" max="100" writable="false" optional="false">UpdateStateProgress</attribute>
<command source="client" code="0x00" name="AnnounceOtaProvider" optional="true" cli="chip ota announceotaprovider">
<description>Announce the presence of an OTA Provider</description>
<arg name="providerNodeId" type="node_id"/>
<arg name="vendorId" type="vendor_id"/>
<arg name="announcementReason" type="OTAAnnouncementReason"/>
<arg name="metadataForNode" type="OCTET_STRING" length="512" optional="true"/>
<arg name="endpoint" type="endpoint_no"/>
</command>
<event side="server" code="0x00" name="StateTransition" priority="info" optional="false">
<description>This event SHALL be generated when a change of the UpdateState attribute occurs due to an OTA Requestor moving through the states necessary to query for updates.</description>
Expand All @@ -141,7 +150,7 @@ limitations under the License.
<description>This event SHALL be generated whenever an error occurs during OTA Requestor download operation.</description>
<field id="0" name="SoftwareVersion" type="INT32U"/>
<field id="1" name="BytesDownloaded" type="INT64U"/>
<field id="2" name="ProgressPercent" type="INT8U"/>
<field id="2" name="ProgressPercent" type="INT8U" min="0" max="100"/>
<field id="3" name="PlatformCode" type="INT64S"/>
</event>
</cluster>
Expand Down
Loading

0 comments on commit cbd2887

Please sign in to comment.