Skip to content

Commit

Permalink
Merge branch 'master' into idm-4.2-troubleshoot
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-marquez-csa authored May 22, 2024
2 parents 8b6725d + 9b6bb5b commit 54870d8
Show file tree
Hide file tree
Showing 78 changed files with 5,119 additions and 1,669 deletions.
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
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)
36 changes: 19 additions & 17 deletions examples/lighting-app/stm32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,22 @@ if (stm32_board == "STM32WB5MM-DK") {
}

stm32_sdk("sdk") {
if (stm32_board == "STM32WB5MM-DK") {
sources = [
"${examples_plat_dir}/config_files/STM32WB5/FreeRTOSConfig.h",
"${examples_plat_dir}/config_files/STM32WB5/matter_config.h",
"${stm32_project_dir}/include/STM32WB5/CHIPProjectConfig.h",
]
}

include_dirs = [
"${chip_root}/src/platform/stm32",
"${examples_plat_dir}",
"${stm32_project_dir}/include/STM32WB5",
"${chip_root}/src/lib",
]

if (stm32_board == "STM32WB5MM-DK") {
sources = [
"${examples_plat_dir}/config_files/STM32WB5/FreeRTOSConfig.h",
"${examples_plat_dir}/config_files/STM32WB5/matter_config.h",
"${stm32_project_dir}/include/STM32WB5/CHIPProjectConfig.h",
]

include_dirs += [
"${stm32_project_dir}/include/STM32WB5",
"${examples_plat_dir}/config_files/STM32WB5",
"${chip_root}/src/include",
]
}
Expand Down Expand Up @@ -100,25 +98,29 @@ stm32_executable("lighting_app") {
"${stm32_board_src}/STM32_WPAN/App/app_matter.c",
"${stm32_board_src}/STM32_WPAN/App/app_thread.c",
"${stm32_board_src}/STM32_WPAN/App/custom_stm.c",

#"${stm32_board_src}/STM32_WPAN/Target/hw_ipcc.c",
"${stm32_board_src}/Src/app_entry.cpp",
"${stm32_board_src}/Src/main.cpp",
"${stm32_board_src}/Src/ota.cpp",
"src/STM32WB5/AppTask.cpp",
"src/STM32WB5/IdentifierEffect.cpp",
"src/STM32WB5/LightingManager.cpp",
"src/STM32WB5/ZclCallbacks.cpp",
]

deps = [
":sdk",
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
]
}

# Add the startup file to the target
sources += [ "${examples_plat_dir}/startup_files/startup_${stm32_mcu}.s" ]

deps = [
":sdk",
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
]

defines += [
"DEBUG",
"USE_HAL_DRIVER",
Expand Down
4 changes: 3 additions & 1 deletion examples/lighting-app/stm32/include/STM32WB5/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "LightingManager.h"
#include "app_entry.h"

#include <DeviceInfoProviderImpl.h>
#include <platform/CHIPDeviceLayer.h>
#include <platform/stm32/FactoryDataProvider.h>
#define APP_NAME "Lighting-app"
Expand Down Expand Up @@ -55,9 +56,10 @@ class AppTask
static void FunctionHandler(AppEvent * aEvent);
static void LightingActionEventHandler(AppEvent * aEvent);
static void TimerEventHandler(TimerHandle_t xTimer);
static void DelayNvmHandler(TimerHandle_t xTimer);
static void MatterEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
#if (OTA_SUPPORT == 0)
static void UpdateLCD(void);
#endif
static void UpdateNvmEventHandler(AppEvent * aEvent);

enum Function_t
Expand Down
42 changes: 40 additions & 2 deletions examples/lighting-app/stm32/include/STM32WB5/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,26 @@
*/
#ifndef CHIPPROJECTCONFIG_H
#define CHIPPROJECTCONFIG_H
#include "app_conf.h"

// Use a default pairing code if one hasn't been provisioned in flash.
#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021
#endif

#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00
#endif

// Use a default pairing code if one hasn't been provisioned in flash.
#define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING_CODE "CHIPUS"

// For convenience, Chip Security Test Mode can be enabled and the
// requirement for authentication in various protocols can be disabled.
//
// WARNING: These options make it possible to circumvent basic Chip security functionality,
// including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS.
//
#define CHIP_CONFIG_SECURITY_TEST_MODE 0

/**
* CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
*
Expand Down Expand Up @@ -73,6 +83,25 @@
*/
#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 0

/**
* CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY
*
* Enables the use of a hard-coded default Chip device id and credentials if no device id
* is found in Chip NV storage.
*
* This option is for testing only and should be disabled in production releases.
*/
#define CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY 34

// For convenience, enable Chip Security Test Mode and disable the requirement for
// authentication in various protocols.
//
// WARNING: These options make it possible to circumvent basic Chip security functionality,
// including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS.
//
#define CHIP_CONFIG_SECURITY_TEST_MODE 0
#define CHIP_CONFIG_REQUIRE_AUTH 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
Expand All @@ -84,6 +113,15 @@
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.1"
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A monothonic number identifying the software version running on the device.
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 1
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION
*
Expand Down
15 changes: 8 additions & 7 deletions examples/lighting-app/stm32/include/STM32WB5/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ extern uint32_t SystemCoreClock;
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configUSE_TICKLESS_IDLE 0
#define configUSE_TICKLESS_IDLE 2
/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */
/* Defaults to size_t for backward compatibility, but can be changed
if lengths will always be less than the number of bytes in a size_t. */
Expand Down Expand Up @@ -172,19 +172,20 @@ standard names. */
/* USER CODE BEGIN Defines */
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
// #define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 1 /* required only for Keil but does not hurt otherwise */
#define configGENERATE_RUN_TIME_STATS 1
/*#define configGENERATE_RUN_TIME_STATS 1
#if (configGENERATE_RUN_TIME_STATS == 1)
#if( configGENERATE_RUN_TIME_STATS == 1 )
extern void RTOS_AppConfigureTimerForRuntimeStats();
extern void RTOS_AppConfigureTimerForRuntimeStats();
extern uint32_t RTOS_AppGetRuntimeCounterValueFromISR();
extern uint32_t RTOS_AppGetRuntimeCounterValueFromISR();
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() RTOS_AppConfigureTimerForRuntimeStats()
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() RTOS_AppConfigureTimerForRuntimeStats()
#define portGET_RUN_TIME_COUNTER_VALUE() RTOS_AppGetRuntimeCounterValueFromISR()
#define portGET_RUN_TIME_COUNTER_VALUE() RTOS_AppGetRuntimeCounterValueFromISR()
#endif
*/

/* USER CODE END Defines */

Expand Down
Loading

0 comments on commit 54870d8

Please sign in to comment.