@@ -69,18 +69,22 @@ CHIP_ERROR EnergyPrefAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
69
69
if (gsDelegate != nullptr )
70
70
{
71
71
return aEncoder.EncodeList ([endpoint](const auto & encoder) -> CHIP_ERROR {
72
- chip::Percent step;
73
- char buffer[64 ];
74
- chip::Optional<chip::MutableCharSpan> label{ chip::MutableCharSpan (buffer) };
75
72
size_t index = 0 ;
76
73
CHIP_ERROR err = CHIP_NO_ERROR;
77
- while ((err = gsDelegate-> GetEnergyBalanceAtIndex (endpoint, index , step, label)) == CHIP_NO_ERROR)
74
+ do
78
75
{
79
- BalanceStruct::Type balance = { step,
80
- label.HasValue () ? Optional<CharSpan>(label.Value ()) : Optional<CharSpan>() };
81
- ReturnErrorOnFailure (encoder.Encode (balance));
82
- index ++;
83
- }
76
+ Percent step;
77
+ char buffer[64 ];
78
+ Optional<MutableCharSpan> label{ MutableCharSpan (buffer) };
79
+ if ((err = gsDelegate->GetEnergyBalanceAtIndex (endpoint, index , step, label)) == CHIP_NO_ERROR)
80
+ {
81
+ BalanceStruct::Type balance = { step,
82
+ label.HasValue () ? Optional<CharSpan>(label.Value ()) : Optional<CharSpan>() };
83
+ ReturnErrorOnFailure (encoder.Encode (balance));
84
+ index ++;
85
+ }
86
+ } while (err == CHIP_NO_ERROR);
87
+
84
88
if (err == CHIP_ERROR_NOT_FOUND)
85
89
{
86
90
return CHIP_NO_ERROR;
@@ -123,21 +127,24 @@ CHIP_ERROR EnergyPrefAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
123
127
if (gsDelegate != nullptr )
124
128
{
125
129
return aEncoder.EncodeList ([endpoint](const auto & encoder) -> CHIP_ERROR {
126
- chip::Percent step;
127
- char buffer[64 ];
128
- chip::Optional<chip::MutableCharSpan> label{ chip::MutableCharSpan (buffer) };
129
130
size_t index = 0 ;
130
131
CHIP_ERROR err = CHIP_NO_ERROR;
131
- while ((err = gsDelegate-> GetLowPowerModeSensitivityAtIndex (endpoint, index , step, label)) == CHIP_NO_ERROR)
132
+ do
132
133
{
133
- BalanceStruct::Type balance = { step,
134
- label.HasValue () ? Optional<CharSpan>(label.Value ()) : Optional<CharSpan>() };
135
- ReturnErrorOnFailure (encoder.Encode (balance));
136
- index ++;
137
- }
134
+ Percent step;
135
+ char buffer[64 ];
136
+ Optional<MutableCharSpan> label{ MutableCharSpan (buffer) };
137
+ if ((err = gsDelegate->GetLowPowerModeSensitivityAtIndex (endpoint, index , step, label)) == CHIP_NO_ERROR)
138
+ {
139
+ BalanceStruct::Type balance = { step,
140
+ label.HasValue () ? Optional<CharSpan>(label.Value ()) : Optional<CharSpan>() };
141
+ ReturnErrorOnFailure (encoder.Encode (balance));
142
+ index ++;
143
+ }
144
+ } while err == CHIP_NO_ERROR);
138
145
if (err == CHIP_ERROR_NOT_FOUND)
139
146
{
140
- return CHIP_NO_ERROR;
147
+ return CHIP_NO_ERROR;
141
148
}
142
149
return err;
143
150
});
0 commit comments