18
18
#import " MTRLogging_Internal.h"
19
19
#import < Matter/Matter.h>
20
20
21
- @implementation MTRCommandWithExpectedResult
21
+ @implementation MTRCommandWithRequiredResponse
22
22
- (instancetype )initWithPath : (MTRCommandPath *)path
23
23
commandFields : (nullable NSDictionary <NSString *, id> *)commandFields
24
- expectedResult : (nullable NSDictionary <NSNumber *, NSDictionary<NSString *, id> *> *)expectedResult
24
+ requiredResponse : (nullable NSDictionary <NSNumber *, NSDictionary<NSString *, id> *> *)requiredResponse
25
25
{
26
26
if (self = [super init ]) {
27
27
self.path = path;
28
28
self.commandFields = commandFields;
29
- self.expectedResult = expectedResult ;
29
+ self.requiredResponse = requiredResponse ;
30
30
}
31
31
32
32
return self;
33
33
}
34
34
35
35
- (id )copyWithZone : (NSZone *)zone
36
36
{
37
- return [[MTRCommandWithExpectedResult alloc ] initWithPath: self .path commandFields: self .commandFields expectedResult :self .expectedResult ];
37
+ return [[MTRCommandWithRequiredResponse alloc ] initWithPath: self .path commandFields: self .commandFields requiredResponse :self .requiredResponse ];
38
38
}
39
39
40
40
- (NSString *)description
41
41
{
42
- return [NSString stringWithFormat: @" <%@ : %p , path: %@ , fields: %@ , expectedResult : %@ " , NSStringFromClass (self .class ), self , self .path, self .commandFields, self .expectedResult ];
42
+ return [NSString stringWithFormat: @" <%@ : %p , path: %@ , fields: %@ , requiredResponse : %@ " , NSStringFromClass (self .class ), self , self .path, self .commandFields, self .requiredResponse ];
43
43
}
44
44
45
- #pragma mark - MTRCommandWithExpectedResult NSSecureCoding implementation
45
+ #pragma mark - MTRCommandWithRequiredResponse NSSecureCoding implementation
46
46
47
47
static NSString * const sPathKey = @" pathKey" ;
48
48
static NSString * const sFieldsKey = @" fieldsKey" ;
49
- static NSString * const sExpectedResultKey = @" expectedResultKey " ;
49
+ static NSString * const sExpectedResultKey = @" requiredResponseKey " ;
50
50
51
51
+ (BOOL )supportsSecureCoding
52
52
{
@@ -62,38 +62,38 @@ - (nullable instancetype)initWithCoder:(NSCoder *)decoder
62
62
63
63
_path = [decoder decodeObjectOfClass: MTRCommandPath.class forKey :sPathKey ];
64
64
if (!_path || ![_path isKindOfClass: MTRCommandPath.class ]) {
65
- MTR_LOG_ERROR (" MTRCommandWithExpectedResult decoded %@ for endpoint, not MTRCommandPath." , _path);
65
+ MTR_LOG_ERROR (" MTRCommandWithRequiredResponse decoded %@ for endpoint, not MTRCommandPath." , _path);
66
66
return nil ;
67
67
}
68
68
69
69
_commandFields = [decoder decodeObjectOfClass: NSDictionary .class forKey :sFieldsKey ];
70
70
if (_commandFields) {
71
71
if (![_commandFields isKindOfClass: NSDictionary .class ]) {
72
- MTR_LOG_ERROR (" MTRCommandWithExpectedResult decoded %@ for commandFields, not NSDictionary." , _commandFields);
72
+ MTR_LOG_ERROR (" MTRCommandWithRequiredResponse decoded %@ for commandFields, not NSDictionary." , _commandFields);
73
73
return nil ;
74
74
}
75
75
76
76
if (!MTRDataValueDictionaryIsWellFormed (_commandFields) || ![MTRStructureValueType isEqual: _commandFields[MTRTypeKey]]) {
77
- MTR_LOG_ERROR (" MTRCommandWithExpectedResult decoded %@ for commandFields, not a structure-typed data-value dictionary." , _commandFields);
77
+ MTR_LOG_ERROR (" MTRCommandWithRequiredResponse decoded %@ for commandFields, not a structure-typed data-value dictionary." , _commandFields);
78
78
return nil ;
79
79
}
80
80
}
81
81
82
- _expectedResult = [decoder decodeObjectOfClass: NSDictionary .class forKey :sExpectedResultKey ];
83
- if (_expectedResult ) {
84
- if (![_expectedResult isKindOfClass: NSDictionary .class ]) {
85
- MTR_LOG_ERROR (" MTRCommandWithExpectedResult decoded %@ for expectedResult , not NSDictionary." , _expectedResult );
82
+ _requiredResponse = [decoder decodeObjectOfClass: NSDictionary .class forKey :sExpectedResultKey ];
83
+ if (_requiredResponse ) {
84
+ if (![_requiredResponse isKindOfClass: NSDictionary .class ]) {
85
+ MTR_LOG_ERROR (" MTRCommandWithRequiredResponse decoded %@ for requiredResponse , not NSDictionary." , _requiredResponse );
86
86
return nil ;
87
87
}
88
88
89
- for (id key in _expectedResult ) {
89
+ for (id key in _requiredResponse ) {
90
90
if (![key isKindOfClass: NSNumber .class ]) {
91
- MTR_LOG_ERROR (" MTRCommandWithExpectedResult decoded key %@ in expectedResult " , key);
91
+ MTR_LOG_ERROR (" MTRCommandWithRequiredResponse decoded key %@ in requiredResponse " , key);
92
92
return nil ;
93
93
}
94
94
95
- if (![_expectedResult [key] isKindOfClass: NSDictionary .class ] || !MTRDataValueDictionaryIsWellFormed (_expectedResult [key])) {
96
- MTR_LOG_ERROR (" MTRCommandWithExpectedResult decoded value %@ for key %@ in expectedResult " , _expectedResult [key], key);
95
+ if (![_requiredResponse [key] isKindOfClass: NSDictionary .class ] || !MTRDataValueDictionaryIsWellFormed (_requiredResponse [key])) {
96
+ MTR_LOG_ERROR (" MTRCommandWithRequiredResponse decoded value %@ for key %@ in requiredResponse " , _requiredResponse [key], key);
97
97
return nil ;
98
98
}
99
99
}
@@ -111,8 +111,8 @@ - (void)encodeWithCoder:(NSCoder *)coder
111
111
if (self.commandFields ) {
112
112
[coder encodeObject: self .commandFields forKey: sFieldsKey ];
113
113
}
114
- if (self.expectedResult ) {
115
- [coder encodeObject: self .expectedResult forKey: sExpectedResultKey ];
114
+ if (self.requiredResponse ) {
115
+ [coder encodeObject: self .requiredResponse forKey: sExpectedResultKey ];
116
116
}
117
117
}
118
118
0 commit comments