Skip to content

Commit

Permalink
Merge branch 'master' into tc-idm-4.3-(python)
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-marquez-csa authored May 22, 2024
2 parents cba575c + eb515e1 commit ab37069
Show file tree
Hide file tree
Showing 164 changed files with 7,289 additions and 3,341 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/examples-qpg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ jobs:
--enable-flashbundle \
--target qpg-qpg6105-lock \
--target qpg-qpg6105-light \
--target qpg-qpg6105-shell \
--target qpg-qpg6105-persistent-storage \
--target qpg-qpg6105-light-switch \
--target qpg-qpg6105-thermostat \
build \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples-stm32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
uses: ./.github/actions/checkout-submodules-and-bootstrap
with:
platform: stm32

extra-submodule-parameters: --recursive
- name: Set up environment for size reports
uses: ./.github/actions/setup-size-reports
if: ${{ !env.ACT }}
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
[submodule "third_party/st/STM32CubeWB"]
path = third_party/st/STM32CubeWB
url = https://github.com/STMicroelectronics/STM32CubeWB.git
branch = v1.17.0
branch = v1.18.0
platforms = stm32
[submodule "p6/lwip-network-interface-integration"]
path = third_party/infineon/psoc6/psoc6_sdk/libs/lwip-network-interface-integration
Expand Down
1 change: 1 addition & 0 deletions .gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ script_executable = "python3"

