Merge branch 'bugfix/nonvolatile-attr' into 'main'

bugfix: Add nonvolatile attribute initializing for on_off cluster

See merge request app-frameworks/esp-matter!152
This commit is contained in:
Shu Chen
2022-07-01 17:59:40 +08:00
7 changed files with 16 additions and 30 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ git clone --recursive https://github.com/espressif/esp-matter.git
## Supported ESP-IDF and connectedhomeip versions
- ESP Matter currently works with [commit c38e915](https://github.com/project-chip/connectedhomeip/commit/c38e915) of connectedhomeip.
- ESP Matter currently works with [commit c1d5431](https://github.com/project-chip/connectedhomeip/tree/c1d5431) of connectedhomeip.
- For Wi-Fi devices (ESP32, ESP32-C3, ESP32-S3), ESP-IDF [v4.4.1 release](https://github.com/espressif/esp-idf/releases/tag/v4.4.1) is required.
- For Thread devices (ESP32-H2), ESP-IDF master branch at [commit 047903c](https://github.com/espressif/esp-idf/commit/047903c) should be used.
@@ -658,7 +658,7 @@ namespace attribute {
attribute_t *create_on_off(cluster_t *cluster, bool value)
{
return esp_matter::attribute::create(cluster, OnOff::Attributes::OnOff::Id, ATTRIBUTE_FLAG_NONE,
return esp_matter::attribute::create(cluster, OnOff::Attributes::OnOff::Id, ATTRIBUTE_FLAG_NONVOLATILE,
esp_matter_bool(value));
}
@@ -682,8 +682,8 @@ attribute_t *create_off_wait_time(cluster_t *cluster, uint16_t value)
attribute_t *create_start_up_on_off(cluster_t *cluster, uint8_t value)
{
return esp_matter::attribute::create(cluster, OnOff::Attributes::StartUpOnOff::Id, ATTRIBUTE_FLAG_WRITABLE,
esp_matter_enum8(value));
return esp_matter::attribute::create(cluster, OnOff::Attributes::StartUpOnOff::Id,
ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_enum8(value));
}
} /* attribute */
+1 -1
View File
@@ -61,7 +61,7 @@ void esp_matter_new_connection_failure_callback(void *context, PeerId peerId, CH
esp_err_t connect(uint8_t fabric_index, uint64_t node_id, uint16_t remote_endpoint_id)
{
/* Get info */
FabricInfo *fabric_info = chip::Server::GetInstance().GetFabricTable().FindFabricWithIndex(fabric_index);
const FabricInfo *fabric_info = chip::Server::GetInstance().GetFabricTable().FindFabricWithIndex(fabric_index);
if (!fabric_info) {
ESP_LOGE(TAG, "Couldn't find fabric info");
return ESP_FAIL;
@@ -1047,6 +1047,8 @@ esp_err_t store_val_in_nvs(attribute_t *attribute)
if (err != ESP_OK) {
return err;
}
ESP_LOGI(TAG, "strore attribute in nvs: endpoint_id-0x%x, cluster_id-0x%x, attribute_id-0x%x",
endpoint_id, cluster_id, attribute_id);
if (current_attribute->val.type == ESP_MATTER_VAL_TYPE_CHAR_STRING ||
current_attribute->val.type == ESP_MATTER_VAL_TYPE_OCTET_STRING ||
current_attribute->val.type == ESP_MATTER_VAL_TYPE_ARRAY) {
@@ -1087,6 +1089,8 @@ esp_err_t get_val_from_nvs(attribute_t *attribute, esp_matter_attr_val_t *val)
if (err != ESP_OK) {
return err;
}
ESP_LOGI(TAG, "read attribute from nvs: endpoint_id-0x%x, cluster_id-0x%x, attribute_id-0x%x",
endpoint_id, cluster_id, attribute_id);
if (current_attribute->val.type == ESP_MATTER_VAL_TYPE_CHAR_STRING ||
current_attribute->val.type == ESP_MATTER_VAL_TYPE_OCTET_STRING ||
current_attribute->val.type == ESP_MATTER_VAL_TYPE_ARRAY) {
+6 -6
View File
@@ -60,7 +60,7 @@ namespace lighting {
uint32_t get_id()
{
return (uint32_t)chip::app::Clusters::OnOff::OnOffFeature::kLighting;
return (uint32_t)OnOff::OnOffFeature::kLighting;
}
esp_err_t add(cluster_t *cluster, config_t *config)
@@ -95,7 +95,7 @@ namespace on_off {
uint32_t get_id()
{
return (uint32_t)chip::app::Clusters::LevelControl::LevelControlFeature::kOnOff;
return (uint32_t)LevelControl::LevelControlFeature::kOnOff;
}
esp_err_t add(cluster_t *cluster)
@@ -115,7 +115,7 @@ namespace lighting {
uint32_t get_id()
{
return (uint32_t)chip::app::Clusters::LevelControl::LevelControlFeature::kLighting;
return (uint32_t)LevelControl::LevelControlFeature::kLighting;
}
esp_err_t add(cluster_t *cluster, config_t *config)
@@ -145,7 +145,7 @@ namespace hue_saturation {
uint32_t get_id()
{
return (uint32_t)chip::app::Clusters::ColorControl::ColorCapabilities::kHueSaturationSupported;
return (uint32_t)ColorControl::ColorCapabilities::kHueSaturationSupported;
}
esp_err_t add(cluster_t *cluster, config_t *config)
@@ -179,7 +179,7 @@ namespace color_temperature {
uint32_t get_id()
{
return (uint32_t)chip::app::Clusters::ColorControl::ColorCapabilities::kColorTemperatureSupported;
return (uint32_t)ColorControl::ColorCapabilities::kColorTemperatureSupported;
}
esp_err_t add(cluster_t *cluster, config_t *config)
@@ -212,7 +212,7 @@ namespace xy {
uint32_t get_id()
{
return (uint32_t)chip::app::Clusters::ColorControl::ColorCapabilities::kXYAttributesSupported;
return (uint32_t)ColorControl::ColorCapabilities::kXYAttributesSupported;
}
esp_err_t add(cluster_t *cluster, config_t *config)
@@ -110,7 +110,6 @@ SemaphoreHandle_t semaphoreHandle = NULL;
} // unnamed namespace
BLEManagerImpl BLEManagerImpl::sInstance;
constexpr System::Clock::Timeout BLEManagerImpl::kAdvertiseTimeout;
constexpr System::Clock::Timeout BLEManagerImpl::kFastAdvertiseTimeout;
const struct ble_gatt_svc_def BLEManagerImpl::CHIPoBLEGATTAttrs[] = {
@@ -200,7 +199,6 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val)
if (val)
{
mAdvertiseStartTime = System::SystemClock().GetMonotonicTimestamp();
ReturnErrorOnFailure(DeviceLayer::SystemLayer().StartTimer(kAdvertiseTimeout, HandleAdvertisementTimer, this));
ReturnErrorOnFailure(DeviceLayer::SystemLayer().StartTimer(kFastAdvertiseTimeout, HandleFastAdvertisementTimer, this));
}
@@ -213,22 +211,6 @@ exit:
return err;
}
void BLEManagerImpl::HandleAdvertisementTimer(System::Layer * systemLayer, void * context)
{
static_cast<BLEManagerImpl *>(context)->HandleAdvertisementTimer();
}
void BLEManagerImpl::HandleAdvertisementTimer()
{
System::Clock::Timestamp currentTimestamp = System::SystemClock().GetMonotonicTimestamp();
if (currentTimestamp - mAdvertiseStartTime >= kAdvertiseTimeout)
{
mFlags.Set(Flags::kAdvertisingEnabled, 0);
PlatformMgr().ScheduleWork(DriveBLEState, 0);
}
}
void BLEManagerImpl::HandleFastAdvertisementTimer(System::Layer * systemLayer, void * context)
{
static_cast<BLEManagerImpl *>(context)->HandleFastAdvertisementTimer();