Skip to content

Commit

Permalink
Merge branch 'master' into zap_download_script
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Jan 25, 2023
2 parents 9532413 + 14dada3 commit fdc290c
Show file tree
Hide file tree
Showing 76 changed files with 3,600 additions and 1,327 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/bloat_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
pull_request_update:
name: Report on pull requests

# Don't run on forked repos
if: github.repository_owner == 'project-chip'

runs-on: ubuntu-latest

container:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples-linux-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target linux-arm64-chip-cert \
--target linux-arm64-chip-cert-clang \
--target linux-arm64-all-clusters-clang \
--target linux-arm64-chip-tool-ipv6only-clang \
--target linux-arm64-lock-clang \
Expand Down
6 changes: 3 additions & 3 deletions config/esp32/components/chip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ endif()

include(${CMAKE_CURRENT_LIST_DIR}/ota-image.cmake)

set(CHIP_REQURIE_COMPONENTS freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash)
set(CHIP_REQUIRE_COMPONENTS freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash spi_flash)

if((NOT "${IDF_TARGET}" STREQUAL "esp32h2") AND (NOT "${IDF_TARGET}" STREQUAL "esp32c2"))
list(APPEND CHIP_REQURIE_COMPONENTS mdns)
list(APPEND CHIP_REQUIRE_COMPONENTS mdns)
endif()

if (NOT CMAKE_BUILD_EARLY_EXPANSION)
Expand All @@ -49,7 +49,7 @@ if (NOT CMAKE_BUILD_EARLY_EXPANSION)
endif()

idf_component_register(SRCS chip.c chip.cpp
PRIV_REQUIRES ${CHIP_REQURIE_COMPONENTS})
PRIV_REQUIRES ${CHIP_REQUIRE_COMPONENTS})

# Prepare initial args file (lacking compile flags)
# This will be saved as args.gn.in
Expand Down
2 changes: 1 addition & 1 deletion config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ menu "CHIP Device Layer"

config ENABLE_ESP32_LOCATIONCAPABILITY
depends on ENABLE_ESP32_FACTORY_DATA_PROVIDER
bool "Enable ESP32 Device LocationCapability "
bool "Enable ESP32 Device LocationCapability"
default n
help
Enable ESP32 Device LocationCapability
Expand Down
6 changes: 6 additions & 0 deletions config/esp32/components/chip/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## IDF Component Manager Manifest File
dependencies:
espressif/mdns:
version: "^1.0.3"
rules:
- if: "idf_version >=5.0"
4 changes: 4 additions & 0 deletions examples/chip-tool/commands/common/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,16 @@ int Commands::RunInteractive(const char * command)
char * argv[kInteractiveModeArgumentsMaxLength] = {};
argv[argc++] = kInteractiveModeName;

std::string commandStr;
for (auto & arg : arguments)
{
argv[argc] = new char[arg.size() + 1];
strcpy(argv[argc++], arg.c_str());
commandStr += arg;
commandStr += " ";
}

ChipLogProgress(chipTool, "Command: %s", commandStr.c_str());
auto err = RunCommand(argc, argv, true);

