Skip to content

Commit

Permalink
Merge branch 'project-chip:master' into metering-identification-clust…
Browse files Browse the repository at this point in the history
…er-test-scripts
  • Loading branch information
dmitrymaslovdsr authored May 24, 2024
2 parents 7208c75 + 21e239e commit 3b0a991
Show file tree
Hide file tree
Showing 91 changed files with 2,423 additions and 353 deletions.
24 changes: 14 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,29 @@
"${workspaceFolder}/build/default/src/lib/**",
"${workspaceFolder}/config/standalone/",
"${workspaceFolder}/config/standalone/**",
"${workspaceFolder}/darwin/Framework/CHIP/**",
"${workspaceFolder}/examples/**",
"${workspaceFolder}/src/**",
"${workspaceFolder}/src/app/**",
"${workspaceFolder}/src/ble/**",
"${workspaceFolder}/src/controller/**",
"${workspaceFolder}/src/credentials/**",
"${workspaceFolder}/src/crypto/**",
"${workspaceFolder}/src/darwin/**",
"${workspaceFolder}/src/include/",
"${workspaceFolder}/src/include/**",
"${workspaceFolder}/src/inet/**",
"${workspaceFolder}/src/lib/**",
"${workspaceFolder}/src/system/**",
"${workspaceFolder}/third_party/nlassert/repo/include/**",
"${workspaceFolder}/third_party/nlio/repo/include/**",
"${workspaceFolder}/darwin/Framework/CHIP/**",
"${workspaceFolder}/src/lwip/**",
"${workspaceFolder}/src/messaging/**",
"${workspaceFolder}/src/platform/**",
"${workspaceFolder}/src/protocols/**",
"${workspaceFolder}/src/setup_payload/**",
"${workspaceFolder}/src/system/**",
"${workspaceFolder}/src/tracing/**",
"${workspaceFolder}/src/transport/**",
"${workspaceFolder}/src/inet/**",
"${workspaceFolder}/src/credentials/**",
"${workspaceFolder}/src/data_model/**",
"${workspaceFolder}/src/app/**",
"${workspaceFolder}/src/crytpo/**",
"${workspaceFolder}/src/platform/**"
"${workspaceFolder}/third_party/nlassert/repo/include/**",
"${workspaceFolder}/third_party/nlio/repo/include/**"
],
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@ class CHIPToolActivity :
}
}

override fun onResume() {
super.onResume()
ChipClient.startDnssd(this)
}

override fun onPause() {
ChipClient.stopDnssd(this)
super.onPause()
}

