Skip to content

Commit

Permalink
Merge branch 'master' into cctrl-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq authored Dec 19, 2024
2 parents 853eee0 + 238e801 commit 2c84d40
Show file tree
Hide file tree
Showing 23 changed files with 290 additions and 72 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/examples-esp32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ jobs:
"./scripts/build/build_examples.py \
--enable-flashbundle \
--target esp32-m5stack-all-clusters-minimal \
--target esp32-m5stack-all-clusters-rpc-ipv6only \
--pregen-dir ./zzz_pregenerated \
build \
--copy-artifacts-to out/artifacts \
Expand All @@ -95,6 +94,15 @@ jobs:
mv scripts/tools/zap/generate.py.renamed scripts/tools/zap/generate.py
- name: Build example All Clusters App(Target:ESP32C3)
run: scripts/examples/esp_example.sh all-clusters-app sdkconfig.defaults.esp32c3 esp32c3
- name: Build example All Clusters App(Target:ESP32)
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--enable-flashbundle \
--target esp32-devkitc-all-clusters-rpc-ipv6only \
build \
--copy-artifacts-to out/artifacts \
"
- name: Copy aside build products
run: |
mkdir -p example_binaries/esp32-build
Expand Down
2 changes: 0 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,6 @@
"esp32-devkitc-temperature-measurement",
"esp32-m5stack-all-clusters",
"esp32-m5stack-all-clusters-ipv6only",
"esp32-m5stack-all-clusters-rpc",
"esp32-m5stack-all-clusters-rpc-ipv6only",
"infineon-psoc6-all-clusters",
"infineon-psoc6-lock",
"infineon-psoc6-light",
Expand Down
92 changes: 92 additions & 0 deletions examples/all-clusters-app/esp32/sdkconfig_rpc.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#
# Copyright (c) 2024 Project CHIP Authors
# Copyright (c) 2024 Nest Labs, Inc.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Description:
# CI uses this to select the ESP32.
#
CONFIG_IDF_TARGET="esp32"
CONFIG_IDF_TARGET_ESP32=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_MONITOR_BAUD_115200B=y
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200

#enable BT
CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y

#enable lwip ipv6 autoconfig
CONFIG_LWIP_IPV6_AUTOCONFIG=y

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

# Vendor and product id
CONFIG_DEVICE_VENDOR_ID=0xFFF1
CONFIG_DEVICE_PRODUCT_ID=0x8001

# Main task needs a bit more stack than the default
# default is 3584, bump this up to 5k.
CONFIG_ESP_MAIN_TASK_STACK_SIZE=5120

# PW RPC Debug channel
CONFIG_EXAMPLE_UART_PORT_NUM=0
CONFIG_EXAMPLE_UART_BAUD_RATE=115200
CONFIG_EXAMPLE_UART_RXD=3
CONFIG_EXAMPLE_UART_TXD=1
CONFIG_ENABLE_PW_RPC=y

# Disable shell
CONFIG_ENABLE_CHIP_SHELL=n

# Serial Flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"


#disable Bluetooth modem sleep
#enable it may cause GPIO ISR triggers continuously
CONFIG_BTDM_CTRL_MODEM_SLEEP=n
CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG=n
CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=n

# Enable HKDF in mbedtls
CONFIG_MBEDTLS_HKDF_C=y

# Build chip tests
CONFIG_BUILD_CHIP_TESTS=y

# Move functions from IRAM to flash
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y

CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y

# Memory Optimizations
CONFIG_NIMBLE_MAX_CONNECTIONS=1
CONFIG_BTDM_CTRL_BLE_MAX_CONN=1
CONFIG_BT_NIMBLE_ROLE_CENTRAL=n
CONFIG_BT_NIMBLE_ROLE_OBSERVER=n

# Reduce the event logging buffer to reduce the DRAM overflow
# TODO: [ESP32] Fix the DRAM overflow in esp32 apps #34717
CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE=512
CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE=512
CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE=512
6 changes: 4 additions & 2 deletions examples/chef/nrfconnect/rpc.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ CONFIG_LOG_OUTPUT=y
# Increase zephyr tty rx buffer
CONFIG_CONSOLE_GETCHAR_BUFSIZE=128

# Increase BLE thread stack size
CONFIG_BT_RX_STACK_SIZE=2048
# Increase thread stack sizes
CONFIG_BT_RX_STACK_SIZE=4096
CONFIG_MAIN_STACK_SIZE=8092
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

6 changes: 4 additions & 2 deletions examples/lighting-app/nrfconnect/rpc.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ CONFIG_LOG_OUTPUT=y
# Increase zephyr tty rx buffer
CONFIG_CONSOLE_GETCHAR_BUFSIZE=128

# Increase BLE thread stack size
CONFIG_BT_RX_STACK_SIZE=2048
# Increase thread stack sizes
CONFIG_BT_RX_STACK_SIZE=4096
CONFIG_MAIN_STACK_SIZE=8092
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

