Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ability to create out-of-tree MEI clusters #36818

Draft
wants to merge 30 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f20f644
Ability to create out-of-tree MEI clusters
markus-becker-tridonic-com Dec 12, 2024
e6a4ff0
change for gni based builds
markus-becker-tridonic-com Dec 12, 2024
c56864a
Restyled by clang-format
restyled-commits Dec 12, 2024
4c675db
Restyled by gn
restyled-commits Dec 12, 2024
550f58c
Remove commented code (address review comment)
markus-becker-tridonic-com Jan 10, 2025
6923bb8
Rename from Mei to Manufacturer-specific
markus-becker-tridonic-com Jan 10, 2025
a37e464
zap_regen_all
markus-becker-tridonic-com Jan 10, 2025
adc269b
Some restyles
markus-becker-tridonic-com Jan 10, 2025
62a23dd
Rename kotlin files
markus-becker-tridonic-com Jan 10, 2025
140ff47
Restyled by clang-format
restyled-commits Jan 10, 2025
f1f2648
Restyled by prettier-json
restyled-commits Jan 10, 2025
864e025
Exclude generated Accessors.cpp examples/manufacturer-specific-app fr…
markus-becker-tridonic-com Jan 10, 2025
7787e44
Add an MD file including the
markus-becker-tridonic-com Jan 10, 2025
4ca33c7
Exclude Accessors.cpp also for emberAfWriteAttribute and indent ember…
markus-becker-tridonic-com Jan 10, 2025
0abdfa5
regen again
markus-becker-tridonic-com Jan 10, 2025
ac840e4
Restyled by clang-format
restyled-commits Jan 10, 2025
2822948
ktfmt
markus-becker-tridonic-com Jan 13, 2025
b7b76d7
Add manufacturer-specific-app nrfconnect build step
markus-becker-tridonic-com Jan 13, 2025
a10f99c
remove duplicated/old generated file
markus-becker-tridonic-com Jan 13, 2025
b830097
add PROJECT_APP_COMMON_INC_DIR for telink as well
markus-becker-tridonic-com Jan 13, 2025
08a2d71
correct name of external manufacturer specific cluster filename
markus-becker-tridonic-com Jan 13, 2025
d16850f
remove more commented code.
markus-becker-tridonic-com Jan 13, 2025
1e783c8
Remove duplicated ClusterCluster
markus-becker-tridonic-com Jan 13, 2025
b0d8bb0
regenerated files
markus-becker-tridonic-com Jan 13, 2025
9d9ce81
Fix some remainders of MEI
markus-becker-tridonic-com Jan 14, 2025
3661fb5
Restyled by clang-format
restyled-commits Jan 14, 2025
06f910c
Remove more commented build code
markus-becker-tridonic-com Jan 14, 2025
716d6b4
More changes for the external MS cluster.
markus-becker-tridonic-com Jan 14, 2025
a5bb7ce
zap generate for manufacturer specific sample.
markus-becker-tridonic-com Jan 14, 2025
cffa1b4
Restyled by clang-format
restyled-commits Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/examples-nrfconnect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ jobs:
nrfconnect nrf7002dk_nrf5340_cpuapp all-clusters-app \
examples/all-clusters-app/nrfconnect/build/nrfconnect/zephyr/zephyr.elf \
/tmp/bloat_reports/
- name: Build example nRF Connect SDK Manufacturer Specific App on nRF52840 DK
run: |
scripts/examples/nrfconnect_example.sh manufacturer-specific-app nrf52840dk/nrf52840
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
nrfconnect nrf52840dk_nrf52840 manufacturer-specific-app \
examples/manufacturer-specific-app/nrfconnect/build/nrfconnect/zephyr/zephyr.elf \
/tmp/bloat_reports/
- name: Run unit tests for Zephyr native_posix_64 platform
if: github.event_name == 'push' || steps.changed_paths.outputs.tests == 'true' || steps.changed_paths.outputs.nrfconnect == 'true'
run: |
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,14 @@ jobs:
type-safe getters
if: always()
run: |
git grep -I -n 'emberAfReadAttribute' -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)src/app/util/attribute-table.h' ':(exclude)zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' ':(exclude)src/app/zap-templates/templates/app/attributes/Accessors-src.zapt' ':(exclude)src/app/util/attribute-table.cpp' && exit 1 || exit 0
git grep -I -n 'emberAfReadAttribute' -- './*' \
':(exclude).github/workflows/lint.yml' \
':(exclude)src/app/util/attribute-table.h' \
':(exclude)zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' \
':(exclude)examples/manufacturer-specific-app/nrfconnect/manufacturer-specific/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' \
':(exclude)src/app/zap-templates/templates/app/attributes/Accessors-src.zapt' \
':(exclude)src/app/util/attribute-table.cpp' \
&& exit 1 || exit 0