// Do not delete arg[0]
Expand Down
20 changes: 20 additions & 0 deletions examples/chip-tool/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
{
auto params = CommissioningParameters();
params.SetSkipCommissioningComplete(mSkipCommissioningComplete.ValueOr(false));
if (mBypassAttestationVerifier.ValueOr(false))
{
params.SetDeviceAttestationDelegate(this);
}

switch (mNetworkType)
{
Expand Down Expand Up @@ -281,3 +285,19 @@ void PairingCommand::OnCurrentFabricRemove(void * context, NodeId nodeId, CHIP_E

command->SetCommandExitStatus(err);
}

chip::Optional<uint16_t> PairingCommand::FailSafeExpiryTimeoutSecs() const
{
// We don't need to set additional failsafe timeout as we don't ask the final user if he wants to continue
return chip::Optional<uint16_t>();
}

void PairingCommand::OnDeviceAttestationCompleted(chip::Controller::DeviceCommissioner * deviceCommissioner,
chip::DeviceProxy * device,
const chip::Credentials::DeviceAttestationVerifier::AttestationDeviceInfo & info,
chip::Credentials::AttestationVerificationResult attestationResult)
{
// Bypass attestation verification, continue with success
deviceCommissioner->ContinueCommissioningAfterDeviceAttestation(device,
chip::Credentials::AttestationVerificationResult::kSuccess);
}
13 changes: 12 additions & 1 deletion examples/chip-tool/commands/pairing/PairingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ enum class PairingNetworkType

class PairingCommand : public CHIPCommand,
public chip::Controller::DevicePairingDelegate,
public chip::Controller::DeviceDiscoveryDelegate
public chip::Controller::DeviceDiscoveryDelegate,
public chip::Credentials::DeviceAttestationDelegate
{
public:
PairingCommand(const char * commandName, PairingMode mode, PairingNetworkType networkType,
Expand All @@ -60,6 +61,9 @@ class PairingCommand : public CHIPCommand,
mCurrentFabricRemoveCallback(OnCurrentFabricRemove, this)
{
AddArgument("node-id", 0, UINT64_MAX, &mNodeId);
AddArgument("bypass-attestation-verifier", 0, 1, &mBypassAttestationVerifier,
"Bypass the attestation verifier. If not provided or false, the attestation verifier is not bypassed."
" If true, the commissioning will continue in case of attestation verification failure.");

switch (networkType)
{
Expand Down Expand Up @@ -158,6 +162,12 @@ class PairingCommand : public CHIPCommand,
void OnDiscoveredDevice(const chip::Dnssd::DiscoveredNodeData & nodeData) override;
bool IsDiscoverOnce() { return mDiscoverOnce.ValueOr(false); }

/////////// DeviceAttestationDelegate /////////
chip::Optional<uint16_t> FailSafeExpiryTimeoutSecs() const override;
void OnDeviceAttestationCompleted(chip::Controller::DeviceCommissioner * deviceCommissioner, chip::DeviceProxy * device,
const chip::Credentials::DeviceAttestationVerifier::AttestationDeviceInfo & info,
chip::Credentials::AttestationVerificationResult attestationResult) override;

private:
CHIP_ERROR RunInternal(NodeId remoteId);
CHIP_ERROR Pair(NodeId remoteId, PeerAddress address);
Expand All @@ -177,6 +187,7 @@ class PairingCommand : public CHIPCommand,
chip::Optional<bool> mUseOnlyOnNetworkDiscovery;
chip::Optional<bool> mPaseOnly;
chip::Optional<bool> mSkipCommissioningComplete;
chip::Optional<bool> mBypassAttestationVerifier;
uint16_t mRemotePort;
uint16_t mDiscriminator;
uint32_t mSetupPINCode;
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/cm
set(EXTRA_COMPONENT_DIRS
"${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components"
"${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/QRCode"
"${IDF_PATH}/examples/common_components/led_strip"
)

project(chip-lighting-app)
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server"
)

set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash)
set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash spi_flash)

if (CONFIG_ENABLE_PW_RPC)
# Append additional directories for RPC build
Expand Down
14 changes: 8 additions & 6 deletions examples/lighting-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ using namespace chip::app::Clusters;
void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId,
uint8_t type, uint16_t size, uint8_t * value)
{
ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%04x', EndPoint ID: '0x%02x', Attribute ID: '0x%04x'", clusterId,
endpointId, attributeId);
ESP_LOGI(TAG,
"PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x', Attribute ID: '0x%04" PRIx32 "'",
clusterId, endpointId, attributeId);

switch (clusterId)
{
Expand All @@ -67,7 +68,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus
#endif

default:
ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId);
ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId);
break;
}

Expand All @@ -76,7 +77,8 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus

void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
{
VerifyOrExit(attributeId == OnOff::Attributes::OnOff::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId));
VerifyOrExit(attributeId == OnOff::Attributes::OnOff::Id,
ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId));
VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId));

AppLED.Set(*value);
Expand All @@ -88,7 +90,7 @@ void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointI
void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
{
VerifyOrExit(attributeId == LevelControl::Attributes::CurrentLevel::Id,
ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId));
ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId));
VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId));

AppLED.SetBrightness(*value);
Expand All @@ -105,7 +107,7 @@ void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpoi

VerifyOrExit(attributeId == ColorControl::Attributes::CurrentHue::Id ||
attributeId == ColorControl::Attributes::CurrentSaturation::Id,
ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04x", attributeId));
ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04" PRIx32 "'", attributeId));
VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId));

if (attributeId == ColorControl::Attributes::CurrentHue::Id)
Expand Down
6 changes: 5 additions & 1 deletion examples/lighting-app/esp32/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ menu "Demo"
default DEVICE_TYPE_ESP32_DEVKITC if IDF_TARGET_ESP32
default DEVICE_TYPE_ESP32_C3_DEVKITM if IDF_TARGET_ESP32C3
default DEVICE_TYPE_ESP32_S3_DEVKITM if IDF_TARGET_ESP32S3
default DEVICE_TYPE_ESP32_C2_DEVKITM if IDF_TARGET_ESP32C2
help
Specifies the type of ESP32 device.

Expand All @@ -46,6 +47,9 @@ menu "Demo"
config DEVICE_TYPE_ESP32H2_DEVKITC
bool "ESP32H2-DevKitC"
depends on IDF_TARGET_ESP32H2
config DEVICE_TYPE_ESP32_C2_DEVKITM
bool "ESP32C2-DevKitM"
depends on IDF_TARGET_ESP32C2
endchoice

