Skip to content

Commit

Permalink
[QPG] Adding thermostat and light-switch apps for QPG platform (#31366)
Browse files Browse the repository at this point in the history
* [QPG] Added light-switch app to gn build

* [QPG] Added thermostat app to gn build

* [QPG] Added requirements needed

* [QPG] Light-switch and thermostat added to build targets

* [QPG] Bump qpg_sdk subrepo

* Restyled by gn

* Fixes

* Fixed switch zap and matter files

* Fix zap and matter for thermostat part 1

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Feb 20, 2024
1 parent 88062d3 commit 1234179
Show file tree
Hide file tree
Showing 49 changed files with 19,168 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/examples-qpg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
--target qpg-qpg6105-light \
--target qpg-qpg6105-shell \
--target qpg-qpg6105-persistent-storage \
--target qpg-qpg6105-light-switch \
--target qpg-qpg6105-thermostat \
build \
--copy-artifacts-to out/artifacts \
"
Expand Down
7 changes: 7 additions & 0 deletions config/qpg/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ arm_toolchain("qpg_lighting_app") {
}
}

arm_toolchain("qpg_light_switch_app") {
toolchain_args = {
current_os = "freertos"
import("${chip_root}/examples/light-switch-app/qpg/args.gni")
}
}

arm_toolchain("qpg_shell_app") {
toolchain_args = {
current_os = "freertos"
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ lighting-app/qpg/APPLICATION
:maxdepth: 1
light-switch-app/**/README
light-switch-app/qpg/APPLICATION
```

## Lock example
Expand Down Expand Up @@ -282,6 +283,7 @@ temperature-measurement-app/**/README
thermostat/**/README
thermostat/**/Readme
thermostat/qpg/APPLICATION
```

## TV example
Expand Down
28 changes: 28 additions & 0 deletions examples/light-switch-app/qpg/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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/build.gni")

# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
target_cpu = "arm"
target_os = "freertos"

import("//args.gni")
}
17 changes: 17 additions & 0 deletions examples/light-switch-app/qpg/APPLICATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Matter QPG6105 Light Switch Example Application

## Light-switch-app

A light switch example application showing the use of
[Matter](https://github.com/project-chip/connectedhomeip) on the Qorvo QPG6105
can be found in this folder.

## Qorvo SDK

More detailed information on the Qorvo SDK can be found in the
[Qorvo Matter SDK](https://github.com/Qorvo/QMatter).

## More information

For more information on our product line and support options, please visit
[www.qorvo.com](https://www.qorvo.com) or contact us at <[email protected]>
154 changes: 154 additions & 0 deletions examples/light-switch-app/qpg/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# Copyright(c) 2021 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/openthread.gni")
import("//build_overrides/qpg_sdk.gni")

import("${build_root}/config/defaults.gni")
import("${chip_root}/src/platform/device.gni")
import("${qpg_sdk_build_root}/qpg_executable.gni")
import("${qpg_sdk_build_root}/qpg_sdk.gni")

# declares chip_build_libshell = false
import("${chip_root}/src/lib/lib.gni")

# declares chip_enable_pw_rpc = false
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
if (chip_enable_pw_rpc) {
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")
}

assert(current_os == "freertos")

qpg_project_dir = "${chip_root}/examples/light-switch-app/qpg"
examples_plat_dir = "${chip_root}/examples/platform/qpg"

qpg_sdk("sdk") {
include_dirs = [
"${chip_root}/src/platform/qpg",
"${examples_plat_dir}",
"${qpg_project_dir}/include",
]

defines = [ "PW_RPC_ENABLED=${chip_enable_pw_rpc}" ]
}

qpg_executable("light_switch_app") {
output_name = "chip-${qpg_target_ic}-light-switch-example.out"

sources = [
"${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp",
"${examples_plat_dir}/app/main.cpp",
"${examples_plat_dir}/ota/ota.cpp",
"src/AppTask.cpp",
"src/SwitchManager.cpp",
"src/ZclCallbacks.cpp",
"src/binding-handler.cpp",
]

deps = [
":sdk",
"${chip_root}/examples/light-switch-app/qpg/zap/",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
"${chip_root}/third_party/qpg_sdk:qpg_switch_factorydata_lib",
"${chip_root}/third_party/qpg_sdk:qpg_switch_firmwaredata_lib",
]

if (chip_openthread_ftd) {
deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-ftd" ]
} else {
deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ]
}

include_dirs = [
"include",
"${examples_plat_dir}/ota",
]

defines = []

if (chip_enable_pw_rpc) {
defines += [
"PW_RPC_ATTRIBUTE_SERVICE=1",
"PW_RPC_BUTTON_SERVICE=1",
"PW_RPC_DEVICE_SERVICE=1",
"PW_RPC_LOCKING_SERVICE=1",
]

sources += [
"${chip_root}/examples/common/pigweed/RpcService.cpp",
"${chip_root}/examples/common/pigweed/qpg/PigweedLoggerMutex.cpp",
"${examples_plat_dir}/PigweedLogger.cpp",
"${examples_plat_dir}/Rpc.cpp",
"${examples_plat_dir}/uart.c",
]

deps += [
"$dir_pw_hdlc:rpc_channel_output",
"$dir_pw_stream:sys_io_stream",
"${chip_root}/config/qpg/lib/pw_rpc:pw_rpc",
"${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:button_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:device_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:locking_service.nanopb_rpc",
"${examples_plat_dir}/pw_sys_io:pw_sys_io_qpg",
]

deps += pw_build_LINK_DEPS

include_dirs += [
"${chip_root}/examples/common",
"${chip_root}/examples/common/pigweed/qpg",
]
} else {
# The below gives compiler erros in pigweed, therefore it is only enabled
# when rpc is not
cflags = [ "-Wconversion" ]
}

if (chip_build_libshell) {
deps += [ "${examples_plat_dir}:qpg-matter-shell" ]
} else {
if (chip_openthread_ftd) {
deps +=
[ "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd" ]
} else {
deps +=
[ "${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd" ]
}
}

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

inputs = [ ldscript ]

ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]

output_dir = root_out_dir
}

group("qpg") {
deps = [ ":light_switch_app" ]
}

group("default") {
deps = [ ":qpg" ]
}
15 changes: 15 additions & 0 deletions examples/light-switch-app/qpg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
orphan: true
---

# Matter QPG6105 SDK

## Qorvo SDK

More detailed information on the Qorvo SDK can be found in the
[Qorvo Matter SDK](https://github.com/Qorvo/QMatter).

## More information

For more information on our product line and support options, please visit
[www.qorvo.com](https://www.qorvo.com) or contact us at <[email protected]>
35 changes: 35 additions & 0 deletions examples/light-switch-app/qpg/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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("//build_overrides/pigweed.gni")
import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/examples/platform/qpg/args.gni")

qpg_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_enable_ota_requestor = true
chip_openthread_ftd = false
enable_sleepy_device = true
chip_enable_icd_server = true

# Disable lock tracking, since our FreeRTOS configuration does not set
# INCLUDE_xSemaphoreGetMutexHolder
chip_stack_lock_tracking = "none"

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

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
1 change: 1 addition & 0 deletions examples/light-switch-app/qpg/build_overrides
34 changes: 34 additions & 0 deletions examples/light-switch-app/qpg/include/AppConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
*
* 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.
*/

#ifndef APP_CONFIG_H
#define APP_CONFIG_H

#define APP_TASK_NAME "APP"

// Mapping of Functional buttons
#define APP_FUNCTION1_BUTTON BTN_SW1
#define APP_FUNCTION2_SWITCH BTN_SW2
#define APP_FUNCTION3_BUTTON BTN_SW3
#define APP_FUNCTION4_BUTTON BTN_SW4
#define APP_FUNCTION5_BUTTON BTN_SW5

// Mapping of LEDs
#define SYSTEM_STATE_LED LED_GREEN

#endif // APP_CONFIG_H
51 changes: 51 additions & 0 deletions examples/light-switch-app/qpg/include/AppEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
*
* 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.
*/

#ifndef APP_EVENT_H
#define APP_EVENT_H

struct AppEvent;
typedef void (*EventHandler)(AppEvent *);

struct AppEvent
{
enum AppEventTypes
{
kEventType_Button = 0,
kEventType_Timer,
};

uint16_t Type;

union
{
struct
{
uint8_t ButtonIdx;
uint8_t Action;
} ButtonEvent;
struct
{
void * Context;
} TimerEvent;
};

EventHandler Handler;
};

#endif // APP_EVENT_H
Loading

0 comments on commit 1234179

Please sign in to comment.