# git grep exits with 0 if it finds a match, but we want
# to fail (exit nonzero) on match. And we want to exclude this file,
Expand All @@ -292,15 +299,16 @@ jobs:
git grep -I -n 'emberAfWriteAttribute' -- './*' \
':(exclude).github/workflows/lint.yml' \
':(exclude)examples/common/pigweed/rpc_services/Attributes.h' \
':(exclude)src/data-model-providers/codegen/CodegenDataModelProvider_Write.cpp' \
':(exclude)src/data-model-providers/codegen/tests/EmberReadWriteOverride.cpp' \
':(exclude)src/data-model-providers/codegen/CodegenDataModelProvider_Write.cpp' \
':(exclude)src/data-model-providers/codegen/tests/EmberReadWriteOverride.cpp' \
':(exclude)src/app/dynamic_server/DynamicDispatcher.cpp' \
':(exclude)src/app/util/attribute-table.cpp' \
':(exclude)src/app/util/attribute-table.h' \
':(exclude)src/app/util/mock/CodegenEmberMocks.cpp' \
':(exclude)src/app/zap-templates/templates/app/attributes/Accessors-src.zapt' \
':(exclude)src/darwin/Framework/CHIP/ServerEndpoint/MTRIMDispatch.mm' \
':(exclude)zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' \
':(exclude)examples/manufacturer-specific-app/nrfconnect/manufacturer-specific/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' \
&& exit 1 || exit 0

# Run ruff python linter
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ jobs:
src/app/zap-templates/zcl/data-model/chip/temperature-control-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/matter-devices.xml \
src/app/zap-templates/zcl/data-model/chip/resource-monitoring-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/sample-manufacturer-specific-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/electrical-power-measurement-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/zone-management-cluster.xml \
Expand Down
1 change: 0 additions & 1 deletion config/common/cmake/chip_gn.cmake
markus-becker-tridonic-com marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ macro(matter_build target)
${CHIP_ROOT}/third_party/nlassert/repo/include
${CHIP_ROOT}/third_party/nlio/repo/include
${CHIP_ROOT}/third_party/nlfaultinjection/include
${CHIP_ROOT}/zzz_generated/app-common
${CMAKE_CURRENT_BINARY_DIR}/gen/include
)

