Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and hicklin committed Jul 11, 2024
1 parent dcbe505 commit 5c4093d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
6 changes: 4 additions & 2 deletions src/app/clusters/basic-information/basic-information.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,10 @@ CHIP_ERROR BasicAttrAccess::WriteDeviceLocation(AttributeValueDecoder & aDecoder

ReturnErrorOnFailure(aDecoder.Decode(deviceLocation));

if (!deviceLocation.IsNull()) {
if (deviceLocation.Value().locationName.empty() && deviceLocation.Value().floorNumber.IsNull() && deviceLocation.Value().areaType.IsNull())
if (!deviceLocation.IsNull())
{
if (deviceLocation.Value().locationName.empty() && deviceLocation.Value().floorNumber.IsNull() &&
deviceLocation.Value().areaType.IsNull())
{
ChipLogError(Zcl, "At least one of the fields should not be null or an empty string.");
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
Expand Down
8 changes: 4 additions & 4 deletions src/include/platform/ConfigurationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
#include <setup_payload/CHIPAdditionalDataPayloadBuildConfig.h>
#endif

#include <app-common/zap-generated/cluster-objects.h>
#include <app/data-model/Nullable.h>
#include <lib/core/ClusterEnums.h>
#include <lib/support/Span.h>
#include <platform/PersistedStorage.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>
#include <app/data-model/Nullable.h>
#include <app-common/zap-generated/cluster-objects.h>

using DeviceLocatioType = chip::app::Clusters::BasicInformation::Attributes::DeviceLocation::TypeInfo::Type;

Expand Down Expand Up @@ -136,8 +136,8 @@ class ConfigurationManager
virtual CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) = 0;
virtual CHIP_ERROR GetFailSafeArmed(bool & val) = 0;
virtual CHIP_ERROR SetFailSafeArmed(bool val) = 0;
virtual CHIP_ERROR GetDeviceLocation(DeviceLocatioType &location) = 0;
virtual CHIP_ERROR SetDeviceLocation(DeviceLocatioType location) = 0;
virtual CHIP_ERROR GetDeviceLocation(DeviceLocatioType & location) = 0;
virtual CHIP_ERROR SetDeviceLocation(DeviceLocatioType location) = 0;

virtual CHIP_ERROR GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo) = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/include/platform/DeviceInstanceInfoProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <app/data-model/Nullable.h>
#include <lib/core/CHIPError.h>
#include <lib/core/ClusterEnums.h>
#include <lib/support/Span.h>
#include <app/data-model/Nullable.h>
#include <app-common/zap-generated/cluster-objects.h>

namespace chip {
namespace DeviceLayer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class GenericConfigurationManagerImpl : public ConfigurationManager
* @brief Update location with the current device location.
*
* Expects that location is initialised with a locationName CharSpan pointing to a buffer of size kMaxDeviceLocationNameLength.
*/
CHIP_ERROR GetDeviceLocation(DeviceLocatioType &location) override;
*/
CHIP_ERROR GetDeviceLocation(DeviceLocatioType & location) override;
CHIP_ERROR SetDeviceLocation(DeviceLocatioType location) override;
CHIP_ERROR GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo) override;
bool IsCommissionableDeviceTypeEnabled() override;
Expand Down
22 changes: 9 additions & 13 deletions src/include/platform/internal/GenericConfigurationManagerImpl.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -586,18 +586,15 @@ CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::SetFailSafeArmed(bool v
return WriteConfigValue(ConfigClass::kConfigKey_FailSafeArmed, val);
}


template <class ConfigClass>
CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::GetDeviceLocation(DeviceLocatioType &location)
CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::GetDeviceLocation(DeviceLocatioType & location)
{
uint8_t locationData[kMaxDeviceLocationNameLength + sizeof(DeviceLocatioType)];
MutableByteSpan locationSpan(locationData);

size_t outLen = 0;
ReturnErrorOnFailure(ReadConfigValueBin(
ConfigClass::kConfigKey_DeviceLocation,
locationSpan.data(), locationSpan.size(),
outLen));
ReturnErrorOnFailure(
ReadConfigValueBin(ConfigClass::kConfigKey_DeviceLocation, locationSpan.data(), locationSpan.size(), outLen));

TLV::TLVReader tlvReader;
tlvReader.Init(locationSpan);
Expand All @@ -610,15 +607,16 @@ CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::GetDeviceLocation(Devic
ReturnErrorOnFailure(tlvReader.Next(TLV::AnonymousTag()));
ReturnErrorOnFailure(loc->Decode(tlvReader));

if (loc.IsNull()) {
if (loc.IsNull())
{
location.SetNull();
return CHIP_NO_ERROR;
}

memcpy((void *)location.Value().locationName.data(), loc.Value().locationName.data(), loc.Value().locationName.size());
memcpy((void *) location.Value().locationName.data(), loc.Value().locationName.data(), loc.Value().locationName.size());
location.Value().locationName.reduce_size(loc.Value().locationName.size());
location.Value().floorNumber = loc.Value().floorNumber;
location.Value().areaType = loc.Value().areaType;
location.Value().areaType = loc.Value().areaType;

return CHIP_NO_ERROR;
}
Expand All @@ -633,10 +631,8 @@ CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::SetDeviceLocation(Devic

ReturnErrorOnFailure(location->Encode(tlvWriter, TLV::AnonymousTag()));

ReturnErrorOnFailure(WriteConfigValueBin(
ConfigClass::kConfigKey_DeviceLocation,
static_cast<const uint8_t *>(locationSpan.data()),
tlvWriter.GetLengthWritten()));
ReturnErrorOnFailure(WriteConfigValueBin(ConfigClass::kConfigKey_DeviceLocation,
static_cast<const uint8_t *>(locationSpan.data()), tlvWriter.GetLengthWritten()));

return CHIP_NO_ERROR;
}
Expand Down

0 comments on commit 5c4093d

Please sign in to comment.