Skip to content

Commit

Permalink
[Tizen] Example lighting app using Tizen app framework (#18137)
Browse files Browse the repository at this point in the history
* Add example lighting-app to Linux builds

* Expose color formatting functions as source set

* Linux lighting manager as a common implementation

* [Tizen] Example Matter app as a service Tizen app

* Add Tizen-related words to spellcheck
  • Loading branch information
arkq authored and pull[bot] committed Sep 22, 2023
1 parent 081acef commit 1146927
Show file tree
Hide file tree
Showing 31 changed files with 632 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ dropdown
dryrun
DS
duplicative
DUT
DV
dynload
eabi
Expand Down Expand Up @@ -1272,6 +1273,7 @@ timedInteractionTimeoutMs
TimeFormatLocalization
timeoutMs
TimeSynchronization
Tizen
TKIP
tlsr
TLV
Expand All @@ -1288,6 +1290,7 @@ tos
TotalColiformBacteriaConcentrationMeasurement
totalTests
TotalTrihalomethanesConcentrationMeasurement
TPK
trackAlloc
trackFree
TransferSession
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ list(
${chip_dir}/zzz_generated/lighting-app/zap-generated/callback-stub.cpp
${chip_dir}/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp

${chip_dir}/examples/lighting-app/lighting-common/color_format/color_format.cpp
${chip_dir}/examples/lighting-app/lighting-common/src/ColorFormat.cpp

${chip_dir}/examples/lighting-app/ameba/main/chipinterface.cpp
${chip_dir}/examples/lighting-app/ameba/main/DeviceCallbacks.cpp
Expand Down Expand Up @@ -57,7 +57,7 @@ target_include_directories(
${chip_dir}/zzz_generated/lighting-app/zap-generated
${chip_dir}/zzz_generated/app-common
${chip_dir}/examples/lighting-app/lighting-common
${chip_dir}/examples/lighting-app/lighting-common/color_format
${chip_dir}/examples/lighting-app/lighting-common/include
${chip_dir}/examples/lighting-app/ameba/main/include
${chip_dir_output}/gen/include
${chip_dir}/src/include/
Expand Down
9 changes: 4 additions & 5 deletions examples/lighting-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@

idf_component_register(PRIV_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/lighting-app"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lighting-app/lighting-common/color_format"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lighting-app/lighting-common/include"
"${CMAKE_CURRENT_LIST_DIR}/include"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32"
SRC_DIRS
"${CMAKE_CURRENT_LIST_DIR}"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/lighting-app/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lighting-app/lighting-common/src"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/route_hook"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lighting-app/lighting-common/color_format"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
Expand Down Expand Up @@ -69,4 +69,3 @@ target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_H
target_compile_options(${COMPONENT_LIB} PUBLIC
"-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>"
)

2 changes: 1 addition & 1 deletion examples/lighting-app/esp32/main/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

#include "LEDWidget.h"
#include "color_format.h"
#include "ColorFormat.h"

void LEDWidget::Init(void)
{
Expand Down
21 changes: 21 additions & 0 deletions examples/lighting-app/lighting-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,30 @@ import("//build_overrides/chip.gni")
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/app/chip_data_model.gni")

config("config") {
include_dirs = [ "include" ]
}

chip_data_model("lighting-common") {
zap_file = "lighting-app.zap"

zap_pregenerated_dir = "${chip_root}/zzz_generated/lighting-app/zap-generated"
is_server = true
}

source_set("color-format") {
public_configs = [ ":config" ]
sources = [
"include/ColorFormat.h",
"src/ColorFormat.cpp",
]
}

source_set("lighting-manager") {
deps = [ "${chip_root}/src/lib" ]
public_configs = [ ":config" ]
sources = [
"include/LightingManager.h",
"src/LightingManager.cpp",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@

#include <functional>

#include <lib/core/CHIPError.h>

class LightingManager
{
public:
enum Action_t
{
ON_ACTION = 0,
OFF_ACTION,

INVALID_ACTION
} Action;

Expand All @@ -40,7 +41,7 @@ class LightingManager
kState_Off,
} State;

int Init();
CHIP_ERROR Init();
bool IsTurnedOn();
bool InitiateAction(Action_t aAction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

#include "color_format.h"
#include "ColorFormat.h"

#include <math.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@

#include "LightingManager.h"

#include <iostream>
#include <lib/support/logging/CHIPLogging.h>

LightingManager LightingManager::sLight;

int LightingManager::Init()
CHIP_ERROR LightingManager::Init()
{
mState = kState_On;
return 0;
return CHIP_NO_ERROR;
}

bool LightingManager::IsTurnedOn()
Expand Down
3 changes: 1 addition & 2 deletions examples/lighting-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ config("includes") {

executable("chip-lighting-app") {
sources = [
"LightingManager.cpp",
"include/CHIPProjectAppConfig.h",
"include/LightingManager.h",
"main.cpp",
]

deps = [
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/examples/lighting-app/lighting-common:lighting-manager",
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/src/lib",
]
Expand Down
6 changes: 2 additions & 4 deletions examples/lighting-app/qpg/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ qpg_sdk("sdk") {
qpg_executable("lighting_app") {
output_name = "chip-${qpg_target_ic}-lighting-example.out"

include_dirs = []

sources = [
"${chip_root}/examples/lighting-app/lighting-common/color_format/color_format.cpp",
"${examples_plat_dir}/app/main.cpp",
"${examples_plat_dir}/ota/ota.cpp",
"include/LightingManager.h",
"src/AppTask.cpp",
"src/LightingManager.cpp",
"src/ZclCallbacks.cpp",
Expand All @@ -66,6 +64,7 @@ qpg_executable("lighting_app") {
deps = [
":sdk",
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/examples/lighting-app/lighting-common:color-format",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
Expand All @@ -81,7 +80,6 @@ qpg_executable("lighting_app") {
include_dirs = [
"include",
"${examples_plat_dir}/ota",
"${chip_root}/examples/lighting-app/lighting-common/color_format",
]

defines = []
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/qpg/include/LightingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

#include "AppEvent.h"

#include "ColorFormat.h"
#include "FreeRTOS.h"
#include "color_format.h"
#include "timers.h" // provides FreeRTOS timer support

#include <lib/core/CHIPError.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Project CHIP Authors
# 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.
Expand All @@ -12,11 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# add this gni as import in your build args to use tizen in the example
# 'import("//with_tizen.gni")'
import("//build_overrides/build.gni")

import("//build_overrides/chip.gni")
# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

import("${chip_root}/config/tizen/chip-gn/args.gni")
# CHIP uses angle bracket includes.
check_system_includes = true

current_os = "tizen"
default_args = {
target_os = "tizen"
import("//args.gni")
}
50 changes: 50 additions & 0 deletions examples/lighting-app/tizen/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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("${chip_root}/build/chip/tools.gni")
import("${chip_root}/src/app/common_flags.gni")

assert(chip_build_tools)

config("includes") {
include_dirs = [ "include" ]
}

executable("chip-lighting-app") {
sources = [
"include/CHIPProjectAppConfig.h",
"src/main.cpp",
]

deps = [
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/examples/lighting-app/lighting-common:lighting-manager",
"${chip_root}/examples/platform/tizen:app-main",
"${chip_root}/src/lib",
]

include_dirs = [ "include" ]

output_dir = root_out_dir
}

group("tizen") {
deps = [ ":chip-lighting-app" ]
}

group("default") {
deps = [ ":tizen" ]
}
24 changes: 24 additions & 0 deletions examples/lighting-app/tizen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# CHIP Tizen Lighting Example

## Installing TPK

Upload TPK package to device under test (DUT). Install it with `pkgcmd` as
follows:

```sh
pkgcmd -i -t tpk -p org.tizen.matter.example.lighting-1.0.0.tpk
```

## Launching application

For launching Tizen application one should use `app_launcher`. It is possible to
pass user arguments from command line which might be used to control application
behavior. However, passed strings cannot start with "-" (minus) character and
all arguments have to consist of name and value. Boolean options (option without
argument) should have value equal to "true".

e.g.:

```sh
app_launcher --start=org.tizen.matter.example.lighting discriminator 43 wifi true
```
25 changes: 25 additions & 0 deletions examples/lighting-app/tizen/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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("${chip_root}/config/standalone/args.gni")

chip_device_project_config_include = "<CHIPProjectAppConfig.h>"
chip_project_config_include = "<CHIPProjectAppConfig.h>"
chip_system_project_config_include = "<SystemProjectConfig.h>"

chip_project_config_include_dirs =
[ "${chip_root}/examples/lighting-app/tizen/include" ]
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ]
1 change: 1 addition & 0 deletions examples/lighting-app/tizen/build_overrides
46 changes: 46 additions & 0 deletions examples/lighting-app/tizen/include/CHIPProjectAppConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
*
* 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.
*/

/**
* @file
* Example project configuration file for CHIP.
*
* This is a place to put application or project-specific overrides
* to the default configuration values for general CHIP features.
*
*/

#pragma once

// include the CHIPProjectConfig from config/standalone
#include <CHIPProjectConfig.h>

#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY 0

// Bulbs do not typically use this - enabled so we can use shell to discover commissioners
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT 1

#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1

#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE 1

#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 257 // 0x0101 = 257 = Dimmable Bulb

#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_NAME 1

#define CHIP_DEVICE_CONFIG_DEVICE_NAME "Test Bulb"
Loading

0 comments on commit 1146927

Please sign in to comment.