Skip to content

Commit

Permalink
Merge branch 'master' into Add_BLE_ManagerImpl_ShutDown_Function
Browse files Browse the repository at this point in the history
  • Loading branch information
shchen-Lab authored Aug 9, 2023
2 parents 53658dc + 4111aac commit 1689073
Show file tree
Hide file tree
Showing 373 changed files with 41,100 additions and 50,224 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/zap_templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ jobs:
uses: ./.github/actions/checkout-submodules-and-bootstrap
with:
platform: linux

# Java formatting requires a newer java to run ktfmt
# TODO: this should be eventually inside Docker files
- name: Update java
run: |
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing openjdk-17-jre
- name: Generate all
run: ./scripts/run_in_build_env.sh scripts/tools/zap_regen_all.py
- name: Ensure git works in current working directory
Expand Down
4 changes: 4 additions & 0 deletions config/esp32/components/chip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ if(CHIP_CODEGEN_PREGEN_DIR)
chip_gn_arg_append("chip_code_pre_generated_directory" "\"${CHIP_CODEGEN_PREGEN_DIR}\"")
endif()

if(CONFIG_ENABLE_ICD_SERVER)
chip_gn_arg_append("chip_enable_icd_server" "true")
endif()

if(CONFIG_ENABLE_PW_RPC)
string(APPEND chip_gn_args "import(\"//build_overrides/pigweed.gni\")\n")
chip_gn_arg_append("remove_default_configs" "[\"//third_party/connectedhomeip/third_party/pigweed/repo/pw_build:toolchain_cpp_standard\"]")
Expand Down
58 changes: 25 additions & 33 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,31 @@ menu "CHIP Device Layer"
help
Enables or Disables the support for Commissionable Device Type.

config ENABLE_ICD_SERVER
bool "Enable ICD server"
depends on OPENTHREAD_MTD
default n
help
Enables or Disables ICD server

config ICD_SLOW_POLL_INTERVAL
int "ICD Slow Polling Interval"
depends on ENABLE_ICD_SERVER
default 5000
help
The value defines the fastest frequency at which the device will typically receive
messages in Idle Mode. The Slow Polling interval MAY be the same as the Idle Mode
Interval.

config ICD_FAST_POLL_INTERVAL
int "ICD Fast Polling Interval"
depends on ENABLE_ICD_SERVER
default 200
help
Fast Polling defines the fastest frequency at which the device can receive messages
in Active Mode. The Fast Polling interval SHALL be smaller than the Active Mode
Interval.

config ENABLE_BG_EVENT_PROCESSING
bool "Enable Background event processing"
default n
Expand Down Expand Up @@ -435,39 +460,6 @@ menu "CHIP Device Layer"
The amount of time (in milliseconds) to wait for Internet connectivity to be established on
the device's WiFi station interface during a Network Provisioning TestConnectivity operation.

choice WIFI_POWER_SAVE_MODE
prompt "WiFi power-saving mode"
default WIFI_POWER_SAVE_MIN
depends on ENABLE_WIFI_STATION && !ENABLE_WIFI_AP
help
The Modem-sleep mode which refers to the legacy power-saving mode in the IEEE 802.11 protocol.

config WIFI_POWER_SAVE_MIN
bool "Minimal power-saving mode"
help
In minimum power-saving mode, station wakes up every DTIM to receive beacon.

config WIFI_POWER_SAVE_MAX
bool "Maximum power-saving mode"
help
In maximum power-saving mode, station wakes up in every listen interval to receive beacon.
Listen interval can be configured by calling API 'esp_wifi_set_config()' before connecting
to AP.

config WIFI_POWER_SAVE_NONE
bool "No power-saving"
help
No power save

endchoice

config WIFI_PS_LISTEN_INTERVAL
int "Listen interval for maximum power-saving mode"
depends on WIFI_POWER_SAVE_MAX
default 3
help
Interval for station to listen to beacon from AP. The unit of listen interval is one beacon interval.

endmenu

