Skip to content

Commit

Permalink
Merge branch 'master' into jtung/darwin-mtrdevice-attribute-storage-w…
Browse files Browse the repository at this point in the history
…rite-optimization
  • Loading branch information
woody-apple authored May 22, 2024
2 parents 8c0085a + eb515e1 commit 2725771
Show file tree
Hide file tree
Showing 176 changed files with 7,508 additions and 3,398 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-linux-tv-casting-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
run: |
./scripts/run_in_build_env.sh \
"python3 ./scripts/tests/run_tv_casting_test.py"
timeout-minutes: 1
timeout-minutes: 2 # Comment this out to debug if GitHub Action times out.

- name: Uploading Size Reports
uses: ./.github/actions/upload-size-reports
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class CHIPDeviceDetailsFragment : Fragment() {
binding.discriminatorEd.setText(deviceInfo.discriminator.toString())
binding.serialNumberEd.setText(deviceInfo.serialNumber)
binding.discoveryCapabilitiesTv.text = "${deviceInfo.discoveryCapabilities}"

if (deviceInfo.optionalQrCodeInfoMap.isEmpty()) {
binding.vendorTagsLabelTv.visibility = View.GONE
binding.vendorTagsContainer.visibility = View.GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import kotlinx.parcelize.Parcelize
import matter.onboardingpayload.DiscoveryCapability
import matter.onboardingpayload.OnboardingPayload
import matter.onboardingpayload.OnboardingPayloadException
import matter.onboardingpayload.OptionalQRCodeInfoType

/** Class to hold the CHIP device information. */
@Parcelize
Expand Down Expand Up @@ -57,6 +58,13 @@ data class CHIPDeviceInfo(
if (serialNumber.isNotEmpty()) {
onboardingPayload.addSerialNumber(serialNumber)
}
optionalQrCodeInfoMap.forEach { (_, info) ->
if (info.type == OptionalQRCodeInfoType.TYPE_STRING && info.data != null) {
onboardingPayload.addOptionalVendorData(info.tag, info.data)
} else {
onboardingPayload.addOptionalVendorData(info.tag, info.intDataValue)
}
}
return onboardingPayload
}

Expand All @@ -78,8 +86,8 @@ data class CHIPDeviceInfo(
setupPayload.getLongDiscriminatorValue(),
setupPayload.setupPinCode,
setupPayload.commissioningFlow,
setupPayload.optionalQRCodeInfo.mapValues { (_, info) ->
QrCodeInfo(info.tag, info.type, info.data, info.int32)
setupPayload.getAllOptionalVendorData().associate { info ->
info.tag to QrCodeInfo(info.tag, info.type, info.data, info.int32)
},
setupPayload.discoveryCapabilities,
setupPayload.hasShortDiscriminator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_below="@id/vendorTagsLabelTv"
android:layout_below="@id/vendorTagsContainer"
android:layout_alignParentStart="true"
android:textSize="20sp"/>
<EditText
android:id="@+id/discoveryCapabilitiesEd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_below="@id/vendorTagsLabelTv"
android:layout_below="@id/vendorTagsContainer"
android:layout_toEndOf="@id/discoveryCapabilitiesLabelTv"
android:layout_alignParentEnd="true"
android:textSize="11sp"
Expand Down Expand Up @@ -260,6 +260,6 @@
android:layout_below="@id/showQRCodeUriBtn"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:textSize="20sp"/>
android:textSize="12sp"/>
</RelativeLayout>
</ScrollView>
17 changes: 13 additions & 4 deletions examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,20 @@ def main() -> int:
if options.build_target == "esp32":
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/esp32")
if options.enable_ipv4:
shell.run_cmd(
"sed -i 's/CONFIG_DISABLE_IPV4=y/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/g' sdkconfig ")
if sys.platform == "darwin":
shell.run_cmd(
"sed -i '' 's/CONFIG_DISABLE_IPV4=y/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/g' sdkconfig ")
else:
shell.run_cmd(
"sed -i 's/CONFIG_DISABLE_IPV4=y/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/g' sdkconfig ")
else:
shell.run_cmd(
"sed -i 's/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/CONFIG_DISABLE_IPV4=y/g' sdkconfig ")
if sys.platform == "darwin":
shell.run_cmd(
"sed -i '' 's/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/CONFIG_DISABLE_IPV4=y/g' sdkconfig ")
else:
shell.run_cmd(
"sed -i 's/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/CONFIG_DISABLE_IPV4=y/g' sdkconfig ")

shell.run_cmd("idf.py build")
shell.run_cmd("idf.py build flashing_script")
shell.run_cmd(
Expand Down
1 change: 1 addition & 0 deletions examples/chef/esp32/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ CONFIG_MBEDTLS_HKDF_C=y

# IRAM optimizations
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y

# Increase LwIP IPv6 address number
CONFIG_LWIP_IPV6_NUM_ADDRESSES=6
1 change: 1 addition & 0 deletions examples/chef/esp32/sdkconfig_rpc.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ CONFIG_MBEDTLS_HKDF_C=y

# IRAM optimizations
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y

CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y
2 changes: 1 addition & 1 deletion examples/common/pigweed/rpc_services/BooleanState.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
namespace chip {
namespace rpc {

class BooleanState final : public pw_rpc::nanopb::BooleanState::Service<BooleanState>
class BooleanState : public pw_rpc::nanopb::BooleanState::Service<BooleanState>
{
public:
virtual ~BooleanState() = default;
Expand Down
2 changes: 1 addition & 1 deletion examples/common/pigweed/rpc_services/Locking.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
namespace chip {
namespace rpc {

class Locking final : public pw_rpc::nanopb::Locking::Service<Locking>
class Locking : public pw_rpc::nanopb::Locking::Service<Locking>
{
public:
virtual ~Locking() = default;
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"
Loading

0 comments on commit 2725771

Please sign in to comment.