@@ -589,9 +589,10 @@ CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::SetFailSafeArmed(bool v
589
589
template <class ConfigClass >
590
590
CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::GetDeviceLocation(MutableDeviceLocation & location)
591
591
{
592
- uint8_t locationData[app::Clusters::BasicInformation::kMaxDeviceLocationNameLength + sizeof (DeviceLocatioType )];
592
+ uint8_t locationData[app::Clusters::BasicInformation::kMaxDeviceLocationNameLength + sizeof (DeviceLocationType )];
593
593
MutableByteSpan locationSpan (locationData);
594
594
595
+ // If the location key is not found, assume a null location.
595
596
size_t outLen = 0 ;
596
597
auto err = ReadConfigValueBin (ConfigClass::kConfigKey_DeviceLocation , locationSpan.data (), locationSpan.size (), outLen);
597
598
if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
@@ -604,34 +605,26 @@ CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::GetDeviceLocation(Mutab
604
605
TLV::TLVReader tlvReader;
605
606
tlvReader.Init (locationSpan);
606
607
607
- char locationNameBuffer[1 ] = { 0 };
608
- DeviceLocatioType loc ({
609
- .locationName = CharSpan (locationNameBuffer, 0 ),
610
- });
608
+ DeviceLocationType loc;
611
609
612
610
ReturnErrorOnFailure (tlvReader.Next (TLV::AnonymousTag ()));
613
- ReturnErrorOnFailure (loc->Decode (tlvReader));
614
-
615
- // This would not be needed if the Decode methed proprly decodes a null value.
616
- if (loc.Value ().locationName .empty () && loc.Value ().floorNumber .IsNull () && loc.Value ().areaType .IsNull ())
617
- {
618
- loc.SetNull ();
619
- }
611
+ ReturnErrorOnFailure (app::DataModel::Decode (tlvReader, loc));
620
612
621
613
location = loc;
622
-
614
+
623
615
return CHIP_NO_ERROR;
624
616
}
617
+
625
618
template <class ConfigClass >
626
- CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::SetDeviceLocation(DeviceLocatioType location)
619
+ CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::SetDeviceLocation(DeviceLocationType location)
627
620
{
628
- uint8_t locationData[app::Clusters::BasicInformation::kMaxDeviceLocationNameLength + sizeof (DeviceLocatioType )];
621
+ uint8_t locationData[app::Clusters::BasicInformation::kMaxDeviceLocationNameLength + sizeof (DeviceLocationType )];
629
622
MutableByteSpan locationSpan (locationData);
630
623
631
624
TLV::TLVWriter tlvWriter;
632
625
tlvWriter.Init (locationSpan);
633
626
634
- ReturnErrorOnFailure (location-> Encode (tlvWriter, TLV::AnonymousTag ()));
627
+ ReturnErrorOnFailure (app::DataModel:: Encode (tlvWriter, TLV::AnonymousTag (), location ));
635
628
636
629
ReturnErrorOnFailure (WriteConfigValueBin (ConfigClass::kConfigKey_DeviceLocation ,
637
630
static_cast <const uint8_t *>(locationSpan.data ()), tlvWriter.GetLengthWritten ()));
0 commit comments