Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the RegulatoryLocation and LocationCapability get and set logic #23579

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ menu "CHIP Device Layer"
default 25
help
The maximum number of events that can be held in the CHIP Platform event queue.

config ENABLE_EXTENDED_DISCOVERY
bool "Enable Extended discovery Support"
default n
Expand Down Expand Up @@ -474,7 +474,7 @@ menu "CHIP Device Layer"
config USE_BLE_ONLY_FOR_COMMISSIONING
bool "Use BLE only for commissioning"
default y
help
help
Disable this flag if BLE is used for any other purpose than commissioning.
When enabled, it deinitialized the BLE on successful commissioning, and on
bootup do not initialize the BLE if device is already provisioned with Wi-Fi/Thread credentials.
Expand Down Expand Up @@ -657,6 +657,13 @@ menu "CHIP Device Layer"
Details like Supported calendar types, supported locales, and fixed labels will be read from factory
partition.

config ENABLE_ESP32_LOCATIONCAPABILITY
depends on ENABLE_ESP32_FACTORY_DATA_PROVIDER
bool "Enable ESP32 Device LocationCapability "
default n
help
Enable ESP32 Device LocationCapability

endmenu


Expand Down Expand Up @@ -850,7 +857,7 @@ menu "CHIP Device Layer"
default "nvs"
help
Label of the partition to store key-values in the "chip-counters" namespace.

config CHIP_KVS_NAMESPACE_PARTITION_LABEL
string "chip-kvs namespace partition label"
default "nvs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,22 @@ void GenericConfigurationManagerImpl<ImplClass>::NotifyOfAdvertisementStart()
template <class ConfigClass>
CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::GetRegulatoryLocation(uint8_t & location)
{
return GetLocationCapability(location);
uint32_t value;
if (CHIP_NO_ERROR != ReadConfigValue(ConfigClass::kConfigKey_RegulatoryLocation, value))
{
ReturnErrorOnFailure(GetLocationCapability(location));

if (CHIP_NO_ERROR != StoreRegulatoryLocation(location))
{
ChipLogError(DeviceLayer, "Failed to store RegulatoryLocation");
}
}
else
{
location = static_cast<uint8_t>(value);
Jerry-ESP marked this conversation as resolved.
Show resolved Hide resolved
}

return CHIP_NO_ERROR;
}

template <class ConfigClass>
Expand Down
19 changes: 19 additions & 0 deletions src/platform/ESP32/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,25 @@ CHIP_ERROR ConfigurationManagerImpl::GetSoftwareVersion(uint32_t & softwareVer)
return CHIP_NO_ERROR;
}

CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location)
{
#if CONFIG_ENABLE_ESP32_LOCATIONCAPABILITY
uint32_t value = 0;
CHIP_ERROR err = ReadConfigValue(ESP32Config::kConfigKey_LocationCapability, value);

if (err == CHIP_NO_ERROR)
{
VerifyOrReturnError(value <= UINT8_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE);
location = static_cast<uint8_t>(value);
}

return err;
#else
location = static_cast<uint8_t>(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor);
return CHIP_NO_ERROR;
#endif
}

CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf)
{
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
Expand Down
1 change: 1 addition & 0 deletions src/platform/ESP32/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours) override;
CHIP_ERROR GetSoftwareVersionString(char * buf, size_t bufSize);
CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override;
CHIP_ERROR GetLocationCapability(uint8_t & location) override;
static ConfigurationManagerImpl & GetDefaultInstance();

private:
Expand Down
1 change: 1 addition & 0 deletions src/platform/ESP32/ESP32Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const ESP32Config::Key ESP32Config::kConfigKey_ProductURL = { kConfig
const ESP32Config::Key ESP32Config::kConfigKey_SupportedCalTypes = { kConfigNamespace_ChipFactory, "cal-types" };
const ESP32Config::Key ESP32Config::kConfigKey_SupportedLocaleSize = { kConfigNamespace_ChipFactory, "locale-sz" };
const ESP32Config::Key ESP32Config::kConfigKey_RotatingDevIdUniqueId = { kConfigNamespace_ChipFactory, "rd-id-uid" };
const ESP32Config::Key ESP32Config::kConfigKey_LocationCapability = { kConfigNamespace_ChipFactory, "loc-capability" };

// Keys stored in the chip-config namespace
const ESP32Config::Key ESP32Config::kConfigKey_ServiceConfig = { kConfigNamespace_ChipConfig, "service-config" };
Expand Down
1 change: 1 addition & 0 deletions src/platform/ESP32/ESP32Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class ESP32Config
static const Key kConfigKey_SupportedCalTypes;
static const Key kConfigKey_SupportedLocaleSize;
static const Key kConfigKey_RotatingDevIdUniqueId;
static const Key kConfigKey_LocationCapability;

// CHIP Config keys
static const Key kConfigKey_ServiceConfig;
Expand Down