1 change: 0 additions & 1 deletion integrations/cloudbuild/smoke-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ steps:
./scripts/build/build_examples.py --enable-flashbundle --target
esp32-devkitc-light-rpc --target
esp32-m5stack-all-clusters-ipv6only --target
esp32-m5stack-all-clusters-rpc-ipv6only --target
esp32-m5stack-light --target
esp32-m5stack-light-ipv6only --target
esp32-m5stack-ota-requestor build --create-archives
Expand Down
1 change: 0 additions & 1 deletion scripts/build/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pw_python_package("build_examples") {
"testdata/dry_run_android-arm64-chip-tool.txt",
"testdata/dry_run_efr32-brd4187c-light-rpc-no-version.txt",
"testdata/dry_run_esp32-devkitc-light-rpc.txt",
"testdata/dry_run_esp32-m5stack-all-clusters-minimal-rpc-ipv6only.txt",
"testdata/dry_run_linux-arm64-chip-tool-ipv6only-clang.txt",
"testdata/dry_run_linux-arm64-ota-requestor-nodeps-ipv6only.txt",
"testdata/dry_run_linux-x64-all-clusters-coverage.txt",
Expand Down
1 change: 0 additions & 1 deletion scripts/build/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def test_general_dry_runs(self):
# build options do not change too much
TARGETS = [
'esp32-devkitc-light-rpc',
'esp32-m5stack-all-clusters-minimal-rpc-ipv6only',
'android-arm64-chip-tool',
'nrf-nrf52840dk-pump',
'efr32-brd4187c-light-rpc-no-version',
Expand Down

This file was deleted.

6 changes: 6 additions & 0 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ source_set("test-event-trigger") {
sources = [ "TestEventTriggerDelegate.h" ]
}

source_set("event-reporter") {
sources = [ "EventReporter.h" ]
}

# interaction-model is a static-library because it currently requires global functions (app/util/...) that are stubbed in different test files that depend on the app static_library
# which in tern depens on the interaction-model.
# Using source_set prevents the unit test to build correctly.
Expand Down Expand Up @@ -211,6 +215,7 @@ static_library("interaction-model") {
":app_config",
":command-handler-impl",
":constants",
":event-reporter",
":paths",
":subscription-info-provider",
"${chip_root}/src/app/MessageDef",
Expand Down Expand Up @@ -456,6 +461,7 @@ static_library("app") {
":app_config",
":attribute-access",
":constants",
":event-reporter",
":global-attributes",
":interaction-model",
"${chip_root}/src/app/data-model",
Expand Down
14 changes: 12 additions & 2 deletions src/app/EventManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct CopyAndAdjustDeltaTimeContext
void EventManagement::Init(Messaging::ExchangeManager * apExchangeManager, uint32_t aNumBuffers,
CircularEventBuffer * apCircularEventBuffer, const LogStorageResources * const apLogStorageResources,
MonotonicallyIncreasingCounter<EventNumber> * apEventNumberCounter,
System::Clock::Milliseconds64 aMonotonicStartupTime)
System::Clock::Milliseconds64 aMonotonicStartupTime, EventReporter * apEventReporter)
{
CircularEventBuffer * current = nullptr;
CircularEventBuffer * prev = nullptr;
Expand Down Expand Up @@ -124,6 +124,16 @@ void EventManagement::Init(Messaging::ExchangeManager * apExchangeManager, uint3
mBytesWritten = 0;

mMonotonicStartupTime = aMonotonicStartupTime;

// TODO(#36890): Should remove using the global instance and rely only on passed in variable.
if (apEventReporter == nullptr)
{
mpEventReporter = &InteractionModelEngine::GetInstance()->GetReportingEngine();
}
else
{
mpEventReporter = apEventReporter;
}
}

CHIP_ERROR EventManagement::CopyToNextBuffer(CircularEventBuffer * apEventBuffer)
Expand Down Expand Up @@ -490,7 +500,7 @@ CHIP_ERROR EventManagement::LogEventPrivate(EventLoggingDelegate * apDelegate, c
opts.mTimestamp.mType == Timestamp::Type::kSystem ? "Sys" : "Epoch", ChipLogValueX64(opts.mTimestamp.mValue));
#endif // CHIP_CONFIG_EVENT_LOGGING_VERBOSE_DEBUG_LOGS

err = InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleEventDelivery(opts.mPath, mBytesWritten);
err = mpEventReporter->NewEventGenerated(opts.mPath, mBytesWritten);
}

return err;
Expand Down
7 changes: 6 additions & 1 deletion src/app/EventManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "EventLoggingDelegate.h"
#include <access/SubjectDescriptor.h>
#include <app/EventLoggingTypes.h>
#include <app/EventReporter.h>
#include <app/MessageDef/EventDataIB.h>
#include <app/MessageDef/StatusIB.h>
#include <app/data-model-provider/EventsGenerator.h>
Expand Down Expand Up @@ -225,11 +226,13 @@ class EventManagement : public DataModel::EventsGenerator
* time 0" for cases when we use
* system-time event timestamps.
*
* @param[in] apEventReporter Event reporter to be notified when events are generated.
*
*/
void Init(Messaging::ExchangeManager * apExchangeManager, uint32_t aNumBuffers, CircularEventBuffer * apCircularEventBuffer,
const LogStorageResources * const apLogStorageResources,
MonotonicallyIncreasingCounter<EventNumber> * apEventNumberCounter,
System::Clock::Milliseconds64 aMonotonicStartupTime);
System::Clock::Milliseconds64 aMonotonicStartupTime, EventReporter * apEventReporter = nullptr);

static EventManagement & GetInstance();

Expand Down Expand Up @@ -563,6 +566,8 @@ class EventManagement : public DataModel::EventsGenerator
Timestamp mLastEventTimestamp; ///< The timestamp of the last event in this buffer

System::Clock::Milliseconds64 mMonotonicStartupTime;

EventReporter * mpEventReporter = nullptr;
};

} // namespace app
Expand Down
46 changes: 46 additions & 0 deletions src/app/EventReporter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <app/ConcreteEventPath.h>
#include <lib/core/CHIPError.h>

