Line data Source code
1 : /**
2 : *
3 : * Copyright (c) 2021 Project CHIP Authors
4 : * Licensed under the Apache License, Version 2.0 (the "License");
5 : * you may not use this file except in compliance with the License.
6 : * You may obtain a copy of the License at
7 : *
8 : * http://www.apache.org/licenses/LICENSE-2.0
9 : *
10 : * Unless required by applicable law or agreed to in writing, software
11 : * distributed under the License is distributed on an "AS IS" BASIS,
12 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 : * See the License for the specific language governing permissions and
14 : * limitations under the License.
15 : */
16 :
17 : #include "MessageParser.h"
18 : #include "MessageDefHelper.h"
19 : #include <app/SpecificationDefinedRevisions.h>
20 :
21 : namespace chip {
22 : namespace app {
23 9003 : CHIP_ERROR MessageParser::Init(TLV::TLVReader & aReader)
24 : {
25 9003 : ReturnErrorOnFailure(aReader.Next(TLV::kTLVType_Structure, TLV::AnonymousTag()));
26 9002 : return StructParser::Init(aReader);
27 : }
28 :
29 7958 : CHIP_ERROR MessageParser::ExitContainer()
30 : {
31 : // Ignore any other tags that might be here.
32 7958 : ReturnErrorOnFailure(mReader.ExitContainer(mOuterContainerType));
33 :
34 : // There should be nothing outside the toplevel struct.
35 7957 : VerifyOrReturnError(mReader.Next() == CHIP_END_OF_TLV, CHIP_ERROR_INVALID_TLV_TAG);
36 7957 : return CHIP_NO_ERROR;
37 : }
38 :
39 : #if CHIP_CONFIG_IM_PRETTY_PRINT
40 7881 : CHIP_ERROR MessageParser::CheckInteractionModelRevision(TLV::TLVReader & aReader) const
41 : {
42 : #if CHIP_DETAIL_LOGGING
43 : {
44 7881 : uint8_t interactionModelRevision = 0;
45 7881 : ReturnErrorOnFailure(aReader.Get(interactionModelRevision));
46 7881 : PRETTY_PRINT("\tInteractionModelRevision = %u", interactionModelRevision);
47 : }
48 : #endif // CHIP_DETAIL_LOGGING
49 7881 : return CHIP_NO_ERROR;
50 : }
51 : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
52 :
53 0 : CHIP_ERROR MessageParser::GetInteractionModelRevision(InteractionModelRevision * const apInteractionModelRevision) const
54 : {
55 0 : return GetUnsignedInteger(Revision::kInteractionModelRevisionTag, apInteractionModelRevision);
56 : }
57 :
58 : } // namespace app
59 : } // namespace chip
|