Skip to content

Commit

Permalink
Fully align the XML for QueryImage and QueryImageResponse with the spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Nov 2, 2021
1 parent 8d7a56b commit 27a0643
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ void OTAProviderExample::SetOTAFilePath(const char * path)
}
}

EmberAfStatus OTAProviderExample::HandleQueryImage(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, uint16_t vendorId,
uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported,
const Optional<uint16_t> & hardwareVersion, const Optional<CharSpan> & location,
const Optional<bool> & requestorCanConsent,
const Optional<ByteSpan> & metadataForProvider)
EmberAfStatus
OTAProviderExample::HandleQueryImage(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
uint16_t vendorId, uint16_t productId, uint32_t softwareVersion,
const chip::app::DataModel::DecodableList<EmberAfOTADownloadProtocol> & protocolsSupported,
const Optional<uint16_t> & hardwareVersion, const Optional<CharSpan> & location,
const Optional<bool> & requestorCanConsent, const Optional<ByteSpan> & metadataForProvider)
{
// TODO: add confiuration for returning BUSY status

Expand Down Expand Up @@ -150,18 +150,15 @@ EmberAfStatus OTAProviderExample::HandleQueryImage(chip::app::CommandHandler * c
}

chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::Type response;
response.status = queryStatus;
response.delayedActionTime = mDelayedActionTimeSec;
response.imageURI = chip::CharSpan(uriBuf, strlen(uriBuf));
response.softwareVersion = newSoftwareVersion;
response.softwareVersionString = chip::CharSpan(kExampleSoftwareString, strlen(kExampleSoftwareString));
response.updateToken = chip::ByteSpan(updateToken);
response.userConsentNeeded = userConsentNeeded;
// TODO: Once our client is using APIs that handle optional arguments
// correctly, update QueryImageResponse to have the right things optional.
// At that point we can decide whether to send metadataForRequestor as an
// empty ByteSpan or whether to not send it at all.
response.metadataForRequestor = chip::ByteSpan();
response.status = queryStatus;
response.delayedActionTime.Emplace(mDelayedActionTimeSec);
response.imageURI.Emplace(chip::CharSpan(uriBuf, strlen(uriBuf)));
response.softwareVersion.Emplace(newSoftwareVersion);
response.softwareVersionString.Emplace(chip::CharSpan(kExampleSoftwareString, strlen(kExampleSoftwareString)));
response.updateToken.Emplace(chip::ByteSpan(updateToken));
response.userConsentNeeded.Emplace(userConsentNeeded);
// Could also just not send metadataForRequestor at all.
response.metadataForRequestor.Emplace(chip::ByteSpan());

VerifyOrReturnError(commandObj->AddResponseData(commandPath, response) == CHIP_NO_ERROR, EMBER_ZCL_STATUS_FAILURE);
return EMBER_ZCL_STATUS_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class OTAProviderExample : public chip::app::Clusters::OTAProviderDelegate

// Inherited from OTAProviderDelegate
EmberAfStatus HandleQueryImage(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
uint16_t vendorId, uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported,
uint16_t vendorId, uint16_t productId, uint32_t softwareVersion,
const chip::app::DataModel::DecodableList<EmberAfOTADownloadProtocol> & protocolsSupported,
const chip::Optional<uint16_t> & hardwareVersion,
const chip::Optional<chip::CharSpan> & location,
const chip::Optional<bool> & requestorCanConsent,
Expand Down
13 changes: 6 additions & 7 deletions examples/ota-requestor-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,12 @@ void OnConnected(void * context, OperationalDeviceProxy * operationalDeviceProxy
constexpr EndpointId kOtaProviderEndpoint = 0;

// These QueryImage params have been chosen arbitrarily
constexpr VendorId kExampleVendorId = VendorId::Common;
constexpr uint16_t kExampleProductId = 77;
constexpr uint16_t kExampleHWVersion = 3;
constexpr uint16_t kExampleSoftwareVersion = 0;
constexpr EmberAfOTADownloadProtocol kExampleProtocolsSupported =
EMBER_ZCL_OTA_DOWNLOAD_PROTOCOL_BDX_SYNCHRONOUS; // TODO: support this as a list once ember adds list support
const char locationBuf[] = { 'U', 'S' };
constexpr VendorId kExampleVendorId = VendorId::Common;
constexpr uint16_t kExampleProductId = 77;
constexpr uint16_t kExampleHWVersion = 3;
constexpr uint16_t kExampleSoftwareVersion = 0;
constexpr EmberAfOTADownloadProtocol kExampleProtocolsSupported[] = { EMBER_ZCL_OTA_DOWNLOAD_PROTOCOL_BDX_SYNCHRONOUS };
const char locationBuf[] = { 'U', 'S' };
CharSpan exampleLocation(locationBuf);
constexpr bool kExampleClientCanConsent = false;
ByteSpan metadata;
Expand Down
5 changes: 3 additions & 2 deletions src/app/clusters/ota-provider/ota-provider-delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <app-common/zap-generated/enums.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/data-model/DecodableList.h>
#include <app/util/af.h>
#include <lib/core/Optional.h>

Expand All @@ -35,9 +36,9 @@ namespace Clusters {
class OTAProviderDelegate
{
public:
// TODO(#8605): protocolsSupported should be list of OTADownloadProtocol enums, not uint8_t
virtual EmberAfStatus HandleQueryImage(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, uint16_t vendorId,
uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported,
uint16_t productId, uint32_t softwareVersion,
const DataModel::DecodableList<EmberAfOTADownloadProtocol> & protocolsSupported,
const Optional<uint16_t> & hardwareVersion, const Optional<CharSpan> & location,
const Optional<bool> & requestorCanConsent,
const Optional<ByteSpan> & metadataForProvider) = 0;
Expand Down
8 changes: 7 additions & 1 deletion src/app/clusters/ota-provider/ota-provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,13 @@ bool emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback(app::CommandHandl
ChipLogDetail(Zcl, " VendorID: 0x%" PRIx16, vendorId);
ChipLogDetail(Zcl, " ProductID: %" PRIu16, productId);
ChipLogDetail(Zcl, " SoftwareVersion: %" PRIu32, softwareVersion);
ChipLogDetail(Zcl, " ProtocolsSupported: %" PRIu8, protocolsSupported);
ChipLogDetail(Zcl, " ProtocolsSupported: [");
auto protocolIter = protocolsSupported.begin();
while (protocolIter.Next())
{
ChipLogDetail(Zcl, " %" PRIu8, protocolIter.GetValue());
}
ChipLogDetail(Zcl, " ]");
if (hardwareVersion.HasValue())
{
ChipLogDetail(Zcl, " HardwareVersion: %" PRIu16, hardwareVersion.Value());
Expand Down
16 changes: 8 additions & 8 deletions src/app/zap-templates/zcl/data-model/chip/chip-ota.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ limitations under the License.
<arg name="vendorId" type="vendor_id"/>
<arg name="productId" type="INT16U"/>
<arg name="softwareVersion" type="INT32U"/>
<arg name="protocolsSupported" type="OTADownloadProtocol"/> <!-- TODO(#8605): add array="true" when lists are supported -->
<arg name="protocolsSupported" type="OTADownloadProtocol" array="true"/>
<arg name="hardwareVersion" type="INT16U" optional="true"/>
<arg name="location" type="CHAR_STRING" length="2" optional="true"/>
<arg name="requestorCanConsent" type="BOOLEAN" optional="true"/>
Expand All @@ -67,13 +67,13 @@ limitations under the License.
<command source="server" code="0x03" name="QueryImageResponse" optional="false" cli="chip ota queryimageresponse">
<description>Response to QueryImage command</description>
<arg name="status" type="OTAQueryStatus"/>
<arg name="delayedActionTime" type="INT32U"/>
<arg name="imageURI" type="CHAR_STRING"/>
<arg name="softwareVersion" type="INT32U"/>
<arg name="softwareVersionString" type="CHAR_STRING"/>
<arg name="updateToken" type="OCTET_STRING" length="32"/>
<arg name="userConsentNeeded" type="BOOLEAN" default="false"/>
<arg name="metadataForRequestor" type="OCTET_STRING" length="512"/>
<arg name="delayedActionTime" type="INT32U" optional="true"/>
<arg name="imageURI" type="CHAR_STRING" optional="true"/>
<arg name="softwareVersion" type="INT32U" optional="true"/>
<arg name="softwareVersionString" type="CHAR_STRING" optional="true"/>
<arg name="updateToken" type="OCTET_STRING" length="32" optional="true"/>
<arg name="userConsentNeeded" type="BOOLEAN" default="false" optional="true"/>
<arg name="metadataForRequestor" type="OCTET_STRING" length="512" optional="true"/>
</command>
<command source="server" code="0x04" name="ApplyUpdateResponse" optional="false" cli="chip ota applyupdateresponse">
<description>Reponse to ApplyUpdateRequest command</description>
Expand Down
4 changes: 2 additions & 2 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions zzz_generated/app-common/app-common/zap-generated/cluster-objects.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions zzz_generated/chip-tool/zap-generated/cluster/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 27a0643

Please sign in to comment.