default_args = {
pw_unit_test_AUTOMATIC_RUNNER = "$dir_pigweed/targets/host/run_test"
pw_unit_test_CONFIG = "//config/pw_unit_test:define_overrides"

pw_build_PIP_CONSTRAINTS = [ "//scripts/setup/constraints.txt" ]
pw_build_PIP_REQUIREMENTS = [ "//scripts/setup/requirements.build.txt" ]
Expand Down
32 changes: 32 additions & 0 deletions config/pw_unit_test/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2024 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/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

import("${chip_root}/build/chip/tests.gni")

import("$dir_pw_build/target_types.gni")
pw_source_set("define_overrides") {
public_configs = [ ":define_options" ]
}

config("define_options") {
if (chip_fake_platform && chip_link_tests) {
defines = [ "PW_UNIT_TEST_CONFIG_MEMORY_POOL_SIZE=65536" ]
} else {
defines = [ "PW_UNIT_TEST_CONFIG_MEMORY_POOL_SIZE=16384" ]
}
}
2 changes: 2 additions & 0 deletions config/qpg/chip-gn/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ env
GN_ROOT_TARGET=$(dirname "$0")
CHIP_ROOT=$GN_ROOT_TARGET/../../../
OUTDIR=$CHIP_ROOT/out
GN_ARGS="qpg_target_ic=\"qpg6105\" qpg_flavour=\"_ext_flash\""

mkdir -p "$OUTDIR"
gn \
Expand All @@ -33,6 +34,7 @@ gn \
--export-compile-commands \
gen \
--check \
--args="$GN_ARGS" \
--fail-on-unused-args \
"$OUTDIR"
ninja -C "$OUTDIR"
123 changes: 123 additions & 0 deletions docs/getting_started/first_example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# An SDK example

The SDK provides a number of example devices and controllers that can be used to
familiarize yourself with the SDK and the Matter ecosystem.

## Example Devices

The example devices (occasionally referred to as "apps") are located in the
[examples](../../examples/) directory. The examples often implement one
particular device type. Some have implementations for various platforms.

The linux platform examples are provided as examples, and are used in the CI.
These can be used for preliminary testing.

The all-clusters-app is used by the QA team for testing. This app implements
nearly all the available clusters and does not conform to a specific device
type. This app is not a good starting place for product development.

## Example Controllers

The SDK has two example controllers that can be used to interact with devices
for testing.

[chip-tool](../../examples/chip-tool/) is a C++ command line controller with an
interactive shell. More information on chip-tool can be found in the
[chip-tool guide](../guides/chip_tool_guide.md).

[chip-repl](../../src/controller/python/chip-repl.py) is a shell for the python
controller. The chip-repl is part of the python controller framework, often used
for testing. More information about the python controller can be found in the
[python testing](../testing/python.md) documentation.

## Building your first demo app (lighting)

The examples directory contains a set of apps using an example device
composition \.zap file. For more information about device composition and zap,
see [ZAP documentation](./zap.md).

This quick start guide will walk you through

- Building an app (lighting app) for the host platform
- Interacting with the app using chip\-tool \(controller\)

### Building the lighting app

- Install prerequisites from docs/guides/BUILDING\.md
- Run bootstrap or activate to install all the required tools etc.
- `. scripts/bootstrap.sh` \- run this first\, or if builds fail
- `. scripts/activate.sh` \- faster\, use if you’ve already bootstrapped
and are just starting a new terminal

The build system we use is Ninja / GN. You can use a standard gn gen / ninja to
build as normal, or use the scripts to build specific variants. More information
about the build system can be found at [BUILDING.md](../guides/BUILDING.md). The
official quickstart guide for the build system is located ag
https://gn.googlesource.com/gn/+/master/docs/quick_start.md and a full reference
can be found at https://gn.googlesource.com/gn/+/main/docs/reference.md.

To build with the scripts, use scripts/build/build_examples\.py -
`scripts/build/build_examples.py targets` -
`scripts/build/build_examples.py --target <your target> build` - builds to
`out/<target_name>/`

Scripts can be used to build both the lighting app and chip tool

- Lighting app \(device\)
- `./scripts/build/build_examples.py --target linux-x64-light-no-ble build`
- This will build an executable to
`./out/linux-x64-light-no-ble/chip-lighting-app`

* NOTE that the host name (linux-x64 here) may be different on different
systems ex. darwin

- chip-tool (controller)
- `./scripts/build/build_examples.py --target linux-x64-chip-tool build`
- This will build an executable to `./out/linux-x64-chip-tool/chip-tool`

### Building / Interacting with Matter Examples

The first thing you need to do is to commission the device. First start up the
app in one terminal. By default it will start up with the default discriminator
(3840) and passcode (20202021) and save its non-volatile information in a KVS in
/temp/chip_kvs. You can change these, and multiple other options on the command
line. For a full description, use the `--help` command.

Start the lighting app in one terminal using

`./out/linux-x64-light-no-ble/chip-lighting-app`

The lighting app will print out all its setup information. You can get the setup
codes, discriminator and passcode from the logs.

Open a new terminal to use chip tool. Commission the device using:

`./out/linux-x64-chip-tool/chip-tool pairing code 0x12344321 MT:-24J0AFN00KA0648G0`

NOTE: pairing is the old name for commissioning. 0x12344321 is the node ID you
want to assign to the node. 0x12344321 is the default for testing.
MT:-24J0AFN00KA0648G0 is the QR code for a device with the default discriminator
and passcode. If you have changed these, the code will be different.

#### Basic device interactions - Sending a command

`./chip-tool onoff on 0x12344321 1`

where:

- onoff is the cluster name
- on is the command name
- 0x12344321 is the node ID you used for commissioning
- 1 is the endpoint

#### Basic device interactions - Reading an attribute

`./chip-tool onoff read on-off 0x12344321 1`

where:

- onoff is the cluster name
- read is the desired action
- on is the attribute name
- 0x12344321 is the node ID you used for commissioning
- 1 is the endpoint
1 change: 1 addition & 0 deletions docs/getting_started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The following docs are a brief introduction to SDK development.
```

- [Running your first example](./first_example.md)
- [SDK Basics](./SDKBasics.md)
- [ZAP](./zap.md)
- [Discover from a host computer](./discovery_from_a_host_computer.md)
Original file line number Diff line number Diff line change
Expand Up @@ -3752,7 +3752,7 @@ cluster ActivatedCarbonFilterMonitoring = 114 {
}

/** This cluster is used to configure a boolean sensor. */
provisional cluster BooleanStateConfiguration = 128 {
cluster BooleanStateConfiguration = 128 {
revision 1;

bitmap AlarmModeBitmap : bitmap8 {
Expand Down Expand Up @@ -3810,7 +3810,7 @@ provisional cluster BooleanStateConfiguration = 128 {
}

/** This cluster is used to configure a valve. */
provisional cluster ValveConfigurationAndControl = 129 {
cluster ValveConfigurationAndControl = 129 {
revision 1;

enum StatusCodeEnum : enum8 {
Expand Down
2 changes: 1 addition & 1 deletion examples/kotlin-matter-controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ the top Matter directory:
```

The Java executable file `kotlin-matter-controller` will be generated at
`out/android-x86-kotlin-matter-controller/bin/`
`out/linux-x64-kotlin-matter-controller/bin/`

Run the kotlin-matter-controller

Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/qpg/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ qpg_executable("light_switch_app") {
}
}

ldscript = "${qpg_sdk_root}/Libraries/Qorvo/QorvoStack/gen/QorvoStack_${qpg_target_ic}/QorvoStack_${qpg_target_ic}.ld"
ldscript = "${qpg_sdk_root}/Libraries/Qorvo/QorvoStack/gen/QorvoStack_${qpg_target_ic}${qpg_flavour}/QorvoStack_${qpg_target_ic}${qpg_flavour}.ld"

inputs = [ ldscript ]

Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/qpg/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ chip_enable_icd_lit = true
chip_stack_lock_tracking = "none"

matter_device_vid = "0xFFF1"
matter_device_pid = "0x8006"
matter_device_pid = "0x8004"

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
17 changes: 15 additions & 2 deletions examples/light-switch-app/qpg/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,18 @@
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
* First two bytes are reflecting the Matter standard
* Last two bytes are reflecting the SDK version of which the first nibble of the first byte represents the major
* version and the second nibble of the first byte has the minor number. The last byte holds the patch number.
* example for SDK v0.1.5 with Matter v1.2 standard:
* 0x01020105
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0003 // Can't be removed, needed for OTA file generation.
#ifndef OTA_TEST_IMAGE
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x01020105
#else
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x01020106
#endif
#endif

