Skip to content

Commit 985e53a

Browse files
Merge branch 'project-chip:master' into tc-idm-4.3-(python)
2 parents 2ba8359 + b398fb4 commit 985e53a

File tree

83 files changed

+1705
-337
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1705
-337
lines changed

examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt

+10
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,16 @@ class CHIPToolActivity :
238238
}
239239
}
240240

241+
override fun onResume() {
242+
super.onResume()
243+
ChipClient.startDnssd(this)
244+
}
245+
246+
override fun onPause() {
247+
ChipClient.stopDnssd(this)
248+
super.onPause()
249+
}
250+
241251
companion object {
242252
private const val TAG = "CHIPToolActivity"
243253
private const val ADDRESS_COMMISSIONING_FRAGMENT_TAG = "address_commissioning_fragment"

examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt

+15
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@ object ChipClient {
114114
icdCheckInCallback = callback
115115
}
116116

117+
fun startDnssd(context: Context) {
118+
if (!this::chipDeviceController.isInitialized) {
119+
getDeviceController(context)
120+
} else {
121+
chipDeviceController.startDnssd()
122+
}
123+
}
124+
125+
fun stopDnssd(context: Context) {
126+
if (!this::chipDeviceController.isInitialized) {
127+
getDeviceController(context)
128+
}
129+
chipDeviceController.stopDnssd()
130+
}
131+
117132
/**
118133
* Wrapper around [ChipDeviceController.getConnectedDevicePointer] to return the value directly.
119134
*/

examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/AddressUpdateFragment.kt

+4
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ class AddressUpdateFragment : ICDCheckInCallback, Fragment() {
230230
val runnable =
231231
object : Runnable {
232232
override fun run() {
233+
if (!isAdded) {
234+
Log.d(TAG, "Fragment is not attached")
235+
return
236+
}
233237
if (icdTotalRemainStayActiveTimeMs >= ICD_PROGRESS_STEP) {
234238
icdDeviceRemainStayActiveTimeMs -= ICD_PROGRESS_STEP
235239
icdTotalRemainStayActiveTimeMs -= ICD_PROGRESS_STEP
+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Matter Linux Contact Sensor Example
2+
3+
An example showing the use of CHIP on the Linux. This document will describe how
4+
to build and run Matter Linux Contact Sensor Example on Raspberry Pi. This
5+
document is tested on **Ubuntu for Raspberry Pi Server 20.04 LTS (aarch64)** and
6+
**Ubuntu for Raspberry Pi Desktop 20.10 (aarch64)**
7+
8+
To cross-compile this example on an x64 host and run it on **NXP i.MX 8M Mini**
9+
**EVK**, see the associated
10+
[README document](../../../docs/guides/nxp/nxp_imx8m_linux_examples.md) for
11+
details.
12+
13+
<hr>
14+
15+
- [Matter Linux Contact Sensor Example](#matter-linux-contact-sensor-example)
16+
- [Building](#building)
17+
- [Commandline Arguments](#commandline-arguments)
18+
- [Running the Complete Example on Raspberry Pi 4](#running-the-complete-example-on-raspberry-pi-4)
19+
- [Running RPC console](#running-rpc-console)
20+
- [Device Tracing](#device-tracing)
21+
22+
<hr>
23+
24+
## Building
25+
26+
- Install tool chain
27+
28+
$ 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
29+
30+
- Build the example application:
31+
32+
$ cd ~/connectedhomeip/examples/contact-sensor-app/linux
33+
$ git submodule update --init
34+
$ source third_party/connectedhomeip/scripts/activate.sh
35+
$ gn gen out/debug
36+
$ ninja -C out/debug
37+
38+
- To delete generated executable, libraries and object files use:
39+
40+
$ cd ~/connectedhomeip/examples/contact-sensor-app/linux
41+
$ rm -rf out/
42+
43+
- Build the example with pigweed RPC
44+
45+
$ cd ~/connectedhomeip/examples/contact-sensor-app/linux
46+
$ git submodule update --init
47+
$ source third_party/connectedhomeip/scripts/activate.sh
48+
$ gn gen out/debug --args='import("//with_pw_rpc.gni")'
49+
$ ninja -C out/debug
50+
51+
## Commandline arguments
52+
53+
- `--wifi`
54+
55+
Enables WiFi management feature. Required for WiFi commissioning.
56+
57+
- `--thread`
58+
59+
Enables Thread management feature, requires ot-br-posix dbus daemon running.
60+
Required for Thread commissioning.
61+
62+
- `--ble-device <interface id>`
63+
64+
Use specific bluetooth interface for BLE advertisement and connections.
65+
66+
`interface id`: the number after `hci` when listing BLE interfaces by
67+
`hciconfig` command, for example, `--ble-device 1` means using `hci1`
68+
interface. Default: `0`.
69+
70+
## Running the Complete Example on Raspberry Pi 4
71+
72+
> If you want to test Echo protocol, please enable Echo handler
73+
>
74+
> gn gen out/debug --args='chip_app_use_echo=true'
75+
> ninja -C out/debug
76+
77+
- Prerequisites
78+
79+
1. A Raspberry Pi 4 board
80+
2. A USB Bluetooth Dongle, Ubuntu desktop will send Bluetooth advertisement,
81+
which will block CHIP from connecting via BLE. On Ubuntu server, you need
82+
to install `pi-bluetooth` via APT.
83+
3. Ubuntu 20.04 or newer image for ARM64 platform.
84+
85+
- Building
86+
87+
Follow [Building](#building) section of this document.
88+
89+
- Running
90+
91+
- [Optional] Plug USB Bluetooth dongle
92+
93+
- Plug USB Bluetooth dongle and find its bluetooth device number. The
94+
number after `hci` is the bluetooth device number, `1` in this
95+
example.
96+
97+
$ hciconfig
98+
hci1: Type: Primary Bus: USB
99+
BD Address: 00:1A:7D:AA:BB:CC ACL MTU: 310:10 SCO MTU: 64:8
100+
UP RUNNING PSCAN ISCAN
101+
RX bytes:20942 acl:1023 sco:0 events:1140 errors:0
102+
TX bytes:16559 acl:1011 sco:0 commands:121 errors:0
103+
104+
hci0: Type: Primary Bus: UART
105+
BD Address: B8:27:EB:AA:BB:CC ACL MTU: 1021:8 SCO MTU: 64:1
106+
UP RUNNING PSCAN ISCAN
107+
RX bytes:8609495 acl:14 sco:0 events:217484 errors:0
108+
TX bytes:92185 acl:20 sco:0 commands:5259 errors:0
109+
110+
- Run Linux Contact Sensor App
111+
112+
$ cd ~/connectedhomeip/examples/contact-sensor-app/linux
113+
$ sudo out/debug/chip-contact-sensor-app --ble-device [bluetooth device number]
114+
# In this example, the device we want to use is hci1
115+
$ sudo out/debug/chip-contact-sensor-app --ble-device 1
116+
117+
- Test the device using ChipDeviceController on your laptop /
118+
workstation etc.
119+
120+
## Running RPC Console
121+
122+
- As part of building the example with RPCs enabled the chip_rpc python
123+
interactive console is installed into your venv. The python wheel files are
124+
also created in the output folder: out/debug/chip_rpc_console_wheels. To
125+
install the wheel files without rebuilding:
126+
`pip3 install out/debug/chip_rpc_console_wheels/*.whl`
127+
128+
- To use the chip-rpc console after it has been installed run:
129+
`chip-console -s localhost:33000 -o /<YourFolder>/pw_log.out`
130+
131+
- Then you can Get the contact sensor status using the RPCs:
132+
`rpcs.chip.rpc.BooleanState.Get()`
133+
134+
## Device Tracing
135+
136+
Device tracing is available to analyze the device performance. To turn on
137+
tracing, build with RPC enabled. See [Building with RPC enabled](#building).
138+
139+
To obtain the tracing json file, run:
140+
141+
```
142+
$ ./{PIGWEED_REPO}/pw_trace_tokenized/py/pw_trace_tokenized/get_trace.py -s localhost:33000 \
143+
-o {OUTPUT_FILE} -t {ELF_FILE} {PIGWEED_REPO}/pw_trace_tokenized/pw_trace_protos/trace_rpc.proto
144+
```

examples/fabric-admin/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ static_library("fabric-admin-utils") {
6969

7070
sources += [ "commands/interactive/InteractiveCommands.cpp" ]
7171
deps += [
72-
"${chip_root}/examples/common/websocket-server",
7372
"${chip_root}/src/platform/logging:headers",
7473
"${editline_root}:editline",
7574
]

examples/fabric-admin/commands/clusters/JsonParser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#pragma once
2020

21-
#include "../common/CustomStringPrefix.h"
21+
#include <commands/common/CustomStringPrefix.h>
2222

2323
#include <json/json.h>
2424
#include <lib/core/Optional.h>

examples/fabric-admin/commands/clusters/ModelCommand.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#ifdef CONFIG_USE_LOCAL_STORAGE
2222
#include <controller/ExamplePersistentStorage.h>
23-
#endif // CONFIG_USE_LOCAL_STORAGE
23+
#endif
2424

2525
#include "../common/CHIPCommand.h"
2626
#include <lib/core/CHIPEncoding.h>

examples/fabric-admin/commands/interactive/Commands.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
#pragma once
2020

21-
#include "commands/common/CHIPCommand.h"
22-
#include "commands/common/Commands.h"
23-
#include "commands/interactive/InteractiveCommands.h"
21+
#include <commands/common/CHIPCommand.h>
22+
#include <commands/common/Commands.h>
23+
#include <commands/interactive/InteractiveCommands.h>
2424

2525
void registerCommandsInteractive(Commands & commands, CredentialIssuerCommands * credsIssuerConfig)
2626
{

examples/fabric-admin/commands/interactive/InteractiveCommands.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818

1919
#pragma once
2020

21-
#include "../clusters/DataModelLogger.h"
22-
#include "../common/CHIPCommand.h"
23-
#include "../common/Commands.h"
24-
25-
#include <websocket-server/WebSocketServer.h>
21+
#include <commands/clusters/DataModelLogger.h>
22+
#include <commands/common/CHIPCommand.h>
23+
#include <commands/common/Commands.h>
2624

2725
#include <string>
2826

examples/fabric-admin/commands/pairing/Commands.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818

1919
#pragma once
2020

21-
#include "commands/common/Commands.h"
22-
#include "commands/pairing/GetCommissionerNodeIdCommand.h"
23-
#include "commands/pairing/GetCommissionerRootCertificateCommand.h"
24-
#include "commands/pairing/IssueNOCChainCommand.h"
25-
#include "commands/pairing/OpenCommissioningWindowCommand.h"
26-
#include "commands/pairing/PairingCommand.h"
21+
#include <commands/common/Commands.h>
22+
#include <commands/common/CredentialIssuerCommands.h>
23+
#include <commands/pairing/GetCommissionerNodeIdCommand.h>
24+
#include <commands/pairing/GetCommissionerRootCertificateCommand.h>
25+
#include <commands/pairing/IssueNOCChainCommand.h>
26+
#include <commands/pairing/OpenCommissioningWindowCommand.h>
27+
#include <commands/pairing/PairingCommand.h>
2728

2829
#include <app/server/Dnssd.h>
29-
#include <commands/common/CredentialIssuerCommands.h>
3030
#include <lib/dnssd/Resolver.h>
3131

3232
class Unpair : public PairingCommand

examples/fabric-admin/commands/pairing/GetCommissionerNodeIdCommand.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
#pragma once
2020

21-
#include "../common/CHIPCommand.h"
22-
#include "../common/RemoteDataModelLogger.h"
21+
#include <commands/common/CHIPCommand.h>
22+
#include <commands/common/RemoteDataModelLogger.h>
2323

2424
class GetCommissionerNodeIdCommand : public CHIPCommand
2525
{

examples/fabric-admin/commands/pairing/GetCommissionerRootCertificateCommand.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
#pragma once
2020

21-
#include "../common/CHIPCommand.h"
22-
#include "../common/RemoteDataModelLogger.h"
21+
#include <commands/common/CHIPCommand.h>
22+
#include <commands/common/RemoteDataModelLogger.h>
2323

2424
#include "ToTLVCert.h"
2525

examples/fabric-admin/commands/pairing/IssueNOCChainCommand.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
#pragma once
2020

21-
#include "../common/CHIPCommand.h"
22-
#include "../common/RemoteDataModelLogger.h"
21+
#include <commands/common/CHIPCommand.h>
22+
#include <commands/common/RemoteDataModelLogger.h>
2323

2424
#include "ToTLVCert.h"
2525

examples/fabric-admin/commands/pairing/OpenCommissioningWindowCommand.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818

1919
#pragma once
2020

21-
#include "../common/CHIPCommand.h"
22-
21+
#include <commands/common/CHIPCommand.h>
2322
#include <controller/CommissioningWindowOpener.h>
2423
#include <lib/support/CHIPMem.h>
2524

examples/fabric-admin/commands/pairing/PairingCommand.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
*/
1818

1919
#include "PairingCommand.h"
20-
#include "platform/PlatformManager.h"
20+
2121
#include <commands/common/DeviceScanner.h>
2222
#include <controller/ExampleOperationalCredentialsIssuer.h>
2323
#include <crypto/CHIPCryptoPAL.h>
2424
#include <lib/core/CHIPSafeCasts.h>
2525
#include <lib/support/logging/CHIPLogging.h>
26+
#include <platform/PlatformManager.h>
2627
#include <protocols/secure_channel/PASESession.h>
27-
2828
#include <setup_payload/ManualSetupPayloadParser.h>
2929
#include <setup_payload/QRCodeSetupPayloadParser.h>
3030

examples/fabric-admin/commands/pairing/PairingCommand.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818

1919
#pragma once
2020

21-
#include "../common/CHIPCommand.h"
21+
#include <commands/common/CHIPCommand.h>
22+
#include <commands/common/CredentialIssuerCommands.h>
2223
#include <controller/CommissioningDelegate.h>
2324
#include <controller/CurrentFabricRemover.h>
24-
25-
#include <commands/common/CredentialIssuerCommands.h>
2625
#include <lib/support/Span.h>
2726
#include <lib/support/ThreadOperationalDataset.h>
2827

examples/fabric-admin/main.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
*
1717
*/
1818

19-
#include "commands/common/Commands.h"
20-
21-
#include "commands/clusters/SubscriptionsCommands.h"
22-
#include "commands/interactive/Commands.h"
23-
#include "commands/pairing/Commands.h"
19+
#include <commands/clusters/SubscriptionsCommands.h>
20+
#include <commands/common/Commands.h>
21+
#include <commands/interactive/Commands.h>
22+
#include <commands/pairing/Commands.h>
2423
#include <zap-generated/cluster/Commands.h>
2524

2625
#include <iostream>

0 commit comments

Comments
 (0)