Skip to content

Commit

Permalink
Merge branch 'master' into small_kvs_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucicop authored Apr 10, 2023
2 parents 59abe07 + 03cb5e3 commit 730c86c
Show file tree
Hide file tree
Showing 22 changed files with 114 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Block zap-cli from being used
# xcodebuild is NOT expected to require zap-cli
run: scripts/run_in_build_env.sh 'mv $PW_ENVIRONMENT_ROOT/cipd/packages/zap/zap-cli $PW_ENVIRONMENT_ROOT/cipd/packages/zap/zap-cli.moved'
run: scripts/run_in_build_env.sh 'D=$(dirname $(which zap-cli)) && mv $D/zap-cli $D/zap-cli.moved'
- name: Validate zap-cli is NOT available
# run_in_build_env.sh is used to ensure PATH is set to something that would otherwise find zap-cli
run: scripts/run_in_build_env.sh '(zap-cli --version && exit 1) || exit 0'
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
run: xcodebuild clean
working-directory: src/darwin/Framework
- name: Make zap-cli work again
run: scripts/run_in_build_env.sh 'mv $PW_ENVIRONMENT_ROOT/cipd/packages/zap/zap-cli.moved $PW_ENVIRONMENT_ROOT/cipd/packages/zap/zap-cli'
run: scripts/run_in_build_env.sh 'D=$(dirname $(which zap-cli.moved)) && mv $D/zap-cli.moved $D/zap-cli'
- name: Validate zap-cli is again available
run: scripts/run_in_build_env.sh 'zap-cli --version'
- name: Build example All Clusters Server
Expand Down
5 changes: 5 additions & 0 deletions config/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ list(APPEND CHIP_DEFINES
PW_RPC_USE_GLOBAL_MUTEX=0
)

