Skip to content

Commit

Permalink
Merge branch 'master' into esp32/test-event-trigger-enable-key
Browse files Browse the repository at this point in the history
  • Loading branch information
wqx6 authored Sep 29, 2022
2 parents c6b795b + 57c7321 commit 6832ad0
Show file tree
Hide file tree
Showing 81 changed files with 3,460 additions and 777 deletions.
15 changes: 11 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#### Issue Being Resolved
* Fixes #12345 (exactly like this, so this PR is associated with an issue)
> !!!!!!!!!! Please delete the instructions below and replace with PR desription
>
> If you have an issue number, please use a syntax of
> `Fixes #12345` and a brief change description
>
> If you do not have an issue number, please have a good description of
> the problem and the fix. Help the reviewer understand what to expect.
>
> Make sure you delete these instructions (to prove you have read them).
>
> !!!!!!!!!! Instructions end
#### Change overview
What's in this PR
32 changes: 0 additions & 32 deletions .github/workflows/require-issue.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
branch = master
[submodule "qpg_sdk"]
path = third_party/qpg_sdk/repo
url = https://github.com/Qorvo/qpg-connectedhomeip
branch = master
url = https://github.com/Qorvo/QMatter
branch = v0.9.0.0-libs
platforms = qpg
[submodule "zap"]
path = third_party/zap/repo
Expand Down
13 changes: 13 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
(current_os == "mac" || current_os == "linux") &&
(host_cpu == "x64" || host_cpu == "arm64" || host_cpu == "arm")
enable_pylib = false

# Build the Linux all clusters app example with default group
chip_build_all_clusters_app = false
}

if (enable_fuzz_test_targets) {
Expand Down Expand Up @@ -218,6 +221,16 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
if (build_tv_casting_common_a) {
deps += [ "${chip_root}/examples/tv-casting-app/tv-casting-common:tvCastingCommon" ]
}

if (chip_build_all_clusters_app) {
if (is_libfuzzer) {
deps += [ "${chip_root}/examples/all-clusters-app/linux:chip-all-clusters-app-fuzzing" ]
} else {
deps += [
"${chip_root}/examples/all-clusters-app/linux:chip-all-clusters-app",
]
}
}
}

if (chip_build_tools) {
Expand Down
1 change: 1 addition & 0 deletions examples/common/pigweed/rpc_console/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pw_python_package("chip_rpc") {
"$dir_pw_log_tokenized/py",
"$dir_pw_protobuf_compiler/py",
"$dir_pw_rpc/py",
"$dir_pw_tokenizer/py",
"${chip_root}/examples/common/pigweed:attributes_service.python",
"${chip_root}/examples/common/pigweed:button_service.python",
"${chip_root}/examples/common/pigweed:descriptor_service.python",
Expand Down
6 changes: 6 additions & 0 deletions examples/lighting-app/lighting-common/include/ColorFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,11 @@ struct XyColor_t
uint16_t y;
};

struct CtColor_t
{
uint16_t ctMireds;
};

RgbColor_t XYToRgb(uint8_t Level, uint16_t currentX, uint16_t currentY);
RgbColor_t HsvToRgb(HsvColor_t hsv);
RgbColor_t CTToRgb(CtColor_t ct);
53 changes: 53 additions & 0 deletions examples/lighting-app/lighting-common/src/ColorFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,56 @@ RgbColor_t XYToRgb(uint8_t Level, uint16_t currentX, uint16_t currentY)

return rgb;
}

RgbColor_t CTToRgb(CtColor_t ct)
{
RgbColor_t rgb;
float r, g, b;

// Algorithm credits to Tanner Helland: https://tannerhelland.com/2012/09/18/convert-temperature-rgb-algorithm-code.html

// Convert Mireds to centiKelvins. k = 1,000,000/mired
float ctCentiKelvin = 10000 / ct.ctMireds;

// Red
if (ctCentiKelvin <= 66)
{
r = 255;
}
else
{
r = 329.698727446f * pow(ctCentiKelvin - 60, -0.1332047592f);
}

// Green
if (ctCentiKelvin <= 66)
{
g = 99.4708025861f * log(ctCentiKelvin) - 161.1195681661f;
}
else
{
g = 288.1221695283f * pow(ctCentiKelvin - 60, -0.0755148492f);
}

// Blue
if (ctCentiKelvin >= 66)
{
b = 255;
}
else
{
if (ctCentiKelvin <= 19)
{
b = 0;
}
else
{
b = 138.5177312231 * log(ctCentiKelvin - 10) - 305.0447927307;
}
}
rgb.r = (uint8_t) clamp(r, 0, 255);
rgb.g = (uint8_t) clamp(g, 0, 255);
rgb.b = (uint8_t) clamp(b, 0, 255);

return rgb;
}
3 changes: 3 additions & 0 deletions examples/lighting-app/qpg/include/LightingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class LightingManager
LEVEL_ACTION,
COLOR_ACTION_XY,
COLOR_ACTION_HSV,
COLOR_ACTION_CT,
INVALID_ACTION
} Action;