choice LED_TYPE
Expand Down Expand Up @@ -76,7 +80,7 @@ menu "Demo"
int "LED GPIO number"
range 0 48
default 26 if DEVICE_TYPE_ESP32_WROVER_KIT
default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32H2_DEVKITC
default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32H2_DEVKITC || DEVICE_TYPE_ESP32_C2_DEVKITM
default 48 if DEVICE_TYPE_ESP32_S3_DEVKITM
default 5
help
Expand Down
16 changes: 1 addition & 15 deletions examples/lighting-app/esp32/main/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,14 @@ void LEDWidget::Init(void)
mBrightness = UINT8_MAX;

#if CONFIG_LED_TYPE_RMT
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
led_strip_config_t strip_config = {
.strip_gpio_num = CONFIG_LED_GPIO,
.max_leds = 1,
};

led_strip_new_rmt_device(&strip_config, &mStrip);
#else
rmt_config_t config = RMT_DEFAULT_CONFIG_TX((gpio_num_t) CONFIG_LED_GPIO, (rmt_channel_t) CONFIG_LED_RMT_CHANNEL);
led_strip_config_t strip_config = LED_STRIP_DEFAULT_CONFIG(1, (led_strip_dev_t) config.channel);

config.clk_div = 2;
rmt_config(&config);
rmt_driver_install(config.channel, 0, 0);

mStrip = led_strip_new_rmt_ws2812(&strip_config);
#endif
mStrip = led_strip_new_rmt_ws2812(&strip_config);
mHue = 0;
mSaturation = 0;
#else
Expand Down Expand Up @@ -131,13 +122,8 @@ void LEDWidget::DoSet(void)
{
HsvColor_t hsv = { mHue, mSaturation, brightness };
RgbColor_t rgb = HsvToRgb(hsv);
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
led_strip_set_pixel(mStrip, 0, rgb.r, rgb.g, rgb.b);
led_strip_refresh(mStrip);
#else
mStrip->set_pixel(mStrip, 0, rgb.r, rgb.g, rgb.b);
mStrip->refresh(mStrip, 100);
#endif
}
#else
ESP_LOGI(TAG, "DoSet to GPIO number %d", mGPIONum);
Expand Down
2 changes: 2 additions & 0 deletions examples/lighting-app/esp32/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
espressif/led_strip: "^1.0.0-alpha"
4 changes: 0 additions & 4 deletions examples/lighting-app/esp32/main/include/LEDWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ class LEDWidget
#if CONFIG_LED_TYPE_RMT
uint8_t mHue;
uint8_t mSaturation;
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
led_strip_handle_t mStrip;
#else
led_strip_t * mStrip;
#endif
#else
gpio_num_t mGPIONum;
#endif
Expand Down
3 changes: 3 additions & 0 deletions examples/lighting-app/esp32/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB"

# Disable softap support by default
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
# This example uses the older version of RMT driver to work with both
# idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option
CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y
19 changes: 19 additions & 0 deletions examples/lighting-app/esp32/sdkconfig.defaults.esp32c2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Disable chip shell
CONFIG_ENABLE_CHIP_SHELL=n

# CONFIG_ESP32_WIFI_IRAM_OPT is not set
# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y

CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y

CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=16
CONFIG_LWIP_TCP_RECVMBOX_SIZE=8

CONFIG_BT_NIMBLE_ROLE_CENTRAL=n
CONFIG_BT_NIMBLE_ROLE_OBSERVER=n

CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16
7 changes: 6 additions & 1 deletion examples/lighting-app/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ if (chip_enable_wifi) {

# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD)
if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" ||
silabs_board == "BRD2703A" || silabs_board == "BRD4319A") {
silabs_board == "BRD2703A" || silabs_board == "BRD4319A" ||
silabs_board == "BRD2704A") {
show_qr_code = false
disable_lcd = true
}
Expand Down Expand Up @@ -208,6 +209,10 @@ efr32_executable("lighting_app") {
include_dirs = [ "include" ]
defines = []

if (silabs_board == "BRD2704A") {
defines += [ "SL_STATUS_LED=0" ]
}

sources = [
"${examples_common_plat_dir}/heap_4_silabs.c",
"${examples_plat_dir}/BaseApplication.cpp",
Expand Down
6 changes: 4 additions & 2 deletions examples/lighting-app/silabs/efr32/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
#include "BaseApplication.h"
#include "FreeRTOS.h"
#include "LightingManager.h"
#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
#include "sl_simple_button_instances.h"
#endif
#include "timers.h" // provides FreeRTOS timer support
#include <app/clusters/identify-server/identify-server.h>
#include <ble/BLEEndPoint.h>
Expand Down Expand Up @@ -69,7 +71,7 @@ class AppTask : public BaseApplication
static void AppTaskMain(void * pvParameter);

CHIP_ERROR StartAppTask();

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
/**
* @brief Event handler when a button is pressed
* Function posts an event for button processing
Expand All @@ -79,7 +81,7 @@ class AppTask : public BaseApplication
* SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED
*/
void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override;

#endif
/**
* @brief Callback called by the identify-server when an identify command is received
*
Expand Down
Loading

0 comments on commit fdc290c

Please sign in to comment.