3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2013-2017 Nest Labs, Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 * This file defines an object for reading and writing CHIP
25 * Status Reports are used in CHIP for over-the-wire status and
26 * error reporting that can act as a notification or confirmation
27 * in response to a request or command.
29 * The format of a status report is:
31 * | <profile ID> | <status code> | <additional status info> |
36 #ifndef _STATUS_REPORT_PROTOCOL_H
37 #define _STATUS_REPORT_PROTOCOL_H
39 #include <message/CHIPMessageLayer.h>
40 #include <support/DLLUtil.h>
43 * @namespace chip::Protocols::StatusReporting
46 * This namespace includes all interfaces within CHIP for the
47 * CHIP Status Reporting subprofile, which is part of and within
48 * the CHIP Common profile.
53 namespace StatusReporting {
56 * in-memory, a status report, at its most basic, is a CHIP profile
57 * ID and status code pair. then there's the option of chaining on
58 * more status information as TLV.
61 class DLL_EXPORT StatusReport
67 CHIP_ERROR init(uint32_t aProtocolId, uint16_t aCode, ReferencedTLVData * aInfo = nullptr);
70 * this version of the intializer is provided as a convenience in
71 * the case where we want to make a status report that reports an
75 CHIP_ERROR init(CHIP_ERROR aError);
77 CHIP_ERROR pack(PacketBuffer * aBuffer, uint32_t maxLen = 0xFFFFFFFFUL);
78 uint16_t packedLength();
79 static CHIP_ERROR parse(PacketBuffer * aBuffer, StatusReport & aDestination);
81 bool operator==(const StatusReport & another) const;
86 * here are some static convenience methods for adding metadata
89 static CHIP_ERROR StartMetaData(chip::TLV::TLVWriter & aWriter);
90 static CHIP_ERROR EndMetaData(chip::TLV::TLVWriter & aWriter);
92 static CHIP_ERROR AddErrorCode(chip::TLV::TLVWriter & aWriter, CHIP_ERROR aError);
99 ReferencedTLVData mAdditionalInfo;
102 } // namespace StatusReporting
103 } // namespace Protocols
106 #endif // _STATUS_REPORT_PROTOCOL_H