@@ -169,48 +169,51 @@ CHIP_ERROR LogDiscoveredNodeData(const chip::Dnssd::DiscoveredNodeData & nodeDat
169
169
{
170
170
VerifyOrReturnError (gDelegate != nullptr , CHIP_NO_ERROR);
171
171
172
- if (!chip::CanCastTo<uint8_t >(nodeData.resolutionData .numIPs ))
172
+ auto & resolutionData = nodeData.resolutionData ;
173
+ auto & commissionData = nodeData.commissionData ;
174
+
175
+ if (!chip::CanCastTo<uint8_t >(resolutionData.numIPs ))
173
176
{
174
177
ChipLogError (chipTool, " Too many ips." );
175
178
return CHIP_ERROR_INVALID_ARGUMENT;
176
179
}
177
180
178
- if (!chip::CanCastTo<uint64_t >(nodeData. commissionData .rotatingIdLen ))
181
+ if (!chip::CanCastTo<uint64_t >(commissionData.rotatingIdLen ))
179
182
{
180
183
ChipLogError (chipTool, " Can not convert rotatingId to json format." );
181
184
return CHIP_ERROR_INVALID_ARGUMENT;
182
185
}
183
186
184
187
char rotatingId[chip::Dnssd::kMaxRotatingIdLen * 2 + 1 ] = " " ;
185
- chip::Encoding::BytesToUppercaseHexString (nodeData. commissionData .rotatingId , nodeData. commissionData .rotatingIdLen , rotatingId ,
186
- sizeof (rotatingId));
188
+ ReturnErrorOnFailure ( chip::Encoding::BytesToUppercaseHexString (commissionData.rotatingId , commissionData.rotatingIdLen ,
189
+ rotatingId, sizeof (rotatingId) ));
187
190
188
191
Json::Value value;
189
- value[" hostName" ] = nodeData. resolutionData .hostName ;
190
- value[" instanceName" ] = nodeData. commissionData .instanceName ;
191
- value[" longDiscriminator" ] = nodeData. commissionData .longDiscriminator ;
192
- value[" shortDiscriminator" ] = ((nodeData. commissionData .longDiscriminator >> 8 ) & 0x0F );
193
- value[" vendorId" ] = nodeData. commissionData .vendorId ;
194
- value[" productId" ] = nodeData. commissionData .productId ;
195
- value[" commissioningMode" ] = nodeData. commissionData .commissioningMode ;
196
- value[" deviceType" ] = nodeData. commissionData .deviceType ;
197
- value[" deviceName" ] = nodeData. commissionData .deviceName ;
192
+ value[" hostName" ] = resolutionData.hostName ;
193
+ value[" instanceName" ] = commissionData.instanceName ;
194
+ value[" longDiscriminator" ] = commissionData.longDiscriminator ;
195
+ value[" shortDiscriminator" ] = ((commissionData.longDiscriminator >> 8 ) & 0x0F );
196
+ value[" vendorId" ] = commissionData.vendorId ;
197
+ value[" productId" ] = commissionData.productId ;
198
+ value[" commissioningMode" ] = commissionData.commissioningMode ;
199
+ value[" deviceType" ] = commissionData.deviceType ;
200
+ value[" deviceName" ] = commissionData.deviceName ;
198
201
value[" rotatingId" ] = rotatingId;
199
- value[" rotatingIdLen" ] = static_cast <uint64_t >(nodeData. commissionData .rotatingIdLen );
200
- value[" pairingHint" ] = nodeData. commissionData .pairingHint ;
201
- value[" pairingInstruction" ] = nodeData. commissionData .pairingInstruction ;
202
- value[" supportsTcp" ] = nodeData. resolutionData .supportsTcp ;
203
- value[" port" ] = nodeData. resolutionData .port ;
204
- value[" numIPs" ] = static_cast <uint8_t >(nodeData. resolutionData .numIPs );
205
-
206
- if (nodeData. resolutionData .mrpRetryIntervalIdle .HasValue ())
202
+ value[" rotatingIdLen" ] = static_cast <uint64_t >(commissionData.rotatingIdLen );
203
+ value[" pairingHint" ] = commissionData.pairingHint ;
204
+ value[" pairingInstruction" ] = commissionData.pairingInstruction ;
205
+ value[" supportsTcp" ] = resolutionData.supportsTcp ;
206
+ value[" port" ] = resolutionData.port ;
207
+ value[" numIPs" ] = static_cast <uint8_t >(resolutionData.numIPs );
208
+
209
+ if (resolutionData.mrpRetryIntervalIdle .HasValue ())
207
210
{
208
- value[" mrpRetryIntervalIdle" ] = nodeData. resolutionData .mrpRetryIntervalIdle .Value ().count ();
211
+ value[" mrpRetryIntervalIdle" ] = resolutionData.mrpRetryIntervalIdle .Value ().count ();
209
212
}
210
213
211
- if (nodeData. resolutionData .mrpRetryIntervalActive .HasValue ())
214
+ if (resolutionData.mrpRetryIntervalActive .HasValue ())
212
215
{
213
- value[" mrpRetryIntervalActive" ] = nodeData. resolutionData .mrpRetryIntervalActive .Value ().count ();
216
+ value[" mrpRetryIntervalActive" ] = resolutionData.mrpRetryIntervalActive .Value ().count ();
214
217
}
215
218
216
219
Json::Value rootValue;
0 commit comments