companion object {
private const val TAG = "CHIPToolActivity"
private const val ADDRESS_COMMISSIONING_FRAGMENT_TAG = "address_commissioning_fragment"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ object ChipClient {
icdCheckInCallback = callback
}

fun startDnssd(context: Context) {
if (!this::chipDeviceController.isInitialized) {
getDeviceController(context)
} else {
chipDeviceController.startDnssd()
}
}

fun stopDnssd(context: Context) {
if (!this::chipDeviceController.isInitialized) {
getDeviceController(context)
}
chipDeviceController.stopDnssd()
}

/**
* Wrapper around [ChipDeviceController.getConnectedDevicePointer] to return the value directly.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ class AddressUpdateFragment : ICDCheckInCallback, Fragment() {
val runnable =
object : Runnable {
override fun run() {
if (!isAdded) {
Log.d(TAG, "Fragment is not attached")
return
}
if (icdTotalRemainStayActiveTimeMs >= ICD_PROGRESS_STEP) {
icdDeviceRemainStayActiveTimeMs -= ICD_PROGRESS_STEP
icdTotalRemainStayActiveTimeMs -= ICD_PROGRESS_STEP
Expand Down
144 changes: 144 additions & 0 deletions examples/contact-sensor-app/linux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# 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 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.

<hr>

- [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)
- [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/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 <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 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 /<YourFolder>/pw_log.out`

- Then you can Get the contact sensor status using the RPCs:
`rpcs.chip.rpc.BooleanState.Get()`

## 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).

To obtain the tracing json file, run:

```
$ ./{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
```
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@implementation CHIPToolDeviceControllerDelegate
- (void)controller:(MTRDeviceController *)controller statusUpdate:(MTRCommissioningStatus)status
{
NSLog(@"Pairing Status Update: %tu", status);
NSLog(@"Pairing Status Update: %ld", static_cast<long>(status));
switch (status) {
case MTRCommissioningStatusSuccess:
ChipLogProgress(chipTool, "Secure Pairing Success");
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-admin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ static_library("fabric-admin-utils") {

sources += [ "commands/interactive/InteractiveCommands.cpp" ]
deps += [
"${chip_root}/examples/common/websocket-server",
"${chip_root}/src/platform/logging:headers",
"${editline_root}:editline",
]
Expand Down
2 changes: 1 addition & 1 deletion examples/fabric-admin/commands/clusters/JsonParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#pragma once

#include "../common/CustomStringPrefix.h"
#include <commands/common/CustomStringPrefix.h>

#include <json/json.h>
#include <lib/core/Optional.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/fabric-admin/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#ifdef CONFIG_USE_LOCAL_STORAGE
#include <controller/ExamplePersistentStorage.h>
#endif // CONFIG_USE_LOCAL_STORAGE
#endif

#include "../common/CHIPCommand.h"
#include <lib/core/CHIPEncoding.h>
Expand Down
6 changes: 3 additions & 3 deletions examples/fabric-admin/commands/interactive/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

#pragma once

#include "commands/common/CHIPCommand.h"
#include "commands/common/Commands.h"
#include "commands/interactive/InteractiveCommands.h"
#include <commands/common/CHIPCommand.h>
#include <commands/common/Commands.h>
#include <commands/interactive/InteractiveCommands.h>

void registerCommandsInteractive(Commands & commands, CredentialIssuerCommands * credsIssuerConfig)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@

#pragma once

#include "../clusters/DataModelLogger.h"
#include "../common/CHIPCommand.h"
#include "../common/Commands.h"

#include <websocket-server/WebSocketServer.h>
#include <commands/clusters/DataModelLogger.h>
#include <commands/common/CHIPCommand.h>
#include <commands/common/Commands.h>

#include <string>

Expand Down
14 changes: 7 additions & 7 deletions examples/fabric-admin/commands/pairing/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

#pragma once

#include "commands/common/Commands.h"
#include "commands/pairing/GetCommissionerNodeIdCommand.h"
#include "commands/pairing/GetCommissionerRootCertificateCommand.h"
#include "commands/pairing/IssueNOCChainCommand.h"
#include "commands/pairing/OpenCommissioningWindowCommand.h"
#include "commands/pairing/PairingCommand.h"
#include <commands/common/Commands.h>
#include <commands/common/CredentialIssuerCommands.h>
#include <commands/pairing/GetCommissionerNodeIdCommand.h>
#include <commands/pairing/GetCommissionerRootCertificateCommand.h>
#include <commands/pairing/IssueNOCChainCommand.h>
#include <commands/pairing/OpenCommissioningWindowCommand.h>
#include <commands/pairing/PairingCommand.h>

#include <app/server/Dnssd.h>
#include <commands/common/CredentialIssuerCommands.h>
#include <lib/dnssd/Resolver.h>

class Unpair : public PairingCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#pragma once

#include "../common/CHIPCommand.h"
#include "../common/RemoteDataModelLogger.h"
#include <commands/common/CHIPCommand.h>
#include <commands/common/RemoteDataModelLogger.h>

class GetCommissionerNodeIdCommand : public CHIPCommand
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#pragma once

#include "../common/CHIPCommand.h"
#include "../common/RemoteDataModelLogger.h"
#include <commands/common/CHIPCommand.h>
#include <commands/common/RemoteDataModelLogger.h>

#include "ToTLVCert.h"

Expand Down
4 changes: 2 additions & 2 deletions examples/fabric-admin/commands/pairing/IssueNOCChainCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#pragma once

#include "../common/CHIPCommand.h"
#include "../common/RemoteDataModelLogger.h"
#include <commands/common/CHIPCommand.h>
#include <commands/common/RemoteDataModelLogger.h>

#include "ToTLVCert.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

#pragma once

#include "../common/CHIPCommand.h"

#include <commands/common/CHIPCommand.h>
#include <controller/CommissioningWindowOpener.h>
#include <lib/support/CHIPMem.h>

Expand Down
4 changes: 2 additions & 2 deletions examples/fabric-admin/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
*/

#include "PairingCommand.h"
#include "platform/PlatformManager.h"

#include <commands/common/DeviceScanner.h>
#include <controller/ExampleOperationalCredentialsIssuer.h>
#include <crypto/CHIPCryptoPAL.h>
#include <lib/core/CHIPSafeCasts.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/PlatformManager.h>
#include <protocols/secure_channel/PASESession.h>

#include <setup_payload/ManualSetupPayloadParser.h>
#include <setup_payload/QRCodeSetupPayloadParser.h>

Expand Down
5 changes: 2 additions & 3 deletions examples/fabric-admin/commands/pairing/PairingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@

#pragma once

#include "../common/CHIPCommand.h"
#include <commands/common/CHIPCommand.h>
#include <commands/common/CredentialIssuerCommands.h>
#include <controller/CommissioningDelegate.h>
#include <controller/CurrentFabricRemover.h>

#include <commands/common/CredentialIssuerCommands.h>
#include <lib/support/Span.h>
#include <lib/support/ThreadOperationalDataset.h>

Expand Down
Loading

0 comments on commit 3b0a991

Please sign in to comment.