Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matter end-device implemented in Python #8589

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
523 changes: 8 additions & 515 deletions examples/chip-tool/commands/clusters/Commands.h

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions examples/chip-tool/commands/reporting/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ class Listen : public ReportingCommand
delete onReportColorControlColorTemperatureCallback;
delete onReportDoorLockLockStateCallback;
delete onReportLevelControlCurrentLevelCallback;
delete onReportLevelControlCurrentLevelCallback;
delete onReportOccupancySensingOccupancyCallback;
delete onReportOnOffOnOffCallback;
delete onReportOnOffOnOffCallback;
delete onReportPressureMeasurementMeasuredValueCallback;
delete onReportPumpConfigurationAndControlCapacityCallback;
delete onReportRelativeHumidityMeasurementMeasuredValueCallback;
Expand Down Expand Up @@ -78,10 +80,14 @@ class Listen : public ReportingCommand
onReportDoorLockLockStateCallback->Cancel());
callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0008, 0x0000,
onReportLevelControlCurrentLevelCallback->Cancel());
callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0008, 0x0000,
onReportLevelControlCurrentLevelCallback->Cancel());
callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0406, 0x0000,
onReportOccupancySensingOccupancyCallback->Cancel());
callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0006, 0x0000,
onReportOnOffOnOffCallback->Cancel());
callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0006, 0x0000,
onReportOnOffOnOffCallback->Cancel());
callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0403, 0x0000,
onReportPressureMeasurementMeasuredValueCallback->Cancel());
callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0200, 0x0013,
Expand Down Expand Up @@ -163,8 +169,12 @@ class Listen : public ReportingCommand
new chip::Callback::Callback<Int8uAttributeCallback>(OnInt8uAttributeResponse, this);
chip::Callback::Callback<Int8uAttributeCallback> * onReportLevelControlCurrentLevelCallback =
new chip::Callback::Callback<Int8uAttributeCallback>(OnInt8uAttributeResponse, this);
// chip::Callback::Callback<Int8uAttributeCallback> * onReportLevelControlCurrentLevelCallback =
// new chip::Callback::Callback<Int8uAttributeCallback>(OnInt8uAttributeResponse, this);
chip::Callback::Callback<Int8uAttributeCallback> * onReportOccupancySensingOccupancyCallback =
new chip::Callback::Callback<Int8uAttributeCallback>(OnInt8uAttributeResponse, this);
// chip::Callback::Callback<BooleanAttributeCallback> * onReportOnOffOnOffCallback =
// new chip::Callback::Callback<BooleanAttributeCallback>(OnBooleanAttributeResponse, this);
chip::Callback::Callback<BooleanAttributeCallback> * onReportOnOffOnOffCallback =
new chip::Callback::Callback<BooleanAttributeCallback>(OnBooleanAttributeResponse, this);
chip::Callback::Callback<Int16sAttributeCallback> * onReportPressureMeasurementMeasuredValueCallback =
Expand Down
1,559 changes: 224 additions & 1,335 deletions examples/chip-tool/commands/tests/Commands.h

Large diffs are not rendered by default.

92 changes: 92 additions & 0 deletions examples/lighting-app/python/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# 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)

import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")

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

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/platform/linux:app-main",
"${chip_root}/src/lib",
]

include_dirs = [ "include" ]

cflags = [ "-Wconversion" ]

if (chip_enable_pw_rpc) {
import("//build_overrides/pigweed.gni")

defines = [ "PW_RPC_ENABLED" ]

sources += [
"${dir_pigweed}/targets/host/system_rpc_server.cc",
"Rpc.cpp",
]

deps += [
"$dir_pw_hdlc:pw_rpc",
"$dir_pw_hdlc:rpc_channel_output",
"$dir_pw_log",
"$dir_pw_rpc:server",
"$dir_pw_rpc:synchronized_channel_output",
"$dir_pw_rpc/system_server:facade",
"$dir_pw_stream:socket_stream",
"$dir_pw_stream:sys_io_stream",
"$dir_pw_sync:mutex",
"${chip_root}/config/linux/lib/pw_rpc:pw_rpc",
"${chip_root}/examples/common/pigweed:button_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:device_service.nanopb_rpc",
"${chip_root}/examples/lighting-app/lighting-common:lighting_service.nanopb_rpc",
]
}

output_dir = root_out_dir
}

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

if (chip_enable_pw_rpc) {
deps += [
"${chip_root}/examples/lighting-app/lighting-common/py:lighting_app.install",
"${chip_root}/examples/lighting-app/lighting-common/py:lighting_app_wheel",
]
}
}

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

Python based lighting example (bridge) device to DALI.

## Installation

Add the following options in scripts/build_python.sh to the gn args:

```shell
chip_config_network_layer_ble=false
```

Build the Python/C library:

```shell
scripts/build_python.sh --clusters_for_ip_commissioning false --chip_mdns platform --chip_detail_logging true

source ./out/python_env/bin/activate
```

Install the python dependencies:

```shell
cd examples/lighting-app/python
pip3 install python-dali
```

Plug-in a python-dali compatible USB-DALI interface.

## Usage

Run the Python lighting matter device:

```shell
cd examples/lighting-app/python
python lighting.py
```

Control the Python lighting matter device:

```shell
source ./out/python_env/bin/activate

chip-device-ctrl

chip-device-ctrl > connect -ip 127.0.0.1 20202021 1234
chip-device-ctrl > zcl OnOff Toggle 1234 1 0
```
Loading