@@ -144,10 +144,10 @@ static bool emitDSTTableEmptyEvent(EndpointId ep)
144
144
145
145
if (CHIP_NO_ERROR != error)
146
146
{
147
- ChipLogError (Zcl, " Unable to emit DSTTableEmpty event [ep=%d] " , ep );
147
+ ChipLogError (Zcl, " DSTTableEmptyEvent failed " );
148
148
return false ;
149
149
}
150
- ChipLogProgress (Zcl, " Emit DSTTableEmpty event [ep=%d] " , ep );
150
+ ChipLogProgress (Zcl, " DSTTableEmptyEvent " );
151
151
152
152
// TODO: re-schedule event for after min 1hr https://github.com/project-chip/connectedhomeip/issues/27200
153
153
// delegate->scheduleDSTTableEmptyEvent()
@@ -164,11 +164,11 @@ static bool emitDSTStatusEvent(EndpointId ep, bool dstOffsetActive)
164
164
165
165
if (CHIP_NO_ERROR != error)
166
166
{
167
- ChipLogError (Zcl, " Unable to emit DSTStatus event [ep=%d] " , ep );
167
+ ChipLogError (Zcl, " DSTStatusEvent failed " );
168
168
return false ;
169
169
}
170
170
171
- ChipLogProgress (Zcl, " Emit DSTStatus event [ep=%d] " , ep );
171
+ ChipLogProgress (Zcl, " DSTStatusEvent active: %d " , dstOffsetActive );
172
172
return true ;
173
173
}
174
174
@@ -190,11 +190,11 @@ static bool emitTimeZoneStatusEvent(EndpointId ep)
190
190
191
191
if (CHIP_NO_ERROR != error)
192
192
{
193
- ChipLogError (Zcl, " Unable to emit TimeZoneStatus event [ep=%d] " , ep );
193
+ ChipLogError (Zcl, " TimeZoneStatusEvent failed " );
194
194
return false ;
195
195
}
196
196
197
- ChipLogProgress (Zcl, " Emit TimeZoneStatus event [ep=%d] " , ep );
197
+ ChipLogProgress (Zcl, " TimeZoneStatusEvent offset: %d " , static_cast < int >(tz. offset ) );
198
198
return true ;
199
199
}
200
200
@@ -207,13 +207,13 @@ static bool emitTimeFailureEvent(EndpointId ep)
207
207
208
208
if (CHIP_NO_ERROR != error)
209
209
{
210
- ChipLogError (Zcl, " Unable to emit TimeFailure event [ep=%d] " , ep );
210
+ ChipLogError (Zcl, " TimeFailureEvent failed " );
211
211
return false ;
212
212
}
213
213
214
214
// TODO: re-schedule event for after min 1hr if no time is still available
215
215
// https://github.com/project-chip/connectedhomeip/issues/27200
216
- ChipLogProgress (Zcl, " Emit TimeFailure event [ep=%d] " , ep );
216
+ ChipLogProgress (Zcl, " TimeFailureEvent " );
217
217
return true ;
218
218
}
219
219
@@ -226,13 +226,13 @@ static bool emitMissingTrustedTimeSourceEvent(EndpointId ep)
226
226
227
227
if (CHIP_NO_ERROR != error)
228
228
{
229
- ChipLogError (Zcl, " Unable to emit MissingTrustedTimeSource event [ep=%d] " , ep );
229
+ ChipLogError (Zcl, " Unable to emit MissingTrustedTimeSource event" );
230
230
return false ;
231
231
}
232
232
233
233
// TODO: re-schedule event for after min 1hr if TTS is null or cannot be reached
234
234
// https://github.com/project-chip/connectedhomeip/issues/27200
235
- ChipLogProgress (Zcl, " Emit MissingTrustedTimeSource event [ep=%d] " , ep );
235
+ ChipLogProgress (Zcl, " Emit MissingTrustedTimeSource event" );
236
236
return true ;
237
237
}
238
238
@@ -536,10 +536,6 @@ CHIP_ERROR TimeSynchronizationServer::SetTimeZone(const DataModel::DecodableList
536
536
size_t items;
537
537
VerifyOrReturnError (CHIP_NO_ERROR == tzL.ComputeSize (&items), CHIP_IM_GLOBAL_STATUS (InvalidCommand));
538
538
539
- if (items > CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE)
540
- {
541
- return CHIP_ERROR_BUFFER_TOO_SMALL;
542
- }
543
539
if (items == 0 )
544
540
{
545
541
return ClearTimeZone ();
@@ -564,6 +560,12 @@ CHIP_ERROR TimeSynchronizationServer::SetTimeZone(const DataModel::DecodableList
564
560
uint8_t i = 0 ;
565
561
InitTimeZone ();
566
562
563
+ if (items > mTimeZoneObj .timeZoneList .size ())
564
+ {
565
+ LoadTimeZone ();
566
+ return CHIP_ERROR_BUFFER_TOO_SMALL;
567
+ }
568
+
567
569
while (newTzL.Next ())
568
570
{
569
571
auto & tzStore = mTimeZoneObj .timeZoneList [i];
@@ -589,20 +591,14 @@ CHIP_ERROR TimeSynchronizationServer::SetTimeZone(const DataModel::DecodableList
589
591
tzStore.timeZone .validAt = newTz.validAt ;
590
592
if (newTz.name .HasValue () && newTz.name .Value ().size () > 0 )
591
593
{
592
- size_t len = newTz.name .Value ().size ();
593
- if (len > sizeof (tzStore.name ))
594
- {
595
- ReturnErrorOnFailure (LoadTimeZone ());
596
- return CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_IB;
597
- }
598
594
memset (tzStore.name , 0 , sizeof (tzStore.name ));
599
- chip::MutableCharSpan tempSpan (tzStore.name , len );
595
+ chip::MutableCharSpan tempSpan (tzStore.name );
600
596
if (CHIP_NO_ERROR != CopyCharSpanToMutableCharSpan (newTz.name .Value (), tempSpan))
601
597
{
602
598
ReturnErrorOnFailure (LoadTimeZone ());
603
599
return CHIP_IM_GLOBAL_STATUS (InvalidCommand);
604
600
}
605
- tzStore.timeZone .name .SetValue (CharSpan (tzStore. name , len) );
601
+ tzStore.timeZone .name .SetValue (tempSpan );
606
602
}
607
603
else
608
604
{
@@ -661,11 +657,6 @@ CHIP_ERROR TimeSynchronizationServer::SetDSTOffset(const DataModel::DecodableLis
661
657
size_t items;
662
658
VerifyOrReturnError (CHIP_NO_ERROR == dstL.ComputeSize (&items), CHIP_IM_GLOBAL_STATUS (InvalidCommand));
663
659
664
- if (items > CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE)
665
- {
666
- return CHIP_ERROR_BUFFER_TOO_SMALL;
667
- }
668
-
669
660
if (items == 0 )
670
661
{
671
662
return ClearDSTOffset ();
@@ -675,6 +666,12 @@ CHIP_ERROR TimeSynchronizationServer::SetDSTOffset(const DataModel::DecodableLis
675
666
size_t i = 0 ;
676
667
InitDSTOffset ();
677
668
669
+ if (items > mDstOffsetObj .dstOffsetList .size ())
670
+ {
671
+ LoadDSTOffset ();
672
+ return CHIP_ERROR_BUFFER_TOO_SMALL;
673
+ }
674
+
678
675
while (newDstL.Next ())
679
676
{
680
677
auto & dst = mDstOffsetObj .dstOffsetList [i];
@@ -975,7 +972,7 @@ CHIP_ERROR TimeSynchronizationAttrAccess::ReadDefaultNtp(EndpointId endpoint, At
975
972
err = TimeSynchronizationServer::Instance ().GetDefaultNtp (dntp);
976
973
if (err == CHIP_NO_ERROR)
977
974
{
978
- err = aEncoder.Encode (CharSpan (buffer, dntp. size ()) );
975
+ err = aEncoder.Encode (dntp);
979
976
}
980
977
else if (err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND)
981
978
{
@@ -1017,9 +1014,10 @@ CHIP_ERROR TimeSynchronizationAttrAccess::ReadDSTOffset(EndpointId endpoint, Att
1017
1014
CHIP_ERROR TimeSynchronizationAttrAccess::ReadLocalTime (EndpointId endpoint, AttributeValueEncoder & aEncoder)
1018
1015
{
1019
1016
DataModel::Nullable<uint64_t > localTime;
1020
- CHIP_ERROR err = TimeSynchronizationServer::Instance ().GetLocalTime (endpoint, localTime);
1021
- err = aEncoder.Encode (localTime);
1022
- return err;
1017
+ VerifyOrReturnError (CHIP_NO_ERROR == TimeSynchronizationServer::Instance ().GetLocalTime (endpoint, localTime),
1018
+ aEncoder.EncodeNull ());
1019
+ ReturnErrorOnFailure (aEncoder.Encode (localTime));
1020
+ return CHIP_NO_ERROR;
1023
1021
}
1024
1022
1025
1023
CHIP_ERROR TimeSynchronizationAttrAccess::Read (const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
@@ -1090,19 +1088,18 @@ bool emberAfTimeSynchronizationClusterSetUTCTimeCallback(
1090
1088
const auto & timeSource = commandData.timeSource ;
1091
1089
1092
1090
auto currentGranularity = TimeSynchronizationServer::Instance ().GetGranularity ();
1093
- if (granularity < GranularityEnum::kNoTimeGranularity || granularity > GranularityEnum:: kMicrosecondsGranularity )
1091
+ if (granularity == GranularityEnum::kUnknownEnumValue )
1094
1092
{
1095
1093
commandObj->AddStatus (commandPath, Status::InvalidCommand);
1096
1094
return true ;
1097
1095
}
1098
- if (timeSource.HasValue () && ( timeSource.Value () < TimeSourceEnum::kNone || timeSource. Value () > TimeSourceEnum:: kGnss ) )
1096
+ if (timeSource.HasValue () && timeSource.Value () == TimeSourceEnum::kUnknownEnumValue )
1099
1097
{
1100
1098
commandObj->AddStatus (commandPath, Status::InvalidCommand);
1101
1099
return true ;
1102
1100
}
1103
1101
1104
- if (granularity != GranularityEnum::kNoTimeGranularity &&
1105
- (currentGranularity == GranularityEnum::kNoTimeGranularity || granularity >= currentGranularity) &&
1102
+ if (granularity > currentGranularity &&
1106
1103
CHIP_NO_ERROR ==
1107
1104
TimeSynchronizationServer::Instance ().SetUTCTime (commandPath.mEndpointId , utcTime, granularity, TimeSourceEnum::kAdmin ))
1108
1105
{
0 commit comments