/**
Expand All @@ -53,7 +62,11 @@
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.1" // Can't be removed, needed for OTA file generation.
#ifndef OTA_TEST_IMAGE
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.2-0.1.5"
#else
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.2-0.1.6"
#endif
#endif

/**
Expand Down
4 changes: 2 additions & 2 deletions examples/light-switch-app/qpg/include/SwitchManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class SwitchManager
};

void Init(void);
static void GenericSwitchInitialPress(void);
static void GenericSwitchReleasePress(void);
static void GenericSwitchInitialPressHandler(AppEvent * aEvent);
static void GenericSwitchReleasePressHandler(AppEvent * aEvent);
static void ToggleHandler(AppEvent * aEvent);
static void LevelHandler(AppEvent * aEvent);
static void ColorHandler(AppEvent * aEvent);
Expand Down
16 changes: 10 additions & 6 deletions examples/light-switch-app/qpg/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,13 @@ void AppTask::ButtonEventHandler(uint8_t btnIdx, bool btnPressed)
case APP_FUNCTION2_SWITCH: {
if (!btnPressed)
{
ChipLogProgress(NotSpecified, "Switch initial press");
SwitchMgr().GenericSwitchInitialPress();
ChipLogProgress(NotSpecified, "Switch release press");
button_event.Handler = SwitchMgr().GenericSwitchReleasePressHandler;
}
else
{
ChipLogProgress(NotSpecified, "Switch release press");
SwitchMgr().GenericSwitchReleasePress();
ChipLogProgress(NotSpecified, "Switch initial press");
button_event.Handler = SwitchMgr().GenericSwitchInitialPressHandler;
}
break;
}
Expand Down Expand Up @@ -516,11 +516,15 @@ void AppTask::UpdateLEDs(void)
// If the system has ble connection(s) uptill the stage above, THEN blink
// the LEDs at an even rate of 100ms.
//
// Otherwise, blink the LED ON for a very short time.
// Otherwise, turn the LED OFF.
if (sIsThreadProvisioned && sIsThreadEnabled)
{
qvIO_LedSet(SYSTEM_STATE_LED, true);
}
else if (sIsThreadProvisioned && !sIsThreadEnabled)
{
qvIO_LedBlink(SYSTEM_STATE_LED, 950, 50);
}
else if (sHaveBLEConnections)
{
qvIO_LedBlink(SYSTEM_STATE_LED, 100, 100);
Expand All @@ -532,7 +536,7 @@ void AppTask::UpdateLEDs(void)
else
{
// not commissioned yet
qvIO_LedBlink(SYSTEM_STATE_LED, 50, 950);
qvIO_LedSet(SYSTEM_STATE_LED, false);
}
}

Expand Down
32 changes: 26 additions & 6 deletions examples/light-switch-app/qpg/src/SwitchManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,40 @@ void SwitchManager::ColorHandler(AppEvent * aEvent)
DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast<intptr_t>(data));
}

void SwitchManager::GenericSwitchInitialPress(void)
void SwitchManager::GenericSwitchInitialPressHandler(AppEvent * aEvent)
{
// Press moves Position from 0 (idle) to 1 (press)
uint8_t newPosition = 1;

SystemLayer().ScheduleLambda(
[newPosition] { chip::app::Clusters::Switch::Attributes::CurrentPosition::Set(GENERICSWITCH_ENDPOINT_ID, newPosition); });
if (aEvent->Type != AppEvent::kEventType_Button)
{
ChipLogError(NotSpecified, "Event type not supported!");
return;
}

ChipLogProgress(NotSpecified, "GenericSwitchInitialPress new position %d", newPosition);
SystemLayer().ScheduleLambda([newPosition] {
chip::app::Clusters::Switch::Attributes::CurrentPosition::Set(GENERICSWITCH_ENDPOINT_ID, newPosition);
// InitialPress event takes newPosition as event data
chip::app::Clusters::SwitchServer::Instance().OnInitialPress(GENERICSWITCH_ENDPOINT_ID, newPosition);
});
}

void SwitchManager::GenericSwitchReleasePress(void)
void SwitchManager::GenericSwitchReleasePressHandler(AppEvent * aEvent)
{
// Release moves Position from 1 (press) to 0
uint8_t newPosition = 0;

SystemLayer().ScheduleLambda(
[newPosition] { chip::app::Clusters::Switch::Attributes::CurrentPosition::Set(GENERICSWITCH_ENDPOINT_ID, newPosition); });
if (aEvent->Type != AppEvent::kEventType_Button)
{
ChipLogError(NotSpecified, "Event type not supported!");
return;
}

ChipLogProgress(NotSpecified, "GenericSwitchReleasePress new position %d", newPosition);
SystemLayer().ScheduleLambda([newPosition] {
chip::app::Clusters::Switch::Attributes::CurrentPosition::Set(GENERICSWITCH_ENDPOINT_ID, newPosition);
// Short Release event takes newPosition as event data
chip::app::Clusters::SwitchServer::Instance().OnShortRelease(GENERICSWITCH_ENDPOINT_ID, newPosition);
});
}
Loading

0 comments on commit ab37069

Please sign in to comment.