| /* |
| * |
| * Copyright (c) 2022 Project CHIP Authors |
| * |
| * 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. |
| */ |
| |
| // THIS FILE IS GENERATED BY ZAP |
| // This file is generated from clusters-Commands.ipp.zapt |
| |
| #include <clusters/OtaSoftwareUpdateProvider/Commands.h> |
| |
| #include <app/data-model/Decode.h> |
| #include <app/data-model/StructDecodeIterator.h> |
| #include <app/data-model/WrappedStructEncoder.h> |
| |
| namespace chip { |
| namespace app { |
| namespace Clusters { |
| namespace OtaSoftwareUpdateProvider { |
| namespace Commands { |
| namespace QueryImage { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kVendorID), vendorID); |
| encoder.Encode(to_underlying(Fields::kProductID), productID); |
| encoder.Encode(to_underlying(Fields::kSoftwareVersion), softwareVersion); |
| encoder.Encode(to_underlying(Fields::kProtocolsSupported), protocolsSupported); |
| encoder.Encode(to_underlying(Fields::kHardwareVersion), hardwareVersion); |
| encoder.Encode(to_underlying(Fields::kLocation), location); |
| encoder.Encode(to_underlying(Fields::kRequestorCanConsent), requestorCanConsent); |
| encoder.Encode(to_underlying(Fields::kMetadataForProvider), metadataForProvider); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kVendorID)) |
| { |
| err = DataModel::Decode(reader, vendorID); |
| } |
| else if (__context_tag == to_underlying(Fields::kProductID)) |
| { |
| err = DataModel::Decode(reader, productID); |
| } |
| else if (__context_tag == to_underlying(Fields::kSoftwareVersion)) |
| { |
| err = DataModel::Decode(reader, softwareVersion); |
| } |
| else if (__context_tag == to_underlying(Fields::kProtocolsSupported)) |
| { |
| err = DataModel::Decode(reader, protocolsSupported); |
| } |
| else if (__context_tag == to_underlying(Fields::kHardwareVersion)) |
| { |
| err = DataModel::Decode(reader, hardwareVersion); |
| } |
| else if (__context_tag == to_underlying(Fields::kLocation)) |
| { |
| err = DataModel::Decode(reader, location); |
| } |
| else if (__context_tag == to_underlying(Fields::kRequestorCanConsent)) |
| { |
| err = DataModel::Decode(reader, requestorCanConsent); |
| } |
| else if (__context_tag == to_underlying(Fields::kMetadataForProvider)) |
| { |
| err = DataModel::Decode(reader, metadataForProvider); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace QueryImage. |
| namespace QueryImageResponse { |
| |
| CHIP_ERROR Type::Encode(DataModel::FabricAwareTLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kStatus), status); |
| encoder.Encode(to_underlying(Fields::kDelayedActionTime), delayedActionTime); |
| encoder.Encode(to_underlying(Fields::kImageURI), imageURI); |
| encoder.Encode(to_underlying(Fields::kSoftwareVersion), softwareVersion); |
| encoder.Encode(to_underlying(Fields::kSoftwareVersionString), softwareVersionString); |
| encoder.Encode(to_underlying(Fields::kUpdateToken), updateToken); |
| encoder.Encode(to_underlying(Fields::kUserConsentNeeded), userConsentNeeded); |
| encoder.Encode(to_underlying(Fields::kMetadataForRequestor), metadataForRequestor); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kStatus)) |
| { |
| err = DataModel::Decode(reader, status); |
| } |
| else if (__context_tag == to_underlying(Fields::kDelayedActionTime)) |
| { |
| err = DataModel::Decode(reader, delayedActionTime); |
| } |
| else if (__context_tag == to_underlying(Fields::kImageURI)) |
| { |
| err = DataModel::Decode(reader, imageURI); |
| } |
| else if (__context_tag == to_underlying(Fields::kSoftwareVersion)) |
| { |
| err = DataModel::Decode(reader, softwareVersion); |
| } |
| else if (__context_tag == to_underlying(Fields::kSoftwareVersionString)) |
| { |
| err = DataModel::Decode(reader, softwareVersionString); |
| } |
| else if (__context_tag == to_underlying(Fields::kUpdateToken)) |
| { |
| err = DataModel::Decode(reader, updateToken); |
| } |
| else if (__context_tag == to_underlying(Fields::kUserConsentNeeded)) |
| { |
| err = DataModel::Decode(reader, userConsentNeeded); |
| } |
| else if (__context_tag == to_underlying(Fields::kMetadataForRequestor)) |
| { |
| err = DataModel::Decode(reader, metadataForRequestor); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace QueryImageResponse. |
| namespace ApplyUpdateRequest { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kUpdateToken), updateToken); |
| encoder.Encode(to_underlying(Fields::kNewVersion), newVersion); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kUpdateToken)) |
| { |
| err = DataModel::Decode(reader, updateToken); |
| } |
| else if (__context_tag == to_underlying(Fields::kNewVersion)) |
| { |
| err = DataModel::Decode(reader, newVersion); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace ApplyUpdateRequest. |
| namespace ApplyUpdateResponse { |
| |
| CHIP_ERROR Type::Encode(DataModel::FabricAwareTLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kAction), action); |
| encoder.Encode(to_underlying(Fields::kDelayedActionTime), delayedActionTime); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kAction)) |
| { |
| err = DataModel::Decode(reader, action); |
| } |
| else if (__context_tag == to_underlying(Fields::kDelayedActionTime)) |
| { |
| err = DataModel::Decode(reader, delayedActionTime); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace ApplyUpdateResponse. |
| namespace NotifyUpdateApplied { |
| |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kUpdateToken), updateToken); |
| encoder.Encode(to_underlying(Fields::kSoftwareVersion), softwareVersion); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kUpdateToken)) |
| { |
| err = DataModel::Decode(reader, updateToken); |
| } |
| else if (__context_tag == to_underlying(Fields::kSoftwareVersion)) |
| { |
| err = DataModel::Decode(reader, softwareVersion); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| } // namespace NotifyUpdateApplied. |
| } // namespace Commands |
| } // namespace OtaSoftwareUpdateProvider |
| } // namespace Clusters |
| } // namespace app |
| } // namespace chip |