@@ -30,10 +30,10 @@ struct EPrefDelegate : public Delegate
30
30
virtual ~EPrefDelegate ();
31
31
32
32
CHIP_ERROR GetEnergyBalanceAtIndex (chip::EndpointId aEndpoint, size_t aIndex, chip::Percent & aOutStep,
33
- chip::MutableCharSpan & aOutLabel) override ;
33
+ chip::Optional<chip:: MutableCharSpan> & aOutLabel) override ;
34
34
CHIP_ERROR GetEnergyPriorityAtIndex (chip::EndpointId aEndpoint, size_t aIndex, EnergyPriorityEnum & priority) override ;
35
35
CHIP_ERROR GetLowPowerModeSensitivityAtIndex (chip::EndpointId aEndpoint, size_t aIndex, chip::Percent & aOutStep,
36
- chip::MutableCharSpan & aOutLabel) override ;
36
+ chip::Optional<chip:: MutableCharSpan> & aOutLabel) override ;
37
37
38
38
size_t GetNumEnergyBalances (chip::EndpointId aEndpoint) override ;
39
39
size_t GetNumLowPowerModeSensitivities (chip::EndpointId aEndpoint) override ;
@@ -63,12 +63,19 @@ size_t EPrefDelegate::GetNumLowPowerModeSensitivities(chip::EndpointId aEndpoint
63
63
64
64
CHIP_ERROR
65
65
EPrefDelegate::GetEnergyBalanceAtIndex (chip::EndpointId aEndpoint, size_t aIndex, chip::Percent & aOutStep,
66
- chip::MutableCharSpan & aOutLabel)
66
+ chip::Optional<chip:: MutableCharSpan> & aOutLabel)
67
67
{
68
68
if (aIndex < GetNumEnergyBalances (aEndpoint))
69
69
{
70
70
aOutStep = gsEnergyBalances[aIndex].step ;
71
- chip::CopyCharSpanToMutableCharSpan (gsEnergyBalances[aIndex].label .ValueOr (" " _span), aOutLabel);
71
+ if (gsEnergyBalances[aIndex].HasValue ())
72
+ {
73
+ chip::CopyCharSpanToMutableCharSpan (gsEnergyBalances[aIndex].label .Value (), aOutLabel.Value ());
74
+ }
75
+ else
76
+ {
77
+ aOutLabel.ClearValue ();
78
+ }
72
79
return CHIP_NO_ERROR;
73
80
}
74
81
return CHIP_ERROR_NOT_FOUND;
@@ -90,12 +97,19 @@ EPrefDelegate::GetEnergyPriorityAtIndex(chip::EndpointId aEndpoint, size_t aInde
90
97
91
98
CHIP_ERROR
92
99
EPrefDelegate::GetLowPowerModeSensitivityAtIndex (chip::EndpointId aEndpoint, size_t aIndex, chip::Percent & aOutStep,
93
- chip::MutableCharSpan & aOutLabel)
100
+ chip::Optional<chip:: MutableCharSpan> & aOutLabel)
94
101
{
95
102
if (aIndex < GetNumLowPowerModeSensitivities (aEndpoint))
96
103
{
97
104
aOutStep = gsPowerBalances[aIndex].step ;
98
- chip::CopyCharSpanToMutableCharSpan (gsPowerBalances[aIndex].label .ValueOr (" " _span), aOutLabel);
105
+ if (gsPowerBalances[aIndex])
106
+ {
107
+ chip::CopyCharSpanToMutableCharSpan (gsPowerBalances[aIndex].label .Value (), aOutLabel.Value ());
108
+ }
109
+ else
110
+ {
111
+ aOutLabel.ClearValue ();
112
+ }
99
113
return CHIP_NO_ERROR;
100
114
}
101
115
0 commit comments