From eb1bdb3e568f5b3cce86e59344b8742650ba5f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Thu, 23 May 2024 08:35:22 +0200 Subject: [PATCH 1/8] Create README.md for Matter Linux Contact Sensor Example --- examples/contact-sensor-app/linux/README.md | 146 ++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 examples/contact-sensor-app/linux/README.md diff --git a/examples/contact-sensor-app/linux/README.md b/examples/contact-sensor-app/linux/README.md new file mode 100644 index 00000000000000..49f5f413772853 --- /dev/null +++ b/examples/contact-sensor-app/linux/README.md @@ -0,0 +1,146 @@ +# Matter Linux Contact Sensor Example + +An example showing the use of CHIP on the Linux. The document will describe how +to build and run Matter Linux Contact Sensor 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)** + +To cross-compile this example on x64 host and run on **NXP i.MX 8M Mini** +**EVK**, see the associated +[README document](../../../docs/guides/nxp/nxp_imx8m_linux_examples.md) for +details. + +
+ +- [Matter Linux Contact Sensor Example](#chip-linux-lighting-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) + +
+ +## 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/contact-sensor-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/contact-sensor-app/linux + $ rm -rf out/ + +- Build the example with pigweed RPC + + $ cd ~/connectedhomeip/examples/contact-sensor-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 ` + + 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 Contact Sensor App + + $ cd ~/connectedhomeip/examples/contact-sensor-app/linux + $ sudo out/debug/chip-contact-sensor-app --ble-device [bluetooth device number] + # In this example, the device we want to use is hci1 + $ sudo out/debug/chip-contact-sensor-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 //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 +``` From 34fd497a3b39635200cb92c58847e5c05aa98501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Thu, 23 May 2024 08:44:56 +0200 Subject: [PATCH 2/8] Update README.md --- examples/contact-sensor-app/linux/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/contact-sensor-app/linux/README.md b/examples/contact-sensor-app/linux/README.md index 49f5f413772853..a19f68b9e0c3b1 100644 --- a/examples/contact-sensor-app/linux/README.md +++ b/examples/contact-sensor-app/linux/README.md @@ -12,7 +12,7 @@ details.
-- [Matter Linux Contact Sensor Example](#chip-linux-lighting-example) +- [Matter Linux Contact Sensor Example](#matter-linux-contact-sensor-example) - [Building](#building) - [Commandline Arguments](#commandline-arguments) - [Running the Complete Example on Raspberry Pi 4](#running-the-complete-example-on-raspberry-pi-4) From c3f198f2fec0c5bb9f40ddbc103fe7faee5479fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Thu, 23 May 2024 08:56:52 +0200 Subject: [PATCH 3/8] Update README.md [PATCH] Restyled by prettier-markdown --- examples/contact-sensor-app/linux/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/contact-sensor-app/linux/README.md b/examples/contact-sensor-app/linux/README.md index a19f68b9e0c3b1..1d15503fe43df5 100644 --- a/examples/contact-sensor-app/linux/README.md +++ b/examples/contact-sensor-app/linux/README.md @@ -1,9 +1,9 @@ # Matter Linux Contact Sensor Example An example showing the use of CHIP on the Linux. The document will describe how -to build and run Matter Linux Contact Sensor 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)** +to build and run Matter Linux Contact Sensor 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)** To cross-compile this example on x64 host and run on **NXP i.MX 8M Mini** **EVK**, see the associated From 8e7f35adba459e04cd6603f09142e5a503b36aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Thu, 23 May 2024 11:27:31 +0200 Subject: [PATCH 4/8] Update README.md Fix 'RPC Console' section --- examples/contact-sensor-app/linux/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/contact-sensor-app/linux/README.md b/examples/contact-sensor-app/linux/README.md index 1d15503fe43df5..ec02588fb04131 100644 --- a/examples/contact-sensor-app/linux/README.md +++ b/examples/contact-sensor-app/linux/README.md @@ -128,10 +128,8 @@ details. - To use the chip-rpc console after it has been installed run: `chip-console -s localhost:33000 -o //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))` +- Then you can Get the contact sensor status using the RPCs: + `rpcs.chip.rpc.BooleanState.Get()` ## Device Tracing From 76943ff308a8fa0e1db95183bfd31bac1288b963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Thu, 23 May 2024 18:18:41 +0200 Subject: [PATCH 5/8] Update examples/contact-sensor-app/linux/README.md Co-authored-by: Kiel Oleson --- examples/contact-sensor-app/linux/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/contact-sensor-app/linux/README.md b/examples/contact-sensor-app/linux/README.md index ec02588fb04131..bcfe31ae2e0778 100644 --- a/examples/contact-sensor-app/linux/README.md +++ b/examples/contact-sensor-app/linux/README.md @@ -5,7 +5,7 @@ to build and run Matter Linux Contact Sensor 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)** -To cross-compile this example on x64 host and run on **NXP i.MX 8M Mini** +To cross-compile this example on an x64 host and run it on **NXP i.MX 8M Mini** **EVK**, see the associated [README document](../../../docs/guides/nxp/nxp_imx8m_linux_examples.md) for details. From 8ed63be1803ca1703902ca8d6c7040a749a7e85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Thu, 23 May 2024 18:20:12 +0200 Subject: [PATCH 6/8] Update examples/contact-sensor-app/linux/README.md Co-authored-by: Kiel Oleson --- examples/contact-sensor-app/linux/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/contact-sensor-app/linux/README.md b/examples/contact-sensor-app/linux/README.md index bcfe31ae2e0778..c0f7ef4c2860ca 100644 --- a/examples/contact-sensor-app/linux/README.md +++ b/examples/contact-sensor-app/linux/README.md @@ -1,7 +1,7 @@ # Matter Linux Contact Sensor Example -An example showing the use of CHIP on the Linux. The document will describe how -to build and run Matter Linux Contact Sensor Example on Raspberry Pi. This doc +An example showing the use of CHIP on the Linux. This document will describe how +to build and run Matter Linux Contact Sensor Example on Raspberry Pi. This document is tested on **Ubuntu for Raspberry Pi Server 20.04 LTS (aarch64)** and **Ubuntu for Raspberry Pi Desktop 20.10 (aarch64)** From d2702f0a85555983496348513f87bd9eed300c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Thu, 23 May 2024 18:20:25 +0200 Subject: [PATCH 7/8] Update examples/contact-sensor-app/linux/README.md Co-authored-by: Kiel Oleson --- examples/contact-sensor-app/linux/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/contact-sensor-app/linux/README.md b/examples/contact-sensor-app/linux/README.md index c0f7ef4c2860ca..3be6201f0054c9 100644 --- a/examples/contact-sensor-app/linux/README.md +++ b/examples/contact-sensor-app/linux/README.md @@ -136,7 +136,7 @@ details. 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. +To obtain the tracing json file, run: ``` $ ./{PIGWEED_REPO}/pw_trace_tokenized/py/pw_trace_tokenized/get_trace.py -s localhost:33000 \ From 1508046415c340f12d9da644e50a8d2046b3ffab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Thu, 23 May 2024 18:53:27 +0200 Subject: [PATCH 8/8] Restyled by prettier-markdown --- examples/contact-sensor-app/linux/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/contact-sensor-app/linux/README.md b/examples/contact-sensor-app/linux/README.md index 3be6201f0054c9..f99162f4fdee10 100644 --- a/examples/contact-sensor-app/linux/README.md +++ b/examples/contact-sensor-app/linux/README.md @@ -1,9 +1,9 @@ # Matter Linux Contact Sensor Example An example showing the use of CHIP on the Linux. This document will describe how -to build and run Matter Linux Contact Sensor Example on Raspberry Pi. This document -is tested on **Ubuntu for Raspberry Pi Server 20.04 LTS (aarch64)** and **Ubuntu -for Raspberry Pi Desktop 20.10 (aarch64)** +to build and run Matter Linux Contact Sensor Example on Raspberry Pi. This +document is tested on **Ubuntu for Raspberry Pi Server 20.04 LTS (aarch64)** and +**Ubuntu for Raspberry Pi Desktop 20.10 (aarch64)** To cross-compile this example on an x64 host and run it on **NXP i.MX 8M Mini** **EVK**, see the associated