Expand Down
10 changes: 10 additions & 0 deletions config/common/cmake/chip_gn_args.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ endmacro()
# DEVICE_INFO_EXAMPLE_PROVIDER Add example device info provider support
# PROJECT_CONFIG Path to the project-specific configuration file
# PROJECT_CONFIG_INC_DIR Extra include dirs for project configurations
# PROJECT_APP_COMMON_INC_DIR Extra include dir for custom app-common
#
macro(matter_common_gn_args)
set(options)
Expand All @@ -171,6 +172,7 @@ macro(matter_common_gn_args)
LIB_PW_RPC
DEVICE_INFO_EXAMPLE_PROVIDER
PROJECT_CONFIG
PROJECT_APP_COMMON_INC_DIR
)
set(multiValueArgs
PROJECT_CONFIG_INC_DIR
Expand Down Expand Up @@ -215,6 +217,14 @@ macro(matter_common_gn_args)
if (ARG_PROJECT_CONFIG_INC_DIR)
matter_add_gn_arg_list("chip_project_config_include_dirs" ${ARG_PROJECT_CONFIG_INC_DIR})
endif()
if (ARG_PROJECT_APP_COMMON_INC_DIR)
get_filename_component(PROJECT_APP_COMMON_INC_DIR
${ARG_PROJECT_APP_COMMON_INC_DIR}
REALPATH
BASE_DIR ${CMAKE_SOURCE_DIR}
)
matter_add_gn_arg_string("chip_project_app_common_include_dir" "${PROJECT_APP_COMMON_INC_DIR}")
endif()
endmacro()

# Generate the temporary GN arguments file from the settings
Expand Down
1 change: 1 addition & 0 deletions config/nrfconnect/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ matter_common_gn_args(
LIB_SHELL CONFIG_CHIP_LIB_SHELL
LIB_TESTS CONFIG_CHIP_BUILD_TESTS
PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG}
PROJECT_APP_COMMON_INC_DIR ${CONFIG_CHIP_PROJECT_APP_COMMON_INCLUDE_DIRS}
DEVICE_INFO_EXAMPLE_PROVIDER CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER
)
matter_add_gn_arg_string("zephyr_ar" ${CMAKE_AR})
Expand Down
1 change: 1 addition & 0 deletions config/telink/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ matter_common_gn_args(
LIB_SHELL CONFIG_CHIP_LIB_SHELL
LIB_TESTS CONFIG_CHIP_BUILD_TESTS
PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG}
PROJECT_APP_COMMON_INC_DIR ${CONFIG_CHIP_PROJECT_APP_COMMON_INCLUDE_DIRS}
DEVICE_INFO_EXAMPLE_PROVIDER CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER
)
matter_add_gn_arg_string("zephyr_ar" ${CMAKE_AR})
Expand Down
5 changes: 5 additions & 0 deletions config/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ config CHIP_PROJECT_CONFIG
configuration file that can be used to override any of Matter's default or
platform-specific settings.

config CHIP_PROJECT_APP_COMMON_INCLUDE_DIRS
string "Project specific app-common directory for Manufacturer-specific clusters"
help
Provides a directory to the app-common/ folder.

# Thread network features

config CHIP_ENABLE_DNSSD_SRP
Expand Down
8 changes: 8 additions & 0 deletions docs/examples/manufacturer_specific.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Manufacturer specific cluster

```{toctree}
:glob:
:maxdepth: 1

manufacturer-specific-app/**/README
```
2 changes: 1 addition & 1 deletion docs/ids_and_codes/zap_clusters.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ Generally regenerate using one of:
| 1873 | 0x751 | CommissionerControl |
| 4294048773 | 0xFFF1FC05 | UnitTesting |
| 4294048774 | 0xFFF1FC06 | FaultInjection |
| 4294048800 | 0xFFF1FC20 | SampleMei |
| 4294048800 | 0xFFF1FC20 | SampleManufacturerSpecific |
15 changes: 8 additions & 7 deletions examples/chef/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ To add new devices for chef:
## Manufacturer Extensions / Custom Clusters

You may add vendor-defined features to chef. The
`rootnode_onofflight_meisample*` device showcases its usage by using the Sample
MEI cluster which is defined on
`src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml`
`rootnode_onofflight_manufacturer_specific_sample*` device showcases its usage
by using the Sample Manufacturer-specific cluster which is defined in
`src/app/zap-templates/zcl/data-model/chip/sample-manufacturer-specific-cluster.xml`

This cluster has

Expand All @@ -246,15 +246,16 @@ This cluster has
- A command/response pair `add-arguments`. The command takes two uint8
arguments and the response command returns their sum.

