Skip to content

Commit d55cca4

Browse files
[nxp fromtree] [NXP][k32w1] Rework reference apps (project-chip#34926)
* [NXP][platform][common] Update pw RPC flag in streamer_nxp Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 4ae033a1bddd5d914e862791c111eebca41a62e8) * [NXP][examples][common] Fix binding issue due to generated Zap flag renaming Signed-off-by: Martin Girardot <martin.girardot@nxp.com> (cherry picked from commit b50b382478138ad02103e55194b0145b1e61e841) * [NXP][examples][common] make-pretty update (cherry picked from commit efc51cc65471f4f5f667947ef18a4656e1d29578) * [NXP][examples][common] Fix contact-sensor-app always returning empty diagnostic logs The LogProvider class method GetSizeForIntent() was always returning zero as log size due to an incorrect evaluation of the result of the SyncGetValue() call. GetSizeForIntent() is evaluating the size of the diagnostic log by trying to read the key using a zero length buffer. This action will return the size of the key in storage, but it will also yield a CHIP_ERROR_BUFFER_TOO_SMALL error code. GetSizeForIntent() however was not expecting this error code and it was returning zero in all situations when the status returned by SyncGetValue() was anything else but CHIP_NO_ERROR. The function was updated to take into account that, under these circumstances, the SyncGetValue() function always returns CHIP_ERROR_BUFFER_TOO_SMALL. Signed-off-by: Marian Chereji <marian.chereji@nxp.com> Reviewed-by: Doru-Cristian Gucea <doru-cristian.gucea@nxp.com> (cherry picked from commit dd3b3b784318f73cf6f0390f79d1fdf0160169d3) * [NXP][examples][common] Call init using the base class reference Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit b7a0a0a4d88bd5d03b70f36b34c2475b614bd296) * [NXP][examples][common] Update app task common code New task base API: - PostEventsProcessedAction - this will be called in the main loop, after all events have been processed. An example of concrete action is to animate some LEDs. - PrintOnboardingInfo - the default implementation remains the same. It can be overwritten by the concrete application task class. - AppMatter_DisallowDeviceToSleep/AppMatter_AllowDeviceToSleep - An application that uses low power mode should overwrite the API to implement the allow/disallow entering low power mechanism. Before taking the OT mutex, the device is disallowed to enter low power. The device is allowed to enter low power after the OT mutex is released. Other changes: - The app event queue handle should be static such that the concrete application task can initialize it during Start() call. - The ticksToWait passed to xQueueReceived is used to specify the maximum amount of time the task should block waiting for an event. This can be modified according to the application needs, e.g. is needed by an application that has LED animation. - PostEvent should take into account ISR context when populating the event queue. - PostEvent becomes a static method. - Thread device type is specified by the following flag: CONFIG_THREAD_DEVICE_TYPE This is set by default to kThreadDeviceType_Router. Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit d88e78ea6c973eb736915110bb227ad3515eec98) * [NXP][examples][common] Add additional common components - Add led widget component - Add diagnostic logs component - chip::NXP::App::DiagnosticLogsDemo::DisplayUsage should be implemeneted to showcase how the diagnostic logs provider should be used. - Add low power component - chip::NXP::App::LowPower::Init should be implemented according to the application needs. A default example is implemented, which registers an empty enter/exit low power callback. - Add operational keystore component - the API contains two functions: - GetInstance - should return the address of a concrete operational keystore class - Init - can be used to register a persistent storage delegate in case the concrete class is using persistent storage (which will be our case) - Add user interface feedback component - this component defines an abstract interface that can be implemented by applications in order to provide some kind of feedback to the user in certain conditions: logging, LED animations, etc. Add example of lighting manager, which uses LED animation for user feedback. - Add clusters component - add an API for identify related callbacks. Add implementation for common MatterPostAttributeChangeCallback, which delegates the work to the device manager component. - Add RPC component - this is a simple Init API that can be used to initialize PW RPC related components, such as UART. Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 46a1d3d673b9cae14d33c749e3741727449e6ff9) * [NXP][examples][common] Add missing header in Identify Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 3abfee2c6eea327ae931a150733ac83639d157d5) * [NXP][examples][common] Add multi-image OTA requestor initiator Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 5848e4d4e2d384c4bfe41714bd41e25c4b1ba1e8) * [NXP][examples][common] Update pw RPC implementation Update AppRpc API by adding two new methods used by the common RPC implementation: - ButtonHandler - Reboot Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 5e40934145825c61444e43e479ed7ac5c26605a4) * [NXP][examples][common] Small updates to common app code - Add call to feedback manager init. - Remove PostEventsProcessedAction. Call FeedbackMgr().DisplayInLoop() directly in the main loop. - Move PostEvent in AppTaskBase interface and make it virtual. - Add demo of diagnostic logs usage. - Update PrintOnboardingInfo to take into account user action requried commissioning flow. - Remove usage of deprecated sFunction from Lighting manager. - Add LowPower::Init call. - If FSL_OSA_TASK_ENABLE is used, then call AppTaskMain inside Start, instead of creating the app task. - Add PrintCurrentVersion API to print the software version string and software version. - Enclose DeviceInfoProviderImpl usage based on CONFIG_DEVICE_INFO_PROVIDER_IMPL - Add diagnostic logs cluster init under the corresponding flag. Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 1619c92380275dc0466f9cf9dc9e818671406b06) * [NXP][examples][common] Make Animate pure virtual Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit eaf3789fc2d1e562fe030acc758e5f322b5f02d3) * [NXP][examples][common] Add pw RPC init RPC_TASK_STACK_SIZE and RPC_TASK_PRIORITY can now be defined in the build system to override the default values. Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 7962d612b14502dc3f514c5c3d39891b086cfd63) * [NXP][examples][common] Allow platforms to redefine the path to the FactoryDataProvider.h that needs to be included Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> (cherry picked from commit 097cd999c4767572f8cc55fac18f93ac3cb5d50c) * [NXP][examples][common] Add TestEventTriggerDelegate * TestEventTriggerDelegate is now used at Server Initialization to add the ICDManager instance as Handler Signed-off-by: Andrei Menzopol <andrei.menzopol@nxp.com> (cherry picked from commit edce1dc967130589e74cdd9c8289719171141178) * [NXP][examples][common] Minor updates for some components The KVS wear stats are stored in the user diagnostic log key hence only initialize this key if the KVS wear stats are not enabled. Signed-off-by: Marian Chereji <marian.chereji@nxp.com> [nxp noup][examples][common] Remove UpdateState API The interface can be simplified by calling RestoreState instead of UpdateState when needed. This implies that the caller must update the cluster attribute by itself. Signed-off-by: marius-alex-tache <marius.tache@nxp.com> [nxp noup][examples][common] Rename LightingManager to LedManager Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][examples][common] Add initial version of lighting app - Copy lighting app sources to common folder - Add device callbacks - Use common OTA support - Use common app factory data - Use led widgets for lighting app - Use common app task and button management - Decouple lighting manager from app task - Update LED status function - Update lighting manager related flags Flags: - LIGHTING_MANAGER_ENABLE_DIMMABLE_LED to enable dimmable LED feature - LIGHTING_MANAGER_ENABLE_STATUS_LED to enable status LED usage These flags can be overwritten in AppConfig.h. - Make lighting manager more configurable - Create button manager The ButtonManager class should define the buttons callbacks and all callback delegates. Moved AppMatterButton_registerButtons implementation inside the button manager source file. - Update lighting manager interface - Replace lighting manager calls with feedback manager LightingManager now implements the UserFeedbackInterface abstract class and the dimmable feature was moved to a new class: LightingManagerDimmable. - Move identify code in a separate file - Remove deprecated #include statements from all files. - Add commissioning complete state A boolean static member is added to AppTask. It is set when the kCommissioningComplete event is received. It should be used by other components if they need a way to check the state of the device. - Add button action to switch to ICD active mode - Add support for BooleanState in device callbacks - Add diagnostic logs usage demo - Enclose feedback manager calls in CONFIG_ENABLE_FEEDBACK flag This flag should be defined whenever the application must provide some kind of user interface feedback, such as LED animation. In case of low power, this flag will not be defined. - Remove unused features (e.g. diagnostic logs) - Overwrite event queue and ticks to wait - Call PlatformMgrImpl API for PreInitMatterStack actions - Replace PW_RPC_ENABLED with CONFIG_ENABLE_PW_RPC Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit bed6655227d44900279cbd0ef547771da9143895) * [NXP][examples][common] Add initial version of contact sensor Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 637580aa6c63048ae1a956807c284165c2af17ed) * [NXP][openthread][k32w1] Update mbedtls target Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 3c84b1fd3987958bc0dcf49a283c281e48b400f8) * [NXP][platform][k32w] OTA/FactoryData changes * Add FactoryDataDriver interface which handles factory data update functionality and factory data ram backup operations; must be implemented for each platform * Make FactoryDataProvider global instances * Move Restore mechanism and plain-text SignWithDacKey in common FactoryDataProvider * Adapt Validate and SearchForId to use factory data config which stores size, start, payload * Move OTAFactoryDataProcessor in common folder * Adapt to be generic and use FactoryDataDriver functions instead Signed-off-by: Andrei Menzopol <andrei.menzopol@nxp.com> (cherry picked from commit 3a81c2367013c2a2ed08ecbbeac89ce15943998e) * [NXP][platform][k32w1] SDK 2.15 platform updates * remove RNG_SetPseudoRandomNoSeed call to accomodate new RNG API changes. * add SDK root, SDK release, and SDK 2.15 gn arguments. They will be used to differentiate between SDK versions (2.12 vs 2.15) and release status (repo vs packages). Signed-off-by: Andrei Menzopol <andrei.menzopol@nxp.com> [nxp noup][platform][k32w] Small fixes for k32w platform code * correct typos * remove executable access permissions * remove unused files * change openthread_root to ot-nxp/openthread-k32w1 * use nxp_mbedtls gn target Signed-off-by: Andrei Menzopol <andrei.menzopol@nxp.com> (cherry picked from commit 1905c1cea645506f8a88e514c2eacecea81ac385) * [NXP][platform][k32w1] Add "chip_key_storage" solution selector and littlefs support Updated the K32W1 platform build files by adding the "chip_key_storage" selector which will help developers select an implementation option for the key storage between "littlefs" and "fwk_nvm". Signed-off-by: Marian Chereji <marian.chereji@nxp.com> [nxp noup][k32w1] Temporarily disable OpenThread settings save-on-idle when using LittleFS key storage When using LittleFS key storage, the OpenThread settings save-on-idle feature requires additional support in the application idle task, which is not yet available. In order for the OT settings saving to work at this stage and in this configuration, the save-on-idle feature must be disabled until the required idle task support will be implemented. Signed-off-by: Marian Chereji <marian.chereji@nxp.com> [nxp noup][platform][k32w1] Fix minimum data chunk size required when programming the flash memory According to the specifications, the internal flash memory of the K32W1 platform supports programming chunks of memory which are 128 bytes long (instead of 256). Signed-off-by: Marian Chereji <marian.chereji@nxp.com> [nxp noup][platform][k32w1] Increase LittleFS cache size to 1K to suppress frequent data synchronizations A small cache size forces LittleFS to perform frequent data synchronizations with the storage (flash memory) and this consumes a number of data blocks which are not available in the K32W1 Matter applications. To reduce the fast consumption of flash memory data blocks, the LittleFS cache size was increased to 1KB. Signed-off-by: Marian Chereji <marian.chereji@nxp.com> (cherry picked from commit 753f7d7390661bd5dbd29cc9cfa7d3a4e4728ba2) * [NXP][platform][k32w1] Add Zephyr NVS based key storage build option Added a new build option (chip_key_storage="nvs") which allows the developers to use the Zephyr NVS file system as a key storage solution. Signed-off-by: Marian Chereji <marian.chereji@nxp.com> (cherry picked from commit 1d42e48d8f50f6e9999b49025ea3d71545e89a3d) * [NXP][examples][k32w1] App updates * the sdk root was moved to platform args. * update readme files * Add CONNECTIVITY_MANAGER_THREAD_DEVICE_TYPE define. * Set define accordingly based on FTD/MTD configuration. * Solve issue when lighting-app is MTD but device type is set to Router because it was hardcoded. * Remove deprecated files * Move some headers in examples/platform for common usage Signed-off-by: Andrei Menzopol <andrei.menzopol@nxp.com> (cherry picked from commit c2b626df132e058ce674df0ee20965b3029c462d) * [NXP][examples][k32w1] Update ZclCallbacks after transition to common code Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][k32w1] Remove k32w parent folder Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][platform][k32w1] Add FactoryDataDriver implementation Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][platform][k32w] Remove k32w/common This folder was moved to nxp/common/legacy area. Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 755081c71bde287e2d065e5fd9b1a0922c3b341a) * [NXP][scripts] Minor updates for NXP related scripts Add HWParams APP FactoryData support * Add proper format for HWParameters app factory data section * Put changes under new argument Signed-off-by: Andrei Menzopol <andrei.menzopol@nxp.com> [nxp noup][scripts][common] Fix Crc16 attribute when using latest version Signed-off-by: marius-alex-tache <marius.tache@nxp.com> [nxp noup][scripts] Update structure k32w1 path All k32w1 folders were moved under nxp, removing the k32w parent. Signed-off-by: marius-alex-tache <marius.tache@nxp.com> [nxp noup][scripts][ota] Update paths after k32w transition Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 4963ce98725b74e94f498f959d46edf4933fa56c) * [NXP][platform][common] Add nxp_factory_data, nxp_ota gn targets The application can use these targets to integrate the default, platform-specific NXP factory data provider and OTA implementation. Each platform should define an "nxp_factory_data" and "nxp_ota" source sets. Usage: deps += [ "${chip_root}/src/platform/nxp:nxp_factory_data" ] deps += [ "${chip_root}/src/platform/nxp:nxp_ota" ] Signed-off-by: marius-alex-tache <marius.tache@nxp.com> (cherry picked from commit 4869c4a97134692fe87a59b9b69d33f836d9b2e9) * [NXP][platform][common] Create NXPConfigNVS.cpp file, remove NXPConfig BLE dependencies Signed-off-by: Martin Girardot <martin.girardot@nxp.com> (cherry picked from commit 50e14e4a1b9f8561126310e19ebbaf72ca7bbdbe) * [NXP] revert mcxw71 headers Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][k32w1] Add default logging target Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][k32w1] Update paths to reference nxp_matter_support Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP] Bump nxp_matter_support Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Restyled by prettier-markdown * Restyled by autopep8 * Restyled by isort * [NXP][k32w1] Fix gn import order Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][k32w1] Fix wrong README reference Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][k32w1] Update workflow docker image Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][rw61x] Adding nxp_ota and nxp_factory_data as they are now mandatory Signed-off-by: Gatien Chapon <gatien.chapon@nxp.com> * [NXP][platform][common] Fix build warning (cherry picked from commit 72b1cbaaf36fe6cf2af57a8c7ad3cc457b45c713) * Restyled by gn * [NXP][platform] Remove deprecated files Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][workflow] Create separate jobs for k32w0/k32w1 k32w0 builds use chip-build-k32w Docker image, but k32w1 builds use chip-build-nxp Docker image. Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][k32w0] Adding nxp_ota and nxp_factory_data as they are now mandatory Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [NXP][scripts] Fix script issue when there is no --args Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * [NXP][k32w1] Disable SMU2 Signed-off-by: marius-alex-tache <marius.tache@nxp.com> --------- Signed-off-by: marius-alex-tache <marius.tache@nxp.com> Signed-off-by: Gatien Chapon <gatien.chapon@nxp.com> Signed-off-by: Martin Girardot <martin.girardot@nxp.com> Co-authored-by: Martin Girardot <martin.girardot@nxp.com> Co-authored-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> Co-authored-by: Marian Chereji <marian.chereji@nxp.com> Co-authored-by: Andrei Menzopol <andrei.menzopol@nxp.com> Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Gatien Chapon <gatien.chapon@nxp.com> Co-authored-by: Yassine El Aissaoui <yassine.elaissaoui@nxp.com> (cherry picked from commit 5e37f1e)
1 parent a25fd07 commit d55cca4

