William 985794a2fd Fix/post pr 28707 comments (#28993) há 2 anos atrás
..
entitlements d5bfb4b38f Add isort formatter to restyled configuration (#24148) há 3 anos atrás
include 4eaace433a Mode base sdk implementation (#27504) há 2 anos atrás
third_party 280d80f921 Add a linux version of the all-clusters-app demo (#3678) há 5 anos atrás
.gn 4e1faf236d [gn] introduce build_root variable (#4352) há 5 anos atrás
AllClustersCommandDelegate.cpp 985794a2fd Fix/post pr 28707 comments (#28993) há 2 anos atrás
AllClustersCommandDelegate.h 985794a2fd Fix/post pr 28707 comments (#28993) há 2 anos atrás
AppOptions.cpp b006baba9d [all-clusters-app] Add some command line options to modify what is returned by the CSRResponse (#19461) há 3 anos atrás
AppOptions.h d7f91d81eb Add GetExampleDACProvider(const ExampleDACProviderData & data) to pass custom data onto the command line for Linux-based example apps (#17107) há 3 anos atrás
BUILD.gn 2991c76b8f Refactor Resource Monitoring to Separate out The Delegate functionality (#28725) há 2 anos atrás
Dockerfile 14930ea13d Pinning all versions, fixing script (#28140) há 2 anos atrás
README.md 671d25c72d Update build documentation for all-clusters-app. (#24775) há 3 anos atrás
WindowCoveringManager.cpp 4325527db6 Use seperate timers to control lift and tilt window coverings (#22733) há 3 anos atrás
WindowCoveringManager.h 4325527db6 Use seperate timers to control lift and tilt window coverings (#22733) há 3 anos atrás
args.gni a3c4b48365 Add support for SmokeCO TC's in chip-all-clusters-app (#28548) há 2 anos atrás
build_overrides 280d80f921 Add a linux version of the all-clusters-app demo (#3678) há 5 anos atrás
entrypoint.sh aa919a943b Rename Linux examples to their directory prefixed by "chip-" (#5065) há 4 anos atrás
fuzzing-main.cpp c1862d6620 Make all-clusters be able to fuzz (#25968) há 2 anos atrás
main-common.cpp 2991c76b8f Refactor Resource Monitoring to Separate out The Delegate functionality (#28725) há 2 anos atrás
main.cpp 7b6cbc545a Replaced the use of std::set with IntrusiveList in ModeBase. (#28163) há 2 anos atrás

README.md

Matter Linux/Mac All Clusters Example

Compiling all-clusters-app for testing on Linux and Mac

To compile all-clusters-app on Intel Mac, using the bootstrap-provided clang, run:

$ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target darwin-x64-all-clusters-no-ble-asan-clang build"

at the top level of the Matter tree.

To compile all-clusters-app on Intel Mac, using the system clang, run:

$ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target darwin-x64-all-clusters-no-ble-asan build"

To compile on an Arm Mac, which can only be done using the system clang, run:

$ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target darwin-arm64-all-clusters-no-ble-asan build"

Similarly, to compile on Linux x86-64 run:

$ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target linux-x64-all-clusters-no-ble-asan-clang build"

And to compile on Linux ARM run:

$ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target linux-arm64-all-clusters-no-ble-asan-clang build"

Fuzzing integration

This example also supports compilation with libfuzzer enabled. This should be used when trying to fuzz-test the Matter SDK.

Compiling with fuzzing enabled

To compile with libfuzzer enabled on Mac, run:

$ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target darwin-x64-all-clusters-no-ble-asan-libfuzzer-clang build"

at the top level of the Matter tree.

Similarly, to compile on Linux run:

$ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target linux-x64-all-clusters-no-ble-asan-libfuzzer-clang build"

Running libfuzzer-enabled binaries

Initial run

To run the resulting binary with no particular inputs do:

$ ./out/darwin-x64-all-clusters-no-ble-asan-libfuzzer-clang/chip-all-clusters-app-fuzzing

or

$ ./out/linux-x64-all-clusters-no-ble-asan-libfuzzer-clang/chip-all-clusters-app-fuzzing

If this crashes, it will output the input that caused the crash in a variety of formats, looking something like this:

0xe,0x0,0xf1,0xb1,0xf1,0xf1,0xf1,0xf1,0xed,0x73,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc1,0x0,0x0,0x0,0x0,0x0,0x5c,0xf3,0x25,0x0,0x0,0x0,0x0,0x0,
\016\000\361\261\361\361\361\361\355s\007\000\000\000\000\000\000\000\301\000\000\000\000\000\\\363%\000\000\000\000\000
artifact_prefix='./'; Test unit written to ./crash-c9fd2434ccf4a33a7f49765dcc519e1fd529a8e5
Base64: DgDxsfHx8fHtcwcAAAAAAAAAwQAAAAAAXPMlAAAAAAA=

Note that this creates a file holding the input that caused the crash.

Run with a fixed input

To run the binary with a specific input, place the input bytes in a file (which a crashing run of the fuzzer does automatically). If $(INPUT_FILE) is the name of that file, then run:

$ ./out/darwin-x64-all-clusters-no-ble-asan-libfuzzer-clang/chip-all-clusters-app-fuzzing $(INPUT_FILE)

or

$ ./out/linux-x64-all-clusters-no-ble-asan-libfuzzer-clang/chip-all-clusters-app-fuzzing $(INPUT_FILE)

Additional execution options.

The binary can be run with -help=1 to see more available options.

Running with ASAN_OPTIONS="handle_abort=2" set in the environment may produce nicer stack traces.

Trigger event using all-cluster-app event named pipe

You can send a command to all-cluster-app to trigger specific event via all-cluster-app event named pipe /tmp/chip_all_clusters_fifo-.

Trigger SoftwareFault events

  1. Generate event SoftwareFault when a software fault takes place on the Node.

    $ echo '{"Name":"SoftwareFault"}' > /tmp/chip_all_clusters_fifo-<PID>
    

Trigger HardwareFault events

  1. Generate event HardwareFaultChange to indicate a change in the set of hardware faults currently detected by the Node.

    $ echo '{"Name":"HardwareFaultChange"}' > /tmp/chip_all_clusters_fifo-<PID>
    
  2. Generate event RadioFaultChange to indicate a change in the set of radio faults currently detected by the Node.

    $ echo '{"Name":"RadioFaultChange"}' > /tmp/chip_all_clusters_fifo-<PID>
    
  3. Generate event NetworkFaultChange to indicate a change in the set of network faults currently detected by the Node.

    $ echo '{"Name":"NetworkFaultChange"}' > /tmp/chip_all_clusters_fifo-<PID>
    
  4. Generate event BootReason to indicate the reason that caused the device to start-up, from the following set of BootReasons.

  • PowerOnReboot The Node has booted as the result of physical interaction with the device resulting in a reboot.

  • BrownOutReset The Node has rebooted as the result of a brown-out of the Node’s power supply.

  • SoftwareWatchdogReset The Node has rebooted as the result of a software watchdog timer.

  • HardwareWatchdogReset The Node has rebooted as the result of a hardware watchdog timer.

  • SoftwareUpdateCompleted The Node has rebooted as the result of a completed software update.

  • SoftwareReset The Node has rebooted as the result of a software initiated reboot.

    $ echo '{"Name":"<BootReason>"}' > /tmp/chip_all_clusters_fifo-<PID>
    

Trigger Switch events

  1. Generate event SwitchLatched, when the latching switch is moved to a new position.

    $ echo '{"Name":"SwitchLatched","NewPosition":3}' > /tmp/chip_all_clusters_fifo-<PID>
    
  2. Generate event InitialPress, when the momentary switch starts to be pressed.

    $ echo '{"Name":"InitialPress","NewPosition":3}' > /tmp/chip_all_clusters_fifo-<PID>
    
  3. Generate event LongPress, when the momentary switch has been pressed for a "long" time.

    $ echo '{"Name":"LongPress","NewPosition":3}' > /tmp/chip_all_clusters_fifo-<PID>
    
  4. Generate event ShortRelease, when the momentary switch has been released.

    $ echo '{"Name":"ShortRelease","PreviousPosition":3}' > /tmp/chip_all_clusters_fifo-<PID>
    
  5. Generate event LongRelease when the momentary switch has been released and after having been pressed for a long time.

    $ echo '{"Name":"LongRelease","PreviousPosition":3}' > /tmp/chip_all_clusters_fifo-<PID>
    
  6. Generate event MultiPressOngoing to indicate how many times the momentary switch has been pressed in a multi-press sequence, during that sequence.

    $ echo '{"Name":"MultiPressOngoing","NewPosition":3,"CurrentNumberOfPressesCounted":4}' > /tmp/chip_all_clusters_fifo-<PID>
    
  7. Generate event MultiPressComplete to indicate how many times the momentary switch has been pressed in a multi-press sequence, after it has been detected that the sequence has ended.

    $ echo '{"Name":"MultiPressComplete","PreviousPosition":3,"TotalNumberOfPressesCounted":2}' > /tmp/chip_all_clusters_fifo-<PID>