CI: add astyle pre-commit hook

This commit is contained in:
WanqQixiang
2026-02-03 15:30:42 +08:00
parent cb27fe763d
commit 968ff042a8
199 changed files with 4422 additions and 4726 deletions
-109
View File
@@ -1,109 +0,0 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories:
- Regex: '^<'
Priority: 2
- Regex: '^".*/'
Priority: 5
- Regex: '^"'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...
+31 -2
View File
@@ -1,5 +1,5 @@
stages: stages:
- check_typos - pre_check
- cleanup - cleanup
- docker_build - docker_build
- build - build
@@ -250,6 +250,7 @@ build_image:
- job: build_image - job: build_image
optional: true optional: true
- job: check_typos - job: check_typos
- job: pre_commit_check
tags: tags:
- build - build
# runner: `sudo mkdir -p /cache/matter_build/` # runner: `sudo mkdir -p /cache/matter_build/`
@@ -616,6 +617,7 @@ build_managed_component_light:
- job: build_image - job: build_image
optional: true optional: true
- job: check_typos - job: check_typos
- job: pre_commit_check
script: script:
- cd ${ESP_MATTER_PATH}/examples/managed_component_light - cd ${ESP_MATTER_PATH}/examples/managed_component_light
- idf.py set-target esp32c3 - idf.py set-target esp32c3
@@ -649,6 +651,7 @@ build_esp_rainmaker_apps:
- job: build_image - job: build_image
optional: true optional: true
- job: check_typos - job: check_typos
- job: pre_commit_check
artifacts: artifacts:
paths: paths:
@@ -754,7 +757,7 @@ deploy_docs_production:
check_typos: check_typos:
image: $CI_DOCKER_REGISTRY/esp-env-v6.0:1 image: $CI_DOCKER_REGISTRY/esp-env-v6.0:1
stage: check_typos stage: pre_check
script: script:
- pip install codespell - pip install codespell
- git fetch origin main - git fetch origin main
@@ -766,3 +769,29 @@ check_typos:
fi fi
tags: tags:
- build - build
pre_commit_check:
image: $CI_DOCKER_REGISTRY/esp-env-v6.0:1
stage: pre_check
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push" || $CI_COMMIT_BRANCH == "main"
script:
- pip install pre-commit
- git fetch origin main
- pre-commit install-hooks
- |
# Get the base commit for comparison
BASE_COMMIT=$(git merge-base origin/main HEAD)
# Run pre-commit on changed files
FILES=$(git diff --name-only --diff-filter=ACMRT ${BASE_COMMIT}...HEAD)
if [ -n "$FILES" ]; then
echo "Running pre-commit on changed files:"
echo "$FILES"
# Convert newline-separated files to space-separated and pass to pre-commit
echo "$FILES" | xargs pre-commit run --files
else
echo "No files changed, skipping pre-commit"
fi
tags:
- build
+4 -4
View File
@@ -1,8 +1,8 @@
repos: repos:
- repo: https://github.com/pre-commit/mirrors-clang-format - repo: https://github.com/espressif/astyle_py.git
rev: '0f8362ad84fe4a446b807ffbfc9e65d078ecf732' rev: v1.0.5
hooks: hooks:
- id: clang-format - id: astyle_py
exclude: '^.*/zap-generated/.*$' args: ['--astyle-version=3.4.7', '--rules=tools/ci/astyle-rules.yml']
@@ -310,7 +310,6 @@ attribute_t *create_configuration_version(cluster_t *cluster, uint32_t value)
ATTRIBUTE_FLAG_MANAGED_INTERNALLY, esp_matter_uint32(value)); ATTRIBUTE_FLAG_MANAGED_INTERNALLY, esp_matter_uint32(value));
} }
} /* attribute */ } /* attribute */
} /* basic_information */ } /* basic_information */
@@ -558,7 +557,6 @@ attribute_t *create_test_event_triggers_enabled(cluster_t *cluster, bool value)
} /* attribute */ } /* attribute */
} /* general_diagnostics */ } /* general_diagnostics */
namespace software_diagnostics { namespace software_diagnostics {
namespace attribute { namespace attribute {
@@ -709,7 +707,7 @@ attribute_t *create_active_mode_threshold(cluster_t *cluster, uint16_t value)
attribute_t *create_registered_clients(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) attribute_t *create_registered_clients(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{ {
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::RegisteredClients::Id, return esp_matter::attribute::create(cluster, IcdManagement::Attributes::RegisteredClients::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_array(value,length, count)); ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_array(value, length, count));
} }
attribute_t *create_icd_counter(cluster_t *cluster, uint32_t value) attribute_t *create_icd_counter(cluster_t *cluster, uint32_t value)
@@ -2776,7 +2774,7 @@ attribute_t *create_operating_mode(cluster_t *cluster, uint8_t value, uint8_t mi
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, DoorLock::Attributes::OperatingMode::Id, attribute_t *attribute = esp_matter::attribute::create(cluster, DoorLock::Attributes::OperatingMode::Id,
ATTRIBUTE_FLAG_WRITABLE, esp_matter_enum8(value)); ATTRIBUTE_FLAG_WRITABLE, esp_matter_enum8(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), DoorLock::Attributes::OperatingMode::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), DoorLock::Attributes::OperatingMode::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max));
return attribute; return attribute;
} }
@@ -2827,7 +2825,7 @@ attribute_t *create_wrong_code_entry_limit(cluster_t *cluster, uint8_t value)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, DoorLock::Attributes::WrongCodeEntryLimit::Id, attribute_t *attribute = esp_matter::attribute::create(cluster, DoorLock::Attributes::WrongCodeEntryLimit::Id,
ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value)); ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), DoorLock::Attributes::WrongCodeEntryLimit::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), DoorLock::Attributes::WrongCodeEntryLimit::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint8(1), esp_matter_uint8(255)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint8(1), esp_matter_uint8(255));
return attribute; return attribute;
} }
@@ -2836,7 +2834,7 @@ attribute_t *create_user_code_temporary_disable_time(cluster_t *cluster, uint8_t
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, attribute_t *attribute = esp_matter::attribute::create(cluster, DoorLock::Attributes::UserCodeTemporaryDisableTime::Id,
ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value)); ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), DoorLock::Attributes::UserCodeTemporaryDisableTime::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), DoorLock::Attributes::UserCodeTemporaryDisableTime::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint8(1), esp_matter_uint8(255)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint8(1), esp_matter_uint8(255));
return attribute; return attribute;
} }
@@ -2857,7 +2855,7 @@ attribute_t *create_expiring_user_timeout(cluster_t *cluster, uint16_t value)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, DoorLock::Attributes::ExpiringUserTimeout::Id, attribute_t *attribute = esp_matter::attribute::create(cluster, DoorLock::Attributes::ExpiringUserTimeout::Id,
ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value)); ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), DoorLock::Attributes::ExpiringUserTimeout::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), DoorLock::Attributes::ExpiringUserTimeout::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(1), esp_matter_uint16(2880)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(1), esp_matter_uint16(2880));
return attribute; return attribute;
} }
@@ -3156,13 +3154,13 @@ attribute_t *create_pir_occupied_to_unoccupied_delay(cluster_t *cluster, uint16_
attribute_t *create_pir_unoccupied_to_occupied_delay(cluster_t *cluster, uint16_t value) attribute_t *create_pir_unoccupied_to_occupied_delay(cluster_t *cluster, uint16_t value)
{ {
return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::PIRUnoccupiedToOccupiedDelay::Id, return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::PIRUnoccupiedToOccupiedDelay::Id,
ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE , esp_matter_uint16(value)); ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value));
} }
attribute_t *create_pir_unoccupied_to_occupied_threshold(cluster_t *cluster, uint8_t value) attribute_t *create_pir_unoccupied_to_occupied_threshold(cluster_t *cluster, uint8_t value)
{ {
return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::PIRUnoccupiedToOccupiedThreshold::Id, return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::PIRUnoccupiedToOccupiedThreshold::Id,
ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE , esp_matter_uint8(value)); ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value));
} }
attribute_t *create_ultrasonic_occupied_to_unoccupied_delay(cluster_t *cluster, uint16_t value) attribute_t *create_ultrasonic_occupied_to_unoccupied_delay(cluster_t *cluster, uint16_t value)
@@ -3174,13 +3172,13 @@ attribute_t *create_ultrasonic_occupied_to_unoccupied_delay(cluster_t *cluster,
attribute_t *create_ultrasonic_unoccupied_to_occupied_delay(cluster_t *cluster, uint16_t value) attribute_t *create_ultrasonic_unoccupied_to_occupied_delay(cluster_t *cluster, uint16_t value)
{ {
return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::UltrasonicUnoccupiedToOccupiedDelay::Id, return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::UltrasonicUnoccupiedToOccupiedDelay::Id,
ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE , esp_matter_uint16(value)); ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value));
} }
attribute_t *create_ultrasonic_unoccupied_to_occupied_threshold(cluster_t *cluster, uint8_t value) attribute_t *create_ultrasonic_unoccupied_to_occupied_threshold(cluster_t *cluster, uint8_t value)
{ {
return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::UltrasonicUnoccupiedToOccupiedThreshold::Id, return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::UltrasonicUnoccupiedToOccupiedThreshold::Id,
ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE , esp_matter_uint8(value)); ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value));
} }
attribute_t *create_physical_contact_occupied_to_unoccupied_delay(cluster_t *cluster, uint16_t value) attribute_t *create_physical_contact_occupied_to_unoccupied_delay(cluster_t *cluster, uint16_t value)
@@ -3192,13 +3190,13 @@ attribute_t *create_physical_contact_occupied_to_unoccupied_delay(cluster_t *clu
attribute_t *create_physical_contact_unoccupied_to_occupied_delay(cluster_t *cluster, uint16_t value) attribute_t *create_physical_contact_unoccupied_to_occupied_delay(cluster_t *cluster, uint16_t value)
{ {
return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::PhysicalContactUnoccupiedToOccupiedDelay::Id, return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::PhysicalContactUnoccupiedToOccupiedDelay::Id,
ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE , esp_matter_uint16(value)); ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value));
} }
attribute_t *create_physical_contact_unoccupied_to_occupied_threshold(cluster_t *cluster, uint8_t value) attribute_t *create_physical_contact_unoccupied_to_occupied_threshold(cluster_t *cluster, uint8_t value)
{ {
return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::PhysicalContactUnoccupiedToOccupiedThreshold::Id, return esp_matter::attribute::create(cluster, OccupancySensing::Attributes::PhysicalContactUnoccupiedToOccupiedThreshold::Id,
ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE , esp_matter_uint8(value)); ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value));
} }
} /* attribute */ } /* attribute */
@@ -3340,7 +3338,7 @@ namespace attribute {
attribute_t *create_measured_value(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> max) attribute_t *create_measured_value(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, IlluminanceMeasurement::Attributes::MeasuredValue::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, IlluminanceMeasurement::Attributes::MeasuredValue::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), IlluminanceMeasurement::Attributes::MeasuredValue::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), IlluminanceMeasurement::Attributes::MeasuredValue::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint16(min), esp_matter_nullable_uint16(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint16(min), esp_matter_nullable_uint16(max));
return attribute; return attribute;
} }
@@ -3348,7 +3346,7 @@ attribute_t *create_measured_value(cluster_t *cluster, nullable<uint16_t> value,
attribute_t *create_min_measured_value(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> max) attribute_t *create_min_measured_value(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, IlluminanceMeasurement::Attributes::MinMeasuredValue::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, IlluminanceMeasurement::Attributes::MinMeasuredValue::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), IlluminanceMeasurement::Attributes::MinMeasuredValue::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), IlluminanceMeasurement::Attributes::MinMeasuredValue::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint16(min), esp_matter_nullable_uint16(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint16(min), esp_matter_nullable_uint16(max));
return attribute; return attribute;
} }
@@ -3356,7 +3354,7 @@ attribute_t *create_min_measured_value(cluster_t *cluster, nullable<uint16_t> va
attribute_t *create_max_measured_value(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> max) attribute_t *create_max_measured_value(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, IlluminanceMeasurement::Attributes::MaxMeasuredValue::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, IlluminanceMeasurement::Attributes::MaxMeasuredValue::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), IlluminanceMeasurement::Attributes::MaxMeasuredValue::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), IlluminanceMeasurement::Attributes::MaxMeasuredValue::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint16(min), esp_matter_nullable_uint16(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint16(min), esp_matter_nullable_uint16(max));
return attribute; return attribute;
} }
@@ -3364,7 +3362,7 @@ attribute_t *create_max_measured_value(cluster_t *cluster, nullable<uint16_t> va
attribute_t *create_tolerance(cluster_t *cluster, uint16_t value, uint16_t min, uint16_t max) attribute_t *create_tolerance(cluster_t *cluster, uint16_t value, uint16_t min, uint16_t max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, IlluminanceMeasurement::Attributes::Tolerance::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, IlluminanceMeasurement::Attributes::Tolerance::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), IlluminanceMeasurement::Attributes::Tolerance::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), IlluminanceMeasurement::Attributes::Tolerance::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max));
return attribute; return attribute;
} }
@@ -3372,7 +3370,7 @@ attribute_t *create_tolerance(cluster_t *cluster, uint16_t value, uint16_t min,
attribute_t *create_light_sensor_type(cluster_t *cluster, nullable<uint8_t> value, nullable<uint8_t> min, nullable<uint8_t> max) attribute_t *create_light_sensor_type(cluster_t *cluster, nullable<uint8_t> value, nullable<uint8_t> min, nullable<uint8_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, IlluminanceMeasurement::Attributes::LightSensorType::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_enum8(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, IlluminanceMeasurement::Attributes::LightSensorType::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_enum8(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), IlluminanceMeasurement::Attributes::LightSensorType::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), IlluminanceMeasurement::Attributes::LightSensorType::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_enum8(min), esp_matter_nullable_enum8(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_enum8(min), esp_matter_nullable_enum8(max));
return attribute; return attribute;
} }
@@ -3401,7 +3399,7 @@ attribute_t *create_max_measured_value(cluster_t *cluster, nullable<int16_t> val
attribute_t *create_tolerance(cluster_t *cluster, uint16_t value, uint16_t min, uint16_t max) attribute_t *create_tolerance(cluster_t *cluster, uint16_t value, uint16_t min, uint16_t max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PressureMeasurement::Attributes::Tolerance::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PressureMeasurement::Attributes::Tolerance::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PressureMeasurement::Attributes::Tolerance::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PressureMeasurement::Attributes::Tolerance::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max));
return attribute; return attribute;
} }
@@ -3424,7 +3422,7 @@ attribute_t *create_max_scaled_value(cluster_t *cluster, nullable<int16_t> value
attribute_t *create_scaled_tolerance(cluster_t *cluster, uint16_t value, uint16_t min, uint16_t max) attribute_t *create_scaled_tolerance(cluster_t *cluster, uint16_t value, uint16_t min, uint16_t max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PressureMeasurement::Attributes::ScaledTolerance::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PressureMeasurement::Attributes::ScaledTolerance::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PressureMeasurement::Attributes::ScaledTolerance::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PressureMeasurement::Attributes::ScaledTolerance::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max));
return attribute; return attribute;
} }
@@ -3458,7 +3456,7 @@ attribute_t *create_max_measured_value(cluster_t *cluster, nullable<uint16_t> va
attribute_t *create_tolerance(cluster_t *cluster, uint16_t value, uint16_t min, uint16_t max) attribute_t *create_tolerance(cluster_t *cluster, uint16_t value, uint16_t min, uint16_t max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, FlowMeasurement::Attributes::Tolerance::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, FlowMeasurement::Attributes::Tolerance::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), FlowMeasurement::Attributes::Tolerance::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), FlowMeasurement::Attributes::Tolerance::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max));
return attribute; return attribute;
} }
@@ -3635,7 +3633,7 @@ attribute_t *create_status(cluster_t *cluster, uint8_t value)
attribute_t *create_order(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max) attribute_t *create_order(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::Order::Id, ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint8(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::Order::Id, ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint8(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::Order::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::Order::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint8(min), esp_matter_uint8(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint8(min), esp_matter_uint8(max));
return attribute; return attribute;
} }
@@ -3650,7 +3648,7 @@ attribute_t *create_description(cluster_t *cluster, const char * value, uint16_t
attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max) attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedInputVoltage::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedInputVoltage::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::WiredAssessedInputVoltage::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::WiredAssessedInputVoltage::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
return attribute; return attribute;
} }
@@ -3658,7 +3656,7 @@ attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable<ui
attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> max) attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedInputFrequency::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedInputFrequency::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::WiredAssessedInputFrequency::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::WiredAssessedInputFrequency::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint16(min), esp_matter_nullable_uint16(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint16(min), esp_matter_nullable_uint16(max));
return attribute; return attribute;
} }
@@ -3671,7 +3669,7 @@ attribute_t *create_wired_current_type(cluster_t *cluster, const uint8_t value)
attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max) attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedCurrent::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedCurrent::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::WiredAssessedCurrent::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::WiredAssessedCurrent::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
return attribute; return attribute;
} }
@@ -3679,7 +3677,7 @@ attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable<uint32_t
attribute_t *create_wired_nominal_voltage(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max) attribute_t *create_wired_nominal_voltage(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredNominalVoltage::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredNominalVoltage::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::WiredNominalVoltage::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::WiredNominalVoltage::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max));
return attribute; return attribute;
} }
@@ -3687,7 +3685,7 @@ attribute_t *create_wired_nominal_voltage(cluster_t *cluster, const uint32_t val
attribute_t *create_wired_maximum_current(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max) attribute_t *create_wired_maximum_current(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredMaximumCurrent::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredMaximumCurrent::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::WiredMaximumCurrent::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::WiredMaximumCurrent::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max));
return attribute; return attribute;
} }
@@ -3706,7 +3704,7 @@ attribute_t *create_active_wired_faults(cluster_t *cluster, uint8_t * value, uin
attribute_t *create_bat_voltage(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max) attribute_t *create_bat_voltage(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatVoltage::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatVoltage::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::BatVoltage::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::BatVoltage::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
return attribute; return attribute;
} }
@@ -3714,7 +3712,7 @@ attribute_t *create_bat_voltage(cluster_t *cluster, nullable<uint32_t> value, nu
attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable<uint8_t> value, nullable<uint8_t> min, nullable<uint8_t> max) attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable<uint8_t> value, nullable<uint8_t> min, nullable<uint8_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatPercentRemaining::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint8(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatPercentRemaining::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint8(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::BatPercentRemaining::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::BatPercentRemaining::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max));
return attribute; return attribute;
} }
@@ -3722,7 +3720,7 @@ attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable<uint8_t>
attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable< uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max) attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable< uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatTimeRemaining::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatTimeRemaining::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::BatTimeRemaining::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::BatTimeRemaining::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
return attribute; return attribute;
} }
@@ -3764,7 +3762,7 @@ attribute_t *create_bat_replacement_description(cluster_t *cluster, const char *
attribute_t *create_bat_common_designation(cluster_t *cluster, const uint8_t value, uint8_t min, uint8_t max) attribute_t *create_bat_common_designation(cluster_t *cluster, const uint8_t value, uint8_t min, uint8_t max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatCommonDesignation::Id, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatCommonDesignation::Id, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::BatCommonDesignation::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::BatCommonDesignation::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max));
return attribute; return attribute;
} }
@@ -3784,7 +3782,7 @@ attribute_t *create_bat_iec_designation(cluster_t *cluster, const char * value,
attribute_t *create_bat_approved_chemistry(cluster_t *cluster, const uint8_t value, uint8_t min, uint8_t max) attribute_t *create_bat_approved_chemistry(cluster_t *cluster, const uint8_t value, uint8_t min, uint8_t max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatApprovedChemistry::Id, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatApprovedChemistry::Id, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::BatApprovedChemistry::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::BatApprovedChemistry::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max));
return attribute; return attribute;
} }
@@ -3792,7 +3790,7 @@ attribute_t *create_bat_approved_chemistry(cluster_t *cluster, const uint8_t val
attribute_t *create_bat_capacity(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max) attribute_t *create_bat_capacity(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatCapacity::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatCapacity::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::BatCapacity::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::BatCapacity::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max));
return attribute; return attribute;
} }
@@ -3800,7 +3798,7 @@ attribute_t *create_bat_capacity(cluster_t *cluster, const uint32_t value, uint3
attribute_t *create_bat_quantity(cluster_t *cluster, const uint8_t value, uint8_t min, uint8_t max) attribute_t *create_bat_quantity(cluster_t *cluster, const uint8_t value, uint8_t min, uint8_t max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatQuantity::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatQuantity::Id, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::BatQuantity::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::BatQuantity::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_uint8(min), esp_matter_uint8(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_uint8(min), esp_matter_uint8(max));
return attribute; return attribute;
} }
@@ -3813,7 +3811,7 @@ attribute_t *create_bat_charge_state(cluster_t *cluster, uint8_t value)
attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max) attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatTimeToFullCharge::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatTimeToFullCharge::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::BatTimeToFullCharge::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::BatTimeToFullCharge::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
return attribute; return attribute;
} }
@@ -3826,7 +3824,7 @@ attribute_t *create_bat_functional_while_charging(cluster_t *cluster, bool value
attribute_t *create_bat_charging_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max) attribute_t *create_bat_charging_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
{ {
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatChargingCurrent::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatChargingCurrent::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32 , cluster::get_id(cluster), PowerSource::Attributes::BatChargingCurrent::Id)); VerifyOrReturnValue(attribute, NULL, ESP_LOGE(TAG, "Could not create attribute. cluster_id: 0x%08" PRIX32 "'s attribute_id: 0x%08" PRIX32, cluster::get_id(cluster), PowerSource::Attributes::BatChargingCurrent::Id));
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
return attribute; return attribute;
} }
@@ -4920,7 +4918,6 @@ attribute_t *create_current_sessions(cluster_t *cluster, uint8_t *value, uint16_
} /* attribute */ } /* attribute */
}/*webrtc transport requestor*/ }/*webrtc transport requestor*/
namespace chime { namespace chime {
namespace attribute { namespace attribute {
attribute_t *create_installed_chime_sounds(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) attribute_t *create_installed_chime_sounds(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
@@ -570,7 +570,6 @@ namespace activated_carbon_filter_monitoring {
namespace attribute = resource_monitoring::attribute; namespace attribute = resource_monitoring::attribute;
} /* activated_carbon_filter_monitoring */ } /* activated_carbon_filter_monitoring */
namespace concentration_measurement { namespace concentration_measurement {
namespace attribute { namespace attribute {
attribute_t *create_measured_value(cluster_t *cluster, nullable<float> value); attribute_t *create_measured_value(cluster_t *cluster, nullable<float> value);
@@ -1257,14 +1256,14 @@ attribute_t *create_status_light_brightness(cluster_t *cluster, uint8_t value);
} /*camera av stream management*/ } /*camera av stream management*/
namespace webrtc_transport_provider { namespace webrtc_transport_provider {
namespace attribute { namespace attribute {
attribute_t *create_current_sessions(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count); attribute_t *create_current_sessions(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
} /* attribute */ } /* attribute */
}/*webrtc transport provider*/ }/*webrtc transport provider*/
namespace webrtc_transport_requestor { namespace webrtc_transport_requestor {
namespace attribute { namespace attribute {
attribute_t *create_current_sessions(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count); attribute_t *create_current_sessions(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
} /* attribute */ } /* attribute */
@@ -38,8 +38,8 @@ void add_bounds_cb(cluster_t *cluster)
VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!")); VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!"));
attribute_t *current_attribute = esp_matter::attribute::get_first(cluster); attribute_t *current_attribute = esp_matter::attribute::get_first(cluster);
VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL.")); VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL."));
while(current_attribute) { while (current_attribute) {
switch(esp_matter::attribute::get_id(current_attribute)) { switch (esp_matter::attribute::get_id(current_attribute)) {
case ScenesManagement::Attributes::SceneTableSize::Id: { case ScenesManagement::Attributes::SceneTableSize::Id: {
uint16_t min = 16, max = UINT16_MAX; uint16_t min = 16, max = UINT16_MAX;
@@ -61,8 +61,8 @@ void add_bounds_cb(cluster_t *cluster)
VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!")); VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!"));
attribute_t *current_attribute = esp_matter::attribute::get_first(cluster); attribute_t *current_attribute = esp_matter::attribute::get_first(cluster);
VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL.")); VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL."));
while(current_attribute) { while (current_attribute) {
switch(esp_matter::attribute::get_id(current_attribute)) { switch (esp_matter::attribute::get_id(current_attribute)) {
case OnOff::Attributes::StartUpOnOff::Id: { case OnOff::Attributes::StartUpOnOff::Id: {
uint8_t min = 0, max = 2; uint8_t min = 0, max = 2;
@@ -85,21 +85,19 @@ void add_bounds_cb(cluster_t *cluster)
VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!")); VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!"));
attribute_t *current_attribute = esp_matter::attribute::get_first(cluster); attribute_t *current_attribute = esp_matter::attribute::get_first(cluster);
VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL.")); VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL."));
while(current_attribute) { while (current_attribute) {
switch(esp_matter::attribute::get_id(current_attribute)) { switch (esp_matter::attribute::get_id(current_attribute)) {
case LevelControl::Attributes::CurrentLevel::Id: { case LevelControl::Attributes::CurrentLevel::Id: {
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
uint16_t min = 0, max = UINT16_MAX; uint16_t min = 0, max = UINT16_MAX;
if(cluster::get_attribute_value(cluster, LevelControl::Attributes::MinLevel::Id, if (cluster::get_attribute_value(cluster, LevelControl::Attributes::MinLevel::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.u16; min = min_val.val.u16;
} }
if(cluster::get_attribute_value(cluster, LevelControl::Attributes::MaxLevel::Id, if (cluster::get_attribute_value(cluster, LevelControl::Attributes::MaxLevel::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.u16; max = max_val.val.u16;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max));
@@ -113,9 +111,8 @@ void add_bounds_cb(cluster_t *cluster)
case LevelControl::Attributes::MaxLevel::Id: { case LevelControl::Attributes::MaxLevel::Id: {
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
uint8_t min = 1, max = UINT8_MAX; uint8_t min = 1, max = UINT8_MAX;
if(cluster::get_attribute_value(cluster, LevelControl::Attributes::MinLevel::Id, if (cluster::get_attribute_value(cluster, LevelControl::Attributes::MinLevel::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.u8; min = min_val.val.u8;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint8(min), esp_matter_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint8(min), esp_matter_uint8(max));
@@ -125,14 +122,12 @@ void add_bounds_cb(cluster_t *cluster)
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
uint16_t min = 0, max = UINT16_MAX; uint16_t min = 0, max = UINT16_MAX;
if(cluster::get_attribute_value(cluster, LevelControl::Attributes::MinFrequency::Id, if (cluster::get_attribute_value(cluster, LevelControl::Attributes::MinFrequency::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.u16; min = min_val.val.u16;
} }
if(cluster::get_attribute_value(cluster, LevelControl::Attributes::MaxFrequency::Id, if (cluster::get_attribute_value(cluster, LevelControl::Attributes::MaxFrequency::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.u16; max = max_val.val.u16;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint16(min), esp_matter_uint16(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint16(min), esp_matter_uint16(max));
@@ -141,9 +136,8 @@ void add_bounds_cb(cluster_t *cluster)
case LevelControl::Attributes::MinFrequency::Id: { case LevelControl::Attributes::MinFrequency::Id: {
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
uint16_t min = 0, max = UINT16_MAX; uint16_t min = 0, max = UINT16_MAX;
if(cluster::get_attribute_value(cluster, LevelControl::Attributes::MaxFrequency::Id, if (cluster::get_attribute_value(cluster, LevelControl::Attributes::MaxFrequency::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.u16; max = max_val.val.u16;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint16(min), esp_matter_uint16(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint16(min), esp_matter_uint16(max));
@@ -152,9 +146,8 @@ void add_bounds_cb(cluster_t *cluster)
case LevelControl::Attributes::MaxFrequency::Id: { case LevelControl::Attributes::MaxFrequency::Id: {
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
uint16_t min = 0, max = UINT16_MAX; uint16_t min = 0, max = UINT16_MAX;
if(cluster::get_attribute_value(cluster, LevelControl::Attributes::MinFrequency::Id, if (cluster::get_attribute_value(cluster, LevelControl::Attributes::MinFrequency::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.u16; min = min_val.val.u16;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint16(min), esp_matter_uint16(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint16(min), esp_matter_uint16(max));
@@ -164,14 +157,12 @@ void add_bounds_cb(cluster_t *cluster)
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
uint8_t min = 0, max = UINT8_MAX; uint8_t min = 0, max = UINT8_MAX;
if(cluster::get_attribute_value(cluster, LevelControl::Attributes::MinLevel::Id, if (cluster::get_attribute_value(cluster, LevelControl::Attributes::MinLevel::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.u8; min = min_val.val.u8;
} }
if(cluster::get_attribute_value(cluster, LevelControl::Attributes::MaxLevel::Id, if (cluster::get_attribute_value(cluster, LevelControl::Attributes::MaxLevel::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.u8; max = max_val.val.u8;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max));
@@ -198,8 +189,8 @@ void add_bounds_cb(cluster_t *cluster)
VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!")); VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!"));
attribute_t *current_attribute = esp_matter::attribute::get_first(cluster); attribute_t *current_attribute = esp_matter::attribute::get_first(cluster);
VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL.")); VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL."));
while(current_attribute) { while (current_attribute) {
switch(esp_matter::attribute::get_id(current_attribute)) { switch (esp_matter::attribute::get_id(current_attribute)) {
case ColorControl::Attributes::CurrentHue::Id: case ColorControl::Attributes::CurrentHue::Id:
case ColorControl::Attributes::CurrentSaturation::Id: { case ColorControl::Attributes::CurrentSaturation::Id: {
@@ -286,14 +277,12 @@ void add_bounds_cb(cluster_t *cluster)
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
uint16_t min = 0, max = UINT16_MAX; uint16_t min = 0, max = UINT16_MAX;
if(cluster::get_attribute_value(cluster, ColorControl::Attributes::ColorTempPhysicalMinMireds::Id, if (cluster::get_attribute_value(cluster, ColorControl::Attributes::ColorTempPhysicalMinMireds::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.u16; min = min_val.val.u16;
} }
if(cluster::get_attribute_value(cluster, ColorControl::Attributes::ColorTemperatureMireds::Id, if (cluster::get_attribute_value(cluster, ColorControl::Attributes::ColorTemperatureMireds::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.u16; max = max_val.val.u16;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint16(min), esp_matter_uint16(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint16(min), esp_matter_uint16(max));
@@ -315,8 +304,8 @@ void add_bounds_cb(cluster_t *cluster)
VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!")); VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!"));
attribute_t *current_attribute = esp_matter::attribute::get_first(cluster); attribute_t *current_attribute = esp_matter::attribute::get_first(cluster);
VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL.")); VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL."));
while(current_attribute) { while (current_attribute) {
switch(esp_matter::attribute::get_id(current_attribute)) { switch (esp_matter::attribute::get_id(current_attribute)) {
case FanControl::Attributes::FanMode::Id: { case FanControl::Attributes::FanMode::Id: {
uint8_t min = 0, max = 6; uint8_t min = 0, max = 6;
@@ -346,9 +335,8 @@ void add_bounds_cb(cluster_t *cluster)
case FanControl::Attributes::SpeedSetting::Id: { case FanControl::Attributes::SpeedSetting::Id: {
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
nullable<uint8_t> min = 0, max = 100; nullable<uint8_t> min = 0, max = 100;
if(cluster::get_attribute_value(cluster, FanControl::Attributes::SpeedMax::Id, if (cluster::get_attribute_value(cluster, FanControl::Attributes::SpeedMax::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.u8; max = max_val.val.u8;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max));
@@ -357,9 +345,8 @@ void add_bounds_cb(cluster_t *cluster)
case FanControl::Attributes::SpeedCurrent::Id: { case FanControl::Attributes::SpeedCurrent::Id: {
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
uint8_t min = 0, max = 100; uint8_t min = 0, max = 100;
if(cluster::get_attribute_value(cluster, FanControl::Attributes::SpeedMax::Id, if (cluster::get_attribute_value(cluster, FanControl::Attributes::SpeedMax::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.u8; max = max_val.val.u8;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint8(min), esp_matter_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint8(min), esp_matter_uint8(max));
@@ -386,8 +373,8 @@ void add_bounds_cb(cluster_t *cluster)
VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!")); VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!"));
attribute_t *current_attribute = esp_matter::attribute::get_first(cluster); attribute_t *current_attribute = esp_matter::attribute::get_first(cluster);
VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL.")); VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL."));
while(current_attribute) { while (current_attribute) {
switch(esp_matter::attribute::get_id(current_attribute)) { switch (esp_matter::attribute::get_id(current_attribute)) {
case Thermostat::Attributes::PICoolingDemand::Id: case Thermostat::Attributes::PICoolingDemand::Id:
case Thermostat::Attributes::PIHeatingDemand::Id: { case Thermostat::Attributes::PIHeatingDemand::Id: {
@@ -400,14 +387,12 @@ void add_bounds_cb(cluster_t *cluster)
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
int16_t min = 1600, max = 3200; int16_t min = 1600, max = 3200;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::MinCoolSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::MinCoolSetpointLimit::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.i16; min = min_val.val.i16;
} }
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::MaxCoolSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::MaxCoolSetpointLimit::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.i16; max = max_val.val.i16;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max));
@@ -418,14 +403,12 @@ void add_bounds_cb(cluster_t *cluster)
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
int16_t min = 700, max = 3000; int16_t min = 700, max = 3000;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::MinHeatSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::MinHeatSetpointLimit::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.i16; min = min_val.val.i16;
} }
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::MaxHeatSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::MaxHeatSetpointLimit::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.i16; max = max_val.val.i16;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max));
@@ -435,14 +418,12 @@ void add_bounds_cb(cluster_t *cluster)
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
int16_t min = 700, max = 3000; int16_t min = 700, max = 3000;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::AbsMinHeatSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::AbsMinHeatSetpointLimit::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.i16; min = min_val.val.i16;
} }
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::MaxHeatSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::MaxHeatSetpointLimit::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.i16; max = max_val.val.i16;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max));
@@ -452,14 +433,12 @@ void add_bounds_cb(cluster_t *cluster)
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
int16_t min = 1600, max = 3200; int16_t min = 1600, max = 3200;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::MinHeatSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::MinHeatSetpointLimit::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.i16; min = min_val.val.i16;
} }
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::AbsMaxHeatSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::AbsMaxHeatSetpointLimit::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.i16; max = max_val.val.i16;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max));
@@ -469,14 +448,12 @@ void add_bounds_cb(cluster_t *cluster)
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
int16_t min = 700, max = 3000; int16_t min = 700, max = 3000;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::AbsMinCoolSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::AbsMinCoolSetpointLimit::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.i16; min = min_val.val.i16;
} }
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::MaxCoolSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::MaxCoolSetpointLimit::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.i16; max = max_val.val.i16;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max));
@@ -486,14 +463,12 @@ void add_bounds_cb(cluster_t *cluster)
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
int16_t min = 700, max = 3000; int16_t min = 700, max = 3000;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::MinCoolSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::MinCoolSetpointLimit::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.i16; min = min_val.val.i16;
} }
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::AbsMaxCoolSetpointLimit::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::AbsMaxCoolSetpointLimit::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.i16; max = max_val.val.i16;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_int16(min), esp_matter_int16(max));
@@ -545,14 +520,12 @@ void add_bounds_cb(cluster_t *cluster)
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
nullable<uint8_t> min = 0, max = 254; nullable<uint8_t> min = 0, max = 254;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::OccupiedSetbackMin::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::OccupiedSetbackMin::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.u8; min = min_val.val.u8;
} }
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::OccupiedSetbackMax::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::OccupiedSetbackMax::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.u8; max = max_val.val.u8;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max));
@@ -561,9 +534,8 @@ void add_bounds_cb(cluster_t *cluster)
case Thermostat::Attributes::OccupiedSetbackMin::Id: { case Thermostat::Attributes::OccupiedSetbackMin::Id: {
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
nullable<uint8_t> min = 0, max = 254; nullable<uint8_t> min = 0, max = 254;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::OccupiedSetbackMax::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::OccupiedSetbackMax::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.u8; max = max_val.val.u8;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max));
@@ -572,9 +544,8 @@ void add_bounds_cb(cluster_t *cluster)
case Thermostat::Attributes::OccupiedSetbackMax::Id: { case Thermostat::Attributes::OccupiedSetbackMax::Id: {
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
nullable<uint8_t> min = 0, max = 254; nullable<uint8_t> min = 0, max = 254;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::OccupiedSetbackMin::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::OccupiedSetbackMin::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.u8; min = min_val.val.u8;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max));
@@ -584,14 +555,12 @@ void add_bounds_cb(cluster_t *cluster)
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
nullable<uint8_t> min = 0, max = 254; nullable<uint8_t> min = 0, max = 254;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::UnoccupiedSetbackMin::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::UnoccupiedSetbackMin::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.u8; min = min_val.val.u8;
} }
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::UnoccupiedSetbackMax::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::UnoccupiedSetbackMax::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.u8; max = max_val.val.u8;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max));
@@ -600,9 +569,8 @@ void add_bounds_cb(cluster_t *cluster)
case Thermostat::Attributes::UnoccupiedSetbackMin::Id: { case Thermostat::Attributes::UnoccupiedSetbackMin::Id: {
esp_matter_attr_val_t max_val = esp_matter_invalid(NULL); esp_matter_attr_val_t max_val = esp_matter_invalid(NULL);
nullable<uint8_t> min = 0, max = 254; nullable<uint8_t> min = 0, max = 254;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::UnoccupiedSetbackMax::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::UnoccupiedSetbackMax::Id,
&max_val) == ESP_OK) &max_val) == ESP_OK) {
{
max = max_val.val.u8; max = max_val.val.u8;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max));
@@ -611,9 +579,8 @@ void add_bounds_cb(cluster_t *cluster)
case Thermostat::Attributes::UnoccupiedSetbackMax::Id: { case Thermostat::Attributes::UnoccupiedSetbackMax::Id: {
esp_matter_attr_val_t min_val = esp_matter_invalid(NULL); esp_matter_attr_val_t min_val = esp_matter_invalid(NULL);
nullable<uint8_t> min = 0, max = 254; nullable<uint8_t> min = 0, max = 254;
if(cluster::get_attribute_value(cluster, Thermostat::Attributes::UnoccupiedSetbackMin::Id, if (cluster::get_attribute_value(cluster, Thermostat::Attributes::UnoccupiedSetbackMin::Id,
&min_val) == ESP_OK) &min_val) == ESP_OK) {
{
min = min_val.val.u8; min = min_val.val.u8;
} }
esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max));
@@ -646,8 +613,8 @@ void add_bounds_cb(cluster_t *cluster)
VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!")); VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!"));
attribute_t *current_attribute = esp_matter::attribute::get_first(cluster); attribute_t *current_attribute = esp_matter::attribute::get_first(cluster);
VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL.")); VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL."));
while(current_attribute) { while (current_attribute) {
switch(esp_matter::attribute::get_id(current_attribute)) { switch (esp_matter::attribute::get_id(current_attribute)) {
case ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::Id: { case ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::Id: {
uint8_t min = 0, max = 1; uint8_t min = 0, max = 1;
@@ -680,8 +647,8 @@ void add_bounds_cb(cluster_t *cluster)
VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!")); VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!"));
attribute_t *current_attribute = esp_matter::attribute::get_first(cluster); attribute_t *current_attribute = esp_matter::attribute::get_first(cluster);
VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL.")); VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL."));
while(current_attribute) { while (current_attribute) {
switch(esp_matter::attribute::get_id(current_attribute)) { switch (esp_matter::attribute::get_id(current_attribute)) {
case CameraAvSettingsUserLevelManagement::Attributes::ZoomMax::Id: { case CameraAvSettingsUserLevelManagement::Attributes::ZoomMax::Id: {
uint8_t min = 2, max = 100; uint8_t min = 2, max = 100;
esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint8(min), esp_matter_uint8(max)); esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint8(min), esp_matter_uint8(max));
@@ -82,8 +82,7 @@ esp_matter_attr_val_t esp_matter_nullable_bool(nullable<bool> val)
}; };
if (val.is_null()) { if (val.is_null()) {
chip::app::NumericAttributeTraits<bool>::SetNull(*(uint8_t *)(&(attr_val.val.b))); chip::app::NumericAttributeTraits<bool>::SetNull(*(uint8_t *)(&(attr_val.val.b)));
} } else {
else {
attr_val.val.b = val.value(); attr_val.val.b = val.value();
} }
return attr_val; return attr_val;
@@ -521,7 +520,6 @@ esp_matter_attr_val_t esp_matter_array(uint8_t *val, uint16_t data_size, uint16_
namespace esp_matter { namespace esp_matter {
namespace attribute { namespace attribute {
bool val_is_null(esp_matter_attr_val_t *val) bool val_is_null(esp_matter_attr_val_t *val)
{ {
switch (val->type) { switch (val->type) {
@@ -572,7 +570,7 @@ bool val_is_null(esp_matter_attr_val_t *val)
void val_print(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val, bool is_read) void val_print(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val, bool is_read)
{ {
char action = (is_read) ? 'R' :'W'; char action = (is_read) ? 'R' : 'W';
VerifyOrReturn(!val_is_null(val), ESP_LOGI(TAG, "********** %c : Endpoint 0x%04" PRIX16 "'s Cluster 0x%08" PRIX32 "'s Attribute 0x%08" PRIX32 " is null **********", action, VerifyOrReturn(!val_is_null(val), ESP_LOGI(TAG, "********** %c : Endpoint 0x%04" PRIX16 "'s Cluster 0x%08" PRIX32 "'s Attribute 0x%08" PRIX32 " is null **********", action,
endpoint_id, cluster_id, attribute_id)); endpoint_id, cluster_id, attribute_id));
@@ -601,7 +599,7 @@ void val_print(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
|| val->type == ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP16 || val->type == ESP_MATTER_VAL_TYPE_NULLABLE_ENUM16) { || val->type == ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP16 || val->type == ESP_MATTER_VAL_TYPE_NULLABLE_ENUM16) {
ESP_LOGI(TAG, "********** %c : Endpoint 0x%04" PRIX16 "'s Cluster 0x%08" PRIX32 "'s Attribute 0x%08" PRIX32 " is %" PRIu16 " **********", action, ESP_LOGI(TAG, "********** %c : Endpoint 0x%04" PRIX16 "'s Cluster 0x%08" PRIX32 "'s Attribute 0x%08" PRIX32 " is %" PRIu16 " **********", action,
endpoint_id, cluster_id, attribute_id, val->val.u16); endpoint_id, cluster_id, attribute_id, val->val.u16);
} else if (val->type == ESP_MATTER_VAL_TYPE_INT32|| val->type == ESP_MATTER_VAL_TYPE_NULLABLE_INT32) { } else if (val->type == ESP_MATTER_VAL_TYPE_INT32 || val->type == ESP_MATTER_VAL_TYPE_NULLABLE_INT32) {
ESP_LOGI(TAG, "********** %c : Endpoint 0x%04" PRIX16 "'s Cluster 0x%08" PRIX32 "'s Attribute 0x%08" PRIX32 " is %" PRIi32 " **********", action, ESP_LOGI(TAG, "********** %c : Endpoint 0x%04" PRIX16 "'s Cluster 0x%08" PRIX32 "'s Attribute 0x%08" PRIX32 " is %" PRIi32 " **********", action,
endpoint_id, cluster_id, attribute_id, val->val.i32); endpoint_id, cluster_id, attribute_id, val->val.i32);
} else if (val->type == ESP_MATTER_VAL_TYPE_UINT32 || val->type == ESP_MATTER_VAL_TYPE_BITMAP32 } else if (val->type == ESP_MATTER_VAL_TYPE_UINT32 || val->type == ESP_MATTER_VAL_TYPE_BITMAP32
@@ -85,7 +85,7 @@ typedef enum {
ESP_MATTER_VAL_TYPE_NULLABLE_ENUM8 = ESP_MATTER_VAL_TYPE_ENUM8 + ESP_MATTER_VAL_NULLABLE_BASE, ESP_MATTER_VAL_TYPE_NULLABLE_ENUM8 = ESP_MATTER_VAL_TYPE_ENUM8 + ESP_MATTER_VAL_NULLABLE_BASE,
ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP8 = ESP_MATTER_VAL_TYPE_BITMAP8 + ESP_MATTER_VAL_NULLABLE_BASE, ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP8 = ESP_MATTER_VAL_TYPE_BITMAP8 + ESP_MATTER_VAL_NULLABLE_BASE,
ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP16 = ESP_MATTER_VAL_TYPE_BITMAP16 + ESP_MATTER_VAL_NULLABLE_BASE, ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP16 = ESP_MATTER_VAL_TYPE_BITMAP16 + ESP_MATTER_VAL_NULLABLE_BASE,
ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP32= ESP_MATTER_VAL_TYPE_BITMAP32 + ESP_MATTER_VAL_NULLABLE_BASE, ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP32 = ESP_MATTER_VAL_TYPE_BITMAP32 + ESP_MATTER_VAL_NULLABLE_BASE,
ESP_MATTER_VAL_TYPE_NULLABLE_ENUM16 = ESP_MATTER_VAL_TYPE_ENUM16 + ESP_MATTER_VAL_NULLABLE_BASE, ESP_MATTER_VAL_TYPE_NULLABLE_ENUM16 = ESP_MATTER_VAL_TYPE_ENUM16 + ESP_MATTER_VAL_NULLABLE_BASE,
} esp_matter_val_type_t; } esp_matter_val_type_t;
@@ -148,7 +148,7 @@ typedef struct esp_matter_attr_bounds {
template <typename T> template <typename T>
class nullable { class nullable {
/** NOTE: GetNullValue is taken from src/app/util/attribute-storage-null-handling.h */ /** NOTE: GetNullValue is taken from src/app/util/attribute-storage-null-handling.h */
private: private:
template <typename U = T, typename std::enable_if_t<std::is_floating_point<U>::value, int> = 0> template <typename U = T, typename std::enable_if_t<std::is_floating_point<U>::value, int> = 0>
static constexpr T GetNullValue() static constexpr T GetNullValue()
@@ -223,8 +223,7 @@ private:
/** Template specialization for bool */ /** Template specialization for bool */
template <> template <>
class nullable<bool> class nullable<bool> {
{
using Traits = chip::app::NumericAttributeTraits<bool>; using Traits = chip::app::NumericAttributeTraits<bool>;
using StorageType = typename Traits::StorageType; // Resolves to uint8_t using StorageType = typename Traits::StorageType; // Resolves to uint8_t
@@ -233,12 +232,21 @@ class nullable<bool>
public: public:
/** Constructors */ /** Constructors */
nullable() { Traits::SetNull(storage); } nullable()
nullable(std::nullptr_t) { Traits::SetNull(storage); } {
Traits::SetNull(storage);
}
nullable(std::nullptr_t)
{
Traits::SetNull(storage);
}
constexpr nullable(bool v) : storage(static_cast<StorageType>(v)) {} constexpr nullable(bool v) : storage(static_cast<StorageType>(v)) {}
/** Observers */ /** Observers */
constexpr bool is_null() const { return Traits::IsNullValue(storage); } constexpr bool is_null() const
{
return Traits::IsNullValue(storage);
}
/** /**
* @brief Gets the stored bool value. * @brief Gets the stored bool value.
@@ -255,13 +263,25 @@ public:
* ``` * ```
* @return `true` if storage is non-zero (includes null state), `false` if storage is zero. * @return `true` if storage is non-zero (includes null state), `false` if storage is zero.
*/ */
constexpr bool value() const { return static_cast<bool>(storage); } constexpr bool value() const
{
return static_cast<bool>(storage);
}
constexpr bool value_or(bool d) const { return is_null() ? d : static_cast<bool>(storage); } constexpr bool value_or(bool d) const
{
return is_null() ? d : static_cast<bool>(storage);
}
/** Modifiers */ /** Modifiers */
void operator=(std::nullptr_t) { Traits::SetNull(storage); } void operator=(std::nullptr_t)
void operator=(bool v) { storage = static_cast<StorageType>(v); } {
Traits::SetNull(storage);
}
void operator=(bool v)
{
storage = static_cast<StorageType>(v);
}
private: private:
StorageType storage; // 1byte payload holding 0 / 1 / 0xFF StorageType storage; // 1byte payload holding 0 / 1 / 0xFF
@@ -54,8 +54,7 @@ namespace {
// this space is for feature validation functions // this space is for feature validation functions
enum class feature_policy enum class feature_policy {
{
k_exact_one = 0, // O.a k_exact_one = 0, // O.a
k_at_least_one = 1, // 0.a+ k_at_least_one = 1, // 0.a+
k_at_most_one = 2, // 0.a- k_at_most_one = 2, // 0.a-
@@ -768,7 +767,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
/* Attributes managed internally */ /* Attributes managed internally */
global::attribute::create_feature_map(cluster, 0); global::attribute::create_feature_map(cluster, 0);
/* Attributes not managed internally */ /* Attributes not managed internally */
global::attribute::create_cluster_revision(cluster, cluster_revision); global::attribute::create_cluster_revision(cluster, cluster_revision);
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterEthernetNetworkDiagnosticsClusterServerInitCallback, cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterEthernetNetworkDiagnosticsClusterServerInitCallback,
@@ -1360,7 +1358,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VALIDATE_FEATURES_AT_LEAST_ONE("Heat,Cool", VALIDATE_FEATURES_AT_LEAST_ONE("Heat,Cool",
feature::heating::get_id(), feature::cooling::get_id()); feature::heating::get_id(), feature::cooling::get_id());
if(has(feature::heating::get_id())) { if (has(feature::heating::get_id())) {
feature::heating::add(cluster, &(config->features.heating)); feature::heating::add(cluster, &(config->features.heating));
} }
if (has(feature::cooling::get_id())) { if (has(feature::cooling::get_id())) {
@@ -1505,7 +1503,7 @@ static cluster_t *create(endpoint_t *endpoint, T *config, uint8_t flags, uint32_
namespace hepa_filter_monitoring { namespace hepa_filter_monitoring {
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
{ {
cluster_t *cluster = resource_monitoring::create<config_t, HepaFilterMonitoringDelegateInitCB>(endpoint, config, flags,HepaFilterMonitoring::Id, cluster_revision); cluster_t *cluster = resource_monitoring::create<config_t, HepaFilterMonitoringDelegateInitCB>(endpoint, config, flags, HepaFilterMonitoring::Id, cluster_revision);
if (cluster && (flags & CLUSTER_FLAG_SERVER)) { if (cluster && (flags & CLUSTER_FLAG_SERVER)) {
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterHepaFilterMonitoringClusterServerInitCallback, cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterHepaFilterMonitoringClusterServerInitCallback,
ESPMatterHepaFilterMonitoringClusterServerShutdownCallback); ESPMatterHepaFilterMonitoringClusterServerShutdownCallback);
@@ -1517,7 +1515,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
namespace activated_carbon_filter_monitoring { namespace activated_carbon_filter_monitoring {
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
{ {
cluster_t *cluster = resource_monitoring::create<config_t, ActivatedCarbonFilterMonitoringDelegateInitCB>(endpoint, config, flags,ActivatedCarbonFilterMonitoring::Id, cluster_revision); cluster_t *cluster = resource_monitoring::create<config_t, ActivatedCarbonFilterMonitoringDelegateInitCB>(endpoint, config, flags, ActivatedCarbonFilterMonitoring::Id, cluster_revision);
if (cluster && (flags & CLUSTER_FLAG_SERVER)) { if (cluster && (flags & CLUSTER_FLAG_SERVER)) {
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterActivatedCarbonFilterMonitoringClusterServerInitCallback, cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterActivatedCarbonFilterMonitoringClusterServerInitCallback,
ESPMatterActivatedCarbonFilterMonitoringClusterServerShutdownCallback); ESPMatterActivatedCarbonFilterMonitoringClusterServerShutdownCallback);
@@ -1552,7 +1550,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
VALIDATE_FEATURES_AT_LEAST_ONE("NumericMeasurement,LevelIndication", VALIDATE_FEATURES_AT_LEAST_ONE("NumericMeasurement,LevelIndication",
feature::numeric_measurement::get_id(), feature::level_indication::get_id()); feature::numeric_measurement::get_id(), feature::level_indication::get_id());
if(has(feature::numeric_measurement::get_id())) { if (has(feature::numeric_measurement::get_id())) {
feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement));
if (has(feature::peak_measurement::get_id())) { if (has(feature::peak_measurement::get_id())) {
feature::peak_measurement::add(cluster, &(config->features.peak_measurement)); feature::peak_measurement::add(cluster, &(config->features.peak_measurement));
@@ -2077,7 +2075,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
} }
} /* window_covering */ } /* window_covering */
namespace switch_cluster { namespace switch_cluster {
const function_generic_t *function_list = NULL; const function_generic_t *function_list = NULL;
const int function_flags = CLUSTER_FLAG_NONE; const int function_flags = CLUSTER_FLAG_NONE;
@@ -2355,7 +2352,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
namespace localization_configuration { namespace localization_configuration {
const function_generic_t function_list[] = { const function_generic_t function_list[] = {
(function_generic_t)emberAfLocalizationConfigurationClusterServerInitCallback, (function_generic_t)emberAfLocalizationConfigurationClusterServerInitCallback,
(function_generic_t)MatterLocalizationConfigurationClusterServerPreAttributeChangedCallback}; (function_generic_t)MatterLocalizationConfigurationClusterServerPreAttributeChangedCallback
};
const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION; const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
@@ -2393,7 +2391,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
namespace time_format_localization { namespace time_format_localization {
const function_generic_t function_list[] = { const function_generic_t function_list[] = {
(function_generic_t)emberAfTimeFormatLocalizationClusterServerInitCallback, (function_generic_t)emberAfTimeFormatLocalizationClusterServerInitCallback,
(function_generic_t)MatterTimeFormatLocalizationClusterServerPreAttributeChangedCallback}; (function_generic_t)MatterTimeFormatLocalizationClusterServerPreAttributeChangedCallback
};
const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION; const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
@@ -3044,7 +3043,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
/* Attributes managed internally */ /* Attributes managed internally */
global::attribute::create_feature_map(cluster, 0); global::attribute::create_feature_map(cluster, 0);
/* Attributes not managed internally */ /* Attributes not managed internally */
global::attribute::create_cluster_revision(cluster, cluster_revision); global::attribute::create_cluster_revision(cluster, cluster_revision);
} }
@@ -3433,10 +3431,10 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
/* Attributes should managed by application */ /* Attributes should managed by application */
attribute::create_application_name(cluster, NULL, 0); attribute::create_application_name(cluster, NULL, 0);
attribute::create_application(cluster, NULL, 0 , 0); attribute::create_application(cluster, NULL, 0, 0);
attribute::create_status(cluster, 0); attribute::create_status(cluster, 0);
attribute::create_application_version(cluster, NULL, 0); attribute::create_application_version(cluster, NULL, 0);
attribute::create_allowed_vendor_list(cluster, NULL, 0 , 0); attribute::create_allowed_vendor_list(cluster, NULL, 0, 0);
/** Attributes not managed internally **/ /** Attributes not managed internally **/
global::attribute::create_cluster_revision(cluster, cluster_revision); global::attribute::create_cluster_revision(cluster, cluster_revision);
} }
@@ -3827,7 +3825,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
attribute::create_supported_stream_usages(cluster, NULL, 0, 0); attribute::create_supported_stream_usages(cluster, NULL, 0, 0);
attribute::create_stream_usage_priorities(cluster, NULL, 0, 0); attribute::create_stream_usage_priorities(cluster, NULL, 0, 0);
// check against at least one feature conformance // check against at least one feature conformance
VALIDATE_FEATURES_AT_LEAST_ONE("Audio,Video,Snapshot", VALIDATE_FEATURES_AT_LEAST_ONE("Audio,Video,Snapshot",
feature::audio::get_id(), feature::video::get_id(), feature::snapshot::get_id()); feature::audio::get_id(), feature::video::get_id(), feature::snapshot::get_id());
@@ -3848,7 +3845,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(feature::local_storage::add(cluster) == ESP_OK, ABORT_CLUSTER_CREATE(cluster)); VerifyOrReturnValue(feature::local_storage::add(cluster) == ESP_OK, ABORT_CLUSTER_CREATE(cluster));
} }
if (has(feature::video::get_id())|| has(feature::snapshot::get_id())) { if (has(feature::video::get_id()) || has(feature::snapshot::get_id())) {
if (has(feature::image_control::get_id())) { if (has(feature::image_control::get_id())) {
VerifyOrReturnValue(feature::image_control::add(cluster) == ESP_OK, ABORT_CLUSTER_CREATE(cluster)); VerifyOrReturnValue(feature::image_control::add(cluster) == ESP_OK, ABORT_CLUSTER_CREATE(cluster));
} }
@@ -3902,7 +3899,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
attribute::create_current_sessions(cluster, NULL, 0, 0); attribute::create_current_sessions(cluster, NULL, 0, 0);
command::create_solicit_offer(cluster); command::create_solicit_offer(cluster);
command::create_solicit_offer_response(cluster); command::create_solicit_offer_response(cluster);
command::create_provide_offer(cluster); command::create_provide_offer(cluster);
@@ -3944,7 +3940,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
attribute::create_current_sessions(cluster, NULL, 0, 0); attribute::create_current_sessions(cluster, NULL, 0, 0);
command::create_offer(cluster); command::create_offer(cluster);
command::create_answer(cluster); command::create_answer(cluster);
command::create_ice_candidates(cluster); command::create_ice_candidates(cluster);
@@ -3959,7 +3954,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
} }
} /*webrtc transport requestor*/ } /*webrtc transport requestor*/
// namespace binary_input_basic { // namespace binary_input_basic {
// // ToDo // // ToDo
// } /* binary_input_basic */ // } /* binary_input_basic */
@@ -969,7 +969,6 @@ using config_t = common::config_t;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
}/*webrtc transport requestor*/ }/*webrtc transport requestor*/
namespace chime { namespace chime {
typedef struct config { typedef struct config {
void *delegate; void *delegate;
@@ -2811,8 +2811,6 @@ command_t *create_capture_snapshot_response(cluster_t *cluster)
} /* command */ } /* command */
} /*camera av stream management*/ } /*camera av stream management*/
namespace webrtc_transport_provider { namespace webrtc_transport_provider {
namespace command { namespace command {
@@ -2843,7 +2841,7 @@ command_t *create_provide_answer(cluster_t *cluster)
command_t *create_provide_ice_candidates(cluster_t *cluster) command_t *create_provide_ice_candidates(cluster_t *cluster)
{ {
return esp_matter::command::create(cluster, WebRTCTransportProvider::Commands::ProvideICECandidates::Id, COMMAND_FLAG_ACCEPTED,NULL); return esp_matter::command::create(cluster, WebRTCTransportProvider::Commands::ProvideICECandidates::Id, COMMAND_FLAG_ACCEPTED, NULL);
} }
command_t *create_end_session(cluster_t *cluster) command_t *create_end_session(cluster_t *cluster)
@@ -2855,32 +2853,31 @@ command_t *create_end_session(cluster_t *cluster)
}/*webrtc_transport_provider*/ }/*webrtc_transport_provider*/
namespace webrtc_transport_requestor { namespace webrtc_transport_requestor {
namespace command { namespace command {
command_t *create_offer(cluster_t *cluster) command_t *create_offer(cluster_t *cluster)
{ {
return esp_matter::command::create(cluster, WebRTCTransportRequestor::Commands::Offer::Id, COMMAND_FLAG_ACCEPTED, NULL); return esp_matter::command::create(cluster, WebRTCTransportRequestor::Commands::Offer::Id, COMMAND_FLAG_ACCEPTED, NULL);
} }
command_t *create_answer(cluster_t *cluster) command_t *create_answer(cluster_t *cluster)
{ {
return esp_matter::command::create(cluster, WebRTCTransportRequestor::Commands::Answer::Id, COMMAND_FLAG_ACCEPTED, NULL); return esp_matter::command::create(cluster, WebRTCTransportRequestor::Commands::Answer::Id, COMMAND_FLAG_ACCEPTED, NULL);
} }
command_t *create_ice_candidates(cluster_t *cluster) command_t *create_ice_candidates(cluster_t *cluster)
{ {
return esp_matter::command::create(cluster, WebRTCTransportRequestor::Commands::ICECandidates::Id, COMMAND_FLAG_ACCEPTED, NULL); return esp_matter::command::create(cluster, WebRTCTransportRequestor::Commands::ICECandidates::Id, COMMAND_FLAG_ACCEPTED, NULL);
} }
command_t *create_end(cluster_t *cluster) command_t *create_end(cluster_t *cluster)
{ {
return esp_matter::command::create(cluster, WebRTCTransportRequestor::Commands::End::Id, COMMAND_FLAG_ACCEPTED, NULL); return esp_matter::command::create(cluster, WebRTCTransportRequestor::Commands::End::Id, COMMAND_FLAG_ACCEPTED, NULL);
} }
} /* command */ } /* command */
}/*webrtc_transport_requestor*/ }/*webrtc_transport_requestor*/
namespace chime { namespace chime {
namespace command { namespace command {
command_t *create_play_chime_sound(cluster_t *cluster) command_t *create_play_chime_sound(cluster_t *cluster)
@@ -382,7 +382,6 @@ namespace activated_carbon_filter_monitoring {
namespace command = resource_monitoring::command; namespace command = resource_monitoring::command;
} /* activated_carbon_filter_monitoring */ } /* activated_carbon_filter_monitoring */
namespace mode_base { namespace mode_base {
namespace command { namespace command {
command_t *create_change_to_mode(cluster_t *cluster); command_t *create_change_to_mode(cluster_t *cluster);
@@ -545,7 +544,6 @@ command_t *create_end(cluster_t *cluster);
} /* command */ } /* command */
}/*webrtc transport requestor*/ }/*webrtc transport requestor*/
namespace chime { namespace chime {
namespace command { namespace command {
command_t *create_play_chime_sound(cluster_t *cluster); command_t *create_play_chime_sound(cluster_t *cluster);
@@ -1921,11 +1921,13 @@ uint32_t get_cluster_count(uint32_t endpoint_id, uint32_t cluster_id, uint8_t cl
// lambda to count all matching clusters for an endpoint // lambda to count all matching clusters for an endpoint
auto get_count_on_all_clusters = [&check_cluster_flags](endpoint_t *endpoint) -> uint32_t { auto get_count_on_all_clusters = [&check_cluster_flags](endpoint_t *endpoint) -> uint32_t {
uint32_t result = 0; uint32_t result = 0;
if (!endpoint) if (!endpoint) {
return result; return result;
}
cluster_t *cluster = cluster::get_first(endpoint); cluster_t *cluster = cluster::get_first(endpoint);
while (cluster) { while (cluster)
{
result += check_cluster_flags(cluster); result += check_cluster_flags(cluster);
cluster = cluster::get_next(cluster); cluster = cluster::get_next(cluster);
} }
@@ -1935,8 +1937,9 @@ uint32_t get_cluster_count(uint32_t endpoint_id, uint32_t cluster_id, uint8_t cl
// lambda to find and count a specific cluster // lambda to find and count a specific cluster
auto get_count_on_specific_cluster = [&check_cluster_flags](const endpoint_t *endpoint, auto get_count_on_specific_cluster = [&check_cluster_flags](const endpoint_t *endpoint,
uint32_t cluster_id) -> uint32_t { uint32_t cluster_id) -> uint32_t {
if (!endpoint) if (!endpoint) {
return 0; return 0;
}
cluster_t *cluster = cluster::get((endpoint_t *)endpoint, cluster_id); cluster_t *cluster = cluster::get((endpoint_t *)endpoint, cluster_id);
return check_cluster_flags(cluster); return check_cluster_flags(cluster);
}; };
@@ -442,7 +442,6 @@ esp_err_t set_identify(uint16_t endpoint_id, void *identify);
*/ */
esp_err_t enable(endpoint_t *endpoint); esp_err_t enable(endpoint_t *endpoint);
/** Check if attribute is enabled /** Check if attribute is enabled
* *
* Check if the attribute of a cluster is enabled on an endpoint. * Check if the attribute of a cluster is enabled on an endpoint.
@@ -532,14 +531,14 @@ typedef void (*function_cluster_shutdown_t)(uint16_t endpoint_id);
* *
* This will be called when attributes are change for the cluster. * This will be called when attributes are change for the cluster.
*/ */
typedef void (*function_attribute_change_t)(const chip::app::ConcreteAttributePath & attributePath); typedef void (*function_attribute_change_t)(const chip::app::ConcreteAttributePath &attributePath);
/** Pre attribute change function /** Pre attribute change function
* *
* This function is called before an attribute changes. * This function is called before an attribute changes.
*/ */
typedef chip::Protocols::InteractionModel::Status (*function_pre_attribute_change_t)( typedef chip::Protocols::InteractionModel::Status(*function_pre_attribute_change_t)(
const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value); const chip::app::ConcreteAttributePath &attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value);
/** Initialization callback /** Initialization callback
* *
@@ -851,7 +850,6 @@ attribute_t *get(cluster_t *cluster, uint32_t attribute_id);
*/ */
attribute_t *get(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id); attribute_t *get(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id);
/** Get first attribute /** Get first attribute
* *
* Get the first attribute present on the cluster. * Get the first attribute present on the cluster.
@@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include <inttypes.h> #include <inttypes.h>
#include <esp_matter_delegate_callbacks.h> #include <esp_matter_delegate_callbacks.h>
#include <esp_matter_core.h> #include <esp_matter_core.h>
@@ -222,8 +221,7 @@ void MicrowaveOvenModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
ModeBase::Delegate *mode_delegate = static_cast<ModeBase::Delegate*>(delegate); ModeBase::Delegate *mode_delegate = static_cast<ModeBase::Delegate*>(delegate);
ModeBase::Instance * modeInstance = nullptr; ModeBase::Instance * modeInstance = nullptr;
// Create new instance of MicrowaveOvenMode if not found in the map, otherwise use existing instance. // Create new instance of MicrowaveOvenMode if not found in the map, otherwise use existing instance.
if(s_microwave_oven_mode_instances.find(endpoint_id) == s_microwave_oven_mode_instances.end()) if (s_microwave_oven_mode_instances.find(endpoint_id) == s_microwave_oven_mode_instances.end()) {
{
uint32_t feature_map = get_feature_map_value(endpoint_id, MicrowaveOvenMode::Id); uint32_t feature_map = get_feature_map_value(endpoint_id, MicrowaveOvenMode::Id);
modeInstance = new ModeBase::Instance(mode_delegate, endpoint_id, MicrowaveOvenMode::Id, feature_map); modeInstance = new ModeBase::Instance(mode_delegate, endpoint_id, MicrowaveOvenMode::Id, feature_map);
s_microwave_oven_mode_instances[endpoint_id] = modeInstance; s_microwave_oven_mode_instances[endpoint_id] = modeInstance;
@@ -267,8 +265,7 @@ void MicrowaveOvenControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
OperationalState::Instance* operationalStateInstance = nullptr; OperationalState::Instance* operationalStateInstance = nullptr;
// Create new instance of MicrowaveOvenMode if not found in the map, otherwise use existing instance. // Create new instance of MicrowaveOvenMode if not found in the map, otherwise use existing instance.
if(s_microwave_oven_mode_instances.find(endpoint_id) == s_microwave_oven_mode_instances.end()) if (s_microwave_oven_mode_instances.find(endpoint_id) == s_microwave_oven_mode_instances.end()) {
{
uint32_t feature_map = get_feature_map_value(endpoint_id, MicrowaveOvenMode::Id); uint32_t feature_map = get_feature_map_value(endpoint_id, MicrowaveOvenMode::Id);
microwaveOvenModeInstance = new ModeBase::Instance(microwave_oven_mode_delegate, endpoint_id, MicrowaveOvenMode::Id, feature_map); microwaveOvenModeInstance = new ModeBase::Instance(microwave_oven_mode_delegate, endpoint_id, MicrowaveOvenMode::Id, feature_map);
s_microwave_oven_mode_instances[endpoint_id] = microwaveOvenModeInstance; s_microwave_oven_mode_instances[endpoint_id] = microwaveOvenModeInstance;
@@ -277,8 +274,7 @@ void MicrowaveOvenControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
} }
// Create new instance of OperationalState if not found in the map, otherwise use existing instance. // Create new instance of OperationalState if not found in the map, otherwise use existing instance.
if(s_operational_state_instances.find(endpoint_id) == s_operational_state_instances.end()) if (s_operational_state_instances.find(endpoint_id) == s_operational_state_instances.end()) {
{
operationalStateInstance = new OperationalState::Instance(operational_state_delegate, endpoint_id); operationalStateInstance = new OperationalState::Instance(operational_state_delegate, endpoint_id);
s_operational_state_instances[endpoint_id] = operationalStateInstance; s_operational_state_instances[endpoint_id] = operationalStateInstance;
} else { } else {
@@ -300,8 +296,7 @@ void OperationalStateDelegateInitCB(void *delegate, uint16_t endpoint_id)
static OperationalState::Instance * operationalStateInstance = nullptr; static OperationalState::Instance * operationalStateInstance = nullptr;
OperationalState::Delegate *operational_state_delegate = static_cast<OperationalState::Delegate*>(delegate); OperationalState::Delegate *operational_state_delegate = static_cast<OperationalState::Delegate*>(delegate);
// Create new instance of OperationalState if not found in the map, otherwise use existing instance. // Create new instance of OperationalState if not found in the map, otherwise use existing instance.
if(s_operational_state_instances.find(endpoint_id) == s_operational_state_instances.end()) if (s_operational_state_instances.find(endpoint_id) == s_operational_state_instances.end()) {
{
operationalStateInstance = new OperationalState::Instance(operational_state_delegate, endpoint_id); operationalStateInstance = new OperationalState::Instance(operational_state_delegate, endpoint_id);
s_operational_state_instances[endpoint_id] = operationalStateInstance; s_operational_state_instances[endpoint_id] = operationalStateInstance;
} else { } else {
@@ -466,8 +461,7 @@ void ServiceAreaDelegateInitCB(void *delegate, uint16_t endpoint_id)
void WaterHeaterManagementDelegateInitCB(void *delegate, uint16_t endpoint_id) void WaterHeaterManagementDelegateInitCB(void *delegate, uint16_t endpoint_id)
{ {
if(delegate == nullptr) if (delegate == nullptr) {
{
return; return;
} }
static WaterHeaterManagement::Instance * wHtrInstance = nullptr; static WaterHeaterManagement::Instance * wHtrInstance = nullptr;
@@ -479,8 +473,7 @@ void WaterHeaterManagementDelegateInitCB(void *delegate, uint16_t endpoint_id)
void EnergyPreferenceDelegateInitCB(void *delegate, uint16_t endpoint_id) void EnergyPreferenceDelegateInitCB(void *delegate, uint16_t endpoint_id)
{ {
if(delegate == nullptr) if (delegate == nullptr) {
{
return; return;
} }
EnergyPreference::Delegate *energy_preference_delegate = static_cast<EnergyPreference::Delegate*>(delegate); EnergyPreference::Delegate *energy_preference_delegate = static_cast<EnergyPreference::Delegate*>(delegate);
@@ -489,8 +482,7 @@ void EnergyPreferenceDelegateInitCB(void *delegate, uint16_t endpoint_id)
void CommissionerControlDelegateInitCB(void *delegate, uint16_t endpoint_id) void CommissionerControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
{ {
if(delegate == nullptr) if (delegate == nullptr) {
{
return; return;
} }
CommissionerControl::Delegate *commissioner_control_delegate = static_cast<CommissionerControl::Delegate*>(delegate); CommissionerControl::Delegate *commissioner_control_delegate = static_cast<CommissionerControl::Delegate*>(delegate);
@@ -509,7 +501,6 @@ void ActionsDelegateInitCB(void *delegate, uint16_t endpoint_id)
(void)actionsServer->Init(); (void)actionsServer->Init();
} }
void ThermostatDelegateInitCB(void *delegate, uint16_t endpoint_id) void ThermostatDelegateInitCB(void *delegate, uint16_t endpoint_id)
{ {
VerifyOrReturn(delegate != nullptr); VerifyOrReturn(delegate != nullptr);
@@ -548,7 +539,6 @@ void ClosureControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
(void)server_interface->Init(); (void)server_interface->Init();
} }
void ClosureDimensionDelegateInitCB(void *delegate, uint16_t endpoint_id) void ClosureDimensionDelegateInitCB(void *delegate, uint16_t endpoint_id)
{ {
VerifyOrReturn(delegate != nullptr); VerifyOrReturn(delegate != nullptr);
@@ -559,7 +549,6 @@ void ClosureDimensionDelegateInitCB(void *delegate, uint16_t endpoint_id)
(void)server_interface->Init(); (void)server_interface->Init();
} }
void PushAvStreamTransportDelegateInitCB(void *delegate, uint16_t endpoint_id) void PushAvStreamTransportDelegateInitCB(void *delegate, uint16_t endpoint_id)
{ {
VerifyOrReturn(delegate != nullptr); VerifyOrReturn(delegate != nullptr);
@@ -567,7 +556,6 @@ void PushAvStreamTransportDelegateInitCB(void *delegate, uint16_t endpoint_id)
chip::app::Clusters::PushAvStreamTransport::SetDelegate(endpoint_id, push_av_stream_transport_delegate); chip::app::Clusters::PushAvStreamTransport::SetDelegate(endpoint_id, push_av_stream_transport_delegate);
} }
void CommodityTariffDelegateInitCB(void *delegate, uint16_t endpoint_id) void CommodityTariffDelegateInitCB(void *delegate, uint16_t endpoint_id)
{ {
VerifyOrReturn(delegate != nullptr); VerifyOrReturn(delegate != nullptr);
@@ -577,7 +565,6 @@ void CommodityTariffDelegateInitCB(void *delegate, uint16_t endpoint_id)
(void)commodity_tariff_instance->Init(); (void)commodity_tariff_instance->Init();
} }
void CommodityPriceDelegateInitCB(void *delegate, uint16_t endpoint_id) void CommodityPriceDelegateInitCB(void *delegate, uint16_t endpoint_id)
{ {
VerifyOrReturn(delegate != nullptr); VerifyOrReturn(delegate != nullptr);
@@ -587,7 +574,6 @@ void CommodityPriceDelegateInitCB(void *delegate, uint16_t endpoint_id)
(void)commodity_price_instance->Init(); (void)commodity_price_instance->Init();
} }
void ElectricalGridConditionsDelegateInitCB(void *delegate, uint16_t endpoint_id) void ElectricalGridConditionsDelegateInitCB(void *delegate, uint16_t endpoint_id)
{ {
VerifyOrReturn(delegate != nullptr); VerifyOrReturn(delegate != nullptr);
@@ -172,7 +172,7 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
} /** ota_provider **/ } /** ota_provider **/
namespace power_source{ namespace power_source {
uint32_t get_device_type_id() uint32_t get_device_type_id()
{ {
return ESP_MATTER_POWER_SOURCE_DEVICE_TYPE_ID; return ESP_MATTER_POWER_SOURCE_DEVICE_TYPE_ID;
@@ -1260,7 +1260,6 @@ uint8_t get_device_type_version()
return ESP_MATTER_ROOM_AIR_CONDITIONER_DEVICE_TYPE_VERSION; return ESP_MATTER_ROOM_AIR_CONDITIONER_DEVICE_TYPE_VERSION;
} }
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data)
{ {
return common::create<config_t>(node, config, flags, priv_data, add); return common::create<config_t>(node, config, flags, priv_data, add);
@@ -1283,7 +1282,7 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
} }
} /** room_air_conditioner **/ } /** room_air_conditioner **/
namespace temperature_controlled_cabinet{ namespace temperature_controlled_cabinet {
uint32_t get_device_type_id() uint32_t get_device_type_id()
{ {
@@ -1311,7 +1310,7 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
} }
} /** temperature_controlled_cabinet**/ } /** temperature_controlled_cabinet**/
namespace refrigerator{ namespace refrigerator {
uint32_t get_device_type_id() uint32_t get_device_type_id()
{ {
@@ -259,7 +259,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat
esp_err_t add(endpoint_t *endpoint, config_t *config); esp_err_t add(endpoint_t *endpoint, config_t *config);
} /* ota_provider */ } /* ota_provider */
namespace power_source{ namespace power_source {
typedef struct config { typedef struct config {
cluster::descriptor::config_t descriptor; cluster::descriptor::config_t descriptor;
cluster::power_source::config_t power_source; cluster::power_source::config_t power_source;
@@ -274,7 +274,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace on_off_light { namespace on_off_light {
typedef struct config : on_off_with_lighting_config { typedef struct config : on_off_with_lighting_config {
config() { config()
{
/* For lighting product, the default identify type should be 0x01: LightOutput*/ /* For lighting product, the default identify type should be 0x01: LightOutput*/
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kLightOutput); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kLightOutput);
} }
@@ -331,7 +332,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace on_off_light_switch { namespace on_off_light_switch {
typedef struct config : app_client_config { typedef struct config : app_client_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
} config_t; } config_t;
@@ -345,7 +347,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace dimmer_switch { namespace dimmer_switch {
typedef struct config : app_client_config { typedef struct config : app_client_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
} config_t; } config_t;
@@ -359,7 +362,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace color_dimmer_switch { namespace color_dimmer_switch {
typedef struct config : app_client_config { typedef struct config : app_client_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
} config_t; } config_t;
@@ -372,7 +376,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace generic_switch { namespace generic_switch {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
cluster::switch_cluster::config_t switch_cluster; cluster::switch_cluster::config_t switch_cluster;
@@ -387,7 +392,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace on_off_plug_in_unit { namespace on_off_plug_in_unit {
typedef struct config : on_off_with_lighting_config { typedef struct config : on_off_with_lighting_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
} config_t; } config_t;
@@ -412,7 +418,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace fan { namespace fan {
typedef struct config : app_with_group_config { typedef struct config : app_with_group_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator);
} }
cluster::fan_control::config_t fan_control; cluster::fan_control::config_t fan_control;
@@ -426,7 +433,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace thermostat { namespace thermostat {
typedef struct config : app_with_group_config { typedef struct config : app_with_group_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
cluster::scenes_management::config_t scenes_management; cluster::scenes_management::config_t scenes_management;
@@ -441,7 +449,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace air_quality_sensor { namespace air_quality_sensor {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
cluster::air_quality::config_t air_quality; cluster::air_quality::config_t air_quality;
@@ -455,7 +464,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace air_purifier { namespace air_purifier {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator);
} }
cluster::fan_control::config_t fan_control; cluster::fan_control::config_t fan_control;
@@ -496,7 +506,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace smoke_co_alarm { namespace smoke_co_alarm {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kAudibleBeep); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kAudibleBeep);
} }
cluster::smoke_co_alarm::config_t smoke_co_alarm; cluster::smoke_co_alarm::config_t smoke_co_alarm;
@@ -543,7 +554,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace door_lock { namespace door_lock {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kAudibleBeep); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kAudibleBeep);
} }
cluster::door_lock::config_t door_lock; cluster::door_lock::config_t door_lock;
@@ -558,7 +570,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace window_covering { namespace window_covering {
typedef struct config : app_with_group_config { typedef struct config : app_with_group_config {
cluster::window_covering::config_t window_covering; cluster::window_covering::config_t window_covering;
config(uint8_t end_product_type = 0) : window_covering(end_product_type) { config(uint8_t end_product_type = 0) : window_covering(end_product_type)
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator);
} }
} config_t; } config_t;
@@ -571,7 +584,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace temperature_sensor { namespace temperature_sensor {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
cluster::temperature_measurement::config_t temperature_measurement; cluster::temperature_measurement::config_t temperature_measurement;
@@ -585,7 +599,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace humidity_sensor { namespace humidity_sensor {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
cluster::relative_humidity_measurement::config_t relative_humidity_measurement; cluster::relative_humidity_measurement::config_t relative_humidity_measurement;
@@ -599,7 +614,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace occupancy_sensor { namespace occupancy_sensor {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kAudibleBeep); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kAudibleBeep);
} }
cluster::occupancy_sensing::config_t occupancy_sensing; cluster::occupancy_sensing::config_t occupancy_sensing;
@@ -614,7 +630,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace contact_sensor { namespace contact_sensor {
typedef struct config : app_with_bool_state_config { typedef struct config : app_with_bool_state_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
} config_t; } config_t;
@@ -627,7 +644,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace light_sensor { namespace light_sensor {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
cluster::illuminance_measurement::config_t illuminance_measurement; cluster::illuminance_measurement::config_t illuminance_measurement;
@@ -641,7 +659,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace pressure_sensor { namespace pressure_sensor {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
cluster::pressure_measurement::config_t pressure_measurement; cluster::pressure_measurement::config_t pressure_measurement;
@@ -655,7 +674,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace flow_sensor { namespace flow_sensor {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
cluster::flow_measurement::config_t flow_measurement; cluster::flow_measurement::config_t flow_measurement;
@@ -675,7 +695,8 @@ typedef struct config : app_base_config {
nullable<int16_t> max_pressure = nullable<int16_t>(), nullable<int16_t> max_pressure = nullable<int16_t>(),
nullable<uint16_t> max_speed = nullable<uint16_t>(), nullable<uint16_t> max_speed = nullable<uint16_t>(),
nullable<uint16_t> max_flow = nullable<uint16_t>() nullable<uint16_t> max_flow = nullable<uint16_t>()
) : pump_configuration_and_control(max_pressure, max_speed, max_flow) { ) : pump_configuration_and_control(max_pressure, max_speed, max_flow)
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator);
} }
} config_t; } config_t;
@@ -688,7 +709,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace pump_controller { namespace pump_controller {
typedef struct config : app_client_config { typedef struct config : app_client_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
} config_t; } config_t;
@@ -713,7 +735,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace room_air_conditioner { namespace room_air_conditioner {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator);
} }
cluster::on_off::config_t on_off; cluster::on_off::config_t on_off;
@@ -762,7 +785,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace robotic_vacuum_cleaner { namespace robotic_vacuum_cleaner {
typedef struct config : app_base_config { typedef struct config : app_base_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator);
} }
cluster::rvc_run_mode::config_t rvc_run_mode; cluster::rvc_run_mode::config_t rvc_run_mode;
@@ -778,7 +802,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace water_leak_detector { namespace water_leak_detector {
typedef struct config : app_with_bool_state_config { typedef struct config : app_with_bool_state_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
} config_t; } config_t;
@@ -792,7 +817,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace water_freeze_detector { namespace water_freeze_detector {
typedef struct config : app_with_bool_state_config { typedef struct config : app_with_bool_state_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
} config_t; } config_t;
@@ -806,7 +832,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace rain_sensor { namespace rain_sensor {
typedef struct config : app_with_bool_state_config { typedef struct config : app_with_bool_state_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator);
} }
} config_t; } config_t;
@@ -895,7 +922,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace water_valve { namespace water_valve {
typedef struct config : app_base_config { typedef struct config : app_base_config {
cluster::valve_configuration_and_control::config_t valve_configuration_and_control; cluster::valve_configuration_and_control::config_t valve_configuration_and_control;
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator);
} }
} config_t; } config_t;
@@ -946,7 +974,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
namespace mounted_on_off_control { namespace mounted_on_off_control {
typedef struct config : on_off_with_lighting_config { typedef struct config : on_off_with_lighting_config {
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator);
} }
} config_t; } config_t;
@@ -1071,7 +1100,6 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
} /* chime */ } /* chime */
namespace thermostat_controller { namespace thermostat_controller {
using config_t = app_client_config; using config_t = app_client_config;
@@ -1094,7 +1122,8 @@ namespace closure {
typedef struct config : app_base_config { typedef struct config : app_base_config {
cluster::closure_control::config_t closure_control; cluster::closure_control::config_t closure_control;
config() { config()
{
identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator);
} }
} config_t; } config_t;
@@ -107,7 +107,6 @@ event_t *create_reachable_changed(cluster_t *cluster);
} // namespace event } // namespace event
} // namespace bridged_device_basic_information } // namespace bridged_device_basic_information
namespace power_source { namespace power_source {
namespace event { namespace event {
event_t *create_wired_fault_change(cluster_t *cluster); event_t *create_wired_fault_change(cluster_t *cluster);
@@ -1064,7 +1064,6 @@ esp_err_t add(cluster_t *cluster)
} /* feature */ } /* feature */
} /* ethernet_network_diagnostics */ } /* ethernet_network_diagnostics */
namespace air_quality { namespace air_quality {
namespace feature { namespace feature {
@@ -1835,7 +1834,6 @@ esp_err_t add(cluster_t *cluster, config_t *config)
} /* feature */ } /* feature */
} /* mode_select */ } /* mode_select */
namespace pressure_measurement { namespace pressure_measurement {
namespace feature { namespace feature {
@@ -2400,7 +2398,6 @@ esp_err_t add(cluster_t *cluster)
return ESP_ERR_NOT_SUPPORTED; return ESP_ERR_NOT_SUPPORTED;
} }
return ESP_OK; return ESP_OK;
} }
} /* polyphase_power */ } /* polyphase_power */
@@ -2426,7 +2423,6 @@ esp_err_t add(cluster_t *cluster)
return ESP_ERR_NOT_SUPPORTED; return ESP_ERR_NOT_SUPPORTED;
} }
return ESP_OK; return ESP_OK;
} }
} /* harmonics */ } /* harmonics */
@@ -2452,7 +2448,6 @@ esp_err_t add(cluster_t *cluster)
return ESP_ERR_NOT_SUPPORTED; return ESP_ERR_NOT_SUPPORTED;
} }
return ESP_OK; return ESP_OK;
} }
} /* power_quality */ } /* power_quality */
@@ -3208,7 +3203,6 @@ esp_err_t add(cluster_t *cluster)
event::create_power_adjust_start(cluster); event::create_power_adjust_start(cluster);
event::create_power_adjust_end(cluster); event::create_power_adjust_end(cluster);
return ESP_OK; return ESP_OK;
} }
} /* power_adjustment */ } /* power_adjustment */
@@ -3260,7 +3254,6 @@ esp_err_t add(cluster_t *cluster)
return ESP_ERR_NOT_SUPPORTED; return ESP_ERR_NOT_SUPPORTED;
} }
return ESP_OK; return ESP_OK;
} }
} /* state_forecast_reporting */ } /* state_forecast_reporting */
@@ -3494,7 +3487,6 @@ esp_err_t add(cluster_t *cluster)
return ESP_OK; return ESP_OK;
} }
} /* tank_percent */ } /* tank_percent */
} /* feature */ } /* feature */
@@ -4075,7 +4067,6 @@ esp_err_t add(cluster_t *cluster)
attribute::create_soft_recording_privacy_mode_enabled(cluster, 0); attribute::create_soft_recording_privacy_mode_enabled(cluster, 0);
attribute::create_soft_livestream_privacy_mode_enabled(cluster, 0); attribute::create_soft_livestream_privacy_mode_enabled(cluster, 0);
return ESP_OK; return ESP_OK;
} }
@@ -4099,7 +4090,6 @@ esp_err_t add(cluster_t *cluster)
attribute::create_speaker_max_level(cluster, 0); attribute::create_speaker_max_level(cluster, 0);
attribute::create_speaker_min_level(cluster, 0); attribute::create_speaker_min_level(cluster, 0);
return ESP_OK; return ESP_OK;
} }
@@ -4169,7 +4159,6 @@ esp_err_t add(cluster_t *cluster)
attribute::create_local_video_recording_enabled(cluster, 0); attribute::create_local_video_recording_enabled(cluster, 0);
attribute::create_local_snapshot_recording_enabled(cluster, 0); attribute::create_local_snapshot_recording_enabled(cluster, 0);
return ESP_OK; return ESP_OK;
} }
@@ -4220,7 +4209,6 @@ namespace webrtc_transport_provider {
namespace webrtc_transport_requestor { namespace webrtc_transport_requestor {
}/*webrtc_transport_requestor*/ }/*webrtc_transport_requestor*/
namespace closure_control { namespace closure_control {
namespace feature { namespace feature {
namespace positioning { namespace positioning {
@@ -493,7 +493,7 @@ namespace heating {
typedef struct config { typedef struct config {
int16_t occupied_heating_setpoint; int16_t occupied_heating_setpoint;
config (): occupied_heating_setpoint(2000) {} config(): occupied_heating_setpoint(2000) {}
} config_t; } config_t;
uint32_t get_id(); uint32_t get_id();
@@ -505,7 +505,7 @@ namespace cooling {
typedef struct config { typedef struct config {
int16_t occupied_cooling_setpoint; int16_t occupied_cooling_setpoint;
config (): occupied_cooling_setpoint(2600) {} config(): occupied_cooling_setpoint(2600) {}
} config_t; } config_t;
uint32_t get_id(); uint32_t get_id();
@@ -524,7 +524,7 @@ typedef struct config {
nullable<uint8_t> unoccupied_setback_min; nullable<uint8_t> unoccupied_setback_min;
nullable<uint8_t> unoccupied_setback_max; nullable<uint8_t> unoccupied_setback_max;
config (): occupancy(1), unoccupied_cooling_setpoint(2600), unoccupied_heating_setpoint(2000), unoccupied_setback(), unoccupied_setback_min(), unoccupied_setback_max() {} config(): occupancy(1), unoccupied_cooling_setpoint(2600), unoccupied_heating_setpoint(2000), unoccupied_setback(), unoccupied_setback_min(), unoccupied_setback_max() {}
} config_t; } config_t;
uint32_t get_id(); uint32_t get_id();
@@ -538,7 +538,7 @@ typedef struct config {
nullable<uint8_t> occupied_setback_min; nullable<uint8_t> occupied_setback_min;
nullable<uint8_t> occupied_setback_max; nullable<uint8_t> occupied_setback_max;
config (): occupied_setback(), occupied_setback_min(), occupied_setback_max() {} config(): occupied_setback(), occupied_setback_min(), occupied_setback_max() {}
} config_t; } config_t;
uint32_t get_id(); uint32_t get_id();
@@ -553,7 +553,7 @@ namespace auto_mode {
typedef struct config { typedef struct config {
int8_t min_setpoint_dead_band; int8_t min_setpoint_dead_band;
config (): min_setpoint_dead_band(2) {} config(): min_setpoint_dead_band(2) {}
} config_t; } config_t;
uint32_t get_id(); uint32_t get_id();
@@ -565,7 +565,7 @@ namespace local_temperature_not_exposed {
typedef struct config { typedef struct config {
int16_t local_temperature_calibration; int16_t local_temperature_calibration;
config (): local_temperature_calibration(0) {} config(): local_temperature_calibration(0) {}
} config_t; } config_t;
uint32_t get_id(); uint32_t get_id();
@@ -580,7 +580,7 @@ typedef struct config {
nullable<uint8_t> number_of_schedule_transition_per_day; nullable<uint8_t> number_of_schedule_transition_per_day;
uint8_t active_schedule_handle[k_max_active_schedule_handle]; uint8_t active_schedule_handle[k_max_active_schedule_handle];
config (): number_of_schedules(0), number_of_schedule_transitions(0), number_of_schedule_transition_per_day() {} config(): number_of_schedules(0), number_of_schedule_transitions(0), number_of_schedule_transition_per_day() {}
} config_t; } config_t;
uint32_t get_id(); uint32_t get_id();
@@ -1158,7 +1158,6 @@ esp_err_t add(cluster_t *cluster, config_t *config);
} /* feature */ } /* feature */
} /* boolean_state_configuration */ } /* boolean_state_configuration */
namespace power_topology { namespace power_topology {
namespace feature { namespace feature {
@@ -1370,7 +1369,7 @@ uint32_t get_id();
esp_err_t add(cluster_t *cluster); esp_err_t add(cluster_t *cluster);
} /* aliro_provisioning */ } /* aliro_provisioning */
namespace aliro_bleuwb{ namespace aliro_bleuwb {
uint32_t get_id(); uint32_t get_id();
esp_err_t add(cluster_t *cluster); esp_err_t add(cluster_t *cluster);
@@ -1891,7 +1890,6 @@ namespace webrtc_transport_provider {
namespace webrtc_transport_requestor { namespace webrtc_transport_requestor {
}/*webrtc_transport_requestor*/ }/*webrtc_transport_requestor*/
namespace closure_control { namespace closure_control {
namespace feature { namespace feature {
@@ -424,4 +424,3 @@ constexpr uint16_t cluster_revision = 1;
} // namespace soil_measurement } // namespace soil_measurement
} // namespace cluster } // namespace cluster
} // namespace esp_matter } // namespace esp_matter
@@ -108,34 +108,34 @@ esp_err_t destroy(cluster_t *cluster, attribute_t *attribute);
namespace command { namespace command {
/** Destroy command /** Destroy command
* *
* This function destroys a command that was created and added to a cluster. * This function destroys a command that was created and added to a cluster.
* It removes the command from the cluster's command list. * It removes the command from the cluster's command list.
* *
* @param[in] cluster Cluster handle. * @param[in] cluster Cluster handle.
* @param[in] command Command handle. * @param[in] command Command handle.
* *
* @return ESP_OK on success. * @return ESP_OK on success.
* @return error in case of failure. * @return error in case of failure.
*/ */
esp_err_t destroy(cluster_t *cluster, command_t *command); esp_err_t destroy(cluster_t *cluster, command_t *command);
} // namespace command } // namespace command
namespace event { namespace event {
/** Destroy event /** Destroy event
* *
* This function destroys an event that was created and added to a cluster. * This function destroys an event that was created and added to a cluster.
* It removes the event from the cluster's event list. * It removes the event from the cluster's event list.
* *
* @param[in] cluster Cluster handle. * @param[in] cluster Cluster handle.
* @param[in] event Event handle. * @param[in] event Event handle.
* *
* @return ESP_OK on success. * @return ESP_OK on success.
* @return error in case of failure. * @return error in case of failure.
*/ */
esp_err_t destroy(cluster_t *cluster, event_t *event); esp_err_t destroy(cluster_t *cluster, event_t *event);
} // namespace event } // namespace event
@@ -45,10 +45,10 @@ static void get_attribute_key(uint16_t endpoint_id, uint32_t cluster_id, uint32_
attribute_key[14] = 0; attribute_key[14] = 0;
} }
static esp_err_t nvs_store_val(const char *nvs_namespace, const char *attribute_key, const esp_matter_attr_val_t & val); static esp_err_t nvs_store_val(const char *nvs_namespace, const char *attribute_key, const esp_matter_attr_val_t &val);
static esp_err_t nvs_erase_val(const char *nvs_namespace, const char *attribute_key); static esp_err_t nvs_erase_val(const char *nvs_namespace, const char *attribute_key);
static esp_err_t nvs_get_val(const char *nvs_namespace, const char *attribute_key, esp_matter_attr_val_t & val) static esp_err_t nvs_get_val(const char *nvs_namespace, const char *attribute_key, esp_matter_attr_val_t &val)
{ {
nvs_handle_t handle; nvs_handle_t handle;
esp_err_t err = nvs_open_from_partition(ESP_MATTER_NVS_PART_NAME, nvs_namespace, NVS_READONLY, &handle); esp_err_t err = nvs_open_from_partition(ESP_MATTER_NVS_PART_NAME, nvs_namespace, NVS_READONLY, &handle);
@@ -85,37 +85,31 @@ static esp_err_t nvs_get_val(const char *nvs_namespace, const char *attribute_ke
// This switch case handles primitive data types // This switch case handles primitive data types
// if value is stored as primitive data type return it, else check if its stored as blob // if value is stored as primitive data type return it, else check if its stored as blob
// and convert it to primitive data type // and convert it to primitive data type
switch (val.type) switch (val.type) {
{ case ESP_MATTER_VAL_TYPE_BOOLEAN: {
case ESP_MATTER_VAL_TYPE_BOOLEAN:
{
uint8_t b_val; uint8_t b_val;
if ((err = nvs_get_u8(handle, attribute_key, &b_val)) == ESP_OK) if ((err = nvs_get_u8(handle, attribute_key, &b_val)) == ESP_OK) {
{
val.val.b = (b_val != 0); val.val.b = (b_val != 0);
} }
break; break;
} }
case ESP_MATTER_VAL_TYPE_INTEGER: case ESP_MATTER_VAL_TYPE_INTEGER:
case ESP_MATTER_VAL_TYPE_NULLABLE_INTEGER: case ESP_MATTER_VAL_TYPE_NULLABLE_INTEGER: {
{
err = nvs_get_i32(handle, attribute_key, reinterpret_cast<int32_t *>(&val.val.i)); err = nvs_get_i32(handle, attribute_key, reinterpret_cast<int32_t *>(&val.val.i));
break; break;
} }
// no nvs api to read float, since it is stored as blob, reading as blob // no nvs api to read float, since it is stored as blob, reading as blob
case ESP_MATTER_VAL_TYPE_FLOAT: case ESP_MATTER_VAL_TYPE_FLOAT:
case ESP_MATTER_VAL_TYPE_NULLABLE_FLOAT: case ESP_MATTER_VAL_TYPE_NULLABLE_FLOAT: {
{
size_t length = sizeof(val.val.f); size_t length = sizeof(val.val.f);
err = nvs_get_blob(handle, attribute_key, &val.val.f, &length); err = nvs_get_blob(handle, attribute_key, &val.val.f, &length);
break; break;
} }
case ESP_MATTER_VAL_TYPE_INT8: case ESP_MATTER_VAL_TYPE_INT8:
case ESP_MATTER_VAL_TYPE_NULLABLE_INT8: case ESP_MATTER_VAL_TYPE_NULLABLE_INT8: {
{
err = nvs_get_i8(handle, attribute_key, &val.val.i8); err = nvs_get_i8(handle, attribute_key, &val.val.i8);
break; break;
} }
@@ -125,15 +119,13 @@ static esp_err_t nvs_get_val(const char *nvs_namespace, const char *attribute_ke
case ESP_MATTER_VAL_TYPE_BITMAP8: case ESP_MATTER_VAL_TYPE_BITMAP8:
case ESP_MATTER_VAL_TYPE_NULLABLE_UINT8: case ESP_MATTER_VAL_TYPE_NULLABLE_UINT8:
case ESP_MATTER_VAL_TYPE_NULLABLE_ENUM8: case ESP_MATTER_VAL_TYPE_NULLABLE_ENUM8:
case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP8: case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP8: {
{
err = nvs_get_u8(handle, attribute_key, &val.val.u8); err = nvs_get_u8(handle, attribute_key, &val.val.u8);
break; break;
} }
case ESP_MATTER_VAL_TYPE_INT16: case ESP_MATTER_VAL_TYPE_INT16:
case ESP_MATTER_VAL_TYPE_NULLABLE_INT16: case ESP_MATTER_VAL_TYPE_NULLABLE_INT16: {
{
err = nvs_get_i16(handle, attribute_key, &val.val.i16); err = nvs_get_i16(handle, attribute_key, &val.val.i16);
break; break;
} }
@@ -141,15 +133,13 @@ static esp_err_t nvs_get_val(const char *nvs_namespace, const char *attribute_ke
case ESP_MATTER_VAL_TYPE_UINT16: case ESP_MATTER_VAL_TYPE_UINT16:
case ESP_MATTER_VAL_TYPE_BITMAP16: case ESP_MATTER_VAL_TYPE_BITMAP16:
case ESP_MATTER_VAL_TYPE_NULLABLE_UINT16: case ESP_MATTER_VAL_TYPE_NULLABLE_UINT16:
case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP16: case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP16: {
{
err = nvs_get_u16(handle, attribute_key, &val.val.u16); err = nvs_get_u16(handle, attribute_key, &val.val.u16);
break; break;
} }
case ESP_MATTER_VAL_TYPE_INT32: case ESP_MATTER_VAL_TYPE_INT32:
case ESP_MATTER_VAL_TYPE_NULLABLE_INT32: case ESP_MATTER_VAL_TYPE_NULLABLE_INT32: {
{
err = nvs_get_i32(handle, attribute_key, &val.val.i32); err = nvs_get_i32(handle, attribute_key, &val.val.i32);
break; break;
} }
@@ -157,28 +147,24 @@ static esp_err_t nvs_get_val(const char *nvs_namespace, const char *attribute_ke
case ESP_MATTER_VAL_TYPE_UINT32: case ESP_MATTER_VAL_TYPE_UINT32:
case ESP_MATTER_VAL_TYPE_BITMAP32: case ESP_MATTER_VAL_TYPE_BITMAP32:
case ESP_MATTER_VAL_TYPE_NULLABLE_UINT32: case ESP_MATTER_VAL_TYPE_NULLABLE_UINT32:
case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP32: case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP32: {
{
err = nvs_get_u32(handle, attribute_key, &val.val.u32); err = nvs_get_u32(handle, attribute_key, &val.val.u32);
break; break;
} }
case ESP_MATTER_VAL_TYPE_INT64: case ESP_MATTER_VAL_TYPE_INT64:
case ESP_MATTER_VAL_TYPE_NULLABLE_INT64: case ESP_MATTER_VAL_TYPE_NULLABLE_INT64: {
{
err = nvs_get_i64(handle, attribute_key, &val.val.i64); err = nvs_get_i64(handle, attribute_key, &val.val.i64);
break; break;
} }
case ESP_MATTER_VAL_TYPE_UINT64: case ESP_MATTER_VAL_TYPE_UINT64:
case ESP_MATTER_VAL_TYPE_NULLABLE_UINT64: case ESP_MATTER_VAL_TYPE_NULLABLE_UINT64: {
{
err = nvs_get_u64(handle, attribute_key, &val.val.u64); err = nvs_get_u64(handle, attribute_key, &val.val.u64);
break; break;
} }
default: default: {
{
// handle the case where the type is not recognized // handle the case where the type is not recognized
nvs_close(handle); nvs_close(handle);
ESP_LOGE(TAG, "Invalid attribute type: %u", val.type); ESP_LOGE(TAG, "Invalid attribute type: %u", val.type);
@@ -213,7 +199,7 @@ static esp_err_t nvs_get_val(const char *nvs_namespace, const char *attribute_ke
return err; return err;
} }
static esp_err_t nvs_store_val(const char *nvs_namespace, const char *attribute_key, const esp_matter_attr_val_t & val) static esp_err_t nvs_store_val(const char *nvs_namespace, const char *attribute_key, const esp_matter_attr_val_t &val)
{ {
nvs_handle_t handle; nvs_handle_t handle;
esp_err_t err = nvs_open_from_partition(ESP_MATTER_NVS_PART_NAME, nvs_namespace, NVS_READWRITE, &handle); esp_err_t err = nvs_open_from_partition(ESP_MATTER_NVS_PART_NAME, nvs_namespace, NVS_READWRITE, &handle);
@@ -236,32 +222,27 @@ static esp_err_t nvs_store_val(const char *nvs_namespace, const char *attribute_
} else { } else {
// This switch case handles primitive data types // This switch case handles primitive data types
// always store values as primitive data type // always store values as primitive data type
switch (val.type) switch (val.type) {
{ case ESP_MATTER_VAL_TYPE_BOOLEAN: {
case ESP_MATTER_VAL_TYPE_BOOLEAN:
{
err = nvs_set_u8(handle, attribute_key, val.val.b != 0); err = nvs_set_u8(handle, attribute_key, val.val.b != 0);
break; break;
} }
case ESP_MATTER_VAL_TYPE_INTEGER: case ESP_MATTER_VAL_TYPE_INTEGER:
case ESP_MATTER_VAL_TYPE_NULLABLE_INTEGER: case ESP_MATTER_VAL_TYPE_NULLABLE_INTEGER: {
{
err = nvs_set_i32(handle, attribute_key, val.val.i); err = nvs_set_i32(handle, attribute_key, val.val.i);
break; break;
} }
// no nvs api to store float, storing as blob // no nvs api to store float, storing as blob
case ESP_MATTER_VAL_TYPE_FLOAT: case ESP_MATTER_VAL_TYPE_FLOAT:
case ESP_MATTER_VAL_TYPE_NULLABLE_FLOAT: case ESP_MATTER_VAL_TYPE_NULLABLE_FLOAT: {
{
err = nvs_set_blob(handle, attribute_key, &val.val.f, sizeof(val.val.f)); err = nvs_set_blob(handle, attribute_key, &val.val.f, sizeof(val.val.f));
break; break;
} }
case ESP_MATTER_VAL_TYPE_INT8: case ESP_MATTER_VAL_TYPE_INT8:
case ESP_MATTER_VAL_TYPE_NULLABLE_INT8: case ESP_MATTER_VAL_TYPE_NULLABLE_INT8: {
{
err = nvs_set_i8(handle, attribute_key, val.val.i8); err = nvs_set_i8(handle, attribute_key, val.val.i8);
break; break;
} }
@@ -271,15 +252,13 @@ static esp_err_t nvs_store_val(const char *nvs_namespace, const char *attribute_
case ESP_MATTER_VAL_TYPE_BITMAP8: case ESP_MATTER_VAL_TYPE_BITMAP8:
case ESP_MATTER_VAL_TYPE_NULLABLE_UINT8: case ESP_MATTER_VAL_TYPE_NULLABLE_UINT8:
case ESP_MATTER_VAL_TYPE_NULLABLE_ENUM8: case ESP_MATTER_VAL_TYPE_NULLABLE_ENUM8:
case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP8: case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP8: {
{
err = nvs_set_u8(handle, attribute_key, val.val.u8); err = nvs_set_u8(handle, attribute_key, val.val.u8);
break; break;
} }
case ESP_MATTER_VAL_TYPE_INT16: case ESP_MATTER_VAL_TYPE_INT16:
case ESP_MATTER_VAL_TYPE_NULLABLE_INT16: case ESP_MATTER_VAL_TYPE_NULLABLE_INT16: {
{
err = nvs_set_i16(handle, attribute_key, val.val.i16); err = nvs_set_i16(handle, attribute_key, val.val.i16);
break; break;
} }
@@ -287,15 +266,13 @@ static esp_err_t nvs_store_val(const char *nvs_namespace, const char *attribute_
case ESP_MATTER_VAL_TYPE_UINT16: case ESP_MATTER_VAL_TYPE_UINT16:
case ESP_MATTER_VAL_TYPE_BITMAP16: case ESP_MATTER_VAL_TYPE_BITMAP16:
case ESP_MATTER_VAL_TYPE_NULLABLE_UINT16: case ESP_MATTER_VAL_TYPE_NULLABLE_UINT16:
case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP16: case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP16: {
{
err = nvs_set_u16(handle, attribute_key, val.val.u16); err = nvs_set_u16(handle, attribute_key, val.val.u16);
break; break;
} }
case ESP_MATTER_VAL_TYPE_INT32: case ESP_MATTER_VAL_TYPE_INT32:
case ESP_MATTER_VAL_TYPE_NULLABLE_INT32: case ESP_MATTER_VAL_TYPE_NULLABLE_INT32: {
{
err = nvs_set_i32(handle, attribute_key, val.val.i32); err = nvs_set_i32(handle, attribute_key, val.val.i32);
break; break;
} }
@@ -303,28 +280,24 @@ static esp_err_t nvs_store_val(const char *nvs_namespace, const char *attribute_
case ESP_MATTER_VAL_TYPE_UINT32: case ESP_MATTER_VAL_TYPE_UINT32:
case ESP_MATTER_VAL_TYPE_BITMAP32: case ESP_MATTER_VAL_TYPE_BITMAP32:
case ESP_MATTER_VAL_TYPE_NULLABLE_UINT32: case ESP_MATTER_VAL_TYPE_NULLABLE_UINT32:
case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP32: case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP32: {
{
err = nvs_set_u32(handle, attribute_key, val.val.u32); err = nvs_set_u32(handle, attribute_key, val.val.u32);
break; break;
} }
case ESP_MATTER_VAL_TYPE_INT64: case ESP_MATTER_VAL_TYPE_INT64:
case ESP_MATTER_VAL_TYPE_NULLABLE_INT64: case ESP_MATTER_VAL_TYPE_NULLABLE_INT64: {
{
err = nvs_set_i64(handle, attribute_key, val.val.i64); err = nvs_set_i64(handle, attribute_key, val.val.i64);
break; break;
} }
case ESP_MATTER_VAL_TYPE_UINT64: case ESP_MATTER_VAL_TYPE_UINT64:
case ESP_MATTER_VAL_TYPE_NULLABLE_UINT64: case ESP_MATTER_VAL_TYPE_NULLABLE_UINT64: {
{
err = nvs_set_u64(handle, attribute_key, val.val.u64); err = nvs_set_u64(handle, attribute_key, val.val.u64);
break; break;
} }
default: default: {
{
// handle the case where the type is not recognized // handle the case where the type is not recognized
err = ESP_ERR_INVALID_ARG; err = ESP_ERR_INVALID_ARG;
ESP_LOGE(TAG, "Invalid attribute type: %u", val.type); ESP_LOGE(TAG, "Invalid attribute type: %u", val.type);
@@ -350,7 +323,7 @@ static esp_err_t nvs_erase_val(const char *nvs_namespace, const char *attribute_
return err; return err;
} }
esp_err_t get_val_from_nvs(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t & val) esp_err_t get_val_from_nvs(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t &val)
{ {
/* Get attribute key */ /* Get attribute key */
char attribute_key[16] = {0}; char attribute_key[16] = {0};
@@ -381,7 +354,7 @@ esp_err_t get_val_from_nvs(uint16_t endpoint_id, uint32_t cluster_id, uint32_t a
return err; return err;
} }
esp_err_t store_val_in_nvs(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, const esp_matter_attr_val_t & val) esp_err_t store_val_in_nvs(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, const esp_matter_attr_val_t &val)
{ {
/* Get attribute key */ /* Get attribute key */
char attribute_key[16] = {0}; char attribute_key[16] = {0};
@@ -31,7 +31,7 @@ namespace attribute {
* *
* @return ESP_OK on success, appropriate error code otherwise * @return ESP_OK on success, appropriate error code otherwise
*/ */
esp_err_t get_val_from_nvs(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t & val); esp_err_t get_val_from_nvs(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t &val);
/** /**
* @brief Stores the attribute value in NVS, it generates the key based on endpoint, cluster, and attribute id. * @brief Stores the attribute value in NVS, it generates the key based on endpoint, cluster, and attribute id.
@@ -42,7 +42,7 @@ esp_err_t get_val_from_nvs(uint16_t endpoint_id, uint32_t cluster_id, uint32_t a
* *
* @return ESP_OK on success, appropriate error code otherwise * @return ESP_OK on success, appropriate error code otherwise
*/ */
esp_err_t store_val_in_nvs(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, const esp_matter_attr_val_t & val); esp_err_t store_val_in_nvs(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, const esp_matter_attr_val_t &val);
/** /**
* @brief Erases the attribute value in NVS, it generates the key based on endpoint, cluster, and attribute id. * @brief Erases the attribute value in NVS, it generates the key based on endpoint, cluster, and attribute id.
@@ -54,23 +54,35 @@ public:
* Sets the Enabled attribute. Note, this also handles writing the new value into non-volatile storage. * Sets the Enabled attribute. Note, this also handles writing the new value into non-volatile storage.
* @param Enabled The value to which the Enabled is to be set. * @param Enabled The value to which the Enabled is to be set.
*/ */
Protocols::InteractionModel::Status SetEnabled(bool enabled) { return mCluster.Cluster().SetEnabled(enabled); } Protocols::InteractionModel::Status SetEnabled(bool enabled)
{
return mCluster.Cluster().SetEnabled(enabled);
}
// Attribute Getters // Attribute Getters
/** /**
* @return The Current SelectedChime. * @return The Current SelectedChime.
*/ */
uint8_t GetSelectedChime() const { return mCluster.Cluster().GetSelectedChime(); } uint8_t GetSelectedChime() const
{
return mCluster.Cluster().GetSelectedChime();
}
/** /**
* @return The Enabled attribute.. * @return The Enabled attribute..
*/ */
bool GetEnabled() const { return mCluster.Cluster().GetEnabled(); } bool GetEnabled() const
{
return mCluster.Cluster().GetEnabled();
}
/** /**
* @return The endpoint ID. * @return The endpoint ID.
*/ */
EndpointId GetEndpointId() { return mCluster.Cluster().GetPaths()[0].mEndpointId; } EndpointId GetEndpointId()
{
return mCluster.Cluster().GetPaths()[0].mEndpointId;
}
// Cluster constants from the spec // Cluster constants from the spec
static constexpr uint8_t kMaxChimeSoundNameSize = ChimeCluster::kMaxChimeSoundNameSize; static constexpr uint8_t kMaxChimeSoundNameSize = ChimeCluster::kMaxChimeSoundNameSize;
@@ -35,28 +35,25 @@ namespace {
* emberAfSetDynamicEndpointWithEpUniqueId() by calling emberAfEndpointEnableDisable(), which calls initializeEndpoint(). The tag * emberAfSetDynamicEndpointWithEpUniqueId() by calling emberAfEndpointEnableDisable(), which calls initializeEndpoint(). The tag
* list is a fixed attribute, but to maintain backwards compatibility we get that information within the functions here. * list is a fixed attribute, but to maintain backwards compatibility we get that information within the functions here.
*/ */
class ESPMatterDescriptorCluster : public DescriptorCluster class ESPMatterDescriptorCluster : public DescriptorCluster {
{
public: public:
ESPMatterDescriptorCluster(EndpointId endpointId, DescriptorCluster::OptionalAttributesSet optionalAttributeSet) : ESPMatterDescriptorCluster(EndpointId endpointId, DescriptorCluster::OptionalAttributesSet optionalAttributeSet) :
DescriptorCluster(endpointId, optionalAttributeSet, Span<const SemanticTag>()) DescriptorCluster(endpointId, optionalAttributeSet, Span<const SemanticTag>())
{} {}
CHIP_ERROR Attributes(const ConcreteClusterPath & path, ReadOnlyBufferBuilder<DataModel::AttributeEntry> & builder) override CHIP_ERROR Attributes(const ConcreteClusterPath &path, ReadOnlyBufferBuilder<DataModel::AttributeEntry> &builder) override
{
if (!mFetchedSemanticTags)
{ {
if (!mFetchedSemanticTags) {
ReturnErrorOnFailure(GetSemanticTag(path.mEndpointId, mSemanticTags)); ReturnErrorOnFailure(GetSemanticTag(path.mEndpointId, mSemanticTags));
mFetchedSemanticTags = true; mFetchedSemanticTags = true;
} }
return DescriptorCluster::Attributes(path, builder); return DescriptorCluster::Attributes(path, builder);
} }
DataModel::ActionReturnStatus ReadAttribute(const DataModel::ReadAttributeRequest & request, DataModel::ActionReturnStatus ReadAttribute(const DataModel::ReadAttributeRequest &request,
AttributeValueEncoder & encoder) override AttributeValueEncoder &encoder) override
{
if (!mFetchedSemanticTags)
{ {
if (!mFetchedSemanticTags) {
ReturnErrorOnFailure(GetSemanticTag(request.path.mEndpointId, mSemanticTags)); ReturnErrorOnFailure(GetSemanticTag(request.path.mEndpointId, mSemanticTags));
mFetchedSemanticTags = true; mFetchedSemanticTags = true;
} }
@@ -23,7 +23,7 @@ namespace app {
namespace Clusters { namespace Clusters {
namespace DeviceEnergyManagement { namespace DeviceEnergyManagement {
Instance::Instance(EndpointId aEndpointId, Delegate & aDelegate, BitMask<Feature> aFeature) : Instance::Instance(EndpointId aEndpointId, Delegate &aDelegate, BitMask<Feature> aFeature) :
mCluster(DeviceEnergyManagementCluster::Config(aEndpointId, aFeature, aDelegate)) mCluster(DeviceEnergyManagementCluster::Config(aEndpointId, aFeature, aDelegate))
{} {}
@@ -31,8 +31,7 @@ CHIP_ERROR Instance::Init()
{ {
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(mCluster.Registration()); CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(mCluster.Registration());
if (err != CHIP_NO_ERROR) if (err != CHIP_NO_ERROR) {
{
ChipLogError(AppServer, "Failed to register cluster %u/" ChipLogFormatMEI ": %" CHIP_ERROR_FORMAT, ChipLogError(AppServer, "Failed to register cluster %u/" ChipLogFormatMEI ": %" CHIP_ERROR_FORMAT,
mCluster.Cluster().GetPaths()[0].mEndpointId, ChipLogValueMEI(DeviceEnergyManagement::Id), err.Format()); mCluster.Cluster().GetPaths()[0].mEndpointId, ChipLogValueMEI(DeviceEnergyManagement::Id), err.Format());
} }
@@ -43,8 +42,7 @@ void Instance::Shutdown()
{ {
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&mCluster.Cluster()); CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&mCluster.Cluster());
if (err != CHIP_NO_ERROR) if (err != CHIP_NO_ERROR) {
{
ChipLogError(AppServer, "Failed to unregister cluster %u/" ChipLogFormatMEI ": %" CHIP_ERROR_FORMAT, ChipLogError(AppServer, "Failed to unregister cluster %u/" ChipLogFormatMEI ": %" CHIP_ERROR_FORMAT,
mCluster.Cluster().GetPaths()[0].mEndpointId, ChipLogValueMEI(DeviceEnergyManagement::Id), err.Format()); mCluster.Cluster().GetPaths()[0].mEndpointId, ChipLogValueMEI(DeviceEnergyManagement::Id), err.Format());
} }
@@ -19,10 +19,9 @@
namespace chip::app::Clusters::DeviceEnergyManagement { namespace chip::app::Clusters::DeviceEnergyManagement {
class Instance class Instance {
{
public: public:
Instance(EndpointId aEndpointId, Delegate & aDelegate, BitMask<Feature> aFeature); Instance(EndpointId aEndpointId, Delegate &aDelegate, BitMask<Feature> aFeature);
CHIP_ERROR Init(); CHIP_ERROR Init();
void Shutdown(); void Shutdown();
@@ -18,15 +18,15 @@
namespace chip::app::Clusters::ElectricalEnergyMeasurement { namespace chip::app::Clusters::ElectricalEnergyMeasurement {
bool NotifyCumulativeEnergyMeasured(EndpointId endpointId, const Optional<Structs::EnergyMeasurementStruct::Type> & energyImported, bool NotifyCumulativeEnergyMeasured(EndpointId endpointId, const Optional<Structs::EnergyMeasurementStruct::Type> &energyImported,
const Optional<Structs::EnergyMeasurementStruct::Type> & energyExported); const Optional<Structs::EnergyMeasurementStruct::Type> &energyExported);
bool NotifyPeriodicEnergyMeasured(EndpointId endpointId, const Optional<Structs::EnergyMeasurementStruct::Type> & energyImported, bool NotifyPeriodicEnergyMeasured(EndpointId endpointId, const Optional<Structs::EnergyMeasurementStruct::Type> &energyImported,
const Optional<Structs::EnergyMeasurementStruct::Type> & energyExported); const Optional<Structs::EnergyMeasurementStruct::Type> &energyExported);
CHIP_ERROR SetMeasurementAccuracy(EndpointId endpointId, const Structs::MeasurementAccuracyStruct::Type & accuracy); CHIP_ERROR SetMeasurementAccuracy(EndpointId endpointId, const Structs::MeasurementAccuracyStruct::Type &accuracy);
CHIP_ERROR SetCumulativeReset(EndpointId endpointId, const Optional<Structs::CumulativeEnergyResetStruct::Type> & cumulativeReset); CHIP_ERROR SetCumulativeReset(EndpointId endpointId, const Optional<Structs::CumulativeEnergyResetStruct::Type> &cumulativeReset);
const ElectricalEnergyMeasurement::MeasurementData * MeasurementDataForEndpoint(EndpointId endpointId); const ElectricalEnergyMeasurement::MeasurementData * MeasurementDataForEndpoint(EndpointId endpointId);
@@ -20,8 +20,7 @@
namespace chip::app::Clusters::ElectricalPowerMeasurement { namespace chip::app::Clusters::ElectricalPowerMeasurement {
enum class OptionalAttributes : uint32_t enum class OptionalAttributes : uint32_t {
{
kOptionalAttributeRanges = 0x1, kOptionalAttributeRanges = 0x1,
kOptionalAttributeVoltage = 0x2, kOptionalAttributeVoltage = 0x2,
kOptionalAttributeActiveCurrent = 0x4, kOptionalAttributeActiveCurrent = 0x4,
@@ -37,10 +36,9 @@ enum class OptionalAttributes : uint32_t
kOptionalAttributeNeutralCurrent = 0x1000, kOptionalAttributeNeutralCurrent = 0x1000,
}; };
class Instance class Instance {
{
public: public:
Instance(EndpointId aEndpointId, Delegate & aDelegate, BitMask<Feature> aFeature, Instance(EndpointId aEndpointId, Delegate &aDelegate, BitMask<Feature> aFeature,
BitMask<OptionalAttributes> aOptionalAttributes) : BitMask<OptionalAttributes> aOptionalAttributes) :
mCluster(ElectricalPowerMeasurementCluster::Config{ mCluster(ElectricalPowerMeasurementCluster::Config{
.endpointId = aEndpointId, .endpointId = aEndpointId,
@@ -114,7 +114,7 @@ void ESPMatterGeneralDiagnosticsClusterServerInitCallback(EndpointId endpointId)
IsCommandEnabled(endpointId, GeneralDiagnostics::Commands::PayloadTestRequest::Id, COMMAND_FLAG_ACCEPTED), IsCommandEnabled(endpointId, GeneralDiagnostics::Commands::PayloadTestRequest::Id, COMMAND_FLAG_ACCEPTED),
}; };
gServer.fullConfigurableServer.Create(attrSet,featureFlags, InteractionModelEngine::GetInstance(), functionsConfig); gServer.fullConfigurableServer.Create(attrSet, featureFlags, InteractionModelEngine::GetInstance(), functionsConfig);
err = esp_matter::data_model::provider::get_instance().registry().Register( err = esp_matter::data_model::provider::get_instance().registry().Register(
gServer.fullConfigurableServer.Registration()); gServer.fullConfigurableServer.Registration());
} else { } else {
@@ -19,12 +19,12 @@
namespace chip::app::Clusters::GeneralDiagnostics { namespace chip::app::Clusters::GeneralDiagnostics {
void GlobalNotifyDeviceReboot(GeneralDiagnostics::BootReasonEnum bootReason); void GlobalNotifyDeviceReboot(GeneralDiagnostics::BootReasonEnum bootReason);
void GlobalNotifyHardwareFaultsDetect(const DeviceLayer::GeneralFaults<DeviceLayer::kMaxHardwareFaults> & previous, void GlobalNotifyHardwareFaultsDetect(const DeviceLayer::GeneralFaults<DeviceLayer::kMaxHardwareFaults> &previous,
const DeviceLayer::GeneralFaults<DeviceLayer::kMaxHardwareFaults> & current); const DeviceLayer::GeneralFaults<DeviceLayer::kMaxHardwareFaults> &current);
void GlobalNotifyRadioFaultsDetect(const DeviceLayer::GeneralFaults<DeviceLayer::kMaxRadioFaults> & previous, void GlobalNotifyRadioFaultsDetect(const DeviceLayer::GeneralFaults<DeviceLayer::kMaxRadioFaults> &previous,
const DeviceLayer::GeneralFaults<DeviceLayer::kMaxRadioFaults> & current); const DeviceLayer::GeneralFaults<DeviceLayer::kMaxRadioFaults> &current);
void GlobalNotifyNetworkFaultsDetect(const DeviceLayer::GeneralFaults<DeviceLayer::kMaxNetworkFaults> & previous, void GlobalNotifyNetworkFaultsDetect(const DeviceLayer::GeneralFaults<DeviceLayer::kMaxNetworkFaults> &previous,
const DeviceLayer::GeneralFaults<DeviceLayer::kMaxNetworkFaults> & current); const DeviceLayer::GeneralFaults<DeviceLayer::kMaxNetworkFaults> &current);
} // namespace chip::app::Clusters::GeneralDiagnostics } // namespace chip::app::Clusters::GeneralDiagnostics
@@ -86,7 +86,10 @@ public:
} }
} }
} }
bool IsTriggerEffectEnabled() const override { return true; } bool IsTriggerEffectEnabled() const override
{
return true;
}
}; };
IdentifyLegacyDelegate gLegacyDelegate; IdentifyLegacyDelegate gLegacyDelegate;
@@ -140,7 +143,7 @@ Identify::Identify(EndpointId endpoint, onIdentifyStartCb onIdentifyStart, onIde
, mCurrentEffectIdentifier(effectIdentifier) , mCurrentEffectIdentifier(effectIdentifier)
, mEffectVariant(effectVariant) , mEffectVariant(effectVariant)
, mCluster( , mCluster(
chip::app::Clusters::IdentifyCluster::Config(endpoint, timerDelegate ? *timerDelegate : sDefaultTimerDelegate) chip::app::Clusters::IdentifyCluster::Config(endpoint, timerDelegate ? * timerDelegate : sDefaultTimerDelegate)
.WithIdentifyType(identifyType) .WithIdentifyType(identifyType)
.WithDelegate(&gLegacyDelegate) .WithDelegate(&gLegacyDelegate)
.WithEffectIdentifier(effectIdentifier) .WithEffectIdentifier(effectIdentifier)
@@ -52,8 +52,7 @@ static_assert(kNetworkCommissioningClusterCount > 0, "NetworkCommissioningCluste
LazyRegisteredServerCluster<NetworkCommissioningCluster> gServers[kNetworkCommissioningClusterCount]; LazyRegisteredServerCluster<NetworkCommissioningCluster> gServers[kNetworkCommissioningClusterCount];
class ESPMatterGeneralCommissioningBreadcrumbTracker : public BreadCrumbTracker class ESPMatterGeneralCommissioningBreadcrumbTracker : public BreadCrumbTracker {
{
public: public:
void SetBreadCrumb(uint64_t value) override void SetBreadCrumb(uint64_t value) override
{ {
@@ -67,7 +67,8 @@ void ESPMatterOccupancySensingClusterServerInitCallback(EndpointId endpointId)
// SetHoldTime() later to customize. Initial defaults come from typical values found in real devices on the // SetHoldTime() later to customize. Initial defaults come from typical values found in real devices on the
// market. // market.
constexpr chip::app::Clusters::OccupancySensing::Structs::HoldTimeLimitsStruct::Type kDefaultHoldTimeLimits = { constexpr chip::app::Clusters::OccupancySensing::Structs::HoldTimeLimitsStruct::Type kDefaultHoldTimeLimits = {
.holdTimeMin = 1, .holdTimeMax = 300, .holdTimeDefault = 30}; .holdTimeMin = 1, .holdTimeMax = 300, .holdTimeDefault = 30
};
config.WithHoldTime(kDefaultHoldTimeLimits.holdTimeDefault, kDefaultHoldTimeLimits, gDefaultTimerDelegate); config.WithHoldTime(kDefaultHoldTimeLimits.holdTimeDefault, kDefaultHoldTimeLimits, gDefaultTimerDelegate);
// Show deprecated attributes if enabled in Zap // Show deprecated attributes if enabled in Zap
@@ -34,7 +34,8 @@ void ESPMatterOperationalCredentialsClusterServerInitCallback(EndpointId endpoin
.sessionManager = Server::GetInstance().GetSecureSessionManager(), .sessionManager = Server::GetInstance().GetSecureSessionManager(),
.dnssdServer = app::DnssdServer::Instance(), .dnssdServer = app::DnssdServer::Instance(),
.commissioningWindowManager = .commissioningWindowManager =
Server::GetInstance().GetCommissioningWindowManager()}; Server::GetInstance().GetCommissioningWindowManager()
};
gServer.Create(endpoint, context); gServer.Create(endpoint, context);
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(gServer.Registration()); CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(gServer.Registration());
if (err != CHIP_NO_ERROR) { if (err != CHIP_NO_ERROR) {
@@ -38,8 +38,7 @@ CHIP_ERROR Instance::Init()
void Instance::Shutdown() void Instance::Shutdown()
{ {
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&mCluster.Cluster()); CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&mCluster.Cluster());
if (err != CHIP_NO_ERROR) if (err != CHIP_NO_ERROR) {
{
ChipLogError(AppServer, "Failed to unregister Power Topology cluster: %" CHIP_ERROR_FORMAT, err.Format()); ChipLogError(AppServer, "Failed to unregister Power Topology cluster: %" CHIP_ERROR_FORMAT, err.Format());
} }
} }
@@ -20,17 +20,19 @@
namespace chip::app::Clusters::PowerTopology { namespace chip::app::Clusters::PowerTopology {
class Instance class Instance {
{
public: public:
Instance(EndpointId aEndpointId, Delegate & aDelegate, BitMask<Feature> aFeature) : Instance(EndpointId aEndpointId, Delegate &aDelegate, BitMask<Feature> aFeature) :
mCluster(PowerTopologyCluster::Config{ mCluster(PowerTopologyCluster::Config{
.endpointId = aEndpointId, .endpointId = aEndpointId,
.delegate = aDelegate, .delegate = aDelegate,
.features = aFeature, .features = aFeature,
}) })
{} {}
~Instance() { Shutdown(); } ~Instance()
{
Shutdown();
}
CHIP_ERROR Init(); CHIP_ERROR Init();
void Shutdown(); void Shutdown();
@@ -65,22 +65,30 @@ typename app::NumericAttributeTraits<Type>::WorkingType ConvertDefaultValueToWor
bool IsExactlyOneValuePopulated(const AttributeValuePairType &type) bool IsExactlyOneValuePopulated(const AttributeValuePairType &type)
{ {
int count = 0; int count = 0;
if (type.valueUnsigned8.HasValue()) if (type.valueUnsigned8.HasValue()) {
count++; count++;
if (type.valueSigned8.HasValue()) }
if (type.valueSigned8.HasValue()) {
count++; count++;
if (type.valueUnsigned16.HasValue()) }
if (type.valueUnsigned16.HasValue()) {
count++; count++;
if (type.valueSigned16.HasValue()) }
if (type.valueSigned16.HasValue()) {
count++; count++;
if (type.valueUnsigned32.HasValue()) }
if (type.valueUnsigned32.HasValue()) {
count++; count++;
if (type.valueSigned32.HasValue()) }
if (type.valueSigned32.HasValue()) {
count++; count++;
if (type.valueUnsigned64.HasValue()) }
if (type.valueUnsigned64.HasValue()) {
count++; count++;
if (type.valueSigned64.HasValue()) }
if (type.valueSigned64.HasValue()) {
count++; count++;
}
return count == 1; return count == 1;
} }
@@ -40,9 +40,15 @@ public:
mEndpointId = endpointId; mEndpointId = endpointId;
mEndpointTableSize = endpointTableSize; mEndpointTableSize = endpointTableSize;
} }
EndpointId GetEndpointId() const { return mEndpointId; } EndpointId GetEndpointId() const
{
return mEndpointId;
}
ScenesManagementSceneTable *Take() override { return scenes::GetSceneTableImpl(mEndpointId, mEndpointTableSize); } ScenesManagementSceneTable *Take() override
{
return scenes::GetSceneTableImpl(mEndpointId, mEndpointTableSize);
}
void Release(ScenesManagementSceneTable *) override {} void Release(ScenesManagementSceneTable *) override {}
private: private:
@@ -21,8 +21,7 @@
namespace chip::app::Clusters::ScenesManagement { namespace chip::app::Clusters::ScenesManagement {
class ScenesServer class ScenesServer {
{
public: public:
static constexpr SceneId kGlobalSceneId = 0x00; static constexpr SceneId kGlobalSceneId = 0x00;
static constexpr GroupId kGlobalSceneGroupId = 0x0000; static constexpr GroupId kGlobalSceneGroupId = 0x0000;
@@ -30,7 +29,7 @@ public:
ScenesServer() = default; ScenesServer() = default;
~ScenesServer() = default; ~ScenesServer() = default;
static ScenesServer & Instance(); static ScenesServer &Instance();
// Callbacks // Callbacks
void GroupWillBeRemoved(FabricIndex aFabricIx, EndpointId aEndpointId, GroupId aGroupId); void GroupWillBeRemoved(FabricIndex aFabricIx, EndpointId aEndpointId, GroupId aGroupId);
@@ -123,8 +123,7 @@ void SetDefaultDelegate(Delegate * delegate)
VerifyOrReturn(delegate != nullptr); VerifyOrReturn(delegate != nullptr);
gDelegate = delegate; gDelegate = delegate;
auto timeSynchronization = GetClusterInstance(); auto timeSynchronization = GetClusterInstance();
if (timeSynchronization != nullptr) if (timeSynchronization != nullptr) {
{
timeSynchronization->SetDelegate(gDelegate); timeSynchronization->SetDelegate(gDelegate);
} }
} }
@@ -132,12 +131,10 @@ void SetDefaultDelegate(Delegate * delegate)
Delegate * GetDefaultDelegate() Delegate * GetDefaultDelegate()
{ {
auto timeSynchronization = GetClusterInstance(); auto timeSynchronization = GetClusterInstance();
if (timeSynchronization != nullptr) if (timeSynchronization != nullptr) {
{
return timeSynchronization->GetDelegate(); return timeSynchronization->GetDelegate();
} }
if (gDelegate == nullptr) if (gDelegate == nullptr) {
{
static DefaultTimeSyncDelegate delegate; static DefaultTimeSyncDelegate delegate;
gDelegate = &delegate; gDelegate = &delegate;
} }
@@ -23,7 +23,7 @@ using namespace chip::app::Clusters::UnitLocalization;
namespace chip::app::Clusters::UnitLocalization { namespace chip::app::Clusters::UnitLocalization {
UnitLocalizationServer & UnitLocalizationServer::Instance() UnitLocalizationServer &UnitLocalizationServer::Instance()
{ {
static UnitLocalizationServer mInstance; static UnitLocalizationServer mInstance;
return mInstance; return mInstance;
@@ -18,10 +18,9 @@
namespace chip::app::Clusters::UnitLocalization { namespace chip::app::Clusters::UnitLocalization {
class UnitLocalizationServer : public UnitLocalizationCluster class UnitLocalizationServer : public UnitLocalizationCluster {
{
public: public:
static UnitLocalizationServer & Instance(); static UnitLocalizationServer &Instance();
}; };
} }
@@ -71,8 +71,7 @@ void ESPMatterWiFiNetworkDiagnosticsClusterServerInitCallback(EndpointId endpoin
BitFlags<WiFiNetworkDiagnostics::Feature>(GetFeatureMap(endpointId))); BitFlags<WiFiNetworkDiagnostics::Feature>(GetFeatureMap(endpointId)));
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(gServers[endpointId].Registration()); CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(gServers[endpointId].Registration());
if (err != CHIP_NO_ERROR) if (err != CHIP_NO_ERROR) {
{
ChipLogError(AppServer, "Failed to register WiFiNetworkDiagnostics on endpoint %u - Error: %" CHIP_ERROR_FORMAT, endpointId, ChipLogError(AppServer, "Failed to register WiFiNetworkDiagnostics on endpoint %u - Error: %" CHIP_ERROR_FORMAT, endpointId,
err.Format()); err.Format());
} }
@@ -83,8 +82,7 @@ void ESPMatterWiFiNetworkDiagnosticsClusterServerShutdownCallback(EndpointId end
{ {
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster(), shutdownType); CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) if (err != CHIP_NO_ERROR) {
{
ChipLogError(AppServer, "Failed to unregister WiFiNetworkDiagnostics on endpoint %u - Error: %" CHIP_ERROR_FORMAT, endpointId, ChipLogError(AppServer, "Failed to unregister WiFiNetworkDiagnostics on endpoint %u - Error: %" CHIP_ERROR_FORMAT, endpointId,
err.Format()); err.Format());
} }
@@ -44,7 +44,10 @@ public:
} }
} }
esp_matter_attr_val_t &get_attr_val() { return m_attr_val; } esp_matter_attr_val_t &get_attr_val()
{
return m_attr_val;
}
CHIP_ERROR Decode(chip::TLV::TLVReader &reader); CHIP_ERROR Decode(chip::TLV::TLVReader &reader);
@@ -47,15 +47,17 @@ namespace app {
* Accessor class for AttributeValueDecoder to get the TLV reader. * Accessor class for AttributeValueDecoder to get the TLV reader.
* This leverages the existing friend declaration in the SDK's AttributeValueDecoder. * This leverages the existing friend declaration in the SDK's AttributeValueDecoder.
*/ */
class TestOnlyAttributeValueDecoderAccessor class TestOnlyAttributeValueDecoderAccessor {
{
public: public:
TestOnlyAttributeValueDecoderAccessor(AttributeValueDecoder & decoder) : mDecoder(decoder) {} TestOnlyAttributeValueDecoderAccessor(AttributeValueDecoder &decoder) : mDecoder(decoder) {}
const TLV::TLVReader & GetReader() { return mDecoder.mReader; } const TLV::TLVReader &GetReader()
{
return mDecoder.mReader;
}
private: private:
AttributeValueDecoder & mDecoder; AttributeValueDecoder &mDecoder;
}; };
} // namespace app } // namespace app
@@ -597,7 +599,8 @@ CHIP_ERROR provider::AcceptedCommands(const ConcreteClusterPath &path,
static constexpr AttributeId k_global_attributes_not_in_metadata[] = { static constexpr AttributeId k_global_attributes_not_in_metadata[] = {
Clusters::Globals::Attributes::AttributeList::Id, Clusters::Globals::Attributes::AcceptedCommandList::Id, Clusters::Globals::Attributes::AttributeList::Id, Clusters::Globals::Attributes::AcceptedCommandList::Id,
Clusters::Globals::Attributes::GeneratedCommandList::Id}; Clusters::Globals::Attributes::GeneratedCommandList::Id
};
static constexpr size_t k_global_attributes_count = static constexpr size_t k_global_attributes_count =
sizeof(k_global_attributes_not_in_metadata) / sizeof(k_global_attributes_not_in_metadata[0]); sizeof(k_global_attributes_not_in_metadata) / sizeof(k_global_attributes_not_in_metadata[0]);
@@ -631,8 +634,7 @@ CHIP_ERROR provider::Attributes(const ConcreteClusterPath &path, ReadOnlyBufferB
attribute = attribute::get_next(attribute); attribute = attribute::get_next(attribute);
} }
// Append the three Global attributes // Append the three Global attributes
for (size_t index = 0; index < k_global_attributes_count; ++index) for (size_t index = 0; index < k_global_attributes_count; ++index) {
{
AttributeEntry entry(k_global_attributes_not_in_metadata[index], AttributeEntry entry(k_global_attributes_not_in_metadata[index],
chip::BitFlags<DataModel::AttributeQualityFlags>(), chip::Access::Privilege::kView, chip::BitFlags<DataModel::AttributeQualityFlags>(), chip::Access::Privilege::kView,
std::nullopt); std::nullopt);
@@ -68,7 +68,10 @@ public:
// access to the typed global singleton of this class. // access to the typed global singleton of this class.
static provider &get_instance(); static provider &get_instance();
chip::app::ServerClusterInterfaceRegistry &registry() { return mRegistry; } chip::app::ServerClusterInterfaceRegistry &registry()
{
return mRegistry;
}
/// Generic model implementations /// Generic model implementations
CHIP_ERROR Startup(InteractionModelContext context) override; CHIP_ERROR Startup(InteractionModelContext context) override;
@@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// Cluster init functions that don't have a cluster implementation to define // Cluster init functions that don't have a cluster implementation to define
// them in. // them in.
void MatterBallastConfigurationPluginServerInitCallback() {} void MatterBallastConfigurationPluginServerInitCallback() {}
+1 -2
View File
@@ -45,8 +45,7 @@ namespace DeviceEventType {
/** /**
* Enumerates platform-specific event types that are visible to the application. * Enumerates platform-specific event types that are visible to the application.
*/ */
enum enum {
{
/** Signals that Commissioning session has started */ /** Signals that Commissioning session has started */
kCommissioningSessionStarted = kRange_PublicPlatformSpecific + 0x1000, kCommissioningSessionStarted = kRange_PublicPlatformSpecific + 0x1000,
/** Signals that Commissioning session has stopped */ /** Signals that Commissioning session has stopped */
+13 -4
View File
@@ -243,7 +243,7 @@ esp_err_t send_request(void *ctx, peer_device_t *remote_device, const CommandPat
auto decoder = chip::Platform::MakeUnique<custom_command_callback>(ctx, on_success, on_error); auto decoder = chip::Platform::MakeUnique<custom_command_callback>(ctx, on_success, on_error);
VerifyOrReturnError(decoder != nullptr, ESP_ERR_NO_MEM, ESP_LOGE(TAG, "No memory for command callback")); VerifyOrReturnError(decoder != nullptr, ESP_ERR_NO_MEM, ESP_LOGE(TAG, "No memory for command callback"));
auto on_done = [raw_decoder_ptr = decoder.get()](void *context, CommandSender *command_sender) { auto on_done = [raw_decoder_ptr = decoder.get()](void *context, CommandSender * command_sender) {
chip::Platform::Delete(command_sender); chip::Platform::Delete(command_sender);
chip::Platform::Delete(raw_decoder_ptr); chip::Platform::Delete(raw_decoder_ptr);
}; };
@@ -294,9 +294,18 @@ public:
} }
private: private:
void OnReportBegin() override { m_callback.OnReportBegin(); } void OnReportBegin() override
void OnReportEnd() override { m_callback.OnReportEnd(); } {
void OnError(CHIP_ERROR aError) override { m_callback.OnError(aError); } m_callback.OnReportBegin();
}
void OnReportEnd() override
{
m_callback.OnReportEnd();
}
void OnError(CHIP_ERROR aError) override
{
m_callback.OnError(aError);
}
void OnAttributeData(const ConcreteDataAttributePath &aPath, TLVReader *apData, const StatusIB &aStatus) override void OnAttributeData(const ConcreteDataAttributePath &aPath, TLVReader *apData, const StatusIB &aStatus) override
{ {
+20 -11
View File
@@ -53,7 +53,7 @@ typedef struct request_handle {
*/ */
void *request_data; void *request_data;
request_handle() : type(INVOKE_CMD), request_data(NULL) {} request_handle() : type(INVOKE_CMD), request_data(NULL) {}
request_handle(struct request_handle& req) : type(req.type), request_data(req.request_data) request_handle(struct request_handle &req) : type(req.type), request_data(req.request_data)
{ {
if (req.type == INVOKE_CMD) { if (req.type == INVOKE_CMD) {
command_path = req.command_path; command_path = req.command_path;
@@ -178,8 +178,7 @@ using chip::TLV::TLVReader;
using client::peer_device_t; using client::peer_device_t;
using chip::app::DataModel::EncodableToTLV; using chip::app::DataModel::EncodableToTLV;
class custom_encodable_type : public EncodableToTLV class custom_encodable_type : public EncodableToTLV {
{
public: public:
const char *k_empty_command_data = "{}"; const char *k_empty_command_data = "{}";
const char *k_null_attribute_data = "null"; const char *k_null_attribute_data = "null";
@@ -202,9 +201,12 @@ public:
assert(m_json_str); assert(m_json_str);
} }
~custom_encodable_type() { free(m_json_str); } ~custom_encodable_type()
{
free(m_json_str);
}
CHIP_ERROR EncodeTo(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const override CHIP_ERROR EncodeTo(chip::TLV::TLVWriter &writer, chip::TLV::Tag tag) const override
{ {
if (json_to_tlv(m_json_str, writer, tag) != ESP_OK) { if (json_to_tlv(m_json_str, writer, tag) != ESP_OK) {
return CHIP_ERROR_INTERNAL; return CHIP_ERROR_INTERNAL;
@@ -215,15 +217,17 @@ private:
char *m_json_str = NULL; char *m_json_str = NULL;
}; };
class multiple_write_encodable_type class multiple_write_encodable_type {
{
public: public:
multiple_write_encodable_type(const char *json_str) multiple_write_encodable_type(const char *json_str)
{ {
json = cJSON_Parse(json_str); json = cJSON_Parse(json_str);
} }
~multiple_write_encodable_type() { cJSON_Delete(json); } ~multiple_write_encodable_type()
{
cJSON_Delete(json);
}
CHIP_ERROR EncodeTo(chip::TLV::TLVWriter &writer, chip::TLV::Tag tag, size_t index) CHIP_ERROR EncodeTo(chip::TLV::TLVWriter &writer, chip::TLV::Tag tag, size_t index)
{ {
@@ -242,7 +246,10 @@ public:
return CHIP_NO_ERROR; return CHIP_NO_ERROR;
} }
size_t GetJsonArraySize() { return static_cast<size_t>(cJSON_GetArraySize(json)); } size_t GetJsonArraySize()
{
return static_cast<size_t>(cJSON_GetArraySize(json));
}
private: private:
cJSON *json = NULL; cJSON *json = NULL;
@@ -269,7 +276,10 @@ public:
, context(ctx) , context(ctx)
{ {
} }
void set_on_done_callback(on_done_callback_t on_done) { on_done_cb = on_done; } void set_on_done_callback(on_done_callback_t on_done)
{
on_done_cb = on_done;
}
private: private:
void OnResponse(CommandSender *command_sender, const ConcreteCommandPath &command_path, const StatusIB &status, void OnResponse(CommandSender *command_sender, const ConcreteCommandPath &command_path, const StatusIB &status,
@@ -328,7 +338,6 @@ esp_err_t send_request(void *ctx, peer_device_t *remote_device, const CommandPat
const Optional<uint16_t> &timed_invoke_timeout_ms, const Optional<uint16_t> &timed_invoke_timeout_ms,
const Optional<Timeout> &response_timeout = chip::NullOptional); const Optional<Timeout> &response_timeout = chip::NullOptional);
esp_err_t send_group_request(const uint8_t fabric_index, const CommandPathParams &command_path, esp_err_t send_group_request(const uint8_t fabric_index, const CommandPathParams &command_path,
const chip::app::DataModel::EncodableToTLV &encodable); const chip::app::DataModel::EncodableToTLV &encodable);
+13 -15
View File
@@ -84,8 +84,7 @@ void PostEvent(uint16_t eventType)
VerifyOrReturn(error == CHIP_NO_ERROR, ESP_LOGE(TAG, "Failed to post event for event type:%" PRIu16 ", err:%" CHIP_ERROR_FORMAT, eventType, error.Format())); VerifyOrReturn(error == CHIP_NO_ERROR, ESP_LOGE(TAG, "Failed to post event for event type:%" PRIu16 ", err:%" CHIP_ERROR_FORMAT, eventType, error.Format()));
} }
class AppDelegateImpl : public AppDelegate class AppDelegateImpl : public AppDelegate {
{
public: public:
void OnCommissioningSessionStarted() void OnCommissioningSessionStarted()
{ {
@@ -108,25 +107,24 @@ public:
} }
}; };
class FabricDelegateImpl : public chip::FabricTable::Delegate class FabricDelegateImpl : public chip::FabricTable::Delegate {
{
public: public:
void FabricWillBeRemoved(const chip::FabricTable & fabricTable,chip::FabricIndex fabricIndex) void FabricWillBeRemoved(const chip::FabricTable &fabricTable, chip::FabricIndex fabricIndex)
{ {
PostEvent(chip::DeviceLayer::DeviceEventType::kFabricWillBeRemoved); PostEvent(chip::DeviceLayer::DeviceEventType::kFabricWillBeRemoved);
} }
void OnFabricRemoved(const chip::FabricTable & fabricTable,chip::FabricIndex fabricIndex) void OnFabricRemoved(const chip::FabricTable &fabricTable, chip::FabricIndex fabricIndex)
{ {
PostEvent(chip::DeviceLayer::DeviceEventType::kFabricRemoved); PostEvent(chip::DeviceLayer::DeviceEventType::kFabricRemoved);
} }
void OnFabricCommitted(const chip::FabricTable & fabricTable, chip::FabricIndex fabricIndex) void OnFabricCommitted(const chip::FabricTable &fabricTable, chip::FabricIndex fabricIndex)
{ {
PostEvent(chip::DeviceLayer::DeviceEventType::kFabricCommitted); PostEvent(chip::DeviceLayer::DeviceEventType::kFabricCommitted);
} }
void OnFabricUpdated(const chip::FabricTable & fabricTable, chip::FabricIndex fabricIndex) void OnFabricUpdated(const chip::FabricTable &fabricTable, chip::FabricIndex fabricIndex)
{ {
PostEvent(chip::DeviceLayer::DeviceEventType::kFabricUpdated); PostEvent(chip::DeviceLayer::DeviceEventType::kFabricUpdated);
} }
@@ -171,7 +169,7 @@ esp_err_t ScopedChipStackLock::chip_stack_unlock()
static void deinit_ble_if_commissioned(intptr_t unused) static void deinit_ble_if_commissioned(intptr_t unused)
{ {
#if CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING #if CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING
if(chip::Server::GetInstance().GetFabricTable().FabricCount() > 0) { if (chip::Server::GetInstance().GetFabricTable().FabricCount() > 0) {
chip::DeviceLayer::Internal::BLEMgr().Shutdown(); chip::DeviceLayer::Internal::BLEMgr().Shutdown();
} }
#endif /* CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING */ #endif /* CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING */
@@ -220,8 +218,7 @@ static void esp_matter_chip_init_task(intptr_t context)
#endif // CONFIG_ESP_MATTER_ENABLE_DATA_MODEL #endif // CONFIG_ESP_MATTER_ENABLE_DATA_MODEL
CHIP_ERROR ret = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(&s_fabric_delegate); CHIP_ERROR ret = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(&s_fabric_delegate);
if (ret != CHIP_NO_ERROR) if (ret != CHIP_NO_ERROR) {
{
ESP_LOGE(TAG, "Failed to add fabric delegate, err:%" CHIP_ERROR_FORMAT, ret.Format()); ESP_LOGE(TAG, "Failed to add fabric delegate, err:%" CHIP_ERROR_FORMAT, ret.Format());
} }
ret = chip::Server::GetInstance().Init(initParams); ret = chip::Server::GetInstance().Init(initParams);
@@ -256,8 +253,7 @@ static void esp_matter_chip_init_task(intptr_t context)
static void device_callback_internal(const ChipDeviceEvent * event, intptr_t arg) static void device_callback_internal(const ChipDeviceEvent * event, intptr_t arg)
{ {
switch (event->Type) switch (event->Type) {
{
case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged: case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged:
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET #if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
if (event->InterfaceIpAddressChanged.Type == chip::DeviceLayer::InterfaceIpChangeType::kIpV6_Assigned || if (event->InterfaceIpAddressChanged.Type == chip::DeviceLayer::InterfaceIpChangeType::kIpV6_Assigned ||
@@ -336,7 +332,7 @@ static esp_err_t chip_init(event_callback_t callback, intptr_t callback_arg)
ESP_LOGE(TAG, "Failed to add internal device callback"); ESP_LOGE(TAG, "Failed to add internal device callback");
return ESP_FAIL; return ESP_FAIL;
} }
if(callback) { if (callback) {
if (PlatformMgr().AddEventHandler(callback, callback_arg) != CHIP_NO_ERROR) { if (PlatformMgr().AddEventHandler(callback, callback_arg) != CHIP_NO_ERROR) {
(void)PlatformMgr().StopEventLoopTask(); (void)PlatformMgr().StopEventLoopTask();
chip::Platform::MemoryShutdown(); chip::Platform::MemoryShutdown();
@@ -393,7 +389,9 @@ esp_err_t start(event_callback_t callback, intptr_t callback_arg)
// If Thread is Provisioned, publish the dns service // If Thread is Provisioned, publish the dns service
if (chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned() && if (chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned() &&
(chip::Server::GetInstance().GetFabricTable().FabricCount() != 0)) { (chip::Server::GetInstance().GetFabricTable().FabricCount() != 0)) {
PlatformMgr().ScheduleWork([](intptr_t){ chip::app::DnssdServer::Instance().StartServer(); }, PlatformMgr().ScheduleWork([](intptr_t) {
chip::app::DnssdServer::Instance().StartServer();
},
reinterpret_cast<intptr_t>(nullptr)); reinterpret_cast<intptr_t>(nullptr));
} }
#endif // CONFIG_ESP_MATTER_ENABLE_OPENTHREAD #endif // CONFIG_ESP_MATTER_ENABLE_OPENTHREAD
+4 -2
View File
@@ -134,10 +134,12 @@ typedef enum status {
*/ */
class ScopedChipStackLock { class ScopedChipStackLock {
public: public:
ScopedChipStackLock(uint32_t ticks_to_wait) { ScopedChipStackLock(uint32_t ticks_to_wait)
{
status = chip_stack_lock(ticks_to_wait); status = chip_stack_lock(ticks_to_wait);
} }
~ScopedChipStackLock() { ~ScopedChipStackLock()
{
if (status == SUCCESS) { if (status == SUCCESS) {
chip_stack_unlock(); chip_stack_unlock();
} }
+1 -2
View File
@@ -120,8 +120,7 @@ esp_err_t esp_matter_ota_requestor_encrypted_init(const char *key, uint16_t size
} }
#endif // CONFIG_ENABLE_ENCRYPTED_OTA #endif // CONFIG_ENABLE_ENCRYPTED_OTA
esp_err_t esp_matter_ota_requestor_set_config(const esp_matter_ota_config_t &config)
esp_err_t esp_matter_ota_requestor_set_config(const esp_matter_ota_config_t & config)
{ {
#if CONFIG_ENABLE_OTA_REQUESTOR #if CONFIG_ENABLE_OTA_REQUESTOR
if (config.periodic_query_timeout) { if (config.periodic_query_timeout) {
+1 -1
View File
@@ -85,4 +85,4 @@ esp_err_t esp_matter_ota_requestor_encrypted_init(const char *key, uint16_t size
* *
* @note Ensure that this API is called only after esp_matter::start() has been invoked. * @note Ensure that this API is called only after esp_matter::start() has been invoked.
*/ */
esp_err_t esp_matter_ota_requestor_set_config(const esp_matter_ota_config_t & config); esp_err_t esp_matter_ota_requestor_set_config(const esp_matter_ota_config_t &config);
@@ -19,11 +19,11 @@
IRAM_ATTR void *esp_matter_mem_calloc(size_t n, size_t size) IRAM_ATTR void *esp_matter_mem_calloc(size_t n, size_t size)
{ {
#if CONFIG_ESP_MATTER_MEM_ALLOC_MODE_INTERNAL #if CONFIG_ESP_MATTER_MEM_ALLOC_MODE_INTERNAL
return heap_caps_calloc(n, size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); return heap_caps_calloc(n, size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
#elif CONFIG_ESP_MATTER_MEM_ALLOC_MODE_EXTERNAL #elif CONFIG_ESP_MATTER_MEM_ALLOC_MODE_EXTERNAL
return heap_caps_calloc(n, size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT); return heap_caps_calloc(n, size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
#elif CONFIG_ESP_MATTER_MEM_ALLOC_MODE_IRAM_8BIT #elif CONFIG_ESP_MATTER_MEM_ALLOC_MODE_IRAM_8BIT
return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_INTERNAL | MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
#else #else
return calloc(n, size); return calloc(n, size);
#endif #endif
+2 -4
View File
@@ -34,21 +34,19 @@ __attribute__((weak)) const SupportedModesManager * getSupportedModesManager(voi
} /* namespace Clusters */ } /* namespace Clusters */
} /* namespace ModeSelect */ } /* namespace ModeSelect */
// Provide weak defaults for attribute changed callbacks so apps // Provide weak defaults for attribute changed callbacks so apps
// Strong definitions in an app will override these. // Strong definitions in an app will override these.
__attribute__((weak)) void MatterClosureControlClusterServerAttributeChangedCallback( __attribute__((weak)) void MatterClosureControlClusterServerAttributeChangedCallback(
const chip::app::ConcreteAttributePath & attributePath) const chip::app::ConcreteAttributePath &attributePath)
{ {
ESP_LOGI(TAG, "Attribute Changed Callback: Endpoint: %d, Cluster: %ld, Attribute: %ld", ESP_LOGI(TAG, "Attribute Changed Callback: Endpoint: %d, Cluster: %ld, Attribute: %ld",
attributePath.mEndpointId, attributePath.mClusterId, attributePath.mAttributeId); attributePath.mEndpointId, attributePath.mClusterId, attributePath.mAttributeId);
} }
__attribute__((weak)) void MatterClosureDimensionClusterServerAttributeChangedCallback( __attribute__((weak)) void MatterClosureDimensionClusterServerAttributeChangedCallback(
const chip::app::ConcreteAttributePath & attributePath) const chip::app::ConcreteAttributePath &attributePath)
{ {
ESP_LOGI(TAG, "Attribute Changed Callback: Endpoint: %d, Cluster: %ld, Attribute: %ld", ESP_LOGI(TAG, "Attribute Changed Callback: Endpoint: %d, Cluster: %ld, Attribute: %ld",
attributePath.mEndpointId, attributePath.mClusterId, attributePath.mAttributeId); attributePath.mEndpointId, attributePath.mClusterId, attributePath.mAttributeId);
} }
@@ -256,8 +256,9 @@ esp_err_t set_device_type(device_t *bridged_device, uint32_t device_type_id, voi
return ESP_ERR_INVALID_ARG; return ESP_ERR_INVALID_ARG;
} }
err = device_type_callback(bridged_device->endpoint, device_type_id, priv_data); err = device_type_callback(bridged_device->endpoint, device_type_id, priv_data);
if (err != ESP_OK) if (err != ESP_OK) {
return err; return err;
}
return plugin_init_callback_endpoint(bridged_device->endpoint); return plugin_init_callback_endpoint(bridged_device->endpoint);
} }
@@ -61,7 +61,8 @@ const device_type_handler device_handlers[] = {
{"temperature_sensor", ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID, ADD_DEVICE_FUN(temperature_sensor)}, {"temperature_sensor", ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID, ADD_DEVICE_FUN(temperature_sensor)},
}; };
static bool is_device_type_supported(uint32_t device_type_id) { static bool is_device_type_supported(uint32_t device_type_id)
{
for (const auto &handler : device_handlers) { for (const auto &handler : device_handlers) {
if (handler.device_type_id == device_type_id) { if (handler.device_type_id == device_type_id) {
return true; return true;
@@ -274,7 +275,8 @@ esp_err_t bridge_register_commands()
.name = "reset", .name = "reset",
.description = "reset bridge. Usage: matter esp bridge reset.", .description = "reset bridge. Usage: matter esp bridge reset.",
.handler = reset_bridge_handler, .handler = reset_bridge_handler,
}}; }
};
bridge_console.register_commands(bridge_commands, sizeof(bridge_commands) / sizeof(command_t)); bridge_console.register_commands(bridge_commands, sizeof(bridge_commands) / sizeof(command_t));
return add_commands(&command, 1); return add_commands(&command, 1);
} }
@@ -88,7 +88,6 @@ esp_err_t print_description(const command_t *command, void *arg)
return ESP_OK; return ESP_OK;
} }
static esp_err_t help_handler(int argc, char **argv) static esp_err_t help_handler(int argc, char **argv)
{ {
base_engine.for_each_command(print_description, NULL); base_engine.for_each_command(print_description, NULL);
@@ -97,7 +96,7 @@ static esp_err_t help_handler(int argc, char **argv)
static esp_err_t register_default_commands() static esp_err_t register_default_commands()
{ {
static const command_t command= { static const command_t command = {
.name = "help", .name = "help",
.description = "Print help", .description = "Print help",
.handler = help_handler, .handler = help_handler,
@@ -50,8 +50,7 @@ typedef struct {
*/ */
typedef esp_err_t command_iterator_t(const command_t *command, void *arg); typedef esp_err_t command_iterator_t(const command_t *command, void *arg);
class engine class engine {
{
protected: protected:
const command_t *_command_set[CONSOLE_MAX_COMMAND_SETS]; const command_t *_command_set[CONSOLE_MAX_COMMAND_SETS];
unsigned _command_set_size[CONSOLE_MAX_COMMAND_SETS]; unsigned _command_set_size[CONSOLE_MAX_COMMAND_SETS];
@@ -215,5 +215,3 @@ esp_err_t attribute_register_commands()
} // namespace console } // namespace console
} // namespace esp_matter } // namespace esp_matter
@@ -72,7 +72,7 @@ esp_err_t diagnostics_register_commands()
.handler = up_time_console_handler, .handler = up_time_console_handler,
}, },
}; };
diagnostics_console.register_commands(diagnostics_commands, sizeof(diagnostics_commands)/sizeof(command_t)); diagnostics_console.register_commands(diagnostics_commands, sizeof(diagnostics_commands) / sizeof(command_t));
return add_commands(&command, 1); return add_commands(&command, 1);
} }
@@ -102,7 +102,8 @@ void paa_der_cert_iterator::release()
esp_err_t spiffs_attestation_trust_store::init() esp_err_t spiffs_attestation_trust_store::init()
{ {
esp_vfs_spiffs_conf_t conf = { esp_vfs_spiffs_conf_t conf = {
.base_path = "/paa", .partition_label = nullptr, .max_files = 5, .format_if_mount_failed = false}; .base_path = "/paa", .partition_label = nullptr, .max_files = 5, .format_if_mount_failed = false
};
ESP_RETURN_ON_ERROR(esp_vfs_spiffs_register(&conf), TAG, "Failed to initialize SPIFFS"); ESP_RETURN_ON_ERROR(esp_vfs_spiffs_register(&conf), TAG, "Failed to initialize SPIFFS");
size_t total = 0, used = 0; size_t total = 0, used = 0;
ESP_RETURN_ON_ERROR(esp_spiffs_info(conf.partition_label, &total, &used), TAG, "Failed to get SPIFFS info"); ESP_RETURN_ON_ERROR(esp_spiffs_info(conf.partition_label, &total, &used), TAG, "Failed to get SPIFFS info");
@@ -31,8 +31,14 @@ typedef struct paa_der_cert {
class paa_der_cert_iterator { class paa_der_cert_iterator {
public: public:
paa_der_cert_iterator(const char *path); paa_der_cert_iterator(const char *path);
~paa_der_cert_iterator() { release(); }; ~paa_der_cert_iterator()
size_t count() { return m_count; } {
release();
};
size_t count()
{
return m_count;
}
bool next(paa_der_cert_t &item); bool next(paa_der_cert_t &item);
void release(); void release();
@@ -84,7 +90,10 @@ public:
CHIP_ERROR GetProductAttestationAuthorityCert(const ByteSpan &skid, CHIP_ERROR GetProductAttestationAuthorityCert(const ByteSpan &skid,
MutableByteSpan &outPaaDerBuffer) const override; MutableByteSpan &outPaaDerBuffer) const override;
void SetDCLNetType(dcl_net_type_t type) { dcl_net_type = type; } void SetDCLNetType(dcl_net_type_t type)
{
dcl_net_type = type;
}
private: private:
dcl_net_type_t dcl_net_type = DCL_MAIN_NET; dcl_net_type_t dcl_net_type = DCL_MAIN_NET;
@@ -147,7 +147,8 @@ void cluster_command::on_device_connected_fcn(void *context, ExchangeManager &ex
cluster_command *cmd = reinterpret_cast<cluster_command *>(context); cluster_command *cmd = reinterpret_cast<cluster_command *>(context);
chip::OperationalDeviceProxy device_proxy(&exchangeMgr, sessionHandle); chip::OperationalDeviceProxy device_proxy(&exchangeMgr, sessionHandle);
chip::app::CommandPathParams command_path = {cmd->m_endpoint_id, 0, cmd->m_cluster_id, cmd->m_command_id, chip::app::CommandPathParams command_path = {cmd->m_endpoint_id, 0, cmd->m_cluster_id, cmd->m_command_id,
chip::app::CommandPathFlags::kEndpointIdValid}; chip::app::CommandPathFlags::kEndpointIdValid
};
interaction::invoke::send_request(context, &device_proxy, command_path, cmd->m_command_data_field, interaction::invoke::send_request(context, &device_proxy, command_path, cmd->m_command_data_field,
cmd->on_success_cb, cmd->on_error_cb, cmd->m_timed_invoke_timeout_ms); cmd->on_success_cb, cmd->on_error_cb, cmd->m_timed_invoke_timeout_ms);
chip::Platform::Delete(cmd); chip::Platform::Delete(cmd);
@@ -166,11 +167,11 @@ void cluster_command::default_success_fcn(void *ctx, const ConcreteCommandPath &
{ {
ESP_LOGI(TAG, "Send command success"); ESP_LOGI(TAG, "Send command success");
ESP_LOGI(TAG, ESP_LOGI(TAG,
"Some commands of specific clusters will have a reponse which is not NullObject, so we need to handle the " "Some commands of specific clusters will have a response which is not NullObject, so we need to handle the "
"response data for those commands. Here we print the reponse data."); "response data for those commands. Here we print the response data.");
ESP_LOGI(TAG, ESP_LOGI(TAG,
"If your command's reponse is not printed here, please register another success callback when creating " "If your command's response is not printed here, please register another success callback when creating "
"the cluster_command object to handle the reponse data."); "the cluster_command object to handle the response data.");
switch (command_path.mClusterId) { switch (command_path.mClusterId) {
case GroupKeyManagement::Id: case GroupKeyManagement::Id:
cluster::group_key_management::command::decode_response(command_path, response_data); cluster::group_key_management::command::decode_response(command_path, response_data);
@@ -208,7 +209,8 @@ esp_err_t cluster_command::dispatch_group_command(void *context)
uint8_t fabric_index = matter_controller_client::get_instance().get_fabric_index(); uint8_t fabric_index = matter_controller_client::get_instance().get_fabric_index();
#endif // CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER #endif // CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER
chip::app::CommandPathParams command_path = {cmd->m_endpoint_id, group_id, cmd->m_cluster_id, cmd->m_command_id, chip::app::CommandPathParams command_path = {cmd->m_endpoint_id, group_id, cmd->m_cluster_id, cmd->m_command_id,
chip::app::CommandPathFlags::kGroupIdValid}; chip::app::CommandPathFlags::kGroupIdValid
};
err = interaction::invoke::send_group_request(fabric_index, command_path, cmd->m_command_data_field); err = interaction::invoke::send_group_request(fabric_index, command_path, cmd->m_command_data_field);
chip::Platform::Delete(cmd); chip::Platform::Delete(cmd);
return err; return err;
@@ -58,7 +58,10 @@ public:
esp_err_t send_command(); esp_err_t send_command();
bool is_group_command() { return chip::IsGroupId(m_destination_id); } bool is_group_command()
{
return chip::IsGroupId(m_destination_id);
}
private: private:
uint64_t m_destination_id; uint64_t m_destination_id;
@@ -44,7 +44,7 @@ esp_err_t commissioning_window_opener::send_open_commissioning_window_command(ui
return ESP_ERR_INVALID_ARG; return ESP_ERR_INVALID_ARG;
} }
m_is_enhanced = is_enhanced; m_is_enhanced = is_enhanced;
m_timout = timeout; m_timeout = timeout;
m_iteration = iteration; m_iteration = iteration;
m_discriminator = discriminator; m_discriminator = discriminator;
m_timed_invoke_timeout_ms = timed_invoke_timeout_ms; m_timed_invoke_timeout_ms = timed_invoke_timeout_ms;
@@ -125,7 +125,7 @@ void commissioning_window_opener::on_device_connected_fcn(void *context, Exchang
return; return;
} }
AdministratorCommissioning::Commands::OpenCommissioningWindow::Type command_data; AdministratorCommissioning::Commands::OpenCommissioningWindow::Type command_data;
command_data.commissioningTimeout = window_opener->m_timout; command_data.commissioningTimeout = window_opener->m_timeout;
command_data.PAKEPasscodeVerifier = serialized_verifier_span; command_data.PAKEPasscodeVerifier = serialized_verifier_span;
command_data.discriminator = window_opener->m_discriminator; command_data.discriminator = window_opener->m_discriminator;
command_data.iterations = window_opener->m_iteration; command_data.iterations = window_opener->m_iteration;
@@ -136,7 +136,7 @@ void commissioning_window_opener::on_device_connected_fcn(void *context, Exchang
chip::MakeOptional(window_opener->m_timed_invoke_timeout_ms)); chip::MakeOptional(window_opener->m_timed_invoke_timeout_ms));
} else { } else {
AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Type command_data; AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Type command_data;
command_data.commissioningTimeout = window_opener->m_timout; command_data.commissioningTimeout = window_opener->m_timeout;
chip::Controller::ClusterBase cluster(exchangeMgr, sessionHandle, window_opener->m_default_remote_endpoint_id); chip::Controller::ClusterBase cluster(exchangeMgr, sessionHandle, window_opener->m_default_remote_endpoint_id);
cluster.InvokeCommand(command_data, window_opener, send_command_success_callback, send_command_failure_callback, cluster.InvokeCommand(command_data, window_opener, send_command_success_callback, send_command_failure_callback,
chip::MakeOptional(window_opener->m_timed_invoke_timeout_ms)); chip::MakeOptional(window_opener->m_timed_invoke_timeout_ms));
@@ -148,7 +148,7 @@ void commissioning_window_opener::on_device_connection_failure_fcn(void *context
{ {
commissioning_window_opener *window_opener = reinterpret_cast<commissioning_window_opener *>(context); commissioning_window_opener *window_opener = reinterpret_cast<commissioning_window_opener *>(context);
if (window_opener) { if (window_opener) {
ESP_LOGE(TAG, "Failed to establish CASE session for open %s commisioning window command", ESP_LOGE(TAG, "Failed to establish CASE session for open %s commissioning window command",
window_opener->m_is_enhanced ? "enhanced" : "basic"); window_opener->m_is_enhanced ? "enhanced" : "basic");
} }
} }
@@ -176,7 +176,7 @@ void commissioning_window_opener::send_command_failure_callback(void *context, C
{ {
commissioning_window_opener *window_opener = reinterpret_cast<commissioning_window_opener *>(context); commissioning_window_opener *window_opener = reinterpret_cast<commissioning_window_opener *>(context);
if (window_opener) { if (window_opener) {
ESP_LOGE(TAG, "Failed to send open %s commisioning window command", ESP_LOGE(TAG, "Failed to send open %s commissioning window command",
window_opener->m_is_enhanced ? "enhanced" : "basic"); window_opener->m_is_enhanced ? "enhanced" : "basic");
} }
} }
@@ -38,7 +38,10 @@ public:
return instance; return instance;
} }
void set_callback(commissioning_window_open_callback_t callback) { m_callback = callback; } void set_callback(commissioning_window_open_callback_t callback)
{
m_callback = callback;
}
esp_err_t send_open_commissioning_window_command(uint64_t node_id, bool is_enhanced, uint16_t timeout, esp_err_t send_open_commissioning_window_command(uint64_t node_id, bool is_enhanced, uint16_t timeout,
uint32_t iteration, uint16_t discriminator, uint32_t iteration, uint16_t discriminator,
@@ -68,7 +71,7 @@ private:
uint32_t m_discriminator = 0; uint32_t m_discriminator = 0;
bool m_is_enhanced = false; bool m_is_enhanced = false;
uint32_t m_pincode = 0; uint32_t m_pincode = 0;
uint16_t m_timout = 0; uint16_t m_timeout = 0;
uint32_t m_iteration = 0; uint32_t m_iteration = 0;
uint16_t m_timed_invoke_timeout_ms = 0; uint16_t m_timed_invoke_timeout_ms = 0;
commissioning_window_open_callback_t m_callback = nullptr; commissioning_window_open_callback_t m_callback = nullptr;
@@ -68,9 +68,15 @@ public:
return s_instance; return s_instance;
} }
void set_callbacks(pairing_command_callbacks_t callbacks) { m_callbacks = callbacks; } void set_callbacks(pairing_command_callbacks_t callbacks)
{
m_callbacks = callbacks;
}
void set_icd_registration(bool icd_registration) { m_icd_registration = icd_registration; } void set_icd_registration(bool icd_registration)
{
m_icd_registration = icd_registration;
}
/** /**
* Pairing a Matter end-device on the same IP network * Pairing a Matter end-device on the same IP network
@@ -54,8 +54,9 @@ void subscribe_command::on_device_connection_failure_fcn(void *context, const Sc
{ {
subscribe_command *cmd = (subscribe_command *)context; subscribe_command *cmd = (subscribe_command *)context;
if (cmd->subscribe_failure_cb) if (cmd->subscribe_failure_cb) {
cmd->subscribe_failure_cb((void *)cmd); cmd->subscribe_failure_cb((void *)cmd);
}
chip::Platform::Delete(cmd); chip::Platform::Delete(cmd);
return; return;
@@ -120,7 +120,10 @@ public:
CHIP_ERROR OnResubscriptionNeeded(ReadClient *apReadClient, CHIP_ERROR aTerminationCause) override; CHIP_ERROR OnResubscriptionNeeded(ReadClient *apReadClient, CHIP_ERROR aTerminationCause) override;
uint32_t get_subscription_id() { return m_subscription_id; } uint32_t get_subscription_id()
{
return m_subscription_id;
}
private: private:
uint64_t m_node_id; uint64_t m_node_id;
@@ -200,7 +203,7 @@ esp_err_t send_subscribe_event_command(uint64_t node_id, ScopedMemoryBufferWithS
* @param[in] node_id Remote NodeId * @param[in] node_id Remote NodeId
* @param[in] endpoint_id EndpointId of the attribute path * @param[in] endpoint_id EndpointId of the attribute path
* @param[in] cluster_id ClusterId of the attribute path * @param[in] cluster_id ClusterId of the attribute path
* @param[in] attribute_id AttributeId of the attribue path * @param[in] attribute_id AttributeId of the attribute path
* @param[in] min_interval Minimum interval of the subscription * @param[in] min_interval Minimum interval of the subscription
* @param[in] max_interval Maximum interval of the subscription * @param[in] max_interval Maximum interval of the subscription
* @param[in] auto_resubscribe Auto re-subscribe flag * @param[in] auto_resubscribe Auto re-subscribe flag
@@ -170,7 +170,10 @@ public:
} }
esp_err_t init(NodeId node_id, FabricId fabric_id, uint16_t listen_port); esp_err_t init(NodeId node_id, FabricId fabric_id, uint16_t listen_port);
chip::app::DefaultICDClientStorage &get_icd_client_storage() { return m_icd_client_storage; } chip::app::DefaultICDClientStorage &get_icd_client_storage()
{
return m_icd_client_storage;
}
void set_icd_client_callback(controller_check_in_delegate::check_in_complete_callback check_in_complete_cb, void set_icd_client_callback(controller_check_in_delegate::check_in_complete_callback check_in_complete_cb,
controller_check_in_delegate::key_refresh_done_callback key_refresh_done_cb) controller_check_in_delegate::key_refresh_done_callback key_refresh_done_cb)
{ {
@@ -179,17 +182,26 @@ public:
#ifdef CONFIG_ESP_MATTER_COMMISSIONER_ENABLE #ifdef CONFIG_ESP_MATTER_COMMISSIONER_ENABLE
esp_err_t setup_commissioner(); esp_err_t setup_commissioner();
MatterDeviceCommissioner *get_commissioner() { return &m_device_commissioner; } MatterDeviceCommissioner *get_commissioner()
{
return &m_device_commissioner;
}
esp_err_t unpair(NodeId remote_node, remove_fabric_callback callback = nullptr) esp_err_t unpair(NodeId remote_node, remove_fabric_callback callback = nullptr)
{ {
return auto_fabric_remover::remove_fabric(&m_device_commissioner, remote_node, callback); return auto_fabric_remover::remove_fabric(&m_device_commissioner, remote_node, callback);
} }
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY #if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY
CommissionerDiscoveryController *get_discovery_controller() { return &m_commissioner_discovery_controller; } CommissionerDiscoveryController *get_discovery_controller()
{
return &m_commissioner_discovery_controller;
}
#endif #endif
#else #else
esp_err_t setup_controller(chip::MutableByteSpan &ipk); esp_err_t setup_controller(chip::MutableByteSpan &ipk);
MatterDeviceController *get_controller() { return &m_device_controller; } MatterDeviceController *get_controller()
{
return &m_device_controller;
}
#endif #endif
chip::FabricIndex get_fabric_index() chip::FabricIndex get_fabric_index()
{ {
@@ -25,7 +25,10 @@ class example_credentials_issuer : public credentials_issuer {
return m_operational_creds_issuer.Initialize(storage) == CHIP_NO_ERROR ? ESP_OK : ESP_FAIL; return m_operational_creds_issuer.Initialize(storage) == CHIP_NO_ERROR ? ESP_OK : ESP_FAIL;
} }
chip::Controller::OperationalCredentialsDelegate *get_delegate() override { return &m_operational_creds_issuer; } chip::Controller::OperationalCredentialsDelegate *get_delegate() override
{
return &m_operational_creds_issuer;
}
esp_err_t generate_controller_noc_chain(chip::NodeId node_id, chip::FabricId fabric_id, esp_err_t generate_controller_noc_chain(chip::NodeId node_id, chip::FabricId fabric_id,
chip::Crypto::P256Keypair &keypair, chip::MutableByteSpan &rcac, chip::Crypto::P256Keypair &keypair, chip::MutableByteSpan &rcac,
@@ -44,14 +44,14 @@ esp_err_t list_registered_icd()
while (iter->Next(info)) { while (iter->Next(info)) {
ESP_LOGI(TAG, " | " ChipLogFormatX64 " | " ChipLogFormatX64 " | %13" PRIu32 " | %14" PRIu32 ESP_LOGI(TAG, " | " ChipLogFormatX64 " | " ChipLogFormatX64 " | %13" PRIu32 " | %14" PRIu32
" | " ChipLogFormatX64 " | %10u |", ChipLogValueX64(info.peer_node.GetNodeId()), " | " ChipLogFormatX64 " | %10u |", ChipLogValueX64(info.peer_node.GetNodeId()),
ChipLogValueX64(info.check_in_node.GetNodeId()),info.start_icd_counter, info.offset, ChipLogValueX64(info.check_in_node.GetNodeId()), info.start_icd_counter, info.offset,
ChipLogValueX64(info.monitored_subject), static_cast<uint8_t>(info.client_type)); ChipLogValueX64(info.monitored_subject), static_cast<uint8_t>(info.client_type));
Encoding::BytesToHex(info.aes_key_handle.As<Crypto::Symmetric128BitsKeyByteArray>(), Crypto::kAES_CCM128_Key_Length, Encoding::BytesToHex(info.aes_key_handle.As<Crypto::Symmetric128BitsKeyByteArray>(), Crypto::kAES_CCM128_Key_Length,
icd_aes_key_hex, sizeof(icd_aes_key_hex), Encoding::HexFlags::kNullTerminate); icd_aes_key_hex, sizeof(icd_aes_key_hex), Encoding::HexFlags::kNullTerminate);
ESP_LOGI(TAG," | aes key: %60s |", icd_aes_key_hex); ESP_LOGI(TAG, " | aes key: %60s |", icd_aes_key_hex);
Encoding::BytesToHex(info.hmac_key_handle.As<Crypto::Symmetric128BitsKeyByteArray>(), Crypto::kHMAC_CCM128_Key_Length, Encoding::BytesToHex(info.hmac_key_handle.As<Crypto::Symmetric128BitsKeyByteArray>(), Crypto::kHMAC_CCM128_Key_Length,
icd_hmac_key_hex, sizeof(icd_hmac_key_hex), Encoding::HexFlags::kNullTerminate); icd_hmac_key_hex, sizeof(icd_hmac_key_hex), Encoding::HexFlags::kNullTerminate);
ESP_LOGI(TAG," | hmac key: %60s |", icd_hmac_key_hex); ESP_LOGI(TAG, " | hmac key: %60s |", icd_hmac_key_hex);
ESP_LOGI(TAG, " +------------------------------------------------------------------------------------------------------+"); ESP_LOGI(TAG, " +------------------------------------------------------------------------------------------------------+");
} }
return ESP_OK; return ESP_OK;
@@ -76,7 +76,10 @@ public:
return instance; return instance;
} }
CHIP_ERROR Shutdown() override { return CHIP_NO_ERROR; } CHIP_ERROR Shutdown() override
{
return CHIP_NO_ERROR;
}
ActionReturnStatus ReadAttribute(const ReadAttributeRequest &request, AttributeValueEncoder &encoder) override ActionReturnStatus ReadAttribute(const ReadAttributeRequest &request, AttributeValueEncoder &encoder) override
{ {
@@ -179,7 +182,7 @@ public:
#endif #endif
} }
CHIP_ERROR EventInfo(const ConcreteEventPath & path, EventEntry & eventInfo) override CHIP_ERROR EventInfo(const ConcreteEventPath &path, EventEntry &eventInfo) override
{ {
return CHIP_NO_ERROR; return CHIP_NO_ERROR;
} }
@@ -51,7 +51,10 @@ public:
strncpy(mOtaImageUrl, otaImageUrl, strnlen(otaImageUrl, OTA_URL_MAX_LEN)); strncpy(mOtaImageUrl, otaImageUrl, strnlen(otaImageUrl, OTA_URL_MAX_LEN));
} }
const char *GetOtaImageUrl() const { return mOtaImageUrl; } const char *GetOtaImageUrl() const
{
return mOtaImageUrl;
}
private: private:
void HandleTransferSessionOutput(chip::bdx::TransferSession::OutputEvent &event) override; void HandleTransferSessionOutput(chip::bdx::TransferSession::OutputEvent &event) override;
@@ -75,10 +75,22 @@ public:
} }
esp_err_t Init(bool otaAllowedDefault, chip::System::Layer *system_layer, esp_err_t Init(bool otaAllowedDefault, chip::System::Layer *system_layer,
chip::Messaging::ExchangeManager *exchange_mgr, chip::FabricTable *fabric_table); chip::Messaging::ExchangeManager *exchange_mgr, chip::FabricTable *fabric_table);
void SetApplyUpdateAction(OTAApplyUpdateAction action) { mUpdateAction = action; } void SetApplyUpdateAction(OTAApplyUpdateAction action)
void SetDelayedQueryActionTimeSec(uint32_t time) { mDelayedQueryActionTimeSec = time; } {
void SetDelayedApplyActionTimeSec(uint32_t time) { mDelayedApplyActionTimeSec = time; } mUpdateAction = action;
void SetPollInterval(uint32_t interval) { mPollInterval = (interval != 0) ? interval : mPollInterval; } }
void SetDelayedQueryActionTimeSec(uint32_t time)
{
mDelayedQueryActionTimeSec = time;
}
void SetDelayedApplyActionTimeSec(uint32_t time)
{
mDelayedApplyActionTimeSec = time;
}
void SetPollInterval(uint32_t interval)
{
mPollInterval = (interval != 0) ? interval : mPollInterval;
}
static void FetchImageDoneCallback(OTAQueryStatus status, const char *imageUrl, size_t imageSize, static void FetchImageDoneCallback(OTAQueryStatus status, const char *imageUrl, size_t imageSize,
uint32_t softwareVersion, const char *softwareVersionStr, void *arg); uint32_t softwareVersion, const char *softwareVersionStr, void *arg);
@@ -86,7 +98,10 @@ public:
// When the OTA Provider receives a QueryImage command from an OTA Requestor and there is no existing entry for the // When the OTA Provider receives a QueryImage command from an OTA Requestor and there is no existing entry for the
// Requestor node, the Provider will create an OTA Requestor Entry for the requestor, and set the entry's // Requestor node, the Provider will create an OTA Requestor Entry for the requestor, and set the entry's
// mOtaAllowed to mOtaAllowedDefault. // mOtaAllowed to mOtaAllowedDefault.
void SetOtaAllowedDefault(bool otaAllowed) { mOtaAllowedDefault = otaAllowed; } void SetOtaAllowedDefault(bool otaAllowed)
{
mOtaAllowedDefault = otaAllowed;
}
// When there is a Requestor entry for the nodeId, we can call the EnableOtaForNode/DisableOtaForNode to make the // When there is a Requestor entry for the nodeId, we can call the EnableOtaForNode/DisableOtaForNode to make the
// provider allow whether the requestor proceed the OTA process. // provider allow whether the requestor proceed the OTA process.
esp_err_t EnableOtaForNode(const chip::ScopedNodeId &nodeId, bool forOnlyOnce); esp_err_t EnableOtaForNode(const chip::ScopedNodeId &nodeId, bool forOnlyOnce);
@@ -462,7 +462,8 @@ esp_err_t init_ota_candidates()
// start a timer which will update the candidates cache everyday. // start a timer which will update the candidates cache everyday.
esp_timer_init(); esp_timer_init();
const esp_timer_create_args_t timer_args = { const esp_timer_create_args_t timer_args = {
.callback = _ota_candidates_periodic_update_handler, .arg = nullptr, .name = "ota_candidates_update_timer"}; .callback = _ota_candidates_periodic_update_handler, .arg = nullptr, .name = "ota_candidates_update_timer"
};
esp_timer_create(&timer_args, &_ota_candidates_update_timer); esp_timer_create(&timer_args, &_ota_candidates_update_timer);
esp_timer_start_periodic(_ota_candidates_update_timer, esp_timer_start_periodic(_ota_candidates_update_timer,
(uint64_t)CONFIG_ESP_MATTER_OTA_CANDIDATES_UPDATE_PERIOD * 3600 * 1000 * 1000); (uint64_t)CONFIG_ESP_MATTER_OTA_CANDIDATES_UPDATE_PERIOD * 3600 * 1000 * 1000);
@@ -408,29 +408,26 @@ static esp_err_t custom_cluster_create()
return ESP_OK; return ESP_OK;
} }
class RainmakerAttrAccess : public AttributeAccessInterface class RainmakerAttrAccess : public AttributeAccessInterface {
{
public: public:
// Register for the RainMaker cluster on endpoint 0. // Register for the RainMaker cluster on endpoint 0.
RainmakerAttrAccess() : AttributeAccessInterface(chip::Optional<chip::EndpointId>(cluster::rainmaker::endpoint_id), RainmakerAttrAccess() : AttributeAccessInterface(chip::Optional<chip::EndpointId>(cluster::rainmaker::endpoint_id),
cluster::rainmaker::Id) {} cluster::rainmaker::Id) {}
CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override CHIP_ERROR Read(const ConcreteReadAttributePath &aPath, AttributeValueEncoder &aEncoder) override
{ {
return CHIP_NO_ERROR; return CHIP_NO_ERROR;
} }
CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override CHIP_ERROR Write(const ConcreteDataAttributePath &aPath, AttributeValueDecoder &aDecoder) override
{ {
ConcreteDataAttributePath challengeAttrPath(cluster::rainmaker::endpoint_id, cluster::rainmaker::Id, ConcreteDataAttributePath challengeAttrPath(cluster::rainmaker::endpoint_id, cluster::rainmaker::Id,
cluster::rainmaker::attribute::challenge::Id); cluster::rainmaker::attribute::challenge::Id);
if (challengeAttrPath.MatchesConcreteAttributePath(aPath)) if (challengeAttrPath.MatchesConcreteAttributePath(aPath)) {
{
chip::CharSpan challenge; chip::CharSpan challenge;
CHIP_ERROR c_err = aDecoder.Decode(challenge); CHIP_ERROR c_err = aDecoder.Decode(challenge);
if (c_err != CHIP_NO_ERROR) if (c_err != CHIP_NO_ERROR) {
{
ESP_LOGE(TAG, "Failed to decode challenge, err:%" CHIP_ERROR_FORMAT, c_err.Format()); ESP_LOGE(TAG, "Failed to decode challenge, err:%" CHIP_ERROR_FORMAT, c_err.Format());
return c_err; return c_err;
} }
@@ -21,7 +21,6 @@
#define LED_CHANNEL 0 /* RMT_CHANNEL_0 */ #define LED_CHANNEL 0 /* RMT_CHANNEL_0 */
#define BUTTON_GPIO_PIN GPIO_NUM_9 #define BUTTON_GPIO_PIN GPIO_NUM_9
led_driver_config_t led_driver_get_config() led_driver_config_t led_driver_get_config()
{ {
led_driver_config_t config = { led_driver_config_t config = {
+20 -7
View File
@@ -83,7 +83,8 @@ const HS_color_t temp_table[] = {
{0, 0}, {294, 2}, {265, 3}, {251, 4}, {242, 5}, {237, 6}, {233, 7}, {231, 8}, {229, 9}, {228, 10}, {0, 0}, {294, 2}, {265, 3}, {251, 4}, {242, 5}, {237, 6}, {233, 7}, {231, 8}, {229, 9}, {228, 10},
{227, 11}, {226, 11}, {226, 12}, {225, 13}, {225, 13}, {224, 14}, {224, 14}, {224, 15}, {224, 15}, {223, 16}, {227, 11}, {226, 11}, {226, 12}, {225, 13}, {225, 13}, {224, 14}, {224, 14}, {224, 15}, {224, 15}, {223, 16},
{223, 16}, {223, 17}, {223, 17}, {223, 17}, {222, 18}, {222, 18}, {222, 19}, {222, 19}, {222, 19}, {222, 19}, {223, 16}, {223, 17}, {223, 17}, {223, 17}, {222, 18}, {222, 18}, {222, 19}, {222, 19}, {222, 19}, {222, 19},
{222, 20}, {222, 20}, {222, 20}, {222, 21}, {222, 21}}; {222, 20}, {222, 20}, {222, 20}, {222, 21}, {222, 21}
};
void temp_to_hs(uint32_t temperature, HS_color_t *HS) void temp_to_hs(uint32_t temperature, HS_color_t *HS)
{ {
@@ -146,12 +147,24 @@ void xy_to_rgb(XY_color_t XY, uint8_t brightness, RGB_color_t *RGB)
} }
// Clamp values to [0, 1] range // Clamp values to [0, 1] range
if (r < 0.0f) r = 0.0f; if (r < 0.0f) {
if (r > 1.0f) r = 1.0f; r = 0.0f;
if (g < 0.0f) g = 0.0f; }
if (g > 1.0f) g = 1.0f; if (r > 1.0f) {
if (b < 0.0f) b = 0.0f; r = 1.0f;
if (b > 1.0f) b = 1.0f; }
if (g < 0.0f) {
g = 0.0f;
}
if (g > 1.0f) {
g = 1.0f;
}
if (b < 0.0f) {
b = 0.0f;
}
if (b > 1.0f) {
b = 1.0f;
}
// Convert to 0-255 range // Convert to 0-255 range
RGB->red = (uint8_t)(r * 255.0f); RGB->red = (uint8_t)(r * 255.0f);
+6 -2
View File
@@ -155,8 +155,12 @@ esp_err_t led_driver_set_power(led_driver_handle_t handle, bool power)
esp_err_t led_driver_set_RGB(led_driver_handle_t handle) esp_err_t led_driver_set_RGB(led_driver_handle_t handle)
{ {
TFT_fillWindow(TFT_BLACK); TFT_fillWindow(TFT_BLACK);
TFT_fillCircle(DisplayWidth / 2, DisplayHeight / 2, DisplayWidth / 4, (color_t){mRGB.red, mRGB.green, mRGB.blue}); TFT_fillCircle(DisplayWidth / 2, DisplayHeight / 2, DisplayWidth / 4, (color_t) {
TFT_drawCircle(DisplayWidth / 2, DisplayHeight / 2, DisplayWidth / 4, (color_t){255, 255, 255}); mRGB.red, mRGB.green, mRGB.blue
});
TFT_drawCircle(DisplayWidth / 2, DisplayHeight / 2, DisplayWidth / 4, (color_t) {
255, 255, 255
});
return ESP_OK; return ESP_OK;
} }
@@ -58,23 +58,24 @@ chip::Protocols::InteractionModel::Status FanDelegateImpl::HandleStep(chip::app:
ESP_LOGI(TAG, "Step received value: %d %d %d", (uint8_t)aDirection, aWrap, aLowestOff); ESP_LOGI(TAG, "Step received value: %d %d %d", (uint8_t)aDirection, aWrap, aLowestOff);
/* Update percent-setting when speed is changed by the step command */ /* Update percent-setting when speed is changed by the step command */
if (aLowestOff) if (aLowestOff) {
lowest = 0; lowest = 0;
else } else {
lowest = 1; lowest = 1;
}
if ((uint8_t)aDirection == 0) { if ((uint8_t)aDirection == 0) {
tmp += 1; tmp += 1;
if (aWrap == 0) { if (aWrap == 0) {
tmp = tmp > max_speed ? max_speed:tmp; tmp = tmp > max_speed ? max_speed : tmp;
} else { } else {
tmp = tmp > max_speed ? lowest:tmp; tmp = tmp > max_speed ? lowest : tmp;
} }
} else if ((uint8_t)aDirection == 1) { } else if ((uint8_t)aDirection == 1) {
tmp -= 1; tmp -= 1;
if (aWrap == 0) { if (aWrap == 0) {
tmp = tmp < lowest ? lowest:tmp; tmp = tmp < lowest ? lowest : tmp;
} else { } else {
tmp = tmp < lowest ? max_speed:tmp; tmp = tmp < lowest ? max_speed : tmp;
} }
} }
val.val.u8 = tmp; val.val.u8 = tmp;
@@ -299,4 +300,3 @@ esp_err_t app_driver_init()
return err; return err;
} }
@@ -56,7 +56,7 @@ using namespace chip::Tracing;
using namespace chip::Tracing::Diagnostics; using namespace chip::Tracing::Diagnostics;
using namespace chip::app::Clusters::DiagnosticLogs; using namespace chip::app::Clusters::DiagnosticLogs;
CircularDiagnosticBuffer diagnosticStorage(endUserBuffer, CONFIG_END_USER_BUFFER_SIZE); CircularDiagnosticBuffer diagnosticStorage(endUserBuffer, CONFIG_END_USER_BUFFER_SIZE);
auto & logProvider = LogProvider::GetInstance(); auto &logProvider = LogProvider::GetInstance();
constexpr uint16_t kRootNodeEndpointId = 0; constexpr uint16_t kRootNodeEndpointId = 0;
#endif // CONFIG_ENABLE_ESP_DIAGNOSTICS_TRACE #endif // CONFIG_ENABLE_ESP_DIAGNOSTICS_TRACE
@@ -108,22 +108,18 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
ESP_LOGI(TAG, "Commissioning window closed"); ESP_LOGI(TAG, "Commissioning window closed");
break; break;
case chip::DeviceLayer::DeviceEventType::kFabricRemoved: case chip::DeviceLayer::DeviceEventType::kFabricRemoved: {
{
ESP_LOGI(TAG, "Fabric removed successfully"); ESP_LOGI(TAG, "Fabric removed successfully");
if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) {
{ chip::CommissioningWindowManager &commissionMgr = chip::Server::GetInstance().GetCommissioningWindowManager();
chip::CommissioningWindowManager & commissionMgr = chip::Server::GetInstance().GetCommissioningWindowManager();
constexpr auto kTimeoutSeconds = chip::System::Clock::Seconds16(k_timeout_seconds); constexpr auto kTimeoutSeconds = chip::System::Clock::Seconds16(k_timeout_seconds);
if (!commissionMgr.IsCommissioningWindowOpen()) if (!commissionMgr.IsCommissioningWindowOpen()) {
{
/* After removing last fabric, this example does not remove the Wi-Fi credentials /* After removing last fabric, this example does not remove the Wi-Fi credentials
* and still has IP connectivity so, only advertising on DNS-SD. * and still has IP connectivity so, only advertising on DNS-SD.
*/ */
CHIP_ERROR err = commissionMgr.OpenBasicCommissioningWindow(kTimeoutSeconds, CHIP_ERROR err = commissionMgr.OpenBasicCommissioningWindow(kTimeoutSeconds,
chip::CommissioningWindowAdvertisement::kDnssdOnly); chip::CommissioningWindowAdvertisement::kDnssdOnly);
if (err != CHIP_NO_ERROR) if (err != CHIP_NO_ERROR) {
{
ESP_LOGE(TAG, "Failed to open commissioning window, err:%" CHIP_ERROR_FORMAT, err.Format()); ESP_LOGE(TAG, "Failed to open commissioning window, err:%" CHIP_ERROR_FORMAT, err.Format());
} }
} }
@@ -138,12 +138,11 @@ esp_err_t app_driver_init();
#endif // CONFIG_OPENTHREAD_BORDER_ROUTER #endif // CONFIG_OPENTHREAD_BORDER_ROUTER
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S3 #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S3
class FanDelegateImpl:public chip::app::Clusters::FanControl::Delegate class FanDelegateImpl: public chip::app::Clusters::FanControl::Delegate {
{
public: public:
// Constructor to match the base class design, however endpoint_id set here is not being using at all. // Constructor to match the base class design, however endpoint_id set here is not being using at all.
// FanControlDelegateInitCB sets the delegate on correct endpoint while initialization. // FanControlDelegateInitCB sets the delegate on correct endpoint while initialization.
FanDelegateImpl():Delegate(chip::kInvalidEndpointId) {} FanDelegateImpl(): Delegate(chip::kInvalidEndpointId) {}
chip::Protocols::InteractionModel::Status HandleStep(chip::app::Clusters::FanControl::StepDirectionEnum aDirection, bool aWrap, bool aLowestOff); chip::Protocols::InteractionModel::Status HandleStep(chip::app::Clusters::FanControl::StepDirectionEnum aDirection, bool aWrap, bool aLowestOff);
}; };
@@ -79,7 +79,7 @@ struct device_type_name {
const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = { const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = {
{"on_off_light", ESP_MATTER_ON_OFF_LIGHT}, {"on_off_light", ESP_MATTER_ON_OFF_LIGHT},
{"dimmable_light", ESP_MATTER_DIMMABLE_LIGHT}, {"dimmable_light", ESP_MATTER_DIMMABLE_LIGHT},
{"color_temperature_light",ESP_MATTER_COLOR_TEMP_LIGHT}, {"color_temperature_light", ESP_MATTER_COLOR_TEMP_LIGHT},
{"extended_color_light", ESP_MATTER_EXTENDED_COLOR_LIGHT}, {"extended_color_light", ESP_MATTER_EXTENDED_COLOR_LIGHT},
{"on_off_light_switch", ESP_MATTER_ON_OFF_LIGHT_SWITCH}, {"on_off_light_switch", ESP_MATTER_ON_OFF_LIGHT_SWITCH},
{"dimmer_switch", ESP_MATTER_DIMMER_SWITCH}, {"dimmer_switch", ESP_MATTER_DIMMER_SWITCH},
@@ -219,7 +219,7 @@ esp_err_t hal_bldc_set_fanmode(uint8_t status)
esp_err_t hal_bldc_set_percent_speed(uint16_t percent) esp_err_t hal_bldc_set_percent_speed(uint16_t percent)
{ {
percent = percent > 100 ? 0:percent; percent = percent > 100 ? 0 : percent;
motor_parameter.target_speed = (uint16_t)(percent * DEFAULT_SPEED_MAX * 0.01 * DEFAULT_SPEED2MOTOR); motor_parameter.target_speed = (uint16_t)(percent * DEFAULT_SPEED_MAX * 0.01 * DEFAULT_SPEED2MOTOR);
motor_parameter.target_speed = LIMIT(motor_parameter.target_speed, motor_parameter.min_speed, motor_parameter.max_speed); motor_parameter.target_speed = LIMIT(motor_parameter.target_speed, motor_parameter.min_speed, motor_parameter.max_speed);
if (percent != 0) { if (percent != 0) {
@@ -61,15 +61,15 @@ esp_err_t hal_stepper_motor_init(gpio_num_t pin_1, gpio_num_t pin_2, gpio_num_t
esp_err_t hal_stepper_motor_set_rock(int status) esp_err_t hal_stepper_motor_set_rock(int status)
{ {
uint8_t bldc_status = hal_bldc_status(); uint8_t bldc_status = hal_bldc_status();
if(status == 0) { if (status == 0) {
// close // close
stepper_motor.is_start = 0; stepper_motor.is_start = 0;
} else if ((status == 1 || status == 3 || status == 5 || status == 7) && bldc_status != 0) { } else if ((status == 1 || status == 3 || status == 5 || status == 7) && bldc_status != 0) {
// RockLeftRight // RockLeftRight
stepper_motor.is_start = 1; stepper_motor.is_start = 1;
} else if ((status == 2 || status == 6) && bldc_status !=0) { } else if ((status == 2 || status == 6) && bldc_status != 0) {
// UpDown // UpDown
} else if (status == 4 && bldc_status !=0) { } else if (status == 4 && bldc_status != 0) {
// Round // Round
} }
return ESP_OK; return ESP_OK;
@@ -82,7 +82,7 @@ esp_err_t hal_bldc_set_wind(uint8_t status);
* @param status, aWrap, aLowestOff * @param status, aWrap, aLowestOff
* @return esp_err_t * @return esp_err_t
*/ */
esp_err_t hal_bldc_set_step(uint8_t status,bool aWrap,bool aLowestOff); esp_err_t hal_bldc_set_step(uint8_t status, bool aWrap, bool aLowestOff);
/** /**
* @brief set bldc direction * @brief set bldc direction
@@ -37,12 +37,12 @@ static std::unique_ptr<ElectricalPowerMeasurementDelegate> gEPMDelegate;
// Global pointer to our ElectricalPowerMeasurementInstance // Global pointer to our ElectricalPowerMeasurementInstance
static std::unique_ptr<ElectricalPowerMeasurement::Instance> gEPMInstance; static std::unique_ptr<ElectricalPowerMeasurement::Instance> gEPMInstance;
CHIP_ERROR PowerTopology::PowerTopologyDelegate::GetAvailableEndpointAtIndex(size_t index, EndpointId & endpointId) CHIP_ERROR PowerTopology::PowerTopologyDelegate::GetAvailableEndpointAtIndex(size_t index, EndpointId &endpointId)
{ {
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
} }
CHIP_ERROR PowerTopology::PowerTopologyDelegate::GetActiveEndpointAtIndex(size_t index, EndpointId & endpointId) CHIP_ERROR PowerTopology::PowerTopologyDelegate::GetActiveEndpointAtIndex(size_t index, EndpointId &endpointId)
{ {
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
} }
@@ -348,7 +348,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::StartAccuracyRead()
return CHIP_NO_ERROR; return CHIP_NO_ERROR;
} }
CHIP_ERROR ElectricalPowerMeasurementDelegate::GetAccuracyByIndex(uint8_t index, Structs::MeasurementAccuracyStruct::Type & accuracy) CHIP_ERROR ElectricalPowerMeasurementDelegate::GetAccuracyByIndex(uint8_t index, Structs::MeasurementAccuracyStruct::Type &accuracy)
{ {
if (index >= MATTER_ARRAY_SIZE(kMeasurementAccuracies)) { if (index >= MATTER_ARRAY_SIZE(kMeasurementAccuracies)) {
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
@@ -370,7 +370,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::StartRangesRead()
return CHIP_NO_ERROR; return CHIP_NO_ERROR;
} }
CHIP_ERROR ElectricalPowerMeasurementDelegate::GetRangeByIndex(uint8_t index, Structs::MeasurementRangeStruct::Type & range) CHIP_ERROR ElectricalPowerMeasurementDelegate::GetRangeByIndex(uint8_t index, Structs::MeasurementRangeStruct::Type &range)
{ {
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
} }
@@ -387,7 +387,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::StartHarmonicCurrentsRead()
return CHIP_NO_ERROR; return CHIP_NO_ERROR;
} }
CHIP_ERROR ElectricalPowerMeasurementDelegate::GetHarmonicCurrentsByIndex(uint8_t index, Structs::HarmonicMeasurementStruct::Type & harmonics) CHIP_ERROR ElectricalPowerMeasurementDelegate::GetHarmonicCurrentsByIndex(uint8_t index, Structs::HarmonicMeasurementStruct::Type &harmonics)
{ {
if (index >= MATTER_ARRAY_SIZE(kHarmonicCurrentMeasurements)) { if (index >= MATTER_ARRAY_SIZE(kHarmonicCurrentMeasurements)) {
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
@@ -409,7 +409,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::StartHarmonicPhasesRead()
return CHIP_NO_ERROR; return CHIP_NO_ERROR;
} }
CHIP_ERROR ElectricalPowerMeasurementDelegate::GetHarmonicPhasesByIndex(uint8_t index, Structs::HarmonicMeasurementStruct::Type & harmonics) CHIP_ERROR ElectricalPowerMeasurementDelegate::GetHarmonicPhasesByIndex(uint8_t index, Structs::HarmonicMeasurementStruct::Type &harmonics)
{ {
if (index >= MATTER_ARRAY_SIZE(kHarmonicPhaseMeasurements)) { if (index >= MATTER_ARRAY_SIZE(kHarmonicPhaseMeasurements)) {
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
@@ -430,14 +430,12 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetPowerMode(PowerModeEnum newVal
{ {
PowerModeEnum oldValue = mPowerMode; PowerModeEnum oldValue = mPowerMode;
if (EnsureKnownEnumValue(newValue) == PowerModeEnum::kUnknownEnumValue) if (EnsureKnownEnumValue(newValue) == PowerModeEnum::kUnknownEnumValue) {
{
return CHIP_IM_GLOBAL_STATUS(ConstraintError); return CHIP_IM_GLOBAL_STATUS(ConstraintError);
} }
mPowerMode = newValue; mPowerMode = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
ChipLogDetail(AppServer, "mPowerMode updated to %d", static_cast<int>(mPowerMode)); ChipLogDetail(AppServer, "mPowerMode updated to %d", static_cast<int>(mPowerMode));
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, PowerMode::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, PowerMode::Id);
} }
@@ -450,8 +448,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetVoltage(DataModel::Nullable<in
DataModel::Nullable<int64_t> oldValue = mVoltage; DataModel::Nullable<int64_t> oldValue = mVoltage;
mVoltage = newValue; mVoltage = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, Voltage::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, Voltage::Id);
} }
@@ -464,8 +461,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetActiveCurrent(DataModel::Nulla
DataModel::Nullable<int64_t> oldValue = mActiveCurrent; DataModel::Nullable<int64_t> oldValue = mActiveCurrent;
mActiveCurrent = newValue; mActiveCurrent = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ActiveCurrent::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ActiveCurrent::Id);
} }
@@ -478,8 +474,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetReactiveCurrent(DataModel::Nul
DataModel::Nullable<int64_t> oldValue = mReactiveCurrent; DataModel::Nullable<int64_t> oldValue = mReactiveCurrent;
mReactiveCurrent = newValue; mReactiveCurrent = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ReactiveCurrent::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ReactiveCurrent::Id);
} }
@@ -492,8 +487,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetApparentCurrent(DataModel::Nul
DataModel::Nullable<int64_t> oldValue = mApparentCurrent; DataModel::Nullable<int64_t> oldValue = mApparentCurrent;
mApparentCurrent = newValue; mApparentCurrent = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ApparentCurrent::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ApparentCurrent::Id);
} }
@@ -506,8 +500,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetActivePower(DataModel::Nullabl
DataModel::Nullable<int64_t> oldValue = mActivePower; DataModel::Nullable<int64_t> oldValue = mActivePower;
mActivePower = newValue; mActivePower = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ActivePower::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ActivePower::Id);
} }
@@ -520,8 +513,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetReactivePower(DataModel::Nulla
DataModel::Nullable<int64_t> oldValue = mReactivePower; DataModel::Nullable<int64_t> oldValue = mReactivePower;
mReactivePower = newValue; mReactivePower = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ReactivePower::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ReactivePower::Id);
} }
@@ -534,8 +526,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetApparentPower(DataModel::Nulla
DataModel::Nullable<int64_t> oldValue = mApparentPower; DataModel::Nullable<int64_t> oldValue = mApparentPower;
mApparentPower = newValue; mApparentPower = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ApparentPower::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, ApparentPower::Id);
} }
@@ -548,8 +539,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetRMSVoltage(DataModel::Nullable
DataModel::Nullable<int64_t> oldValue = mRMSVoltage; DataModel::Nullable<int64_t> oldValue = mRMSVoltage;
mRMSVoltage = newValue; mRMSVoltage = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, RMSVoltage::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, RMSVoltage::Id);
} }
@@ -562,8 +552,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetRMSCurrent(DataModel::Nullable
DataModel::Nullable<int64_t> oldValue = mRMSCurrent; DataModel::Nullable<int64_t> oldValue = mRMSCurrent;
mRMSCurrent = newValue; mRMSCurrent = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, RMSCurrent::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, RMSCurrent::Id);
} }
@@ -576,8 +565,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetRMSPower(DataModel::Nullable<i
DataModel::Nullable<int64_t> oldValue = mRMSPower; DataModel::Nullable<int64_t> oldValue = mRMSPower;
mRMSPower = newValue; mRMSPower = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, RMSPower::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, RMSPower::Id);
} }
@@ -590,8 +578,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetFrequency(DataModel::Nullable<
DataModel::Nullable<int64_t> oldValue = mFrequency; DataModel::Nullable<int64_t> oldValue = mFrequency;
mFrequency = newValue; mFrequency = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, Frequency::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, Frequency::Id);
} }
@@ -604,8 +591,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetPowerFactor(DataModel::Nullabl
DataModel::Nullable<int64_t> oldValue = mPowerFactor; DataModel::Nullable<int64_t> oldValue = mPowerFactor;
mPowerFactor = newValue; mPowerFactor = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, PowerFactor::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, PowerFactor::Id);
} }
@@ -618,8 +604,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetNeutralCurrent(DataModel::Null
DataModel::Nullable<int64_t> oldValue = mNeutralCurrent; DataModel::Nullable<int64_t> oldValue = mNeutralCurrent;
mNeutralCurrent = newValue; mNeutralCurrent = newValue;
if (oldValue != newValue) if (oldValue != newValue) {
{
// We won't log raw values since these could change frequently // We won't log raw values since these could change frequently
MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, NeutralCurrent::Id); MatterReportingAttributeChangeCallback(mEndpointId, ElectricalPowerMeasurement::Id, NeutralCurrent::Id);
} }
@@ -56,17 +56,14 @@ namespace app {
namespace Clusters { namespace Clusters {
namespace PowerTopology { namespace PowerTopology {
class PowerTopologyDelegate : public Delegate class PowerTopologyDelegate : public Delegate {
{
public: public:
~PowerTopologyDelegate() = default; ~PowerTopologyDelegate() = default;
CHIP_ERROR GetAvailableEndpointAtIndex(size_t index, EndpointId & endpointId) override; CHIP_ERROR GetAvailableEndpointAtIndex(size_t index, EndpointId &endpointId) override;
CHIP_ERROR GetActiveEndpointAtIndex(size_t index, EndpointId & endpointId) override; CHIP_ERROR GetActiveEndpointAtIndex(size_t index, EndpointId &endpointId) override;
}; };
} // namespace PowerTopology } // namespace PowerTopology
} // namespace Clusters } // namespace Clusters
} // namespace app } // namespace app
@@ -80,8 +77,7 @@ namespace app {
namespace Clusters { namespace Clusters {
namespace ElectricalPowerMeasurement { namespace ElectricalPowerMeasurement {
class ElectricalPowerMeasurementDelegate : public ElectricalPowerMeasurement::Delegate class ElectricalPowerMeasurementDelegate : public ElectricalPowerMeasurement::Delegate {
{
public: public:
~ElectricalPowerMeasurementDelegate() = default; ~ElectricalPowerMeasurementDelegate() = default;
@@ -89,7 +85,10 @@ public:
static constexpr uint8_t kDefaultNumberOfMeasurementTypes = 1; static constexpr uint8_t kDefaultNumberOfMeasurementTypes = 1;
// Attribute Accessors // Attribute Accessors
PowerModeEnum GetPowerMode() override { return mPowerMode; } PowerModeEnum GetPowerMode() override
{
return mPowerMode;
}
uint8_t GetNumberOfMeasurementTypes() override; uint8_t GetNumberOfMeasurementTypes() override;
/* These functions are called by the ReadAttribute handler to iterate through lists /* These functions are called by the ReadAttribute handler to iterate through lists
@@ -114,19 +113,58 @@ public:
CHIP_ERROR GetHarmonicPhasesByIndex(uint8_t, Structs::HarmonicMeasurementStruct::Type &) override; CHIP_ERROR GetHarmonicPhasesByIndex(uint8_t, Structs::HarmonicMeasurementStruct::Type &) override;
CHIP_ERROR EndHarmonicPhasesRead() override; CHIP_ERROR EndHarmonicPhasesRead() override;
DataModel::Nullable<int64_t> GetVoltage() override { return mVoltage; } DataModel::Nullable<int64_t> GetVoltage() override
DataModel::Nullable<int64_t> GetActiveCurrent() override { return mActiveCurrent; } {
DataModel::Nullable<int64_t> GetReactiveCurrent() override { return mReactiveCurrent; } return mVoltage;
DataModel::Nullable<int64_t> GetApparentCurrent() override { return mApparentCurrent; } }
DataModel::Nullable<int64_t> GetActivePower() override { return mActivePower; } DataModel::Nullable<int64_t> GetActiveCurrent() override
DataModel::Nullable<int64_t> GetReactivePower() override { return mReactivePower; } {
DataModel::Nullable<int64_t> GetApparentPower() override { return mApparentPower; } return mActiveCurrent;
DataModel::Nullable<int64_t> GetRMSVoltage() override { return mRMSVoltage; } }
DataModel::Nullable<int64_t> GetRMSCurrent() override { return mRMSCurrent; } DataModel::Nullable<int64_t> GetReactiveCurrent() override
DataModel::Nullable<int64_t> GetRMSPower() override { return mRMSPower; } {
DataModel::Nullable<int64_t> GetFrequency() override { return mFrequency; } return mReactiveCurrent;
DataModel::Nullable<int64_t> GetPowerFactor() override { return mPowerFactor; } }
DataModel::Nullable<int64_t> GetNeutralCurrent() override { return mNeutralCurrent; }; DataModel::Nullable<int64_t> GetApparentCurrent() override
{
return mApparentCurrent;
}
DataModel::Nullable<int64_t> GetActivePower() override
{
return mActivePower;
}
DataModel::Nullable<int64_t> GetReactivePower() override
{
return mReactivePower;
}
DataModel::Nullable<int64_t> GetApparentPower() override
{
return mApparentPower;
}
DataModel::Nullable<int64_t> GetRMSVoltage() override
{
return mRMSVoltage;
}
DataModel::Nullable<int64_t> GetRMSCurrent() override
{
return mRMSCurrent;
}
DataModel::Nullable<int64_t> GetRMSPower() override
{
return mRMSPower;
}
DataModel::Nullable<int64_t> GetFrequency() override
{
return mFrequency;
}
DataModel::Nullable<int64_t> GetPowerFactor() override
{
return mPowerFactor;
}
DataModel::Nullable<int64_t> GetNeutralCurrent() override
{
return mNeutralCurrent;
};
// Internal Application API to set attribute values // Internal Application API to set attribute values
CHIP_ERROR SetPowerMode(PowerModeEnum); CHIP_ERROR SetPowerMode(PowerModeEnum);
@@ -162,10 +200,9 @@ private:
DataModel::Nullable<int64_t> mNeutralCurrent; DataModel::Nullable<int64_t> mNeutralCurrent;
}; };
class ElectricalPowerMeasurementInstance : public Instance class ElectricalPowerMeasurementInstance : public Instance {
{
public: public:
ElectricalPowerMeasurementInstance(EndpointId aEndpointId, ElectricalPowerMeasurementDelegate & aDelegate, Feature aFeature, ElectricalPowerMeasurementInstance(EndpointId aEndpointId, ElectricalPowerMeasurementDelegate &aDelegate, Feature aFeature,
OptionalAttributes aOptionalAttributes) : OptionalAttributes aOptionalAttributes) :
ElectricalPowerMeasurement::Instance(aEndpointId, aDelegate, aFeature, aOptionalAttributes) ElectricalPowerMeasurement::Instance(aEndpointId, aDelegate, aFeature, aOptionalAttributes)
{ {
@@ -175,12 +212,15 @@ public:
// Delete copy constructor and assignment operator. // Delete copy constructor and assignment operator.
ElectricalPowerMeasurementInstance(const ElectricalPowerMeasurementInstance &) = delete; ElectricalPowerMeasurementInstance(const ElectricalPowerMeasurementInstance &) = delete;
ElectricalPowerMeasurementInstance(const ElectricalPowerMeasurementInstance &&) = delete; ElectricalPowerMeasurementInstance(const ElectricalPowerMeasurementInstance &&) = delete;
ElectricalPowerMeasurementInstance & operator=(const ElectricalPowerMeasurementInstance &) = delete; ElectricalPowerMeasurementInstance &operator=(const ElectricalPowerMeasurementInstance &) = delete;
CHIP_ERROR Init(); CHIP_ERROR Init();
void Shutdown(); void Shutdown();
ElectricalPowerMeasurementDelegate * GetDelegate() { return mDelegate; }; ElectricalPowerMeasurementDelegate * GetDelegate()
{
return mDelegate;
};
private: private:
ElectricalPowerMeasurementDelegate * mDelegate; ElectricalPowerMeasurementDelegate * mDelegate;
@@ -117,8 +117,8 @@ static void initialize_console(void)
uart_port_t uart_port = UART_NUM_1; uart_port_t uart_port = UART_NUM_1;
#endif #endif
/* Install UART driver for interrupt-driven reads and writes */ /* Install UART driver for interrupt-driven reads and writes */
ESP_ERROR_CHECK( uart_driver_install(uart_port, 256, 0, 0, NULL, 0) ); ESP_ERROR_CHECK(uart_driver_install(uart_port, 256, 0, 0, NULL, 0));
ESP_ERROR_CHECK( uart_param_config(uart_port, &uart_config) ); ESP_ERROR_CHECK(uart_param_config(uart_port, &uart_config));
/* Tell VFS to use UART driver */ /* Tell VFS to use UART driver */
esp_vfs_dev_uart_use_driver(CONFIG_ESP_CONSOLE_UART_NUM); esp_vfs_dev_uart_use_driver(CONFIG_ESP_CONSOLE_UART_NUM);
@@ -145,7 +145,7 @@ static void initialize_console(void)
.max_cmdline_length = 256, .max_cmdline_length = 256,
.max_cmdline_args = 8, .max_cmdline_args = 8,
}; };
ESP_ERROR_CHECK( esp_console_init(&console_config) ); ESP_ERROR_CHECK(esp_console_init(&console_config));
/* Configure linenoise line completion library */ /* Configure linenoise line completion library */
/* Enable multiline editing. If not set, long commands will scroll within /* Enable multiline editing. If not set, long commands will scroll within
@@ -184,7 +184,7 @@ int create(uint8_t device_type_index)
esp_err_t err = ESP_OK; esp_err_t err = ESP_OK;
esp_matter::node_t *node = node::get(); esp_matter::node_t *node = node::get();
esp_matter::endpoint_t *endpoint = NULL; esp_matter::endpoint_t *endpoint = NULL;
switch(device_type_index) { switch (device_type_index) {
case ESP_MATTER_ON_OFF_LIGHT: { case ESP_MATTER_ON_OFF_LIGHT: {
esp_matter::endpoint::on_off_light::config_t light_config; esp_matter::endpoint::on_off_light::config_t light_config;
endpoint = esp_matter::endpoint::on_off_light::create(node, &light_config, ENDPOINT_FLAG_NONE, NULL); endpoint = esp_matter::endpoint::on_off_light::create(node, &light_config, ENDPOINT_FLAG_NONE, NULL);
@@ -238,10 +238,10 @@ int create(uint8_t device_type_index)
} }
case ESP_MATTER_FAN: { case ESP_MATTER_FAN: {
esp_matter::endpoint::fan::config_t fan_config; esp_matter::endpoint::fan::config_t fan_config;
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S3 #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S3
static FanDelegateImpl fan_delegate; static FanDelegateImpl fan_delegate;
fan_config.fan_control.delegate = &fan_delegate; fan_config.fan_control.delegate = &fan_delegate;
#endif #endif
endpoint = esp_matter::endpoint::fan::create(node, &fan_config, ENDPOINT_FLAG_NONE, NULL); endpoint = esp_matter::endpoint::fan::create(node, &fan_config, ENDPOINT_FLAG_NONE, NULL);
cluster_t *cluster = cluster::get(endpoint, chip::app::Clusters::FanControl::Id); cluster_t *cluster = cluster::get(endpoint, chip::app::Clusters::FanControl::Id);
cluster::fan_control::feature::multi_speed::config_t multispeed_config; cluster::fan_control::feature::multi_speed::config_t multispeed_config;
@@ -545,7 +545,7 @@ int create(uint8_t device_type_index)
#ifdef CONFIG_OPENTHREAD_BORDER_ROUTER #ifdef CONFIG_OPENTHREAD_BORDER_ROUTER
case ESP_MATTER_THREAD_BORDER_ROUTER: { case ESP_MATTER_THREAD_BORDER_ROUTER: {
static chip::KvsPersistentStorageDelegate tbr_storage_delegate; static chip::KvsPersistentStorageDelegate tbr_storage_delegate;
chip::DeviceLayer::PersistedStorage::KeyValueStoreManager & kvsManager = chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr(); chip::DeviceLayer::PersistedStorage::KeyValueStoreManager &kvsManager = chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr();
tbr_storage_delegate.Init(&kvsManager); tbr_storage_delegate.Init(&kvsManager);
GenericOpenThreadBorderRouterDelegate *delegate = chip::Platform::New<GenericOpenThreadBorderRouterDelegate>(&tbr_storage_delegate); GenericOpenThreadBorderRouterDelegate *delegate = chip::Platform::New<GenericOpenThreadBorderRouterDelegate>(&tbr_storage_delegate);
if (!delegate) { if (!delegate) {
@@ -681,15 +681,15 @@ int create(uint8_t device_type_index)
return 1; return 1;
} else { } else {
ESP_LOGI(TAG, "%s created with endpoint_id %d", device_type_list[device_type_index - 1].device_name, endpoint::get_id(endpoint)); ESP_LOGI(TAG, "%s created with endpoint_id %d", device_type_list[device_type_index - 1].device_name, endpoint::get_id(endpoint));
if(esp_matter::nvs_helpers::get_device_type_from_nvs(&device_type_index) != ESP_OK) { if (esp_matter::nvs_helpers::get_device_type_from_nvs(&device_type_index) != ESP_OK) {
err = esp_matter::nvs_helpers::set_device_type_in_nvs(device_type_index); err = esp_matter::nvs_helpers::set_device_type_in_nvs(device_type_index);
if(err != ESP_OK) { if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to store device type in nvs"); ESP_LOGE(TAG, "Failed to store device type in nvs");
return 1; return 1;
} }
} }
if(semaphoreHandle) { if (semaphoreHandle) {
xSemaphoreGive(semaphoreHandle); xSemaphoreGive(semaphoreHandle);
} }
} }
@@ -704,10 +704,10 @@ namespace example {
namespace console { namespace console {
/** Arguments used by 'create' function */ /** Arguments used by 'create' function */
static struct { static struct {
struct arg_str *device_type; struct arg_str *device_type;
struct arg_end *end; struct arg_end *end;
} create_device_args; } create_device_args;
static int create(int argc, char **argv) static int create(int argc, char **argv)
{ {
@@ -715,7 +715,7 @@ static int create(int argc, char **argv)
if (nerrors != 0) { if (nerrors != 0) {
arg_print_errors(stderr, create_device_args.end, argv[0]); arg_print_errors(stderr, create_device_args.end, argv[0]);
ESP_LOGI(TAG, "Please use: create --device_type=device_type where device type can be anyone from the below list:"); ESP_LOGI(TAG, "Please use: create --device_type=device_type where device type can be anyone from the below list:");
for(int traverse=0; traverse < ESP_MATTER_DEVICE_TYPE_MAX - 1 ; traverse++) { for (int traverse = 0; traverse < ESP_MATTER_DEVICE_TYPE_MAX - 1 ; traverse++) {
ESP_LOGI("", "%s", device_type_list[traverse].device_name); ESP_LOGI("", "%s", device_type_list[traverse].device_name);
} }
return 1; return 1;
@@ -723,8 +723,8 @@ static int create(int argc, char **argv)
uint8_t index = 0; uint8_t index = 0;
std::string str = create_device_args.device_type->sval[0]; std::string str = create_device_args.device_type->sval[0];
for(int traverse=0; traverse < ESP_MATTER_DEVICE_TYPE_MAX - 1 ; traverse++) { for (int traverse = 0; traverse < ESP_MATTER_DEVICE_TYPE_MAX - 1 ; traverse++) {
if(device_type_list[traverse].device_name == str) { if (device_type_list[traverse].device_name == str) {
index = device_type_list[traverse].device_id; index = device_type_list[traverse].device_id;
break; break;
} }
@@ -778,15 +778,13 @@ void init(void)
#endif //CONFIG_LOG_COLORS #endif //CONFIG_LOG_COLORS
} }
/* Main loop */ /* Main loop */
while(true) { while (true) {
/* Get a line using linenoise. /* Get a line using linenoise.
* The line is returned when ENTER is pressed. * The line is returned when ENTER is pressed.
*/ */
char* line = linenoise(prompt); char* line = linenoise(prompt);
if (line == NULL) { /* Break on EOF or error */ if (line == NULL) { /* Break on EOF or error */
continue; continue;
} }
+4 -5
View File
@@ -8,19 +8,18 @@
#pragma once #pragma once
namespace esp_matter { namespace esp_matter {
namespace data_model { namespace data_model {
int create(uint8_t device_type_index); int create(uint8_t device_type_index);
} /* namespace data_model */ } /* namespace data_model */
namespace nvs_helpers { namespace nvs_helpers {
esp_err_t set_device_type_in_nvs(uint8_t device_type_index); esp_err_t set_device_type_in_nvs(uint8_t device_type_index);
esp_err_t get_device_type_from_nvs(uint8_t *device_type_index); esp_err_t get_device_type_from_nvs(uint8_t *device_type_index);
} /* namespace nvs_helpers */ } /* namespace nvs_helpers */
} /* namespace esp_matter */ } /* namespace esp_matter */
@@ -50,4 +49,4 @@ void init(void);
void deinit(void); void deinit(void);
} /* namespace console */ } /* namespace console */
} /* namepsace example */ } /* namespace example */
@@ -21,29 +21,29 @@ void MockAccountLoginDelegate::SetSetupPin(char * setupPin)
ESP_LOGE(LOG_TAG, "%s is not implemented", __func__); ESP_LOGE(LOG_TAG, "%s is not implemented", __func__);
} }
bool MockAccountLoginDelegate::HandleLogin(const chip::CharSpan & tempAccountIdentifierString, const chip::CharSpan & setupPinString, bool MockAccountLoginDelegate::HandleLogin(const chip::CharSpan &tempAccountIdentifierString, const chip::CharSpan &setupPinString,
const chip::Optional<NodeId> & nodeId) const chip::Optional<NodeId> &nodeId)
{ {
// Implement your own logic here. // Implement your own logic here.
ESP_LOGE(LOG_TAG, "%s is not implemented", __func__); ESP_LOGE(LOG_TAG, "%s is not implemented", __func__);
return true; return true;
} }
bool MockAccountLoginDelegate::HandleLogout(const chip::Optional<NodeId> & nodeId) bool MockAccountLoginDelegate::HandleLogout(const chip::Optional<NodeId> &nodeId)
{ {
// Implement your own logic here. // Implement your own logic here.
ESP_LOGE(LOG_TAG, "%s is not implemented", __func__); ESP_LOGE(LOG_TAG, "%s is not implemented", __func__);
return true; return true;
} }
void MockAccountLoginDelegate::HandleGetSetupPin(CommandResponseHelper<Commands::GetSetupPINResponse::Type> & helper, void MockAccountLoginDelegate::HandleGetSetupPin(CommandResponseHelper<Commands::GetSetupPINResponse::Type> &helper,
const chip::CharSpan & tempAccountIdentifierString) const chip::CharSpan &tempAccountIdentifierString)
{ {
// Implement your own logic here. // Implement your own logic here.
ESP_LOGE(LOG_TAG, "%s is not implemented", __func__); ESP_LOGE(LOG_TAG, "%s is not implemented", __func__);
} }
void MockAccountLoginDelegate::GetSetupPin(char * setupPin, size_t setupPinSize, const chip::CharSpan & tempAccountIdentifierString) void MockAccountLoginDelegate::GetSetupPin(char * setupPin, size_t setupPinSize, const chip::CharSpan &tempAccountIdentifierString)
{ {
// Implement your own logic here. // Implement your own logic here.
ESP_LOGE(LOG_TAG, "%s is not implemented", __func__); ESP_LOGE(LOG_TAG, "%s is not implemented", __func__);
@@ -27,18 +27,17 @@ namespace app {
namespace Clusters { namespace Clusters {
namespace AccountLogin { namespace AccountLogin {
class MockAccountLoginDelegate : public Delegate class MockAccountLoginDelegate : public Delegate {
{
public: public:
MockAccountLoginDelegate() = default; MockAccountLoginDelegate() = default;
void SetSetupPin(char * setupPin) override; void SetSetupPin(char * setupPin) override;
bool HandleLogin(const chip::CharSpan & tempAccountIdentifierString, const chip::CharSpan & setupPinString, bool HandleLogin(const chip::CharSpan &tempAccountIdentifierString, const chip::CharSpan &setupPinString,
const chip::Optional<NodeId> & nodeId) override; const chip::Optional<NodeId> &nodeId) override;
bool HandleLogout(const chip::Optional<NodeId> & nodeId) override; bool HandleLogout(const chip::Optional<NodeId> &nodeId) override;
void HandleGetSetupPin(CommandResponseHelper<Commands::GetSetupPINResponse::Type> & helper, void HandleGetSetupPin(CommandResponseHelper<Commands::GetSetupPINResponse::Type> &helper,
const chip::CharSpan & tempAccountIdentifierString) override; const chip::CharSpan &tempAccountIdentifierString) override;
void GetSetupPin(char * setupPin, size_t setupPinSize, const chip::CharSpan & tempAccountIdentifierString) override; void GetSetupPin(char * setupPin, size_t setupPinSize, const chip::CharSpan &tempAccountIdentifierString) override;
uint16_t GetClusterRevision(chip::EndpointId endpoint) override; uint16_t GetClusterRevision(chip::EndpointId endpoint) override;
private: private:
@@ -17,14 +17,14 @@ namespace Chime {
MockChimeDelegate::~MockChimeDelegate() = default; MockChimeDelegate::~MockChimeDelegate() = default;
CHIP_ERROR MockChimeDelegate::GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t & chimeID, MutableCharSpan & name) CHIP_ERROR MockChimeDelegate::GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t &chimeID, MutableCharSpan &name)
{ {
// Implement your own logic here. // Implement your own logic here.
ESP_LOGE(LOG_TAG, "%s is not implemented", __func__); ESP_LOGE(LOG_TAG, "%s is not implemented", __func__);
return CHIP_NO_ERROR; return CHIP_NO_ERROR;
} }
CHIP_ERROR MockChimeDelegate::GetChimeIDByIndex(uint8_t chimeIndex, uint8_t & chimeID) CHIP_ERROR MockChimeDelegate::GetChimeIDByIndex(uint8_t chimeIndex, uint8_t &chimeID)
{ {
// Implement your own logic here. // Implement your own logic here.
ESP_LOGE(LOG_TAG, "%s is not implemented", __func__); ESP_LOGE(LOG_TAG, "%s is not implemented", __func__);
@@ -23,14 +23,13 @@ namespace app {
namespace Clusters { namespace Clusters {
namespace Chime { namespace Chime {
class MockChimeDelegate : public ChimeDelegate class MockChimeDelegate : public ChimeDelegate {
{
public: public:
MockChimeDelegate() = default; MockChimeDelegate() = default;
~MockChimeDelegate() override; ~MockChimeDelegate() override;
CHIP_ERROR GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t & chimeID, MutableCharSpan & name) override; CHIP_ERROR GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t &chimeID, MutableCharSpan &name) override;
CHIP_ERROR GetChimeIDByIndex(uint8_t chimeIndex, uint8_t & chimeID) override; CHIP_ERROR GetChimeIDByIndex(uint8_t chimeIndex, uint8_t &chimeID) override;
Protocols::InteractionModel::Status PlayChimeSound() override; Protocols::InteractionModel::Status PlayChimeSound() override;
private: private:
@@ -20,8 +20,7 @@ esp_err_t set_device_type_in_nvs(uint8_t device_type_index)
return err; return err;
} }
err = nvs_set_u8(handle, "device_name", device_type_index); err = nvs_set_u8(handle, "device_name", device_type_index);
if(err == ESP_OK) if (err == ESP_OK) {
{
nvs_commit(handle); nvs_commit(handle);
} }
nvs_close(handle); nvs_close(handle);
@@ -40,4 +39,4 @@ esp_err_t get_device_type_from_nvs(uint8_t *device_type_index)
return err; return err;
} }
} /* namespace nvs_helpers */ } /* namespace nvs_helpers */
} /* namepsace esp_matter */ } /* namespace esp_matter */

Some files were not shown because too many files have changed in this diff Show More