# TODO: Update this to use target_link_libraries instead of
# target_include_directories. target_include_directories never should be used to
# access other libraries since it does not add source files to the build graph
# and does not support transitive dependencies.
target_include_directories(${APP_TARGET} PRIVATE
${PIGWEED_ROOT}/pw_sys_io/public
${PIGWEED_ROOT}/pw_assert/public
Expand Down Expand Up @@ -241,6 +245,7 @@ target_include_directories(${APP_TARGET} PRIVATE
${PIGWEED_ROOT}/pw_function/public
${PIGWEED_ROOT}/pw_preprocessor/public
${PIGWEED_ROOT}/pw_rpc/system_server/public
${PIGWEED_ROOT}/pw_toolchain/public
${PIGWEED_ROOT}/third_party/fuchsia/repo/sdk/lib/fit/include
${PIGWEED_ROOT}/third_party/fuchsia/repo/sdk/lib/stdcompat/include
${CHIP_ROOT}/third_party/nanopb/repo
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC
target_link_options(${COMPONENT_LIB}
PUBLIC
"-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld"
"-L${PIGWEED_ROOT}/pw_tokenizer"
)

target_compile_options(${COMPONENT_LIB} PRIVATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC
target_link_options(${COMPONENT_LIB}
PUBLIC
"-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld"
"-L${PIGWEED_ROOT}/pw_tokenizer"
)

target_compile_options(${COMPONENT_LIB} PRIVATE
Expand Down
1 change: 1 addition & 0 deletions examples/chef/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC
target_link_options(${COMPONENT_LIB}
PUBLIC
"-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld"
"-L${PIGWEED_ROOT}/pw_tokenizer"
)

target_compile_options(${COMPONENT_LIB} PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/silabs/SiWx917/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Silicon Labs platform.
* Build the example application:

cd ~/connectedhomeip
./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/SiWx917/ ./out/light-switch-app BRD4325B
./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/SiWx917/ ./out/light-switch-app BRD4325B

- To delete generated executable, libraries and object files use:

Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/silabs/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Silicon Labs platform.
* Build the example application:

cd ~/connectedhomeip
./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app BRD4161A
./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app BRD4161A

- To delete generated executable, libraries and object files use:

Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC
target_link_options(${COMPONENT_LIB}
PUBLIC
"-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld"
"-L${PIGWEED_ROOT}/pw_tokenizer"
)

target_compile_options(${COMPONENT_LIB} PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/silabs/SiWx917/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ An example showing the use of CHIP on the Silicon Labs SiWx917.
- [Flashing the Application](#flashing-the-application)
- [Viewing Logging Output](#viewing-logging-output)
- [Running the Complete Example](#running-the-complete-example)
- [Notes](#notes)
- [Notes](#notes)
- [Memory settings](#memory-settings)
- [Group Communication (Multicast)](#group-communication-multicast)
- [Building options](#building-options)
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/silabs/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Silicon Labs platform.
* Build the example application:

cd ~/connectedhomeip
./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app BRD4161A
./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app BRD4161A

- To delete generated executable, libraries and object files use:

Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/silabs/SiWx917/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Mac OS X

```
cd ~/connectedhomeip
./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/SiWx917/ ./out/lock_app BRD4325B
./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/SiWx917/ ./out/lock_app BRD4325B
```

- To delete generated executable, libraries and object files use:
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/silabs/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Mac OS X

```
cd ~/connectedhomeip
./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock_app BRD4161A
./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock_app BRD4161A
```

- To delete generated executable, libraries and object files use:
Expand Down
1 change: 1 addition & 0 deletions examples/ota-requestor-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC
target_link_options(${COMPONENT_LIB}
PUBLIC
"-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld"
"-L${PIGWEED_ROOT}/pw_tokenizer"
)

target_compile_options(${COMPONENT_LIB} PRIVATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC
target_link_options(${COMPONENT_LIB}
PUBLIC
"-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld"
"-L${PIGWEED_ROOT}/pw_tokenizer"
)

target_compile_options(${COMPONENT_LIB} PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion examples/thermostat/silabs/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Silicon Labs platform.
* Build the example application:

cd ~/connectedhomeip
./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app BRD4161A
./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app BRD4161A

- To delete generated executable, libraries and object files use:

Expand Down
1 change: 1 addition & 0 deletions examples/window-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ target_link_libraries(app PRIVATE
target_link_options(app
PUBLIC
"-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld"
"-L${PIGWEED_ROOT}/pw_tokenizer"
)

endif(CONFIG_CHIP_PW_RPC)
59 changes: 54 additions & 5 deletions src/app/OperationalSessionSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ CHIP_ERROR OperationalSessionSetup::LookupPeerAddress()
{
++mAttemptsDone;
}
if (mResolveAttemptsAllowed > 0)
{
--mResolveAttemptsAllowed;
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES

// NOTE: This is public API that can be used to update our stored peer
Expand Down Expand Up @@ -502,9 +506,44 @@ void OperationalSessionSetup::OnNodeAddressResolutionFailed(const PeerId & peerI
ChipLogError(Discovery, "OperationalSessionSetup[%u:" ChipLogFormatX64 "]: operational discovery failed: %" CHIP_ERROR_FORMAT,
mPeerId.GetFabricIndex(), ChipLogValueX64(mPeerId.GetNodeId()), reason.Format());

// Does it make sense to ScheduleSessionSetupReattempt() here? DNS-SD
// resolution has its own retry/backoff mechanisms, so if it's failed we
// have already done a lot of that.
#if CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES
// If we're in a mode where we would generally retry CASE, retry operational
// discovery once. That allows us to more-gracefully handle broken networks
// where multicast DNS does not actually work and hence only the initial
// unicast DNS-SD queries get a response.
//
// We check for State::ResolvingAddress just in case in the meantime
// something weird happened and we are no longer trying to resolve an
// address.
if (mState == State::ResolvingAddress && mResolveAttemptsAllowed > 0)
{
ChipLogProgress(Discovery, "Retrying operational DNS-SD discovery. Attempts remaining: %u", mResolveAttemptsAllowed);

// Pretend like our previous attempt (i.e. call to LookupPeerAddress)
// has not happened for purposes of the generic attempt counters, so we
// don't mess up the counters for our actual CASE retry logic.
if (mRemainingAttempts < UINT8_MAX)
{
++mRemainingAttempts;
}
if (mAttemptsDone > 0)
{
--mAttemptsDone;
}

CHIP_ERROR err = LookupPeerAddress();
if (err == CHIP_NO_ERROR)
{
// We need to notify our consumer that the resolve will take more
// time, but we don't actually know how much time it will take,
// because the resolver does not expose that information. Just use
// one minute to be safe.
using namespace chip::System::Clock::Literals;
NotifyRetryHandlers(reason, 60_s16);
return;
}
}
#endif

// No need to modify any variables in `this` since call below releases `this`.
DequeueConnectionCallbacks(reason);
Expand All @@ -531,6 +570,11 @@ void OperationalSessionSetup::UpdateAttemptCount(uint8_t attemptCount)
{
mRemainingAttempts = attemptCount;
}

if (attemptCount > mResolveAttemptsAllowed)
{
mResolveAttemptsAllowed = attemptCount;
}
}

CHIP_ERROR OperationalSessionSetup::ScheduleSessionSetupReattempt(System::Clock::Seconds16 & timerDelay)
Expand Down Expand Up @@ -619,11 +663,16 @@ void OperationalSessionSetup::NotifyRetryHandlers(CHIP_ERROR error, const Reliab
System::Clock::Timeout messageTimeout = CASESession::ComputeSigma1ResponseTimeout(remoteMrpConfig);
auto timeoutSecs = std::chrono::duration_cast<System::Clock::Seconds16>(messageTimeout);
// Add 1 second in case we had fractional milliseconds in messageTimeout.
timeoutSecs += System::Clock::Seconds16(1);
using namespace chip::System::Clock::Literals;
NotifyRetryHandlers(error, timeoutSecs + 1_s16 + retryDelay);
}

void OperationalSessionSetup::NotifyRetryHandlers(CHIP_ERROR error, System::Clock::Seconds16 timeoutEstimate)
{
for (auto * item = mConnectionRetry.First(); item && item != &mConnectionRetry; item = item->mNext)
{
auto cb = Callback::Callback<OnDeviceConnectionRetry>::FromCancelable(item);
cb->mCall(cb->mContext, mPeerId, error, timeoutSecs + retryDelay);
cb->mCall(cb->mContext, mPeerId, error, timeoutEstimate);
}
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES
Expand Down
8 changes: 8 additions & 0 deletions src/app/OperationalSessionSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ class DLL_EXPORT OperationalSessionSetup : public SessionDelegate,
uint8_t mRemainingAttempts = 0;
uint8_t mAttemptsDone = 0;

uint8_t mResolveAttemptsAllowed = 0;

Callback::CallbackDeque mConnectionRetry;
#endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES

Expand Down Expand Up @@ -354,6 +356,12 @@ class DLL_EXPORT OperationalSessionSetup : public SessionDelegate,
*/
void NotifyRetryHandlers(CHIP_ERROR error, const ReliableMessageProtocolConfig & remoteMrpConfig,
System::Clock::Seconds16 retryDelay);

/**
* A version of NotifyRetryHandlers that passes in a retry timeout estimate
* directly.
*/
void NotifyRetryHandlers(CHIP_ERROR error, System::Clock::Seconds16 timeoutEstimate);
#endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES
};

Expand Down
2 changes: 1 addition & 1 deletion src/lib/support/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static_library("support") {
}

if (chip_pw_tokenizer_logging) {
public_deps += [ "${dir_pw_tokenizer}:global_handler_with_payload" ]
public_deps += [ "${dir_pw_tokenizer}" ]
}

if (chip_config_memory_debug_dmalloc) {
Expand Down
32 changes: 22 additions & 10 deletions src/lib/support/logging/CHIPLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,45 @@

#include <atomic>

#if CHIP_PW_TOKENIZER_LOGGING
#include "pw_tokenizer/encode_args.h"
#endif

namespace chip {
namespace Logging {

#if _CHIP_USE_LOGGING

#if CHIP_PW_TOKENIZER_LOGGING

extern "C" void pw_tokenizer_HandleEncodedMessageWithPayload(uintptr_t levels, const uint8_t encoded_message[], size_t size_bytes)
void HandleTokenizedLog(uint32_t levels, pw_tokenizer_Token token, pw_tokenizer_ArgTypes types, ...)
{
uint8_t encoded_message[PW_TOKENIZER_CFG_ENCODING_BUFFER_SIZE_BYTES];

va_list args;
va_start(args, types);
// Use the C argument encoding API, since the C++ API requires C++17.
const size_t encoded_size = pw_tokenizer_EncodeArgs(types, args, encoded_message, sizeof(encoded_message));
va_end(args);

uint8_t log_category = levels >> 8 & 0xFF;
uint8_t log_module = levels & 0xFF;
char * buffer = (char *) chip::Platform::MemoryAlloc(2 * size_bytes + 1);
char * buffer = (char *) chip::Platform::MemoryAlloc(2 * encoded_size + 1);

if (buffer)
{
for (int i = 0; i < size_bytes; i++)
for (int i = 0; i < encoded_size; i++)
{
sprintf(buffer + 2 * i, "%02x", encoded_message[i]);
}
buffer[2 * size_bytes] = '\0';
chip::Logging::Log(log_module, log_category, "%s", buffer);
buffer[2 * encoded_size] = '\0';
Log(log_module, log_category, "%s", buffer);
chip::Platform::MemoryFree(buffer);
}
}

#endif

namespace chip {
namespace Logging {

#if _CHIP_USE_LOGGING

namespace {

std::atomic<LogRedirectCallback_t> sLogRedirectCallback{ nullptr };
Expand Down
10 changes: 7 additions & 3 deletions src/lib/support/logging/CHIPLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#endif

#if CHIP_PW_TOKENIZER_LOGGING
#include "pw_tokenizer/tokenize_to_global_handler_with_payload.h"
#include "pw_tokenizer/tokenize.h"
#endif

/**
Expand Down Expand Up @@ -423,13 +423,17 @@ void LogV(uint8_t module, uint8_t category, const char * msg, va_list args) ENFO
#endif // CHIP_SYSTEM_CONFIG_PLATFORM_LOG

#if CHIP_PW_TOKENIZER_LOGGING

void HandleTokenizedLog(uint32_t levels, pw_tokenizer_Token token, pw_tokenizer_ArgTypes, ...);

#define ChipInternalLogImpl(MOD, CAT, MSG, ...) \
do \
{ \
if (chip::Logging::IsCategoryEnabled(CAT)) \
{ \
PW_TOKENIZE_TO_GLOBAL_HANDLER_WITH_PAYLOAD((pw_tokenizer_Payload)((CAT << 8) | chip::Logging::kLogModule_##MOD), MSG, \
__VA_ARGS__); \
PW_TOKENIZE_FORMAT_STRING(PW_TOKENIZER_DEFAULT_DOMAIN, UINT32_MAX, MSG, __VA_ARGS__); \
::chip::Logging::HandleTokenizedLog((uint32_t)((CAT << 8) | chip::Logging::kLogModule_##MOD), _pw_tokenizer_token, \
PW_TOKENIZER_ARG_TYPES(__VA_ARGS__) PW_COMMA_ARGS(__VA_ARGS__)); \
} \
} while (0)
#else // CHIP_PW_TOKENIZER_LOGGING
Expand Down
2 changes: 1 addition & 1 deletion third_party/pigweed/repo
Submodule repo updated 749 files

0 comments on commit 730c86c

Please sign in to comment.