Expand All @@ -66,6 +67,7 @@ class LightingManager
XyColor_t mXY;
HsvColor_t mHSV;
RgbColor_t mRGB;
CtColor_t mCT;

LightingCallback_fn mActionInitiated_CB;
LightingCallback_fn mActionCompleted_CB;
Expand All @@ -74,6 +76,7 @@ class LightingManager
void SetLevel(uint8_t aLevel);
void SetColor(uint16_t x, uint16_t y);
void SetColor(uint8_t hue, uint8_t saturation);
void SetColorTemperature(CtColor_t ct);

void UpdateLight();

Expand Down
16 changes: 16 additions & 0 deletions examples/lighting-app/qpg/src/LightingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ bool LightingManager::InitiateAction(Action_t aAction, int32_t aActor, uint16_t
State_t new_state;
XyColor_t xy;
HsvColor_t hsv;
CtColor_t ct;

switch (aAction)
{
Expand All @@ -86,6 +87,10 @@ bool LightingManager::InitiateAction(Action_t aAction, int32_t aActor, uint16_t
hsv = *reinterpret_cast<HsvColor_t *>(value);
ChipLogProgress(NotSpecified, "LightMgr:COLOR: hsv:%u|%u->%u|%u", mHSV.h, mHSV.s, hsv.h, hsv.s);
break;
case COLOR_ACTION_CT:
ct.ctMireds = *reinterpret_cast<uint16_t *>(value);
ChipLogProgress(NotSpecified, "LightMgr:COLOR: ct:%u->%u", mCT.ctMireds, ct.ctMireds);
break;
default:
ChipLogProgress(NotSpecified, "LightMgr:Unknown");
break;
Expand Down Expand Up @@ -157,6 +162,10 @@ bool LightingManager::InitiateAction(Action_t aAction, int32_t aActor, uint16_t
{
SetColor(hsv.h, hsv.s);
}
else if (aAction == COLOR_ACTION_CT)
{
SetColorTemperature(ct);
}
else
{
Set(new_state == kState_On);
Expand Down Expand Up @@ -195,6 +204,13 @@ void LightingManager::SetColor(uint8_t hue, uint8_t saturation)
UpdateLight();
}

void LightingManager::SetColorTemperature(CtColor_t ct)
{
mCT = ct;
mRGB = CTToRgb(ct);
UpdateLight();
}

void LightingManager::Set(bool aOn)
{
if (aOn)
Expand Down
54 changes: 36 additions & 18 deletions examples/lighting-app/qpg/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,14 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
return;
}

if ((attributeId != ColorControl::Attributes::CurrentX::Id) && (attributeId != ColorControl::Attributes::CurrentY::Id) &&
(attributeId != ColorControl::Attributes::CurrentHue::Id) &&
(attributeId != ColorControl::Attributes::CurrentSaturation::Id))
{
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
return;
}

if (size == sizeof(uint16_t))
/* XY color space */
if (attributeId == ColorControl::Attributes::CurrentX::Id || attributeId == ColorControl::Attributes::CurrentY::Id)
{
if (size != sizeof(uint16_t))
{
ChipLogError(Zcl, "Wrong length for ColorControl value: %d", size);
return;
}
XyColor_t xy;
if (attributeId == ColorControl::Attributes::CurrentX::Id)
{
Expand All @@ -90,20 +88,37 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
EmberAfStatus status = ColorControl::Attributes::CurrentX::Get(endpoint, &xy.x);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
}

ChipLogProgress(Zcl, "New XY color: %u|%u", xy.x, xy.y);
LightingMgr().InitiateAction(LightingManager::COLOR_ACTION_XY, 0, sizeof(xy), (uint8_t *) &xy);
}
else if (size == sizeof(uint8_t))
/* HSV color space */
else if (attributeId == ColorControl::Attributes::CurrentHue::Id ||
attributeId == ColorControl::Attributes::CurrentSaturation::Id ||
attributeId == ColorControl::Attributes::EnhancedCurrentHue::Id)
{
if (size != sizeof(uint8_t))
{
ChipLogError(Zcl, "Wrong length for ColorControl value: %d", size);
return;
}
HsvColor_t hsv;
if (attributeId == ColorControl::Attributes::CurrentHue::Id)
if (attributeId == ColorControl::Attributes::EnhancedCurrentHue::Id)
{
// We only support 8-bit hue. Assuming hue is linear, normalize 16-bit to 8-bit.
hsv.h = (uint8_t)((*reinterpret_cast<uint16_t *>(value)) >> 8);
// get saturation from cluster value storage
EmberAfStatus status = ColorControl::Attributes::CurrentSaturation::Get(endpoint, &hsv.s);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
}
else if (attributeId == ColorControl::Attributes::CurrentHue::Id)
{
hsv.h = *value;
// get saturation from cluster value storage
EmberAfStatus status = ColorControl::Attributes::CurrentSaturation::Get(endpoint, &hsv.s);
assert(status == EMBER_ZCL_STATUS_SUCCESS);
}
if (attributeId == ColorControl::Attributes::CurrentSaturation::Id)
else if (attributeId == ColorControl::Attributes::CurrentSaturation::Id)
{
hsv.s = *value;
// get hue from cluster value storage
Expand All @@ -113,16 +128,19 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
ChipLogProgress(Zcl, "New HSV color: %u|%u", hsv.h, hsv.s);
LightingMgr().InitiateAction(LightingManager::COLOR_ACTION_HSV, 0, sizeof(hsv), (uint8_t *) &hsv);
}
else if (attributeId == ColorControl::Attributes::ColorTemperatureMireds::Id)
{
CtColor_t ct;
ct.ctMireds = *reinterpret_cast<uint16_t *>(value);
ChipLogProgress(Zcl, "New CT color: %u", ct.ctMireds);
LightingMgr().InitiateAction(LightingManager::COLOR_ACTION_CT, 0, sizeof(ct), (uint8_t *) &ct.ctMireds);
}
else
{
ChipLogError(Zcl, "Wrong length for ColorControl value: %d", size);
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
return;
}
}
else
{
ChipLogProgress(Zcl, "Unknown cluster ID: " ChipLogFormatMEI, ChipLogValueMEI(clusterId));
return;
}
}

/** @brief OnOff Cluster Init
Expand Down
2 changes: 1 addition & 1 deletion examples/tv-app/android/App/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand Down
21 changes: 10 additions & 11 deletions examples/tv-app/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ Desktop 20.10 (aarch64)**
Start the tv-app. Set ports to not conflict with other Matter apps you might run
on the same machine (chip-tool, tv-casting-app, etc)

$ ./out/host/chip-tv-app --secured-device-port 5640
--secured-commissioner-port 5552
$ ./out/debug/chip-tv-app --secured-device-port 5640 --secured-commissioner-port 5552

Using the tv-app shell, invoke the controller commands:

Expand Down Expand Up @@ -118,8 +117,8 @@ entry in the UDC cache):
You can use chip-tool to launch apps by invoking the Application Launcher
cluster on endpoint 1 using chiptool:

$ ./out/host/chip-tool applicationlauncher launch-app Data CatalogVendorId ApplicationId node-id endpoint-id
$ ./out/host/chip-tool applicationlauncher launch-app foo1 1 App2 1234 1
$ ./out/debug/chip-tool applicationlauncher launch-app Data CatalogVendorId ApplicationId node-id endpoint-id
$ ./out/debug/chip-tool applicationlauncher launch-app foo1 1 App2 1234 1

- Target Navigation from chip-tool

Expand All @@ -128,14 +127,14 @@ player) and on Content App endpoints:

Read targets for a given endpoint:

$ ./out/host/chip-tool targetnavigator read attr-name node-id endpoint-id
$ ./out/host/chip-tool targetnavigator read target-navigator-list 1234 1 (video player endpoint 1)
$ ./out/host/chip-tool targetnavigator read target-navigator-list 1234 6 (content app endpoint 6 - requires app to be launched)
$ ./out/debug/chip-tool targetnavigator read attr-name node-id endpoint-id
$ ./out/debug/chip-tool targetnavigator read target-navigator-list 1234 1 (video player endpoint 1)
$ ./out/debug/chip-tool targetnavigator read target-navigator-list 1234 6 (content app endpoint 6 - requires app to be launched)

Navigate to a new target:

$ ./out/host/chip-tool targetnavigator navigate-target Target Data node-id endpoint-id
$ ./out/host/chip-tool targetnavigator navigate-target 2 foo1 1234 6 (target id 2 on endpoint 6)
$ ./out/debug/chip-tool targetnavigator navigate-target Target Data node-id endpoint-id
$ ./out/debug/chip-tool targetnavigator navigate-target 2 foo1 1234 6 (target id 2 on endpoint 6)

## Casting

Expand All @@ -147,11 +146,11 @@ player and/or a Content App on it.

Start the tv-app:

$ ./out/host/chip-tv-app --secured-device-port 5640 --secured-commissioner-port 5552
$ ./out/debug/chip-tv-app --secured-device-port 5640 --secured-commissioner-port 5552

Start the tv-casting-app:

$ ./out/host/chip-tv-casting-app
$ ./out/debug/chip-tv-casting-app

TV casting app should discover video players on the network. Into the shell,
enter "1" to select the first one in the list:
Expand Down
Loading

0 comments on commit 6832ad0

Please sign in to comment.