You may test the `Sample MEI` via chip-tool using the following commands:
You may test the `Sample Manufacturer Specific Cluster` via chip-tool using the
following commands:

```
# commissioning of on-network chef device
chip-tool pairing onnetwork 1 20202021
# tests command to sum arguments: returns 30
chip-tool samplemei add-arguments 1 1 10 20
chip-tool sample-manufacturer-specific add-arguments 1 1 10 20
# sets Flip-Flop to false
chip-tool samplemei write flip-flop 0 1 1
chip-tool sample-manufacturer-specific write flip-flop 0 1 1
# reads Flip-Flop
chip-tool samplemei read flip-flop 1 1
chip-tool sample-manufacturer-specific read flip-flop 1 1
```
Original file line number Diff line number Diff line change
Expand Up @@ -1755,8 +1755,8 @@ cluster FixedLabel = 64 {
readonly attribute int16u clusterRevision = 65533;
}

/** The Sample MEI cluster showcases a cluster manufacturer extensions */
cluster SampleMei = 4294048800 {
/** A manufacturer-specific sample cluster */
cluster SampleManufacturerSpecific = 4294048800 {
revision 1; // NOTE: Default/not specifically set

fabric_sensitive info event PingCountEvent = 0 {
Expand Down Expand Up @@ -2082,7 +2082,7 @@ endpoint 1 {
callback attribute clusterRevision;
}

server cluster SampleMei {
server cluster SampleManufacturerSpecific {
emits event PingCountEvent;
ram attribute flipFlop default = false;
callback attribute generatedCommandList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3258,10 +3258,10 @@
"enabled": 1
},
{
"name": "Sample MEI",
"name": "Sample Manufacturer-Specific",
"code": 4294048800,
"mfgCode": null,
"define": "SAMPLE_MEI_CLUSTER",
"define": "SAMPLE_MANUFACTURER_SPECIFIC_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")
import("${chip_root}/src/app/chip_data_model.gni")

config("config") {
include_dirs = [ "include" ]
}

chip_data_model("lighting-common") {
zap_file = "lighting-app.zap"
is_server = true
}

source_set("color-format") {
public_configs = [ ":config" ]
sources = [
"include/ColorFormat.h",
"src/ColorFormat.cpp",
]
}

source_set("lighting-manager") {
deps = [ "${chip_root}/src/lib" ]
public_configs = [ ":config" ]
sources = [
"include/LightingManager.h",
"src/LightingManager.cpp",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <stdint.h>

struct RgbColor_t
{
uint8_t r;
uint8_t g;
uint8_t b;
};

struct HsvColor_t
{
uint8_t h;
uint8_t s;
uint8_t v;
};

struct XyColor_t
{
uint16_t x;
uint16_t y;
};

struct CtColor_t
{
uint16_t ctMireds;
};

RgbColor_t XYToRgb(uint8_t Level, uint16_t currentX, uint16_t currentY);
RgbColor_t HsvToRgb(HsvColor_t hsv);
RgbColor_t CTToRgb(CtColor_t ct);
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <stdbool.h>
#include <stdint.h>

#include <functional>

#include <lib/core/CHIPError.h>

class LightingManager
{
public:
enum Action_t
{
ON_ACTION = 0,
OFF_ACTION,
INVALID_ACTION
} Action;

enum State_t
{
kState_On = 0,
kState_Off,
} State;

CHIP_ERROR Init();
bool IsTurnedOn();
bool InitiateAction(Action_t aAction);

using LightingCallback_fn = std::function<void(Action_t)>;

void SetCallbacks(LightingCallback_fn aActionInitiated_CB, LightingCallback_fn aActionCompleted_CB);

private:
friend LightingManager & LightingMgr(void);
State_t mState;

LightingCallback_fn mActionInitiated_CB;
LightingCallback_fn mActionCompleted_CB;

void Set(bool aOn);

static LightingManager sLight;
};

inline LightingManager & LightingMgr(void)
{
return LightingManager::sLight;
}
Loading
Loading