Using Matter to set up Wi-Fi for ESP32 (COPY)
Becoming familiar with Matter Wi-Fi Config support
- Build the
ayla_matter_demo
application and flash it to your ESP32 following the steps on the Ayla ESP32 Solution page. - Tap the reset button on the ESP32 board.
- If you’ve previously provisioned the ESP32 to a Wi-Fi network, type
reset factory
at the ESP32 CLI to clear the Wi-Fi configuration. - Run CLI command
matter qrshow
to get the QR Code.
->matter qrshow
vendor: 4190 (0x105e)
product: 18905 (0x49d9)
discovery mask: 0x02
discriminator: 3549
passcode: 53725857
pairing code: 31910532797
QR payload: MT:G8IB6SDF15FEAQ45510
QR code URL: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3AG8IB6SDF15FEAQ45510
->
Proceed with the steps for iPhone or Android, depending on which device you are using.
Provisioning using Aura on iPhone
- Launch the Aura app on an iPhone.
- If you had previously provisioned and registered the ESP32 device, unregister it:
a. Swipe left on the device’s entry.
b. TapUnregister
.
c. When prompted, confirm by tappingUnregister
.
d. TapOK
. - Tap the
+
icon on the upper right. - Tap
Ayla Matter Setup
. - Scan Device QR Code(Open the QR code URL(matter qrshow) to get the QR code).
- Enter the Wi-Fi network Password.
- Tap
Continue
. - Tap
Continue
. - Wait the device to finish Matter setup.
- Tap
Continue
. - Set the device name as you want after Matter setup finish.
- Tap
Done
icon on the upper right. - Observe the device you just added is displayed in the Devices list.
Provisioning using Aura on Android
- Launch the Aura app on an Android.
- If you had previously provisioned and registered the ESP32 device, unregister it:
a. Tap on the device’s entry in the Device List.
b. Tap the vertical ellipsis icon at the upper right.
c. TapUnregister Device
.
d. TapOK
to confirm. - Tap the
+
icon. - Tap the list expander icon at the right of the
Advanced
header. - Tap
Ayla Matter Setup
. - Scan Device QR Code(Open the QR code URL to get the QR code).
- Enter the Wi-Fi network Password.
- Tap
Continue
. - Tap
Continue
. - Wait the device to finish Matter setup.
- Set the device name as you want after Matter setup finish.
- Tap
Return to Device List
. - Observe the device you just added is displayed in the Device List.
Understanding how to integrate Matter support
- Locate and open
examples/ayla_matter_demo/demo_matter.c
, which provides an example of integrating Matter support with an application. - Review
demo_init
. This function performs the initialization to start Matter service. It does the following:
a. Initializes ADM module
b. Register event handler and attribute change callback function
c. Start ADM module(will start Matter protocol service)
d. Initializes Matter demo GPIO port
e. Register Matter demo properties - Review other functions in
demo_matter.c
. Your application will need to implement similar functionality to support Matter protocol.
a.demo_idle
implements the host task thread, which handle button press event and on/off operation.
b.demo_matter_event_cb
implements handling matter event, call ada_client_ip_up when received IPV4 up event, call ada_client_ip_down when received IPV4 down event.
c.demo_on_off_cb
implements handling matter on/off attribute change callback. The demo_on_off_cb is used in the demo_on_off_cb_entry struct, you need to define this variable first.
d.demo_write_notify_event
implements to notify the Matter protocol stack when user pressed the button.
e.demo_props
defines the demo property list, you should use the ada_sprop_mgr_register to register it.
Enabling Matter support in your application
- Base ayla_matter_demo to implement your application.
- Update the ADM_CLUSTER_LIST cluster list to follow your application requirement, the ADM_CLUSTER_LIST defined in CMakeLists.txt in ayla_matter_demo directory.
- Use zap tool to update zap/ayla_demo.zap, define your application cluster/attribute list, and generate the zap code, copy generated files into examples/ayla_matter_demo/main/zap-generated directory or examples/ayla_matter_demo/main/app directory.
- Update the demo_props property list to define your application property list.
- Call adm_attribute_change_cb_register to register your application implement's cluster attribute change notification.
Note: You could refer the below command to install zap tool.
apt-get update
apt-get install --fix-missing libpixman-1-dev libcairo-dev libsdl-pango-dev libjpeg-dev libgif-dev
wget https://github.com/project-chip/zap/releases/download/v2023.11.13/zap-linux-x64.zip
mkdir zap-linux-x64
cd zap-linux-x64
unzip ../zap-linux-x64.zip
export ZAP_INSTALL_PATH=~/work/zap/zap-linux-x64
cd ~/work/aylasrc/examples/ayla_matter_demo/zap # Your zap file path
~/work/CHIP-v1.0.0.2/scripts/tools/zap/run_zaptool.sh ./ayla_demo.zap
Files
lib/adm/adm.*
Initializes Matter protocol stack, starts Matter service, implements the Matter stack event callback and attribute change callback.lib/adm/adm_data_provider.*
implements the Matter factory data handling.lib/adm/ayla-server.*
implements the Ayla Matter register handling, adding/registering device in Mobile App will need these device information.lib/adm/ayla-lc-server.*
implements Ayla local control via Matter protocol.lib/adm/adm_cli.*
implements CLI commands for Matter protocol data configuration.examples/ayla_matter_demo/demo_matter.c
implements Matter application functions.
Build Switches
The define symbol AYLA_MATTER_SUPPORT is used as a compile time switch to enable or disable inclusion of Matter features. Defining this symbol enables compilation of Matter support. This symbol is defined by default. It is defined in the following files:
tools/cmake/ayla_matter_project.cmake
examples/ayla_matter_demo/CMakeLists.txt
Updated about 1 year ago