https://github.com/ambiot/ambz2_matter/blob/main/CHANGELOG.md
Tested on Ubuntu 20.04 and above
Create and enter new directory
mkdir dev
cd dev
To check out AmebaZ2 repository:
git clone --recurse-submodules https://github.com/ambiot/ambz2_matter.git
To check out Matter repository:
git clone --recurse-submodules https://github.com/project-chip/connectedhomeip
Make sure ambz2_matter and connectedhomeip are on the same directory level
dev/
├── ambz2_matter
└── connectedhomeip
> Find more details to setup linux build environment
> https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/BUILDING.md
cd connectedhomeip
source scripts/bootstrap.sh
source scripts/activate.sh
cd ambz2_matter/project/realtek_amebaz2_v0_example/GCC-RELEASE
make all_clusters
cd ambz2_matter/project/realtek_amebaz2_v0_example/GCC-RELEASE
make light
cd ambz2_matter/project/realtek_amebaz2_v0_example/GCC-RELEASE
make switch
cd ambz2_matter/project/realtek_amebaz2_v0_example/GCC-RELEASE
make otar
CHIP core (generated by GN/ninja in connectedhomeip. Configured by lib_chip.mk)
output : ambz2_matter/component/soc/realtek/8710c/misc/bsp/lib/common/GCC
> libCHIP.a
CHIP application (generated and configured by lib_chip_main.mk))
output : ambz2_matter/component/soc/realtek/8710c/misc/bsp/lib/common/GCC
> lib_main.a
cd ambz2_matter/project/realtek_amebaz2_v0_example/GCC-RELEASE
make is_matter
make clean_matter_libs
make clean_matter
To use BLE Mesh with Matter, uncomment the following in platform_opts_bt.h
BT_MATTER_MESH_ADAPTER = 1
The generated image is found in ambz2_matter/project/realtek_amebaz2_v0_example/GCC-RELEASE/application_is/Debug/bin/flash_is.bin
Method 1:
- Find more detail in application_note Chapter4
Method 2 (using image tool and flashing script):
- Follow the Image Tool README
Matter task will auto start after reset the device.
Test with chip-tool
Use standalone chip-tool app(linux) to communicate with the device.
In order to send commands to a device, the device must be commissioned into the Matter network. The configuration state for chip-tool is stored in /tmp/chip_tool_config.ini
; deleting this and other .ini
files in /tmp
can sometimes resolve issues due to stale configuration.
- Run CHIP-TOOL ble-wifi commissioning command
./chip-tool pairing ble-wifi <NODE_ID> <SSID> <PASSWORD> 20202021 3840
- For example:
./chip-tool pairing ble-wifi 12344321 testssid password 20202021 3840
- Connect Ameba to AP using
ATW0, ATW1, ATWC
commands - Run CHIP-TOOL onnetwork commissioning command
./chip-tool pairing onnetwork <NODE_ID> 20202021
- For example:
./chip-tool pairing onnetwork 12344321 20202021
Use PA_20 as output, connect a LED to this pin and GND.
-
Run CHIP-TOOL on-off cluster command
./chip-tool onoff on 12344321 1
-
Run CHIP-TOOL on-off cluster command
./chip-tool onoff off 12344321 1
Find more detail in chip-tool
Test with Android Chip-Tool
- Download Android Studio and Android-NDK-r21e and extract the files.
- Launch Android Studio:
cd android-studio/bin
and run./studio.sh
- Go to Customize and All settings. Under Appearance & Behaviour >> System Settings >> Android SDK, Check Android 5.0 (Lollipop) and uncheck the rest. Default Android SDK location is at
~/Android/Sdk
.
Run the following commands
cd connectedhomeip/
source script/bootstrap.sh
export ANDROID_HOME=~/Android/Sdk
export ANDROID_NDK_HOME={path to android-ndk-r21e}
Target CPU
TARGET_CPU
can have the following values, depending on your smartphone CPU
architecture:
ABI | TARGET_CPU |
---|---|
armeabi-v7a | arm |
arm64-v8a | arm64 |
x86 | x86 |
x86_64 | x64 |
Complete the following steps to prepare the Matter build:
-
Check out the Matter repository.
-
Run bootstrap (only required first time)
source scripts/bootstrap.sh
-
Choose how you want to build the Android CHIPTool. There are two ways: from script, or from source within Android Studio.
This is the simplest option. In the command line, run the following command from the top CHIP directory:
./scripts/build/build_examples.py --target android-arm64-chip-tool build
Note: It has been noticed that this step may fail on the first try, but running the second time will successfully build the apk.
See the table above for other values of TARGET_CPU
.
The debug Android package app-debug.apk
will be generated at
out/android-$TARGET_CPU-chip-tool/outputs/apk/debug/
, and can be installed
with
adb install out/android-$TARGET_CPU-chip-tool/outputs/apk/debug/app-debug.apk
You can use Android Studio to edit the Android CHIPTool app itself and run it
after build_examples.py, but you will not be able to edit Matter Android code
from src/controller/java
, or other Matter C++ code within Android Studio.
This option allows Android Studio to build the core Matter code from source, which allows us to directly edit core Matter code in-IDE.
-
In the command line, run the following command from the top Matter directory:
TARGET_CPU=arm64 ./scripts/examples/android_app_ide.sh
See the table above for other values of
TARGET_CPU
. -
Modify the
matterSdkSourceBuild
variable to true,matterBuildSrcDir
point to the appropriate output directory (e.g.../../../../out/android_arm64
), andmatterSourceBuildAbiFilters
to the desired ABIs in src/android/CHIPTool/gradle.properties
-
Open the project in Android Studio and run Sync Project with Gradle Files.
-
Use one of the following options to build an Android package:
-
Click Make Project in Android Studio.
-
Run the following command in the command line:
cd src/android/CHIPTool ./gradlew build
-
The debug Android package app-debug.apk
will be generated at
src/android/CHIPTool/app/build/outputs/apk/debug/
, and can be installed with
adb install src/android/CHIPTool/app/build/outputs/apk/debug/app-debug.apk
or
(cd src/android/CHIPTool && ./gradlew installDebug)
- Power on device and wait matter task run
- Launch Android Chip-Tool app and press Provision CHIP Device With Wi-Fi
- Scan the QR Code and enter the network credentials of the AP
Note: The QR code will be provided when booting, for example:
chip[SVR] SetupQRCode: [MT:-24J042C00KA0648G00]
chip[SVR] Copy/paste the below URL in a browser to see the QR Code:
chip[SVR] https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J042C00KA0648G00
Copy/paste the URL in a browser and a scannable QR code will be displayed.