From ce69233fc57b863797cad20c43e62b10876980c2 Mon Sep 17 00:00:00 2001 From: Garcia Date: Wed, 5 Mar 2025 16:00:54 -0300 Subject: [PATCH 1/8] feat(matter): enable CHIP over BLE in defconfig.common --- configs/defconfig.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 2fc18a69..3a0111f2 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -125,7 +125,7 @@ CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y # Matter Settings # # Disable Matter BLE -CONFIG_ENABLE_CHIPOBLE=n +CONFIG_ENABLE_CHIPOBLE=y CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING=n # ESP Insights CONFIG_ENABLE_ESP_INSIGHTS_TRACE=n From 1055706b978a6b10fd5b73007de1b1573a007c9f Mon Sep 17 00:00:00 2001 From: Garcia Date: Wed, 5 Mar 2025 16:03:21 -0300 Subject: [PATCH 2/8] feat(matter): remove esp_matter from idf_component.yml (managed components) --- main/idf_component.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main/idf_component.yml b/main/idf_component.yml index c6bb97f4..e1162a43 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -16,8 +16,8 @@ dependencies: version: ">=1.4.2" rules: - if: "target in [esp32s3]" - espressif/esp_matter: - version: "^1.3.0" - require: public - rules: - - if: "target not in [esp32c2, esp32h2, esp32p4]" +# espressif/esp_matter: +# version: "^1.3.0" +# require: public +# rules: +# - if: "target not in [esp32c2, esp32h2, esp32p4]" From b070b69ea0a45ecb68bf71c4118f6dd1f25723f5 Mon Sep 17 00:00:00 2001 From: Garcia Date: Wed, 5 Mar 2025 16:17:07 -0300 Subject: [PATCH 3/8] feat(matter): adds necessary CHIP patch for supporting Bluedroid --- patches/matter_chip_ChipDeviceScanner.diff | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 patches/matter_chip_ChipDeviceScanner.diff diff --git a/patches/matter_chip_ChipDeviceScanner.diff b/patches/matter_chip_ChipDeviceScanner.diff new file mode 100644 index 00000000..dd37263e --- /dev/null +++ b/patches/matter_chip_ChipDeviceScanner.diff @@ -0,0 +1,35 @@ +@@ -31,22 +31,19 @@ + bool BluedroidGetChipDeviceInfo(esp_ble_gap_cb_param_t & scan_result, chip::Ble::ChipBLEDeviceIdentificationInfo & deviceInfo) + { + // Check for CHIP Service UUID +- if (scan_result.scan_rst.ble_adv != NULL) ++ if (scan_result.scan_rst.adv_data_len > 13 && scan_result.scan_rst.ble_adv[5] == 0xf6 && ++ scan_result.scan_rst.ble_adv[6] == 0xff) + { +- if (scan_result.scan_rst.adv_data_len > 13 && scan_result.scan_rst.ble_adv[5] == 0xf6 && +- scan_result.scan_rst.ble_adv[6] == 0xff) +- { +- deviceInfo.OpCode = scan_result.scan_rst.ble_adv[7]; +- deviceInfo.DeviceDiscriminatorAndAdvVersion[0] = scan_result.scan_rst.ble_adv[8]; +- deviceInfo.DeviceDiscriminatorAndAdvVersion[1] = scan_result.scan_rst.ble_adv[9]; +- // vendor and product Id from adv +- deviceInfo.DeviceVendorId[0] = scan_result.scan_rst.ble_adv[10]; +- deviceInfo.DeviceVendorId[1] = scan_result.scan_rst.ble_adv[11]; +- deviceInfo.DeviceProductId[0] = scan_result.scan_rst.ble_adv[12]; +- deviceInfo.DeviceProductId[1] = scan_result.scan_rst.ble_adv[13]; +- deviceInfo.AdditionalDataFlag = scan_result.scan_rst.ble_adv[14]; +- return true; +- } ++ deviceInfo.OpCode = scan_result.scan_rst.ble_adv[7]; ++ deviceInfo.DeviceDiscriminatorAndAdvVersion[0] = scan_result.scan_rst.ble_adv[8]; ++ deviceInfo.DeviceDiscriminatorAndAdvVersion[1] = scan_result.scan_rst.ble_adv[9]; ++ // vendor and product Id from adv ++ deviceInfo.DeviceVendorId[0] = scan_result.scan_rst.ble_adv[10]; ++ deviceInfo.DeviceVendorId[1] = scan_result.scan_rst.ble_adv[11]; ++ deviceInfo.DeviceProductId[0] = scan_result.scan_rst.ble_adv[12]; ++ deviceInfo.DeviceProductId[1] = scan_result.scan_rst.ble_adv[13]; ++ deviceInfo.AdditionalDataFlag = scan_result.scan_rst.ble_adv[14]; ++ return true; + } + return false; + } From 30d245241af0d8b63da26ca9033bbcf40298c099 Mon Sep 17 00:00:00 2001 From: Garcia Date: Wed, 5 Mar 2025 16:58:24 -0300 Subject: [PATCH 4/8] feat(matter): adds esp-matter component to update-components.sh --- tools/update-components.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/update-components.sh b/tools/update-components.sh index 298783c7..0628ffdb 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -15,3 +15,37 @@ else git -C "$TINYUSB_REPO_DIR" pull --ff-only fi if [ $? -ne 0 ]; then exit 1; fi + +echo "Updating Matter v1.3 repository..." +MATTER_REPO_URL="https://github.com/espressif/esp-matter.git" +MATTER_REPO_DIR="$AR_COMPS/espressif__esp-matter" +MATTER_REPO_BRANCH="release/v1.3" +if [ ! -d "$MATTER_REPO_DIR" ]; then + git clone --depth 1 -b "$MATTER_REPO_BRANCH" "$MATTER_REPO_URL" "$MATTER_REPO_DIR" +else + git -C "$MATTER_REPO_DIR" fetch && \ + git -C "$MATTER_REPO_DIR" pull --ff-only +fi +if [ $? -ne 0 ]; then exit 1; fi +echo "Updating CHIP v1.3 repository..." +CHIP_REPO_URL="https://github.com/espressif/connectedhomeip.git" +CHIP_REPO_DIR="$AR_COMPS/espressif__esp-matter/connectedhomeip/connectedhomeip" +CHIP_REPO_BRANCH="v1.3-branch" +if [ ! -d "$CHIP_REPO_DIR" ]; then + git clone --depth 1 -b "$CHIP_REPO_BRANCH" "$CHIP_REPO_URL" "$CHIP_REPO_DIR" + $CHIP_REPO_DIR/scripts/checkout_submodules.py --platform esp32 darwin --shallow +else + git -C "$MATTER_REPO_DIR" fetch && \ + git -C "$MATTER_REPO_DIR" pull --ff-only +fi +if [ $? -ne 0 ]; then exit 1; fi +echo "Patching CHIP v1.3 repository..." +CHIP_BAD_FILE="$AR_COMPS/espressif__esp-matter/connectedhomeip/connectedhomeip/src/platform/ESP32/bluedroid/ChipDeviceScanner.cpp" +CHIP_PATCH="$AR_PATCHES/matter_chip_ChipDeviceScanner.diff" +if [ ! -e "$CHIP_BAD_FILE" ]; then + patch $CHIP_BAD_FILE $CHIP_PATCH +else + echo "Error: $CHIP_BAD_FILE not found. Check the script." +fi +if [ $? -ne 0 ]; then exit 1; fi +echo "Matter v1.3 component is installed and updated." From 43416b0f238d0a92745dbcf04e2c25bacb5cf4c4 Mon Sep 17 00:00:00 2001 From: Garcia Date: Wed, 5 Mar 2025 17:01:54 -0300 Subject: [PATCH 5/8] feat(matter): use existing folder variables in update-components.sh --- tools/update-components.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/update-components.sh b/tools/update-components.sh index 0628ffdb..43fc1a52 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -18,7 +18,7 @@ if [ $? -ne 0 ]; then exit 1; fi echo "Updating Matter v1.3 repository..." MATTER_REPO_URL="https://github.com/espressif/esp-matter.git" -MATTER_REPO_DIR="$AR_COMPS/espressif__esp-matter" +MATTER_REPO_DIR="$AR_COMPS/espressif__esp_matter" MATTER_REPO_BRANCH="release/v1.3" if [ ! -d "$MATTER_REPO_DIR" ]; then git clone --depth 1 -b "$MATTER_REPO_BRANCH" "$MATTER_REPO_URL" "$MATTER_REPO_DIR" @@ -29,7 +29,7 @@ fi if [ $? -ne 0 ]; then exit 1; fi echo "Updating CHIP v1.3 repository..." CHIP_REPO_URL="https://github.com/espressif/connectedhomeip.git" -CHIP_REPO_DIR="$AR_COMPS/espressif__esp-matter/connectedhomeip/connectedhomeip" +CHIP_REPO_DIR="$MATTER_REPO_DIR/connectedhomeip/connectedhomeip" CHIP_REPO_BRANCH="v1.3-branch" if [ ! -d "$CHIP_REPO_DIR" ]; then git clone --depth 1 -b "$CHIP_REPO_BRANCH" "$CHIP_REPO_URL" "$CHIP_REPO_DIR" @@ -40,7 +40,7 @@ else fi if [ $? -ne 0 ]; then exit 1; fi echo "Patching CHIP v1.3 repository..." -CHIP_BAD_FILE="$AR_COMPS/espressif__esp-matter/connectedhomeip/connectedhomeip/src/platform/ESP32/bluedroid/ChipDeviceScanner.cpp" +CHIP_BAD_FILE="$CHIP_REPO_DIR/src/platform/ESP32/bluedroid/ChipDeviceScanner.cpp" CHIP_PATCH="$AR_PATCHES/matter_chip_ChipDeviceScanner.diff" if [ ! -e "$CHIP_BAD_FILE" ]; then patch $CHIP_BAD_FILE $CHIP_PATCH From b5468290515f0dc6df203ca9e6ae976e75786460 Mon Sep 17 00:00:00 2001 From: Garcia Date: Wed, 5 Mar 2025 18:07:24 -0300 Subject: [PATCH 6/8] fix(matter): make the script work in different use cases --- tools/update-components.sh | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tools/update-components.sh b/tools/update-components.sh index 43fc1a52..4caa0fd8 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -31,21 +31,23 @@ echo "Updating CHIP v1.3 repository..." CHIP_REPO_URL="https://github.com/espressif/connectedhomeip.git" CHIP_REPO_DIR="$MATTER_REPO_DIR/connectedhomeip/connectedhomeip" CHIP_REPO_BRANCH="v1.3-branch" -if [ ! -d "$CHIP_REPO_DIR" ]; then - git clone --depth 1 -b "$CHIP_REPO_BRANCH" "$CHIP_REPO_URL" "$CHIP_REPO_DIR" - $CHIP_REPO_DIR/scripts/checkout_submodules.py --platform esp32 darwin --shallow -else - git -C "$MATTER_REPO_DIR" fetch && \ - git -C "$MATTER_REPO_DIR" pull --ff-only +if [ -d "$CHIP_REPO_DIR" ]; then + # Check if directory is empty + if [ -z "$(ls -A "$CHIP_REPO_DIR")" ]; then + rm -rf "$CHIP_REPO_DIR" + git clone --depth 1 -b "$CHIP_REPO_BRANCH" "$CHIP_REPO_URL" "$CHIP_REPO_DIR" + if [ $? -ne 0 ]; then exit 1; fi + $CHIP_REPO_DIR/scripts/checkout_submodules.py --platform esp32 darwin --shallow + if [ $? -ne 0 ]; then exit 1; fi + echo "Patching CHIP v1.3 repository..." + CHIP_BAD_FILE="$CHIP_REPO_DIR/src/platform/ESP32/bluedroid/ChipDeviceScanner.cpp" + CHIP_PATCH="$AR_PATCHES/matter_chip_ChipDeviceScanner.diff" + if [ -f "$CHIP_BAD_FILE" ]; then + patch $CHIP_BAD_FILE $CHIP_PATCH + else + echo "Error: $CHIP_BAD_FILE not found. Check the script." + exit 1 + fi + fi fi -if [ $? -ne 0 ]; then exit 1; fi -echo "Patching CHIP v1.3 repository..." -CHIP_BAD_FILE="$CHIP_REPO_DIR/src/platform/ESP32/bluedroid/ChipDeviceScanner.cpp" -CHIP_PATCH="$AR_PATCHES/matter_chip_ChipDeviceScanner.diff" -if [ ! -e "$CHIP_BAD_FILE" ]; then - patch $CHIP_BAD_FILE $CHIP_PATCH -else - echo "Error: $CHIP_BAD_FILE not found. Check the script." -fi -if [ $? -ne 0 ]; then exit 1; fi echo "Matter v1.3 component is installed and updated." From 5a908e4b7dfc0c9b1c36265841c68b92545ec789 Mon Sep 17 00:00:00 2001 From: Garcia Date: Wed, 5 Mar 2025 19:18:12 -0300 Subject: [PATCH 7/8] feat(lib_builder): adds git ignore matter component --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b0749543..2e26f6b3 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ components/esp32-camera/ components/esp_littlefs/ components/esp-rainmaker/ components/espressif__esp-dsp/ +components/espressif__esp_matter/ components/esp-insights/ components/arduino_tinyusb/tinyusb/ components/tflite-micro/ From 5558f1aa647bb7260c84f4b75fbe0a910bf03a78 Mon Sep 17 00:00:00 2001 From: Garcia Date: Wed, 5 Mar 2025 20:15:58 -0300 Subject: [PATCH 8/8] fix(matter): removes darwin (android) from CHIP targets --- tools/update-components.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/update-components.sh b/tools/update-components.sh index 4caa0fd8..09f50f3b 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -37,7 +37,7 @@ if [ -d "$CHIP_REPO_DIR" ]; then rm -rf "$CHIP_REPO_DIR" git clone --depth 1 -b "$CHIP_REPO_BRANCH" "$CHIP_REPO_URL" "$CHIP_REPO_DIR" if [ $? -ne 0 ]; then exit 1; fi - $CHIP_REPO_DIR/scripts/checkout_submodules.py --platform esp32 darwin --shallow + $CHIP_REPO_DIR/scripts/checkout_submodules.py --platform esp32 --shallow if [ $? -ne 0 ]; then exit 1; fi echo "Patching CHIP v1.3 repository..." CHIP_BAD_FILE="$CHIP_REPO_DIR/src/platform/ESP32/bluedroid/ChipDeviceScanner.cpp"