menu "WiFi AP Options"
Expand Down
21 changes: 11 additions & 10 deletions docs/guides/esp32/setup_idf_chip.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@ step.
[v5.1 release](https://github.com/espressif/esp-idf/releases/tag/v5.1)

```
$ git clone -b v5.1 --recursive --depth 1 --shallow-submodule https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ ./install.sh
git clone -b v5.1 --recursive --depth 1 --shallow-submodule https://github.com/espressif/esp-idf.git
cd esp-idf
./install.sh
```

- To update an existing esp-idf toolchain to v5.1:

```
$ cd path/to/esp-idf
$ git fetch origin
$ git checkout v5.1
$ git reset --hard origin/v5.1
$ git submodule update --recursive --init
$ git clean -fdx
$ ./install.sh
cd path/to/esp-idf
git fetch --depth 1 origin v5.1
git reset --hard FETCH_HEAD
git submodule update --depth 1 --recursive --init
# -ff is for cleaning untracked files as well as submodules
git clean -ffdx
./install.sh
```

## Setup Matter environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <app/clusters/operational-state-server/operational-state-delegate.h>
#include <app/clusters/operational-state-server/operational-state-server.h>
#include <app/util/af-enums.h>
#include <protocols/interaction_model/StatusCode.h>

Expand Down
5 changes: 5 additions & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ set(SRC_DIRS_LIST "${SRC_DIRS_LIST}"
)
endif (CONFIG_ENABLE_PW_RPC)

if (CONFIG_ENABLE_ICD_SERVER)
list(APPEND PRIV_INCLUDE_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/icd")
list(APPEND SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/icd")
endif()

set(PRIV_REQUIRES_LIST chip QRCode bt app_update nvs_flash spi_flash openthread)

if(${IDF_TARGET} STREQUAL "esp32")
Expand Down
7 changes: 5 additions & 2 deletions examples/all-clusters-app/esp32/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ menu "Demo"
config DEVICE_TYPE_ESP32_C6_DEVKITC
bool "ESP32C6-DevKitC"
depends on IDF_TARGET_ESP32C6
config DEVICE_TYPE_ESP32_H2_DEVKITM
bool "ESP32H2-DevKitM"
depends on IDF_TARGET_ESP32H2
endchoice

choice
Expand Down Expand Up @@ -84,7 +87,7 @@ menu "Demo"
config TFT_PREDEFINED_DISPLAY_TYPE
int
range 0 5
default 0 if DEVICE_TYPE_ESP32_DEVKITC
default 0 if DEVICE_TYPE_ESP32_DEVKITC || DEVICE_TYPE_ESP32_H2_DEVKITM
default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM || DEVICE_TYPE_ESP32_C6_DEVKITC
default 3 if DEVICE_TYPE_M5STACK
default 4 if DEVICE_TYPE_ESP32_WROVER_KIT
Expand Down Expand Up @@ -115,7 +118,7 @@ menu "Demo"
range 0 40
default 2 if DEVICE_TYPE_ESP32_DEVKITC #Use LED1 (blue LED) as status LED on DevKitC
default 2 if DEVICE_TYPE_ESP32_ETHERNET_KIT
default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM || DEVICE_TYPE_ESP32_C6_DEVKITC
default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM || DEVICE_TYPE_ESP32_C6_DEVKITC || DEVICE_TYPE_ESP32_H2_DEVKITM
default 26 if DEVICE_TYPE_ESP32_WROVER_KIT
default 40 if DEVICE_TYPE_M5STACK
help
Expand Down
28 changes: 3 additions & 25 deletions examples/all-clusters-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <binding-handler.h>
#include <common/CHIPDeviceManager.h>
#include <common/Esp32AppServer.h>
#include <common/Esp32ThreadInit.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <examples/platform/esp32/mode-support/static-supported-modes-manager.h>
Expand All @@ -52,12 +53,6 @@
#include "Rpc.h"
#endif

#if CONFIG_OPENTHREAD_ENABLED
#include <common/OpenthreadConfig.h>
#include <platform/ESP32/OpenthreadLauncher.h>
#include <platform/ThreadStackManager.h>
#endif

#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
#include <platform/ESP32/ESP32FactoryDataProvider.h>
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
Expand All @@ -71,6 +66,7 @@
using namespace ::chip;
using namespace ::chip::Shell;
using namespace ::chip::DeviceManager;
using namespace ::chip::DeviceLayer;
using namespace ::chip::Credentials;

// Used to indicate that an IP address has been added to the QRCode
Expand Down Expand Up @@ -206,25 +202,7 @@ extern "C" void app_main()
{
ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format());
}
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
esp_openthread_platform_config_t config = {
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(),
.host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(),
.port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(),
};
set_openthread_platform_config(&config);

if (DeviceLayer::ThreadStackMgr().InitThreadStack() != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "Failed to initialize Thread stack");
return;
}
if (DeviceLayer::ThreadStackMgr().StartThreadTask() != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "Failed to launch Thread task");
return;
}
#endif
ESPOpenThreadInit();

chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));
}
Expand Down
78 changes: 78 additions & 0 deletions examples/all-clusters-app/esp32/sdkconfig.defaults.esp32h2
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
CONFIG_IDF_TARGET="esp32h2"
CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_2=y

# Default to 921600 baud when flashing and monitoring device
CONFIG_ESPTOOLPY_BAUD_921600B=y
CONFIG_ESPTOOLPY_BAUD=921600
CONFIG_ESPTOOLPY_COMPRESSED=y
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_40M=y
CONFIG_ESPTOOLPY_FLASHFREQ="40m"
CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200

# libsodium
CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y


# NIMBLE
CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y
CONFIG_BT_NIMBLE_EXT_ADV=n
CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70
CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING=n

# Enable OpenThread
CONFIG_OPENTHREAD_ENABLED=y
CONFIG_OPENTHREAD_SRP_CLIENT=y
CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC=n
CONFIG_OPENTHREAD_LOG_LEVEL_NOTE=y
CONFIG_OPENTHREAD_CLI=n
CONFIG_OPENTHREAD_DNS_CLIENT=y

# Disable lwip ipv6 autoconfig
CONFIG_LWIP_IPV6_AUTOCONFIG=n

# Use a custom partition table
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"

# LwIP config for OpenThread
CONFIG_LWIP_IPV6_NUM_ADDRESSES=8
CONFIG_LWIP_MULTICAST_PING=y

# mbedTLS
CONFIG_MBEDTLS_HARDWARE_AES=n
CONFIG_MBEDTLS_HARDWARE_MPI=n
CONFIG_MBEDTLS_HARDWARE_SHA=n
CONFIG_MBEDTLS_HARDWARE_ECC=y
CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN=n
CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY=n
CONFIG_MBEDTLS_CMAC_C=y
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y

# rtc clk for ble
# CONFIG_ESP32H2_RTC_CLK_SRC_EXT_CRYS=y

# MDNS platform
CONFIG_USE_MINIMAL_MDNS=n
CONFIG_ENABLE_EXTENDED_DISCOVERY=y

# FreeRTOS should use legacy API
CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y

# Disable STA and AP for ESP32H2
CONFIG_ENABLE_WIFI_STATION=n
CONFIG_ENABLE_WIFI_AP=n
# Enable this to avoid implicit declaration of function 'esp_send_assoc_resp'
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y

# Enable OTA Requestor
CONFIG_ENABLE_OTA_REQUESTOR=y

# Enable chip shell
CONFIG_ENABLE_CHIP_SHELL=y

# Enable HKDF in mbedtls
CONFIG_MBEDTLS_HKDF_C=y
27 changes: 2 additions & 25 deletions examples/all-clusters-minimal-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <app/util/af.h>
#include <binding-handler.h>
#include <common/Esp32AppServer.h>
#include <common/Esp32ThreadInit.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <platform/ESP32/ESP32Utils.h>
Expand All @@ -51,12 +52,6 @@
#include "Rpc.h"
#endif

#if CONFIG_OPENTHREAD_ENABLED
#include <common/OpenthreadConfig.h>
#include <platform/ESP32/OpenthreadLauncher.h>
#include <platform/ThreadStackManager.h>
#endif

#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
#include <platform/ESP32/ESP32FactoryDataProvider.h>
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
Expand Down Expand Up @@ -188,25 +183,7 @@ extern "C" void app_main()
ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format());
}

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
esp_openthread_platform_config_t config = {
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(),
.host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(),
.port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(),
};
set_openthread_platform_config(&config);

if (DeviceLayer::ThreadStackMgr().InitThreadStack() != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "Failed to initialize Thread stack");
return;
}
if (DeviceLayer::ThreadStackMgr().StartThreadTask() != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "Failed to launch Thread task");
return;
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
ESPOpenThreadInit();
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <app/clusters/operational-state-server/operational-state-delegate.h>
#include <app/clusters/operational-state-server/operational-state-server.h>
#include <app/util/af-enums.h>
#include <protocols/interaction_model/StatusCode.h>

Expand Down
Loading

0 comments on commit 1689073

Please sign in to comment.