Skip to content

Commit

Permalink
[Feature]Microwave oven control cluster implementation (project-chip#…
Browse files Browse the repository at this point in the history
…30235)

* Microwave oven control cluster implementation

* Restyled by whitespace

* Restyled by clang-format

* updated SDK code of MicrowaveOvenControl for checking all the input values

* Restyled by clang-format

* fix build err

* 1. modified SDK and app layer for MicrowaveOvenControl Cluster to avoid using Attribute accessor; 2. add microwave oven device app

* revised device classification ID in examples/microwave-oven-app/linux/include/CHIPProjectAppConfig.h

* updated all-cluster-app for returning original

* updated zap&matter files for adding new updates

* updated the commented code for Microwave Oven Control cluster

* Restyled by whitespace

* Restyled by clang-format

* Restyled by prettier-json

* revised copyright and README info

* removed 'feature map' in the zcl*.json

* Restyled by whitespace

* Restyled by clang-format

* Restyled by prettier-json

* Restyled by prettier-markdown

* updated SDK code after reviewed

* Restyled by whitespace

* Restyled by clang-format

* updated zap configuration for BASIC

* updated microwave oven control SDK for typo

* updated restyled

* Restyled by whitespace

* Restyled by clang-format

* updated Application for microwave oven device

* Restyled by whitespace

* Restyled by clang-format

* revised some reviewed typo

* Restyled by clang-format

* Restyled by gn

* updated App code after reviewed

* Restyled by whitespace

* Restyled by clang-format

* update some comment

* Restyled by whitespace

* Restyled by gn

* recover examples/build_overrides/pigweed_environment.gni

* Restyled by gn

* fix typos and add unique ptr to stdfunction

* update add-more-time command relative functions name

* Restyled by whitespace

* Restyled by clang-format

* regen microwave-oven-app.matter

* Restyled by clang-format

* update add-more-time command function name

* Restyled by clang-format

* removed mode code

* fix typo in main.cpp

* update microwave oven device app and sdk

* compiling app

* compling sdk

* compiling app, sdk

* update Microwave Oven Application and SDK code after reviewed

* Restyled by whitespace

* Restyled by clang-format

* update MicrowaveOven App after reviewed

* Restyled by whitespace

* Restyled by clang-format

* updated MicrowaveOvenControl

* Restyled by whitespace

* fix all_targets_linux_x64.txt

* update microwave oven app for program entry

* Restyled by whitespace

* Restyled by clang-format

* move all private after public for microwave-oven-device.h

* Restyled by clang-format

* update microwave oven app after reviewed

* Restyled by whitespace

* Restyled by clang-format

* update microwave oven mode after reviewed

* Restyled by clang-format

* update microwave-oven-app.matter

* regen ZAP

* add api for ModeBase and updated MicrowaveOvenControl

* Restyled by whitespace

* Restyled by clang-format

* update code after reviewed

* regen ZAP

* Restyled by clang-format

---------

Co-authored-by: mideayanghui <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: ex_liangpy4 <[email protected]>
  • Loading branch information
4 people authored Dec 17, 2023
1 parent 0a5f3d3 commit cdf984e
Show file tree
Hide file tree
Showing 29 changed files with 6,386 additions and 193 deletions.
9 changes: 9 additions & 0 deletions docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@ smoke-co-alarm-app/**/README
dishwasher-app/**/README
```

## Microwave oven example

```{toctree}
:glob:
:maxdepth: 1
microwave-oven-app/**/README
```

## Temperature measurement example

```{toctree}
Expand Down
25 changes: 25 additions & 0 deletions examples/microwave-oven-app/linux/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2023 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 = {
import("//args.gni")
}
51 changes: 51 additions & 0 deletions examples/microwave-oven-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright (c) 2023 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")

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

executable("chip-microwave-oven-app") {
sources = [
"${chip_root}/examples/microwave-oven-app/microwave-oven-common/src/microwave-oven-device.cpp",
"include/CHIPProjectAppConfig.h",
"main.cpp",
]

deps = [
"${chip_root}/examples/microwave-oven-app/microwave-oven-common",
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/src/lib",
]

include_dirs = [
"include",
"${chip_root}/examples/microwave-oven-app/microwave-oven-common/include",
]
output_dir = root_out_dir
}

group("linux") {
deps = [ ":chip-microwave-oven-app" ]
}

group("default") {
deps = [ ":linux" ]
}
141 changes: 141 additions & 0 deletions examples/microwave-oven-app/linux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Matter Linux Microwave Oven Example

An example showing the use of Matter on the Linux. The document will describe
how to build and run Matter Linux Microwave Oven Example on Raspberry Pi. This
doc is tested on **Ubuntu for Raspberry Pi Server 20.04 LTS (aarch64)** and
**Ubuntu for Raspberry Pi Desktop 20.10 (aarch64)**

<hr>