File tree

183 files changed

+4707
-7961
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+4707
-7961
lines changed

.github/workflows/examples-nxp.yaml

+54-10
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ env:
2929
CHIP_NO_LOG_TIMESTAMPS: true
3030

3131
jobs:
32-
k32w:
33-
name: K32W
32+
k32w0:
33+
name: K32W0
3434

3535
env:
3636
BUILD_TYPE: gn_k32w
@@ -39,7 +39,7 @@ jobs:
3939
if: github.actor != 'restyled-io[bot]'
4040

4141
container:
42-
image: ghcr.io/project-chip/chip-build-k32w:66
42+
image: ghcr.io/project-chip/chip-build-k32w:71
4343
volumes:
4444
- "/tmp/bloat_reports:/tmp/bloat_reports"
4545
steps:
@@ -66,8 +66,6 @@ jobs:
6666
--target nxp-k32w0-freertos-contact-sensor \
6767
--target nxp-k32w0-freertos-contact-sensor-low-power \
6868
--target nxp-k32w0-freertos-contact-sensor-low-power-factory \
69-
--target nxp-k32w1-freertos-lighting \
70-
--target nxp-k32w1-freertos-contact-sensor-low-power \
7169
build \
7270
--copy-artifacts-to out/artifacts \
7371
"
@@ -77,16 +75,62 @@ jobs:
7775
nxp k32w0+release light \
7876
out/artifacts/nxp-k32w0-freertos-lighting/chip-k32w0x-light-example.elf \
7977
/tmp/bloat_reports/
80-
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
81-
nxp k32w1+release light \
82-
out/artifacts/nxp-k32w1-freertos-lighting/chip-k32w1-light-example.elf \
83-
/tmp/bloat_reports/
8478
- name: Get contact sensor size stats
8579
run: |
8680
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
8781
nxp k32w0+release contact \
8882
out/artifacts/nxp-k32w0-freertos-contact-sensor-low-power/chip-k32w0x-contact-example.elf \
8983
/tmp/bloat_reports/
84+
- name: Uploading Size Reports
85+
uses: ./.github/actions/upload-size-reports
86+
if: ${{ !env.ACT }}
87+
with:
88+
platform-name: K32W0
89+
k32w1:
90+
name: K32W1
91+
92+
env:
93+
BUILD_TYPE: gn_k32w
94+
95+
runs-on: ubuntu-latest
96+
if: github.actor != 'restyled-io[bot]'
97+
98+
container:
99+
image: ghcr.io/project-chip/chip-build-nxp:71
100+
volumes:
101+
- "/tmp/bloat_reports:/tmp/bloat_reports"
102+
steps:
103+
- name: Checkout
104+
uses: actions/checkout@v4
105+
- name: Checkout submodules & Bootstrap
106+
uses: ./.github/actions/checkout-submodules-and-bootstrap
107+
with:
108+
platform: nxp
109+
extra-submodule-parameters: --recursive
110+
111+
- name: Set up environment for size reports
112+
uses: ./.github/actions/setup-size-reports
113+
if: ${{ !env.ACT }}
114+
with:
115+
gh-context: ${{ toJson(github) }}
116+
117+
- name: Build examples
118+
run: |
119+
scripts/run_in_build_env.sh "\
120+
./scripts/build/build_examples.py \
121+
--target nxp-k32w1-freertos-lighting \
122+
--target nxp-k32w1-freertos-contact-sensor-low-power \
123+
build \
124+
--copy-artifacts-to out/artifacts \
125+
"
126+
- name: Get lighting app size stats
127+
run: |
128+
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
129+
nxp k32w1+release light \
130+
out/artifacts/nxp-k32w1-freertos-lighting/chip-k32w1-light-example.elf \
131+
/tmp/bloat_reports/
132+
- name: Get contact sensor size stats
133+
run: |
90134
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
91135
nxp k32w1+release contact \
92136
out/artifacts/nxp-k32w1-freertos-contact-sensor-low-power/chip-k32w1-contact-example.elf \
@@ -95,7 +139,7 @@ jobs:
95139
uses: ./.github/actions/upload-size-reports
96140
if: ${{ !env.ACT }}
97141
with:
98-
platform-name: K32W
142+
platform-name: K32W1
99143
rw61x:
100144
name: RW61X
101145

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "AppTask.h"
20+
21+
#if CONFIG_LOW_POWER
22+
#include "PWR_Interface.h"
23+
#endif
24+
25+
#include <platform/CHIPDeviceLayer.h>
26+
27+
void ContactSensorApp::AppTask::PreInitMatterStack()
28+
{
29+
ChipLogProgress(DeviceLayer, "Welcome to NXP Contact Sensor Demo App");
30+
}
31+
32+
#if CONFIG_LOW_POWER
33+
void ContactSensorApp::AppTask::AppMatter_DisallowDeviceToSleep()
34+
{
35+
PWR_DisallowDeviceToSleep();
36+
}
37+
38+
void ContactSensorApp::AppTask::AppMatter_AllowDeviceToSleep()
39+
{
40+
PWR_AllowDeviceToSleep();
41+
}
42+
#endif
43+
44+
ContactSensorApp::AppTask & ContactSensorApp::AppTask::GetDefaultInstance()
45+
{
46+
static ContactSensorApp::AppTask sAppTask;
47+
return sAppTask;
48+
}
49+
50+
chip::NXP::App::AppTaskBase & chip::NXP::App::GetAppTask()
51+
{
52+
return ContactSensorApp::AppTask::GetDefaultInstance();
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include <lib/support/logging/CHIPLogging.h>
20+
21+
#include "DeviceCallbacks.h"
22+
#if CONFIG_ENABLE_FEEDBACK
23+
#include "UserInterfaceFeedback.h"
24+
#endif
25+
26+
#include <app-common/zap-generated/ids/Attributes.h>
27+
#include <app-common/zap-generated/ids/Clusters.h>
28+
#include <app/EventLogging.h>
29+
30+
using namespace ::chip;
31+
using namespace ::chip::app::Clusters;
32+
33+
void logBooleanStateEvent(bool state)
34+
{
35+
chip::EventNumber eventNumber;
36+
chip::app::Clusters::BooleanState::Events::StateChange::Type event{ state };
37+
if (CHIP_NO_ERROR != chip::app::LogEvent(event, 1, eventNumber))
38+
{
39+
ChipLogProgress(Zcl, "booleanstate: failed to reacord state-change event");
40+
}
41+
}
42+
43+
void ContactSensorApp::DeviceCallbacks::PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
44+
chip::AttributeId attributeId, uint8_t type, uint16_t size,
45+
uint8_t * value)
46+
{
47+
if (clusterId == BooleanState::Id)
48+
{
49+
if (attributeId != BooleanState::Attributes::StateValue::Id)
50+
{
51+
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
52+
return;
53+
}
54+
#if CONFIG_ENABLE_FEEDBACK
55+
FeedbackMgr().RestoreState();
56+
#endif
57+
logBooleanStateEvent(static_cast<bool>(*value));
58+
}
59+
else
60+
{
61+
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
62+
}
63+
}
64+
65+
chip::DeviceManager::CHIPDeviceManagerCallbacks & chip::NXP::App::GetDeviceCallbacks()
66+
{
67+
static ContactSensorApp::DeviceCallbacks sDeviceCallbacks;
68+
return sDeviceCallbacks;
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include <app-common/zap-generated/cluster-objects.h>
20+
#include <lib/support/logging/CHIPLogging.h>
21+
22+
#if CONFIG_ENABLE_FEEDBACK
23+
#include "UserInterfaceFeedback.h"
24+
#endif
25+
26+
/** @brief BooleanState Cluster Init
27+
*
28+
* This function is called when a specific cluster is initialized. It gives the
29+
* application an opportunity to take care of cluster initialization procedures.
30+
* It is called exactly once for each endpoint where cluster is present.
31+
*/
32+
void emberAfBooleanStateClusterInitCallback(chip::EndpointId endpoint)
33+
{
34+
ChipLogProgress(Zcl, "emberAfBooleanStateClusterInitCallback\n");
35+
#if CONFIG_ENABLE_FEEDBACK
36+
FeedbackMgr().RestoreState();
37+
#endif
38+
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (c) 2022 Project CHIP Authors
3+
* Copyright (c) 2024 Project CHIP Authors
44
* All rights reserved.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,16 +16,12 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "DefaultTestEventTriggerDelegate.h"
19+
#pragma once
2020

21-
#include <lib/support/CodeUtils.h>
22-
#include <lib/support/logging/CHIPLogging.h>
21+
struct AppEvent;
22+
typedef void (*EventHandler)(const AppEvent &);
2323

24-
namespace chip {
25-
26-
bool DefaultTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const
24+
struct AppEvent
2725
{
28-
return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
29-
}
30-
31-
} // namespace chip
26+
EventHandler Handler;
27+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
#include "AppConfig.h"
22+
#include "AppTaskFreeRTOS.h"
23+
24+
#include <platform/CHIPDeviceLayer.h>
25+
26+
namespace ContactSensorApp {
27+
28+
class AppTask : public chip::NXP::App::AppTaskFreeRTOS
29+
{
30+
public:
31+
// AppTaskFreeRTOS virtual methods
32+
void PreInitMatterStack() override;
33+
#if CONFIG_LOW_POWER
34+
void AppMatter_DisallowDeviceToSleep() override;
35+
void AppMatter_AllowDeviceToSleep() override;
36+
#endif
37+
38+
// This returns an instance of this class.
39+
static AppTask & GetDefaultInstance();
40+
};
41+
42+
} // namespace ContactSensorApp
43+
44+
/**
45+
* Returns the application-specific implementation of the AppTaskBase object.
46+
*
47+
* Applications can use this to gain access to features of the AppTaskBase
48+
* that are specific to the selected application.
49+
*/
50+
chip::NXP::App::AppTaskBase & GetAppTask();

0 commit comments

Comments
 (0)