namespace chip {
namespace app {

/**
* Interface that EventManagement can use to notify when events are generated and may need reporting.
*
*/
class EventReporter
{
public:
virtual ~EventReporter() = default;

/**
* Notify that an event was generated.
*
* @param[in] aPath The path that identifies the kind of event that was generated.
* @param[in] aBytesConsumed The number of bytes needed to store the event in EventManagement.
*/
CHIP_ERROR virtual NewEventGenerated(ConcreteEventPath & aPath, uint32_t aBytesConsumed) = 0;
};

} // namespace app
} // namespace chip
5 changes: 3 additions & 2 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ InteractionModelEngine * InteractionModelEngine::GetInstance()

CHIP_ERROR InteractionModelEngine::Init(Messaging::ExchangeManager * apExchangeMgr, FabricTable * apFabricTable,
reporting::ReportScheduler * reportScheduler, CASESessionManager * apCASESessionMgr,
SubscriptionResumptionStorage * subscriptionResumptionStorage)
SubscriptionResumptionStorage * subscriptionResumptionStorage,
EventManagement * eventManagement)
{
VerifyOrReturnError(apFabricTable != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(apExchangeMgr != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
Expand All @@ -165,7 +166,7 @@ CHIP_ERROR InteractionModelEngine::Init(Messaging::ExchangeManager * apExchangeM
ReturnErrorOnFailure(mpFabricTable->AddFabricDelegate(this));
ReturnErrorOnFailure(mpExchangeMgr->RegisterUnsolicitedMessageHandlerForProtocol(Protocols::InteractionModel::Id, this));

mReportingEngine.Init();
mReportingEngine.Init((eventManagement != nullptr) ? eventManagement : &EventManagement::GetInstance());

StatusIB::RegisterErrorFormatter();

Expand Down
4 changes: 3 additions & 1 deletion src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
* @param[in] apExchangeMgr A pointer to the ExchangeManager object.
* @param[in] apFabricTable A pointer to the FabricTable object.
* @param[in] apCASESessionMgr An optional pointer to a CASESessionManager (used for re-subscriptions).
* @parma[in] eventManagement An optional pointer to a EventManagement. If null, the global instance will be used.
*
*/
CHIP_ERROR Init(Messaging::ExchangeManager * apExchangeMgr, FabricTable * apFabricTable,
reporting::ReportScheduler * reportScheduler, CASESessionManager * apCASESessionMgr = nullptr,
SubscriptionResumptionStorage * subscriptionResumptionStorage = nullptr);
SubscriptionResumptionStorage * subscriptionResumptionStorage = nullptr,
EventManagement * eventManagement = nullptr);

void Shutdown();

Expand Down
9 changes: 8 additions & 1 deletion src/app/clusters/user-label-server/user-label-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,14 @@ CHIP_ERROR UserLabelAttrAccess::WriteLabelList(const ConcreteDataAttributePath &
ReturnErrorOnFailure(aDecoder.Decode(entry));
VerifyOrReturnError(IsValidLabelEntry(entry), CHIP_IM_GLOBAL_STATUS(ConstraintError));

return provider->AppendUserLabel(endpoint, entry);
// Append the single user label entry
CHIP_ERROR err = provider->AppendUserLabel(endpoint, entry);
if (err == CHIP_ERROR_NO_MEMORY)
{
return CHIP_IM_GLOBAL_STATUS(ResourceExhausted);
}

return err;
}

return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
Expand Down
Loading

0 comments on commit 2c84d40

Please sign in to comment.