- [Matter Linux Microwave Oven Example](#matter-linux-microwave-oven-example)
- [Building](#building)
- [Commandline Arguments](#commandline-arguments)
- [Running the Complete Example on Raspberry Pi 4](#running-the-complete-example-on-raspberry-pi-4)
- [Running RPC console](#running-rpc-console)
- [Device Tracing](#device-tracing)

<hr>

## Building

- Install tool chain

$ sudo apt-get install git gcc g++ python pkg-config libssl-dev libdbus-1-dev libglib2.0-dev ninja-build python3-venv python3-dev unzip

- Build the example application:

$ cd ~/connectedhomeip/examples/lighting-app/linux
$ git submodule update --init
$ source third_party/connectedhomeip/scripts/activate.sh
$ gn gen out/debug
$ ninja -C out/debug

- To delete generated executable, libraries and object files use:

$ cd ~/connectedhomeip/examples/lighting-app/linux
$ rm -rf out/

- Build the example with pigweed RPC

$ cd ~/connectedhomeip/examples/lighting-app/linux
$ git submodule update --init
$ source third_party/connectedhomeip/scripts/activate.sh
$ gn gen out/debug --args='import("//with_pw_rpc.gni")'
$ ninja -C out/debug

## Commandline arguments

- `--wifi`

Enables WiFi management feature. Required for WiFi commissioning.

- `--thread`

Enables Thread management feature, requires ot-br-posix dbus daemon running.
Required for Thread commissioning.

- `--ble-device <interface id>`

Use specific bluetooth interface for BLE advertisement and connections.

`interface id`: the number after `hci` when listing BLE interfaces by
`hciconfig` command, for example, `--ble-device 1` means using `hci1`
interface. Default: `0`.

## Running the Complete Example on Raspberry Pi 4

> If you want to test Echo protocol, please enable Echo handler
>
> gn gen out/debug --args='chip_app_use_echo=true'
> ninja -C out/debug
- Prerequisites

1. A Raspberry Pi 4 board
2. A USB Bluetooth Dongle, Ubuntu desktop will send Bluetooth advertisement,
which will block CHIP from connecting via BLE. On Ubuntu server, you need
to install `pi-bluetooth` via APT.
3. Ubuntu 20.04 or newer image for ARM64 platform.

- Building

Follow [Building](#building) section of this document.

- Running

- [Optional] Plug USB Bluetooth dongle

- Plug USB Bluetooth dongle and find its bluetooth device number. The
number after `hci` is the bluetooth device number, `1` in this
example.

$ hciconfig
hci1: Type: Primary Bus: USB
BD Address: 00:1A:7D:AA:BB:CC ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING PSCAN ISCAN
RX bytes:20942 acl:1023 sco:0 events:1140 errors:0
TX bytes:16559 acl:1011 sco:0 commands:121 errors:0

hci0: Type: Primary Bus: UART
BD Address: B8:27:EB:AA:BB:CC ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING PSCAN ISCAN
RX bytes:8609495 acl:14 sco:0 events:217484 errors:0
TX bytes:92185 acl:20 sco:0 commands:5259 errors:0

- Run Linux Lighting Example App

$ cd ~/connectedhomeip/examples/lighting-app/linux
$ sudo out/debug/chip-lighting-app --ble-device [bluetooth device number]
# In this example, the device we want to use is hci1
$ sudo out/debug/chip-lighting-app --ble-device 1

- Test the device using ChipDeviceController on your laptop /
workstation etc.

## Running RPC Console

- As part of building the example with RPCs enabled the chip_rpc python
interactive console is installed into your venv. The python wheel files are
also created in the output folder: out/debug/chip_rpc_console_wheels. To
install the wheel files without rebuilding:
`pip3 install out/debug/chip_rpc_console_wheels/*.whl`

- To use the chip-rpc console after it has been installed run:
`chip-console -s localhost:33000 -o /<YourFolder>/pw_log.out`

- Then you can Get and Set the light using the RPCs:
`rpcs.chip.rpc.Lighting.Get()`

`rpcs.chip.rpc.Lighting.Set(on=True, level=128, color=protos.chip.rpc.LightingColor(hue=5, saturation=5))`

## Device Tracing

Device tracing is available to analyze the device performance. To turn on
tracing, build with RPC enabled. See [Building with RPC enabled](#building).

Obtain tracing json file.

```
$ ./{PIGWEED_REPO}/pw_trace_tokenized/py/pw_trace_tokenized/get_trace.py -s localhost:33000 \
-o {OUTPUT_FILE} -t {ELF_FILE} {PIGWEED_REPO}/pw_trace_tokenized/pw_trace_protos/trace_rpc.proto
```
27 changes: 27 additions & 0 deletions examples/microwave-oven-app/linux/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2023 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.

# CHIPProjectConfig.h

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/microwave-oven-app/linux/include" ]
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ]
1 change: 1 addition & 0 deletions examples/microwave-oven-app/linux/build_overrides
34 changes: 34 additions & 0 deletions examples/microwave-oven-app/linux/include/CHIPProjectAppConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
*
* Copyright (c) 2023 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_DEVICE_TYPE 121 // 0x0079 = 121 = Matter Microwave Oven
#define CHIP_DEVICE_CONFIG_DEVICE_NAME "Test Microwave Oven"
44 changes: 44 additions & 0 deletions examples/microwave-oven-app/linux/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
*
* Copyright (c) 2023 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.
*/
#include "microwave-oven-device.h"
#include <AppMain.h>

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;

void ApplicationInit()
{
MatterMicrowaveOvenServerInit();
}

void ApplicationShutdown()
{
MatterMicrowaveOvenServerShutdown();
}

int main(int argc, char * argv[])
{
if (ChipLinuxAppInit(argc, argv) != 0)
{
return -1;
}

ChipLinuxAppMainLoop();
return 0;
}
28 changes: 28 additions & 0 deletions examples/microwave-oven-app/microwave-oven-common/BUILD.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/chip.gni")
import("${chip_root}/src/app/chip_data_model.gni")

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

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

zap_pregenerated_dir =
"${chip_root}/zzz_generated/microwave-oven-app/zap-generated"
is_server = true
}
Loading

0 comments on commit cdf984e

Please sign in to comment.