3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2016-2017 Nest Labs, Inc.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 * This file defines CHIP interaction model message parsers and encoders
21 * Interaction model profile.
27 #ifndef _CHIP_INTERACTION_MODEL_MESSAGE_DEF_H
28 #define _CHIP_INTERACTION_MODEL_MESSAGE_DEF_H
30 #include <core/CHIPCore.h>
31 #include <core/CHIPTLV.h>
32 #include <support/CodeUtils.h>
33 #include <support/logging/CHIPLogging.h>
34 #include <util/basic-types.h>
40 * The CHIP interaction model message types.
42 * These values are called out in CHIP Interaction Model: Encoding Specification
47 kMsgType_SubscribeRequest = 0x01,
48 kMsgType_ReadRequest = 0x02,
49 kMsgType_ReportData = 0x03,
50 kMsgType_WriteRequest = 0x04,
51 kMsgType_WriteResponse = 0x05,
52 kMsgType_InvokeCommandRequest = 0x06,
53 kMsgType_InvokeCommandResponse = 0x07,
60 * @brief Initialize the Builder object with TLVReader and ContainerType
62 * @param [in] aReader TLVReader
63 * @param [in] aOuterContainerType outer container type
66 void Init(const chip::TLV::TLVReader & aReader, chip::TLV::TLVType aOuterContainerType);
69 * @brief Initialize a TLVReader to point to the beginning of any tagged element in this request
71 * @param [in] aTagToFind Tag to find in the request
72 * @param [out] apReader A pointer to TLVReader, which will be initialized at the specified TLV element
75 * @return #CHIP_NO_ERROR on success
77 CHIP_ERROR GetReaderOnTag(const uint64_t aTagToFind, chip::TLV::TLVReader * const apReader) const;
80 * @brief Get the TLV Reader
82 * @param [in] aReader A pointer to a TLVReader
85 void GetReader(chip::TLV::TLVReader * const apReader);
88 chip::TLV::TLVReader mReader;
89 chip::TLV::TLVType mOuterContainerType;
93 CHIP_ERROR GetUnsignedInteger(const uint8_t aContextTag, T * const apLValue) const;
96 CHIP_ERROR GetSimpleValue(const uint8_t aContextTag, const chip::TLV::TLVType aTLVType, T * const apLValue) const;
99 class ListParser : public chip::app::Parser
106 * @brief Initialize the parser object with TLVReader
108 * @param [in] aReader A pointer to a TLVReader, which should be on the element of the array element
110 * @return #CHIP_NO_ERROR on success
112 CHIP_ERROR Init(const chip::TLV::TLVReader & aReader);
115 * @brief Initialize the parser object with TLVReader if context tag exists
117 * @param [in] aReader A pointer to a TLVReader, which should be on the element of the array element
118 * @param [in] aContextTagToFind A context tag it tries to find
120 * @return #CHIP_NO_ERROR on success
122 CHIP_ERROR InitIfPresent(const chip::TLV::TLVReader & aReader, const uint8_t aContextTagToFind);
125 * @brief Iterate to next element
127 * @return #CHIP_NO_ERROR on success
136 * @brief Initialize the Builder object with TLVWriter and ContainerType
138 * @param [in] apWriter A pointer to a TLVWriter
139 * @param [in] aOuterContainerType outer container type
142 void Init(chip::TLV::TLVWriter * const apWriter, chip::TLV::TLVType aOuterContainerType);
145 * @brief Reset the Error
151 * @brief Reset the Error with particular aErr.
152 * @param [in] aErr the Error it would be reset with
155 void ResetError(CHIP_ERROR aErr);
158 * @brief Get current error
160 * @return #CHIP_NO_ERROR on success
162 CHIP_ERROR GetError() const { return mError; };
165 * @brief Get TLV Writer
167 * @return #Pointer to the TLVWriter
169 chip::TLV::TLVWriter * GetWriter() { return mpWriter; };
173 chip::TLV::TLVWriter * mpWriter;
174 chip::TLV::TLVType mOuterContainerType;
177 void EndOfContainer();
179 CHIP_ERROR InitAnonymousStructure(chip::TLV::TLVWriter * const apWriter);
182 class ListBuilder : public chip::app::Builder
189 * Init the TLV array container with an particular context tag.
190 * Required to implement arrays of arrays, and to test ListBuilder.
192 * @param[in] apWriter Pointer to the TLVWriter that is encoding the message.
193 * @param[in] aContextTagToUse A contextTag to use.
195 * @return CHIP_ERROR codes returned by Chip::TLV objects.
198 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter, const uint8_t aContextTagToUse);
200 * Init the TLV array container with an anonymous tag.
201 * Required to implement arrays of arrays, and to test ListBuilder.
203 * @param[in] apWriter Pointer to the TLVWriter that is encoding the message.
205 * @return CHIP_ERROR codes returned by Chip::TLV objects.
207 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);
210 namespace AttributePath {
214 kCsTag_EndpointId = 1,
215 kCsTag_NamespacedClusterId = 2,
217 kCsTag_ListIndex = 4,
220 class Parser : public chip::app::Parser
224 * @brief Initialize the parser object with TLVReader
226 * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this AttributePath
228 * @return #CHIP_NO_ERROR on success
230 CHIP_ERROR Init(const chip::TLV::TLVReader & aReader);
233 * @brief Roughly verify the message is correctly formed
234 * 1) all mandatory tags are present
235 * 2) all elements have expected data type
236 * 3) any tag can only appear once
237 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
238 * @note The main use of this function is to print out what we're
239 * receiving during protocol development and debugging.
240 * The encoding rule has changed in IM encoding spec so this
241 * check is only "roughly" conformant now.
243 * @return #CHIP_NO_ERROR on success
245 CHIP_ERROR CheckSchemaValidity() const;
248 * @brief Get a TLVReader for the NodeId. Next() must be called before accessing them.
250 * @param [in] apNodeId A pointer to apNodeId
252 * @return #CHIP_NO_ERROR on success
253 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
254 * #CHIP_END_OF_TLV if there is no such element
256 CHIP_ERROR GetNodeId(chip::NodeId * const apNodeId) const;
259 * @brief Get a TLVReader for the EndpointId. Next() must be called before accessing them.
261 * @param [in] apEndpointId A pointer to apEndpointId
263 * @return #CHIP_NO_ERROR on success
264 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
265 * #CHIP_END_OF_TLV if there is no such element
267 CHIP_ERROR GetEndpointId(chip::EndpointId * const apEndpointId) const;
270 * @brief Get a TLVReader for the ClusterId. Next() must be called before accessing them.
272 * @param [in] apClusterId A pointer to apClusterId
274 * @return #CHIP_NO_ERROR on success
275 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
276 * #CHIP_END_OF_TLV if there is no such element
278 CHIP_ERROR GetNamespacedClusterId(chip::ClusterId * const apClusterId) const;
281 * @brief Get a TLVReader for the FieldId. Next() must be called before accessing them.
283 * @param [in] apFieldId A pointer to apFieldId
285 * @return #CHIP_NO_ERROR on success
286 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
287 * #CHIP_END_OF_TLV if there is no such element
289 CHIP_ERROR GetFieldId(uint8_t * const apFieldId) const;
292 * @brief Get a TLVReader for the ListIndex. Next() must be called before accessing them.
294 * @param [in] apListIndex A pointer to apListIndex
296 * @return #CHIP_NO_ERROR on success
297 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
298 * #CHIP_END_OF_TLV if there is no such element
300 CHIP_ERROR GetListIndex(uint16_t * const apListIndex) const;
303 class Builder : public chip::app::Builder
307 * @brief Initialize a AttributePath::Builder for writing into a TLV stream
309 * @param [in] apWriter A pointer to TLVWriter
311 * @return #CHIP_NO_ERROR on success
313 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);
316 * Init the AttributePath container with an particular context tag.
317 * Required to implement arrays of arrays, and to test ListBuilder.
319 * @param[in] apWriter Pointer to the TLVWriter that is encoding the message.
320 * @param[in] aContextTagToUse A contextTag to use.
322 * @return CHIP_ERROR codes returned by Chip::TLV objects.
324 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter, const uint8_t aContextTagToUse);
327 * @brief Inject NodeId into the TLV stream.
329 * @param [in] aNodeId NodeId for this attribute path
331 * @return A reference to *this
333 AttributePath::Builder & NodeId(const chip::NodeId aNodeId);
336 * @brief Inject EndpointId into the TLV stream.
338 * @param [in] aEndpointId NodeId for this attribute path
340 * @return A reference to *this
342 AttributePath::Builder & EndpointId(const chip::EndpointId aEndpointId);
345 * @brief Inject NamespacedClusterId into the TLV stream.
347 * @param [in] aNamespacedClusterId NamespacedClusterId for this attribute path
349 * @return A reference to *this
351 AttributePath::Builder & NamespacedClusterId(const chip::ClusterId aNamespacedClusterId);
354 * @brief Inject FieldId into the TLV stream.
356 * @param [in] aFieldId FieldId for this attribute path
358 * @return A reference to *this
360 AttributePath::Builder & FieldId(const uint8_t aFieldId);
363 * @brief Inject NodeId into the TLV stream.
365 * @param [in] aListIndex NodeId for this attribute path
367 * @return A reference to *this
369 AttributePath::Builder & ListIndex(const uint16_t aListIndex);
372 * @brief Mark the end of this AttributePath
374 * @return A reference to *this
376 AttributePath::Builder & EndOfAttributePath();
379 CHIP_ERROR _Init(chip::TLV::TLVWriter * const apWriter, const uint64_t aTag);
382 }; // namespace AttributePath
384 namespace AttributePathList {
385 class Parser : public ListParser
389 * @brief Roughly verify the message is correctly formed
390 * 1) all mandatory tags are present
391 * 2) all elements have expected data type
392 * 3) any tag can only appear once
393 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
394 * @note The main use of this function is to print out what we're
395 * receiving during protocol development and debugging.
396 * The encoding rule has changed in IM encoding spec so this
397 * check is only "roughly" conformant now.
399 * @return #CHIP_NO_ERROR on success
401 CHIP_ERROR CheckSchemaValidity() const;
404 class Builder : public ListBuilder
408 * @brief Initialize a AttributePath::Builder for writing into the TLV stream
410 * @return A reference to AttributePath::Builder
412 AttributePath::Builder & CreateAttributePathBuilder();
415 * @brief Mark the end of this AttributePath
417 * @return A reference to *this
419 AttributePathList::Builder & EndOfAttributePathList();
422 AttributePath::Builder mAttributePathBuilder;
424 }; // namespace AttributePathList
426 namespace EventPath {
430 kCsTag_EndpointId = 1,
431 kCsTag_NamespacedClusterId = 2,
435 class Parser : public chip::app::Parser
439 * @brief Initialize the parser object with TLVReader
441 * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this EventPath
443 * @return #CHIP_NO_ERROR on success
445 CHIP_ERROR Init(const chip::TLV::TLVReader & aReader);
448 * @brief Roughly verify the message is correctly formed
449 * 1) all mandatory tags are present
450 * 2) all elements have expected data type
451 * 3) any tag can only appear once
452 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
453 * @note The main use of this function is to print out what we're
454 * receiving during protocol development and debugging.
455 * The encoding rule has changed in IM encoding spec so this
456 * check is only "roughly" conformant now.
458 * @return #CHIP_NO_ERROR on success
460 CHIP_ERROR CheckSchemaValidity() const;
463 * @brief Get a TLVReader for the NodeId. Next() must be called before accessing them.
465 * @param [in] apNodeId A pointer to apNodeId
467 * @return #CHIP_NO_ERROR on success
468 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
469 * #CHIP_END_OF_TLV if there is no such element
471 CHIP_ERROR GetNodeId(chip::NodeId * const apNodeId) const;
474 * @brief Get a TLVReader for the EndpointId. Next() must be called before accessing them.
476 * @param [in] apEndpointId A pointer to apEndpointId
478 * @return #CHIP_NO_ERROR on success
479 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
480 * #CHIP_END_OF_TLV if there is no such element
482 CHIP_ERROR GetEndpointId(chip::EndpointId * const apEndpointId) const;
485 * @brief Get a TLVReader for the NamespacedClusterId. Next() must be called before accessing them.
487 * @param [in] apNamespacedClusterId A pointer to apNamespacedClusterId
489 * @return #CHIP_NO_ERROR on success
490 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
491 * #CHIP_END_OF_TLV if there is no such element
493 CHIP_ERROR GetNamespacedClusterId(chip::ClusterId * const apNamespacedClusterId) const;
496 * @brief Get a TLVReader for the EventId. Next() must be called before accessing them.
498 * @param [in] apEventId A pointer to apEventId
500 * @return #CHIP_NO_ERROR on success
501 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
502 * #CHIP_END_OF_TLV if there is no such element
504 CHIP_ERROR GetEventId(chip::EventId * const apEventId) const;
507 class Builder : public chip::app::Builder
511 * @brief Initialize a EventPath::Builder for writing into a TLV stream
513 * @param [in] apWriter A pointer to TLVWriter
515 * @return #CHIP_NO_ERROR on success
517 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);
520 * Init the EventPath container with an particular context tag.
521 * Required to implement arrays of arrays, and to test ListBuilder.
523 * @param[in] apWriter Pointer to the TLVWriter that is encoding the message.
524 * @param[in] aContextTagToUse A contextTag to use.
526 * @return CHIP_ERROR codes returned by Chip::TLV objects.
528 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter, const uint8_t aContextTagToUse);
531 * @brief Inject NodeId into the TLV stream.
533 * @param [in] aNodeId NodeId for this event path
535 * @return A reference to *this
537 EventPath::Builder & NodeId(const chip::NodeId aNodeId);
540 * @brief Inject EndpointId into the TLV stream.
542 * @param [in] aEndpointId EndpointId for this eevent path
544 * @return A reference to *this
546 EventPath::Builder & EndpointId(const chip::EndpointId aEndpointId);
549 * @brief Inject NamespacedClusterId into the TLV stream.
551 * @param [in] aNamespacedClusterId NamespacedClusterId for this event path
553 * @return A reference to *this
555 EventPath::Builder & NamespacedClusterId(const chip::ClusterId aNamespacedClusterId);
558 * @brief Inject EventId into the TLV stream.
560 * @param [in] aEventId NamespacedClusterId for this event path
562 * @return A reference to *this
564 EventPath::Builder & EventId(const chip::EventId aEventId);
567 * @brief Mark the end of this EventPath
569 * @return A reference to *this
571 EventPath::Builder & EndOfEventPath();
574 CHIP_ERROR _Init(chip::TLV::TLVWriter * const apWriter, const uint64_t aTag);
576 }; // namespace EventPath
578 namespace EventPathList {
579 class Parser : public ListParser
583 * @brief Roughly verify the message is correctly formed
584 * 1) all mandatory tags are present
585 * 2) all elements have expected data type
586 * 3) any tag can only appear once
587 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
588 * @note The main use of this function is to print out what we're
589 * receiving during protocol development and debugging.
590 * The encoding rule has changed in IM encoding spec so this
591 * check is only "roughly" conformant now.
593 * @return #CHIP_NO_ERROR on success
595 CHIP_ERROR CheckSchemaValidity() const;
598 class Builder : public ListBuilder
602 * @brief Initialize a EventPath::Builder for writing into the TLV stream
604 * @return A reference to EventPath::Builder
606 EventPath::Builder & CreateEventPathBuilder();
609 * @brief Mark the end of this EventPathList
611 * @return A reference to *this
613 EventPathList::Builder & EndOfEventPathList();
616 EventPath::Builder mEventPathBuilder;
618 }; // namespace EventPathList
620 namespace CommandPath {
623 kCsTag_EndpointId = 0,
625 kCsTag_NamespacedClusterId = 2,
626 kCsTag_CommandId = 3,
629 class Parser : public chip::app::Parser
633 * @brief Initialize the parser object with TLVReader
635 * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this CommandPath
637 * @return #CHIP_NO_ERROR on success
639 CHIP_ERROR Init(const chip::TLV::TLVReader & aReader);
642 * @brief Roughly verify the message is correctly formed
643 * 1) all mandatory tags are present
644 * 2) all elements have expected data type
645 * 3) any tag can only appear once
646 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
647 * @note The main use of this function is to print out what we're
648 * receiving during protocol development and debugging.
649 * The encoding rule has changed in IM encoding spec so this
650 * check is only "roughly" conformant now.
652 * @return #CHIP_NO_ERROR on success
654 CHIP_ERROR CheckSchemaValidity() const;
657 * @brief Get a TLVReader for the EndpointId. Next() must be called before accessing them.
659 * @param [in] apEndpointId A pointer to apEndpointId
661 * @return #CHIP_NO_ERROR on success
662 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
663 * #CHIP_END_OF_TLV if there is no such element
665 CHIP_ERROR GetEndpointId(chip::EndpointId * const apEndpointId) const;
668 * @brief Get a TLVReader for the GroupId. Next() must be called before accessing them.
670 * @param [in] apGroupId A pointer to apGroupId
672 * @return #CHIP_NO_ERROR on success
673 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
674 * #CHIP_END_OF_TLV if there is no such element
676 CHIP_ERROR GetGroupId(chip::GroupId * const apGroupId) const;
679 * @brief Get a TLVReader for the NamespacedClusterId. Next() must be called before accessing them.
681 * @param [in] apEndpointId A pointer to NamespacedClusterId
683 * @return #CHIP_NO_ERROR on success
684 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
685 * #CHIP_END_OF_TLV if there is no such element
687 CHIP_ERROR GetNamespacedClusterId(chip::ClusterId * const apNamespacedClusterId) const;
690 * @brief Get a TLVReader for the CommandId. Next() must be called before accessing them.
692 * @param [in] apEndpointId A pointer to CommandId
694 * @return #CHIP_NO_ERROR on success
695 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
696 * #CHIP_END_OF_TLV if there is no such element
698 CHIP_ERROR GetCommandId(chip::CommandId * const apCommandId) const;
701 class Builder : public chip::app::Builder
705 * @brief Initialize a CommandPath::Builder for writing into a TLV stream
707 * @param [in] apWriter A pointer to TLVWriter
709 * @return #CHIP_NO_ERROR on success
711 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);
714 * Init the CommandPath container with an particular context tag.
715 * Required to implement arrays of arrays, and to test ListBuilder.
717 * @param[in] apWriter Pointer to the TLVWriter that is encoding the message.
718 * @param[in] aContextTagToUse A contextTag to use.
720 * @return CHIP_ERROR codes returned by Chip::TLV objects.
722 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter, const uint8_t aContextTagToUse);
725 * @brief Inject EndpointId into the TLV stream to indicate the endpointId referenced by the path.
727 * @param [in] aEndpointId refer to the ID of the endpoint as described in the descriptor cluster.
729 * @return A reference to *this
731 CommandPath::Builder & EndpointId(const chip::EndpointId aEndpointId);
734 * @brief Inject GroupId into the TLV stream to indicate the GroupId referenced by the path.
736 * @param [in] aGroupId Group Id for this Command path
738 * @return A reference to *this
740 CommandPath::Builder & GroupId(const chip::GroupId aGroupId);
743 * @brief Inject NamespacedClusterId into the TLV stream.
745 * @param [in] aNamespacedClusterId NamespacedClusterId for this command path
747 * @return A reference to *this
749 CommandPath::Builder & NamespacedClusterId(const chip::ClusterId aNamespacedClusterId);
752 * @brief Inject CommandId into the TLV stream
754 * @param [in] aCommandId Command Id for NamespacedClusterId for this command path
756 * @return A reference to *this
758 CommandPath::Builder & CommandId(const chip::CommandId aCommandId);
761 * @brief Mark the end of this CommandPath
763 * @return A reference to *this
765 CommandPath::Builder & EndOfCommandPath();
768 CHIP_ERROR _Init(chip::TLV::TLVWriter * const apWriter, const uint64_t aTag);
770 }; // namespace CommandPath
772 namespace EventDataElement {
775 kCsTag_EventPath = 0,
776 kCsTag_ImportanceLevel = 1,
778 kCsTag_UTCTimestamp = 3,
779 kCsTag_SystemTimestamp = 4,
780 kCsTag_DeltaUTCTimestamp = 5,
781 kCsTag_DeltaSystemTimestamp = 6,
785 class Parser : public chip::app::Parser
789 * @brief Initialize the parser object with TLVReader
791 * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this EventDataElement
793 * @return #CHIP_NO_ERROR on success
795 CHIP_ERROR Init(const chip::TLV::TLVReader & aReader);
798 * @brief Roughly verify the message is correctly formed
799 * 1) all mandatory tags are present
800 * 2) all elements have expected data type
801 * 3) any tag can only appear once
802 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
803 * @note The main use of this function is to print out what we're
804 * receiving during protocol development and debugging.
805 * The encoding rule has changed in IM encoding spec so this
806 * check is only "roughly" conformant now.
808 * @return #CHIP_NO_ERROR on success
810 CHIP_ERROR CheckSchemaValidity() const;
813 * @brief Get a TLVReader for the EventPath. Next() must be called before accessing them.
815 * @param [in] apEventPath A pointer to apEventPath
817 * @return #CHIP_NO_ERROR on success
818 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a Path
819 * #CHIP_END_OF_TLV if there is no such element
821 CHIP_ERROR GetEventPath(EventPath::Parser * const apEventPath);
824 * @brief Get a TLVReader for the Number. Next() must be called before accessing them.
826 * @param [in] apImportanceLevel A pointer to apImportanceLevel
828 * @return #CHIP_NO_ERROR on success
829 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
830 * #CHIP_END_OF_TLV if there is no such element
832 CHIP_ERROR GetImportanceLevel(uint8_t * const apImportanceLevel);
835 * @brief Get a TLVReader for the Number. Next() must be called before accessing them.
837 * @param [in] apNumber A pointer to apNumber
839 * @return #CHIP_NO_ERROR on success
840 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
841 * #CHIP_END_OF_TLV if there is no such element
843 CHIP_ERROR GetNumber(uint64_t * const apNumber);
846 * @brief Get a TLVReader for the UTCTimestamp. Next() must be called before accessing them.
848 * @param [in] apUTCTimestamp A pointer to apUTCTimestamp
850 * @return #CHIP_NO_ERROR on success
851 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
852 * #CHIP_END_OF_TLV if there is no such element
854 CHIP_ERROR GetUTCTimestamp(uint64_t * const apUTCTimestamp);
857 * @brief Get a TLVReader for the SystemTimestamp. Next() must be called before accessing them.
859 * @param [in] apSystemTimestamp A pointer to apSystemTimestamp
861 * @return #CHIP_NO_ERROR on success
862 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
863 * #CHIP_END_OF_TLV if there is no such element
865 CHIP_ERROR GetSystemTimestamp(uint64_t * const apSystemTimestamp);
868 * @brief Get a TLVReader for the DeltaUTCTime. Next() must be called before accessing them.
870 * @param [in] apDeltaUTCTimestamp A pointer to apDeltaUTCTime
872 * @return #CHIP_NO_ERROR on success
873 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
874 * #CHIP_END_OF_TLV if there is no such element
876 CHIP_ERROR GetDeltaUTCTime(uint64_t * const apDeltaUTCTime);
879 * @brief Get a TLVReader for the DeltaSystemTime. Next() must be called before accessing them.
881 * @param [in] apDeltaSystemTimestamp A pointer to apDeltaSystemTime
883 * @return #CHIP_NO_ERROR on success
884 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
885 * #CHIP_END_OF_TLV if there is no such element
887 CHIP_ERROR GetDeltaSystemTime(uint64_t * const apDeltaSystemTime);
890 * @brief Get a TLVReader for the Data. Next() must be called before accessing them.
892 * @param [in] apReader A pointer to apReader
894 * @return #CHIP_NO_ERROR on success
895 * #CHIP_END_OF_TLV if there is no such element
897 CHIP_ERROR GetData(chip::TLV::TLVReader * const apReader) const;
900 // A recursively callable function to parse a data element and pretty-print it.
901 CHIP_ERROR ParseData(chip::TLV::TLVReader & aReader, int aDepth) const;
904 class Builder : public chip::app::Builder
908 * @brief Initialize a EventDataElement::Builder for writing into a TLV stream
910 * @param [in] apWriter A pointer to TLVWriter
912 * @return #CHIP_NO_ERROR on success
914 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);
917 * @brief Initialize a EventPath::Builder for writing into the TLV stream
919 * @return A reference to EventPath::Builder
921 EventPath::Builder & CreateEventPathBuilder();
924 * @brief Inject ImportanceLevel into the TLV stream to indicate the importance level associated with
925 * the cluster that is referenced by the path.
927 * @param [in] aImportanceLevel This is an integer representation of the importance level.
929 * @return A reference to *this
931 EventDataElement::Builder ImportanceLevel(const uint8_t aImportanceLevel);
934 * @brief Inject Number into the TLV stream to indicate the number associated with
935 * the cluster that is referenced by the path. The event number is a monotonically increasing number that
936 * uniquely identifies each emitted event. This number is scoped to the ImportanceLevel.
938 * @param [in] aNumber The uint64_t variable to reflectt the event number
940 * @return A reference to *this
942 EventDataElement::Builder Number(const uint64_t aNumber);
945 * @brief Inject UTCTimestamp into the TLV stream.
946 * This is encoded as a 64-bit millisecond number since UNIX epoch (Jan 1 1970 00:00:00 GMT).
948 * @param [in] aUTCTimestamp The uint64_t variable to reflect the UTC timestamp of the Event.
950 * @return A reference to *this
952 EventDataElement::Builder UTCTimestamp(const uint64_t aUTCTimestamp);
955 * @brief Inject SystemTimestamp into the TLV stream. If UTC time is not available, time since boot
956 * SHALL be encoded in this field as 64-bit, milliseconds.
958 * @param [in] aSystemTimestamp The uint64_t variable to reflect system time
960 * @return A reference to *this
962 EventDataElement::Builder SystemTimestamp(const uint64_t aSystemTimestamp);
965 * @brief Inject DataVersion into the TLV stream to indicate the numerical data version associated with
966 * the cluster that is referenced by the path. When this field is present, the UTC Timestamp field SHALL be omitted.
968 * @param [in] aDataVersion The uint64_t variable to reflect DeltaUTCTime
970 * @return A reference to *this
972 EventDataElement::Builder DeltaUTCTime(const uint64_t aDeltaUTCTime);
975 * @brief Inject DeltaSystemTimestamp into the TLV stream.
976 * This field is present if delta encoding of the System timestamp relative to a prior event is desired for compression
977 * reasons. When this field is present, the System Timestamp field SHALL be omitted.
979 * @param [in] DeltaSystemTimestamp The uint64_t variable to reflect DeltaSystemTime
981 * @return A reference to *this
983 EventDataElement::Builder DeltaSystemTime(const uint64_t aDeltaSystemTime);
986 * @brief Mark the end of this EventDataElement
988 * @return A reference to *this
990 EventDataElement::Builder & EndOfEventDataElement();
993 EventPath::Builder mEventPathBuilder;
995 }; // namespace EventDataElement
997 namespace EventList {
998 class Parser : public ListParser
1002 * @brief Roughly verify the message is correctly formed
1003 * 1) all mandatory tags are present
1004 * 2) all elements have expected data type
1005 * 3) any tag can only appear once
1006 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
1007 * @note The main use of this function is to print out what we're
1008 * receiving during protocol development and debugging.
1009 * The encoding rule has changed in IM encoding spec so this
1010 * check is only "roughly" conformant now.
1012 * @return #CHIP_NO_ERROR on success
1014 CHIP_ERROR CheckSchemaValidity() const;
1017 class Builder : public ListBuilder
1021 * @brief Initialize a EventDataElement::Builder for writing into the TLV stream
1023 * @return A reference to EventDataElement::Builder
1025 EventDataElement::Builder & CreateEventBuilder();
1028 * @brief Mark the end of this EventList
1030 * @return A reference to *this
1032 EventList::Builder & EndOfEventList();
1035 EventDataElement::Builder mEventDataElementBuilder;
1037 }; // namespace EventList
1039 namespace StatusElement {
1042 kCsTag_GeneralCode = 1,
1043 kCsTag_ProtocolId = 2,
1044 kCsTag_ProtocolCode = 3,
1045 kCsTag_NamespacedClusterId = 4
1048 class Parser : public ListParser
1052 * @brief Initialize the parser object with TLVReader
1054 * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this StatusElement
1056 * @return #CHIP_NO_ERROR on success
1058 CHIP_ERROR Init(const chip::TLV::TLVReader & aReader);
1061 * @brief Roughly verify the message is correctly formed
1062 * 1) all mandatory tags are present
1063 * 2) all elements have expected data type
1064 * 3) any tag can only appear once
1065 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
1066 * @note The main use of this function is to print out what we're
1067 * receiving during protocol development and debugging.
1068 * The encoding rule has changed in IM encoding spec so this
1069 * check is only "roughly" conformant now.
1071 * @return #CHIP_NO_ERROR on success
1073 CHIP_ERROR CheckSchemaValidity() const;
1076 `* Read the GeneralCode, ProtocolId, ProtocolCode, NamespacedClusterId
1078 * @param[out] apGeneralCode Pointer to the storage for the GeneralCode
1079 * @param[out] apProtocolId Pointer to the storage for the ProtocolId
1080 * @param[out] apProtocolCode Pointer to the storage for the ProtocolCode
1081 * @param[out] apNamespacedClusterId Pointer to the storage for the NamespacedClusterId
1083 * @return CHIP_ERROR codes returned by Chip::TLV objects. CHIP_END_OF_TLV if either
1084 * element is missing. CHIP_ERROR_WRONG_TLV_TYPE if the elements are of the wrong
1087 CHIP_ERROR DecodeStatusElement(uint16_t * apGeneralCode, uint32_t * apProtocolId, uint16_t * apProtocolCode,
1088 chip::ClusterId * apNamespacedClusterId) const;
1091 class Builder : public ListBuilder
1095 * @brief Initialize a StatusElement::Builder for writing into a TLV stream
1097 * @param [in] apWriter A pointer to TLVWriter
1099 * @return #CHIP_NO_ERROR on success
1101 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);
1104 * Init the StatusElement container with an particular context tag.
1105 * Required to implement arrays of arrays, and to test ListBuilder.
1107 * @param[in] apWriter Pointer to the TLVWriter that is encoding the message.
1108 * @param[in] aContextTagToUse A contextTag to use.
1110 * @return CHIP_ERROR codes returned by Chip::TLV objects.
1112 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter, const uint8_t aContextTagToUse);
1115 `* Read the GeneralCode, ProtocolId, ProtocolCode, NamespacedClusterId
1117 * @param[in] aGeneralCode General status code
1118 * @param[in] aProtocolId A protocol ID (32-bit integer composed of a 16-bit vendor id and 16-bit Scoped id)
1119 * @param[in] aProtocolCode 16-bit protocol-specific error code
1120 * @param[in] aNamespacedClusterId Cluster Id for ZCL
1122 * @return CHIP_ERROR codes returned by Chip::TLV objects. CHIP_END_OF_TLV if either
1123 * element is missing. CHIP_ERROR_WRONG_TLV_TYPE if the elements are of the wrong
1126 StatusElement::Builder & EncodeStatusElement(const uint16_t aGeneralCode, const uint32_t aProtocolId,
1127 const uint16_t aProtocolCode, const chip::ClusterId aNamespacedClusterId);
1130 * @brief Mark the end of this StatusElement
1132 * @return A reference to *this
1134 StatusElement::Builder & EndOfStatusElement();
1136 }; // namespace StatusElement
1138 namespace AttributeStatusElement {
1141 kCsTag_AttributePath = 0,
1142 kCsTag_StatusElement = 1,
1145 class Builder : public chip::app::Builder
1149 * @brief Initialize a AttributeStatusElement::Builder for writing into a TLV stream
1151 * @param [in] apWriter A pointer to TLVWriter
1153 * @return #CHIP_NO_ERROR on success
1155 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);
1158 * @brief Initialize a AttributePath::Builder for writing into the TLV stream
1160 * @return A reference to AttributePath::Builder
1162 AttributePath::Builder & CreateAttributePathBuilder();
1165 * @brief Initialize a StatusElement::Builder for writing into the TLV stream
1167 * @return A reference to StatusElement::Builder
1169 StatusElement::Builder & CreateStatusElementBuilder();
1172 * @brief Mark the end of this AttributeStatusElement
1174 * @return A reference to *this
1176 AttributeStatusElement::Builder & EndOfAttributeStatusElement();
1179 AttributePath::Builder mAttributePathBuilder;
1180 StatusElement::Builder mStatusElementBuilder;
1183 class Parser : public chip::app::Parser
1187 * @brief Initialize the parser object with TLVReader
1189 * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this AttributeStatusElement
1191 * @return #CHIP_NO_ERROR on success
1193 CHIP_ERROR Init(const chip::TLV::TLVReader & aReader);
1196 * @brief Roughly verify the message is correctly formed
1197 * 1) all mandatory tags are present
1198 * 2) all elements have expected data type
1199 * 3) any tag can only appear once
1200 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
1201 * @note The main use of this function is to print out what we're
1202 * receiving during protocol development and debugging.
1203 * The encoding rule has changed in IM encoding spec so this
1204 * check is only "roughly" conformant now.
1206 * @return #CHIP_NO_ERROR on success
1208 CHIP_ERROR CheckSchemaValidity() const;
1211 * @brief Get a TLVReader for the AttributePath. Next() must be called before accessing them.
1213 * @param [in] apAttributePath A pointer to apAttributePath
1215 * @return #CHIP_NO_ERROR on success
1216 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a Path
1217 * #CHIP_END_OF_TLV if there is no such element
1219 CHIP_ERROR GetAttributePath(AttributePath::Parser * const apAttributePath) const;
1222 * @brief Get a TLVReader for the StatusElement. Next() must be called before accessing them.
1224 * @param [in] apStatusElement A pointer to apStatusElement
1226 * @return #CHIP_NO_ERROR on success
1227 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a Path
1228 * #CHIP_END_OF_TLV if there is no such element
1230 CHIP_ERROR GetStatusElement(StatusElement::Parser * const apStatusElement) const;
1232 }; // namespace AttributeStatusElement
1234 namespace AttributeStatusList {
1235 class Builder : public ListBuilder
1239 * @brief Initialize a AttributeStatus::Builder for writing into the TLV stream
1241 * @return A reference to AttributeStatus::Builder
1243 AttributeStatusElement::Builder & CreateAttributeStatusBuilder();
1246 * @brief Mark the end of this AttributeStatusList
1248 * @return A reference to *this
1250 AttributeStatusList::Builder & EndOfAttributeStatusList();
1253 AttributeStatusElement::Builder mAttributeStatusBuilder;
1256 class Parser : public ListParser
1260 * @brief Roughly verify the message is correctly formed
1261 * 1) all mandatory tags are present
1262 * 2) all elements have expected data type
1263 * 3) any tag can only appear once
1264 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
1265 * @note The main use of this function is to print out what we're
1266 * receiving during protocol development and debugging.
1267 * The encoding rule has changed in IM encoding spec so this
1268 * check is only "roughly" conformant now.
1270 * @return #CHIP_NO_ERROR on success
1272 CHIP_ERROR CheckSchemaValidity() const;
1274 }; // namespace AttributeStatusList
1276 namespace AttributeDataElement {
1279 kCsTag_AttributePath = 0,
1280 kCsTag_DataVersion = 1,
1282 kCsTag_MoreClusterDataFlag = 3,
1285 class Parser : public chip::app::Parser
1289 * @brief Initialize the parser object with TLVReader
1291 * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this AttributeDataElement
1293 * @return #CHIP_NO_ERROR on success
1295 CHIP_ERROR Init(const chip::TLV::TLVReader & aReader);
1298 * @brief Roughly verify the message is correctly formed
1299 * 1) all mandatory tags are present
1300 * 2) all elements have expected data type
1301 * 3) any tag can only appear once
1302 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
1303 * @note The main use of this function is to print out what we're
1304 * receiving during protocol development and debugging.
1305 * The encoding rule has changed in IM encoding spec so this
1306 * check is only "roughly" conformant now.
1308 * @return #CHIP_NO_ERROR on success
1310 CHIP_ERROR CheckSchemaValidity() const;
1313 * @brief Get a TLVReader for the AttributePath. Next() must be called before accessing them.
1315 * @param [in] apAttributePath A pointer to apAttributePath
1317 * @return #CHIP_NO_ERROR on success
1318 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a Path
1319 * #CHIP_END_OF_TLV if there is no such element
1321 CHIP_ERROR GetAttributePath(AttributePath::Parser * const apAttributePath) const;
1324 * @brief Get a TLVReader for the DataVersion. Next() must be called before accessing them.
1326 * @param [in] apVersion A pointer to apVersion
1328 * @return #CHIP_NO_ERROR on success
1329 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
1330 * #CHIP_END_OF_TLV if there is no such element
1332 CHIP_ERROR GetDataVersion(chip::DataVersion * const apVersion) const;
1335 * @brief Get a TLVReader for the Data. Next() must be called before accessing them.
1337 * @param [in] apReader A pointer to apReader
1339 * @return #CHIP_NO_ERROR on success
1340 * #CHIP_END_OF_TLV if there is no such element
1342 CHIP_ERROR GetData(chip::TLV::TLVReader * const apReader) const;
1345 * @brief Check whether it need more cluster data Next() must be called before accessing them.
1347 * @param [in] apMoreClusterDataFlag A pointer to apMoreClusterDataFlag
1349 * @return #CHIP_NO_ERROR on success
1350 * #CHIP_END_OF_TLV if there is no such element
1352 CHIP_ERROR GetMoreClusterDataFlag(bool * const apMoreClusterDataFlag) const;
1355 // A recursively callable function to parse a data element and pretty-print it.
1356 CHIP_ERROR ParseData(chip::TLV::TLVReader & aReader, int aDepth) const;
1359 class Builder : public chip::app::Builder
1363 * @brief Initialize a AttributeDataElement::Builder for writing into a TLV stream
1365 * @param [in] apWriter A pointer to TLVWriter
1367 * @return #CHIP_NO_ERROR on success
1369 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);
1372 * @brief Initialize a AttributePath::Builder for writing into the TLV stream
1374 * @return A reference to AttributePath::Builder
1376 AttributePath::Builder & CreateAttributePathBuilder();
1379 * @brief Inject DataVersion into the TLV stream to indicate the numerical data version associated with
1380 * the cluster that is referenced by the path.
1382 * @param [in] aDataVersion The boolean variable to indicate if AttributeDataElement has version
1384 * @return A reference to *this
1386 AttributeDataElement::Builder & DataVersion(const chip::DataVersion aDataVersion);
1389 * @brief Inject aMoreClusterData into the TLV stream to indicate whether there is more cluster data.
1390 * This is present when there is more than one AttributeDataElement as part of a logical Changeset,
1391 * and the entire set needs to be applied ‘atomically’ on the receiver.
1393 * @param [in] aMoreClusterData The boolean variable to indicate if more cluster data is needed.
1395 * @return A reference to *this
1397 AttributeDataElement::Builder & MoreClusterData(const bool aMoreClusterData);
1400 * @brief Mark the end of this AttributeDataElement
1402 * @return A reference to *this
1404 AttributeDataElement::Builder & EndOfAttributeDataElement();
1407 AttributePath::Builder mAttributePathBuilder;
1409 }; // namespace AttributeDataElement
1411 namespace AttributeDataList {
1412 class Parser : public ListParser
1416 * @brief Roughly verify the message is correctly formed
1417 * 1) all mandatory tags are present
1418 * 2) all elements have expected data type
1419 * 3) any tag can only appear once
1420 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
1421 * @note The main use of this function is to print out what we're
1422 * receiving during protocol development and debugging.
1423 * The encoding rule has changed in IM encoding spec so this
1424 * check is only "roughly" conformant now.
1426 * @return #CHIP_NO_ERROR on success
1428 CHIP_ERROR CheckSchemaValidity() const;
1431 class Builder : public ListBuilder
1435 * @brief Initialize a AttributeDataElement::Builder for writing into the TLV stream
1437 * @return A reference to AttributeDataElement::Builder
1439 AttributeDataElement::Builder & CreateAttributeDataElementBuilder();
1442 * @brief Mark the end of this AttributeDataList
1444 * @return A reference to *this
1446 AttributeDataList::Builder & EndOfAttributeDataList();
1449 AttributeDataElement::Builder mAttributeDataElementBuilder;
1451 }; // namespace AttributeDataList
1453 namespace CommandDataElement {
1456 kCsTag_CommandPath = 0,
1458 kCsTag_StatusElement = 2,
1461 class Parser : public chip::app::Parser
1465 * @brief Initialize the parser object with TLVReader
1467 * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this CommandDataElement
1469 * @return #CHIP_NO_ERROR on success
1471 CHIP_ERROR Init(const chip::TLV::TLVReader & aReader);
1474 * @brief Roughly verify the message is correctly formed
1475 * 1) all mandatory tags are present
1476 * 2) all elements have expected data type
1477 * 3) any tag can only appear once
1478 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
1479 * @note The main use of this function is to print out what we're
1480 * receiving during protocol development and debugging.
1481 * The encoding rule has changed in IM encoding spec so this
1482 * check is only "roughly" conformant now.
1484 * @return #CHIP_NO_ERROR on success
1486 CHIP_ERROR CheckSchemaValidity() const;
1489 * @brief Get a TLVReader for the CommandPath. Next() must be called before accessing them.
1491 * @param [in] apCommandPath A pointer to apCommandPath
1493 * @return #CHIP_NO_ERROR on success
1494 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a Path
1495 * #CHIP_END_OF_TLV if there is no such element
1497 CHIP_ERROR GetCommandPath(CommandPath::Parser * const apCommandPath) const;
1500 * @brief Get a TLVReader for the Data. Next() must be called before accessing them.
1502 * @param [in] apReader A pointer to apReader
1504 * @return #CHIP_NO_ERROR on success
1505 * #CHIP_END_OF_TLV if there is no such element
1507 CHIP_ERROR GetData(chip::TLV::TLVReader * const apReader) const;
1510 * @brief Get a TLVReader for the Data. Next() must be called before accessing them.
1512 * @param [in] apStatusElement A pointer to apStatusElement
1514 * @return #CHIP_NO_ERROR on success
1515 * # CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a structure
1516 * #CHIP_END_OF_TLV if there is no such element
1518 CHIP_ERROR GetStatusElement(StatusElement::Parser * const apStatusElement) const;
1521 // A recursively callable function to parse a data element and pretty-print it.
1522 CHIP_ERROR ParseData(chip::TLV::TLVReader & aReader, int aDepth) const;
1525 class Builder : public chip::app::Builder
1529 * @brief Initialize a AttributeDataList::Builder for writing into a TLV stream
1531 * @param [in] apWriter A pointer to TLVWriter
1533 * @return #CHIP_NO_ERROR on success
1535 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);
1538 * @brief Initialize a CommandPath::Builder for writing into the TLV stream
1540 * @return A reference to CommandPath::Builder
1542 CommandPath::Builder & CreateCommandPathBuilder();
1545 * @brief Initialize a StatusElement::Builder for writing into the TLV stream
1547 * @return A reference to StatusElement::Builder
1549 StatusElement::Builder & CreateStatusElementBuilder();
1552 * @brief Mark the end of this CommandDataElement
1554 * @return A reference to *this
1556 CommandDataElement::Builder & EndOfCommandDataElement();
1559 CommandPath::Builder mCommandPathBuilder;
1560 StatusElement::Builder mStatusElementBuilder;
1562 }; // namespace CommandDataElement
1564 namespace CommandList {
1565 class Parser : public ListParser
1569 * @brief Roughly verify the message is correctly formed
1570 * 1) all mandatory tags are present
1571 * 2) all elements have expected data type
1572 * 3) any tag can only appear once
1573 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
1574 * @note The main use of this function is to print out what we're
1575 * receiving during protocol development and debugging.
1576 * The encoding rule has changed in IM encoding spec so this
1577 * check is only "roughly" conformant now.
1579 * @return #CHIP_NO_ERROR on success
1581 CHIP_ERROR CheckSchemaValidity() const;
1584 class Builder : public ListBuilder
1588 * @brief Initialize a CommandDataElement::Builder for writing into the TLV stream
1590 * @return A reference to AttributeDataList::Builder
1592 CommandDataElement::Builder & CreateCommandDataElementBuilder();
1595 * @brief Mark the end of this CommandList
1597 * @return A reference to *this
1599 CommandList::Builder & EndOfCommandList();
1602 CommandDataElement::Builder mCommandDataElementBuilder;
1604 }; // namespace CommandList
1606 namespace ReportData {
1609 kCsTag_RequestResponse = 0,
1610 kCsTag_SubscriptionId = 1,
1611 kCsTag_AttributeStatusList = 2,
1612 kCsTag_AttributeDataList = 3,
1613 kCsTag_EventDataList = 4,
1614 kCsTag_IsLastReport = 5,
1617 class Parser : public chip::app::Parser
1621 * @brief Initialize the parser object with TLVReader
1623 * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this ReportData
1625 * @return #CHIP_NO_ERROR on success
1627 CHIP_ERROR Init(const chip::TLV::TLVReader & aReader);
1630 * @brief Roughly verify the message is correctly formed
1631 * 1) all mandatory tags are present
1632 * 2) all elements have expected data type
1633 * 3) any tag can only appear once
1634 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
1635 * @note The main use of this function is to print out what we're
1636 * receiving during protocol development and debugging.
1637 * The encoding rule has changed in IM encoding spec so this
1638 * check is only "roughly" conformant now.
1640 * @return #CHIP_NO_ERROR on success
1642 CHIP_ERROR CheckSchemaValidity() const;
1645 * @brief Check whether this message needs request response. Next() must be called before accessing them.
1647 * @param [in] apRequestResponse A pointer to apRequestResponse
1649 * @return #CHIP_NO_ERROR on success
1650 * #CHIP_END_OF_TLV if there is no such element
1652 CHIP_ERROR GetRequestResponse(bool * const apRequestResponse) const;
1655 * @brief Get Subscription Id. Next() must be called before accessing them.
1657 * @param [in] apSubscriptionId A pointer to apIsLastReport
1659 * @return #CHIP_NO_ERROR on success
1660 * #CHIP_END_OF_TLV if there is no such element
1662 CHIP_ERROR GetSubscriptionId(uint64_t * const apSubscriptionId) const;
1665 * @brief Get a TLVReader for the AttributesStatusList. Next() must be called before accessing them.
1667 * @param [in] apAttributeStatusList A pointer to apAttributeStatusList
1669 * @return #CHIP_NO_ERROR on success
1670 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a Array
1671 * #CHIP_END_OF_TLV if there is no such element
1673 CHIP_ERROR GetAttributeStatusList(AttributeStatusList::Parser * const apAttributeStatusList) const;
1676 * @brief Get a TLVReader for the AttributesDataList. Next() must be called before accessing them.
1678 * @param [in] apAttributeDataList A pointer to apAttributeDataList
1680 * @return #CHIP_NO_ERROR on success
1681 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a Array
1682 * #CHIP_END_OF_TLV if there is no such element
1684 CHIP_ERROR GetAttributeDataList(AttributeDataList::Parser * const apAttributeDataList) const;
1687 * @brief Get a TLVReader for the EventDataList. Next() must be called before accessing them.
1689 * @param [in] apEventDataList A pointer to apEventDataList
1691 * @return #CHIP_NO_ERROR on success
1692 * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a Array
1693 * #CHIP_END_OF_TLV if there is no such element
1695 CHIP_ERROR GetEventDataList(EventList::Parser * const apEventDataList) const;
1698 * @brief Check whether this message is last report. Next() must be called before accessing them.
1700 * @param [in] apIsLastReport A pointer to apIsLastReport
1702 * @return #CHIP_NO_ERROR on success
1703 * #CHIP_END_OF_TLV if there is no such element
1705 CHIP_ERROR GetIsLastReport(bool * const apIsLastReport) const;
1708 class Builder : public chip::app::Builder
1712 * @brief Initialize a ReportData::Builder for writing into a TLV stream
1714 * @param [in] apWriter A pointer to TLVWriter
1716 * @return #CHIP_NO_ERROR on success
1718 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);
1721 * @brief Inject RequestResponse into the TLV stream to indicate whether a response (a StatusReponse specifically)
1722 * is to be sent back to the request.
1724 * @param [in] aRequestResponse The boolean variable to indicate if request response is needed.
1726 * @return A reference to *this
1728 ReportData::Builder & RequestResponse(const bool aRequestResponse);
1731 * @brief Inject subscription id into the TLV stream, This field contains the Subscription ID
1732 * to which the data is being sent against. This is not present when the ReportDataRequest is
1733 * sent in response to a ReadRequest, but is present when sent in response to a SubscribeRequest.
1734 * Attempts should be made to ensure the SubscriptionId does not collide with IDs from previous
1735 * subscriptions to ensure disambiguation.
1737 * @param [in] aSubscriptionId Subscription Id for this report data
1739 * @return A reference to *this
1741 ReportData::Builder & SubscriptionId(const uint64_t aSubscriptionId);
1744 * @brief Initialize a AttributeStatusList::Builder for writing into the TLV stream
1746 * @return A reference to AttributeStatusList::Builder
1748 AttributeStatusList::Builder & CreateAttributeStatusListBuilder();
1751 * @brief Initialize a AttributeDataList::Builder for writing into the TLV stream
1753 * @return A reference to AttributeDataList::Builder
1755 AttributeDataList::Builder & CreateAttributeDataListBuilder();
1758 * @brief Initialize a EventList::Builder for writing into the TLV stream
1760 * @return A reference to EventList::Builder
1762 EventList::Builder & CreateEventDataListBuilder();
1765 * @brief This flag is set to ‘true’ when this is the last ReportDataRequest message
1766 * in a transaction and there are no more Changes to be conveyed.
1767 * @param [in] aIsLastReport The boolean variable to indicate if it is LastReport
1768 * @return A reference to *this
1770 ReportData::Builder & IsLastReport(const bool aIsLastReport);
1773 * @brief Mark the end of this ReportData
1775 * @return A reference to *this
1777 ReportData::Builder & EndOfReportData();
1780 AttributeStatusList::Builder mAttributeStatusListBuilder;
1781 AttributeDataList::Builder mAttributeDataListBuilder;
1782 EventList::Builder mEventDataListBuilder;
1784 }; // namespace ReportData
1786 namespace InvokeCommand {
1789 kCsTag_CommandList = 0,
1792 class Parser : public chip::app::Parser
1796 * @brief Initialize the parser object with TLVReader
1798 * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this request
1800 * @return #CHIP_NO_ERROR on success
1802 CHIP_ERROR Init(const chip::TLV::TLVReader & aReader);
1805 * @brief Roughly verify the message is correctly formed
1806 * 1) all mandatory tags are present
1807 * 2) all elements have expected data type
1808 * 3) any tag can only appear once
1809 * 4) At the top level of the structure, unknown tags are ignored for forward compatibility
1810 * @note The main use of this function is to print out what we're
1811 * receiving during protocol development and debugging.
1812 * The encoding rule has changed in IM encoding spec so this
1813 * check is only "roughly" conformant now.
1815 * @return #CHIP_NO_ERROR on success
1817 CHIP_ERROR CheckSchemaValidity() const;
1820 * @brief Get a TLVReader for the CommandList. Next() must be called before accessing them.
1822 * @param [in] apWriter A pointer to TLVWriter
1824 * @return #CHIP_NO_ERROR on success
1825 * #CHIP_END_OF_TLV if there is no such element
1827 CHIP_ERROR GetCommandList(CommandList::Parser * const apCommandList) const;
1830 class Builder : public chip::app::Builder
1834 * @brief Initialize a InvokeCommand::Builder for writing into a TLV stream
1836 * @param [in] apWriter A pointer to TLVWriter
1838 * @return #CHIP_NO_ERROR on success
1840 CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter);
1843 * @brief Initialize a CommandList::Builder for writing into the TLV stream
1845 * @return A reference to Path::Builder
1847 CommandList::Builder & CreateCommandListBuilder();
1850 * @brief Mark the end of this InvokeCommand
1852 * @return A reference to *this
1854 InvokeCommand::Builder & EndOfInvokeCommand();
1857 CommandList::Builder mCommandListBuilder;
1859 }; // namespace InvokeCommand
1862 }; // namespace chip
1864 #endif // _CHIP_INTERACTION_MODEL_MESSAGE_DEF_H