Skip to content

Commit

Permalink
Merge Master
Browse files Browse the repository at this point in the history
  • Loading branch information
RitikaNanda committed Jun 21, 2021
2 parents d67eaa5 + e00eac3 commit 66ce627
Show file tree
Hide file tree
Showing 102 changed files with 1,520 additions and 2,153 deletions.
2 changes: 1 addition & 1 deletion config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ menu "CHIP Device Layer"

config CHIPOBLE_SINGLE_CONNECTION
bool "Single Connection Mode"
default n
default y
depends on ENABLE_CHIPOBLE
help
Limit support for CHIP-over-BLE (WoBLE) to a single inbound connection.
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ efr32_sdk("sdk") {
defines = [
"BOARD_ID=${efr32_board}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"SL_HEAP_SIZE=(13 * 1024)",
"SL_HEAP_SIZE=(16 * 1024)",
]

if (chip_enable_pw_rpc) {
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ efr32_sdk("sdk") {
defines = [
"BOARD_ID=${efr32_board}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"SL_HEAP_SIZE=(13 * 1024)",
"SL_HEAP_SIZE=(16 * 1024)",
]
}

Expand Down
15 changes: 15 additions & 0 deletions examples/lock-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "esp_log.h"
#include <app/common/gen/attribute-id.h>
#include <app/common/gen/cluster-id.h>
#include <app/server/Mdns.h>
#include <support/CodeUtils.h>

static const char * TAG = "lock-devicecallbacks";
Expand All @@ -51,6 +52,18 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
case DeviceEventType::kSessionEstablished:
OnSessionEstablished(event);
break;

case DeviceEventType::kInterfaceIpAddressChanged:
if ((event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV4_Assigned) ||
(event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned))
{
// MDNS server restart on any ip assignment: if link local ipv6 is configured, that
// will not trigger a 'internet connectivity change' as there is no internet
// connectivity. MDNS still wants to refresh its listening interfaces to include the
// newly selected address.
chip::app::Mdns::StartServer();
}
break;
}

ESP_LOGI(TAG, "Current free heap: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT));
Expand Down Expand Up @@ -80,6 +93,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event
if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established)
{
ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT);
chip::app::Mdns::StartServer();
}
else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost)
{
Expand All @@ -88,6 +102,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event
if (event->InternetConnectivityChange.IPv6 == kConnectivity_Established)
{
ESP_LOGI(TAG, "IPv6 Server ready...");
chip::app::Mdns::StartServer();
}
else if (event->InternetConnectivityChange.IPv6 == kConnectivity_Lost)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/pigweed-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ efr32_sdk("sdk") {
"HAL_VCOM_ENABLE=1",
"EFR32_LOG_ENABLED=1",
"PW_RPC_ENABLED",
"SL_HEAP_SIZE=(10 * 1024)",
"SL_HEAP_SIZE=(16 * 1024)",
]
}

Expand Down
2 changes: 1 addition & 1 deletion examples/shell/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ efr32_sdk("sdk") {

defines = [
"BOARD_ID=${efr32_board}",
"SL_HEAP_SIZE=(12 * 1024)",
"SL_HEAP_SIZE=(16 * 1024)",
"OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_CONSOLE",
"ENABLE_CHIP_SHELL",
]
Expand Down
19 changes: 9 additions & 10 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import("//build_overrides/chip.gni")
import("//build_overrides/nlio.gni")

import("${chip_root}/build/chip/buildconfig_header.gni")
import("common_flags.gni")

declare_args() {
Expand All @@ -22,12 +24,11 @@ declare_args() {
is_debug && (current_os == "linux" || current_os == "mac")
}

config("app_config") {
if (chip_enable_schema_check) {
defines = [ "CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK=1" ]
} else {
defines = [ "CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK=0" ]
}
buildconfig_header("app_buildconfig") {
header = "AppBuildConfig.h"
header_dir = "app"

defines = [ "CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK=${chip_enable_schema_check}" ]
}

static_library("app") {
Expand Down Expand Up @@ -108,6 +109,7 @@ static_library("app") {
}

public_deps = [
":app_buildconfig",
"${chip_root}/src/lib/support",
"${chip_root}/src/messaging",
"${chip_root}/src/system",
Expand All @@ -116,8 +118,5 @@ static_library("app") {

cflags = [ "-Wconversion" ]

public_configs = [
":app_config",
"${chip_root}/src:includes",
]
public_configs = [ "${chip_root}/src:includes" ]
}
6 changes: 3 additions & 3 deletions src/app/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "CommandHandler.h"
#include "CommandSender.h"
#include "InteractionModelEngine.h"

#include <app/AppBuildConfig.h>
#include <core/CHIPTLVDebug.hpp>

namespace chip {
Expand Down Expand Up @@ -126,7 +128,7 @@ CHIP_ERROR Command::ProcessCommandMessage(System::PacketBufferHandle && payload,

void Command::Shutdown()
{
VerifyOrExit(mState != CommandState::Uninitialized, );
VerifyOrReturn(mState != CommandState::Uninitialized);
mCommandMessageWriter.Reset();

AbortExistingExchangeContext();
Expand All @@ -136,8 +138,6 @@ void Command::Shutdown()
ClearState();

mCommandIndex = 0;
exit:
return;
}

CHIP_ERROR Command::PrepareCommand(const CommandPathParams & aCommandPathParams, bool aIsStatus)
Expand Down
90 changes: 38 additions & 52 deletions src/app/EventManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,29 +668,30 @@ CHIP_ERROR EventManagement::EventIterator(const TLVReader & aReader, size_t aDep

CHIP_ERROR EventManagement::CopyEventsSince(const TLVReader & aReader, size_t aDepth, void * apContext)
{
CHIP_ERROR err = CHIP_NO_ERROR;
TLV::TLVWriter checkpoint;
EventLoadOutContext * loadOutContext = static_cast<EventLoadOutContext *>(apContext);
err = EventIterator(aReader, aDepth, loadOutContext);
EventLoadOutContext * const loadOutContext = static_cast<EventLoadOutContext *>(apContext);
CHIP_ERROR err = EventIterator(aReader, aDepth, loadOutContext);
loadOutContext->mCurrentEventNumber++;
if (err == CHIP_EVENT_ID_FOUND)
{
// checkpoint the writer
checkpoint = loadOutContext->mWriter;
TLV::TLVWriter checkpoint = loadOutContext->mWriter;

err = CopyEvent(aReader, loadOutContext->mWriter, loadOutContext);

// CHIP_NO_ERROR and CHIP_END_OF_TLV signify a
// successful copy. In all other cases, roll back the
// writer state back to the checkpoint, i.e., the state
// before we began the copy operation.
VerifyOrExit((err == CHIP_NO_ERROR) || (err == CHIP_END_OF_TLV), loadOutContext->mWriter = checkpoint);
if ((err != CHIP_NO_ERROR) && (err != CHIP_END_OF_TLV))
{
loadOutContext->mWriter = checkpoint;
return err;
}

loadOutContext->mPreviousSystemTime.mValue = loadOutContext->mCurrentSystemTime.mValue;
loadOutContext->mFirst = false;
}

exit:
return err;
}

Expand Down Expand Up @@ -734,86 +735,75 @@ CHIP_ERROR EventManagement::FetchEventsSince(TLVWriter & aWriter, ClusterInfo *

CHIP_ERROR EventManagement::GetEventReader(TLVReader & aReader, PriorityLevel aPriority, CircularEventBufferWrapper * apBufWrapper)
{
CHIP_ERROR err = CHIP_NO_ERROR;
CircularEventReader reader;
CircularEventBuffer * buffer = GetPriorityBuffer(aPriority);
VerifyOrExit(buffer != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(buffer != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
apBufWrapper->mpCurrent = buffer;

CircularEventReader reader;
reader.Init(apBufWrapper);
aReader.Init(reader);
exit:
return err;

return CHIP_NO_ERROR;
}

CHIP_ERROR EventManagement::FetchEventParameters(const TLVReader & aReader, size_t aDepth, void * apContext)
{
CHIP_ERROR err = CHIP_NO_ERROR;
EventEnvelopeContext * envelope = static_cast<EventEnvelopeContext *>(apContext);
EventEnvelopeContext * const envelope = static_cast<EventEnvelopeContext *>(apContext);
TLVReader reader;
uint16_t extPriority; // Note: the type here matches the type case in EventManagement::LogEvent, priority section
reader.Init(aReader);

if (reader.GetTag() == TLV::ContextTag(EventDataElement::kCsTag_EventPath))
{
EventPath::Parser path;
SuccessOrExit(err = path.Init(aReader));
SuccessOrExit(err = path.GetNodeId(&(envelope->mNodeId)));
SuccessOrExit(err = path.GetEndpointId(&(envelope->mEndpointId)));
SuccessOrExit(err = path.GetClusterId(&(envelope->mClusterId)));
SuccessOrExit(err = path.GetEventId(&(envelope->mEventId)));
ReturnErrorOnFailure(path.Init(aReader));
ReturnErrorOnFailure(path.GetNodeId(&(envelope->mNodeId)));
ReturnErrorOnFailure(path.GetEndpointId(&(envelope->mEndpointId)));
ReturnErrorOnFailure(path.GetClusterId(&(envelope->mClusterId)));
ReturnErrorOnFailure(path.GetEventId(&(envelope->mEventId)));
envelope->mFieldsToRead |= 1 << EventDataElement::kCsTag_EventPath;
}

if (reader.GetTag() == TLV::ContextTag(EventDataElement::kCsTag_PriorityLevel))
{
err = reader.Get(extPriority);
SuccessOrExit(err);
uint16_t extPriority; // Note: the type here matches the type case in EventManagement::LogEvent, priority section
ReturnErrorOnFailure(reader.Get(extPriority));
envelope->mPriority = static_cast<PriorityLevel>(extPriority);
envelope->mFieldsToRead |= 1 << EventDataElement::kCsTag_PriorityLevel;
}

if (reader.GetTag() == TLV::ContextTag(EventDataElement::kCsTag_DeltaSystemTimestamp))
{
err = reader.Get(envelope->mDeltaSystemTime.mValue);
SuccessOrExit(err);
ReturnErrorOnFailure(reader.Get(envelope->mDeltaSystemTime.mValue));

envelope->mFieldsToRead |= 1 << EventDataElement::kCsTag_DeltaSystemTimestamp;
}

exit:
return err;
return CHIP_NO_ERROR;
}

CHIP_ERROR EventManagement::EvictEvent(CHIPCircularTLVBuffer & apBuffer, void * apAppData, TLVReader & aReader)
{
ReclaimEventCtx * ctx = static_cast<ReclaimEventCtx *>(apAppData);
CircularEventBuffer * eventBuffer = ctx->mpEventBuffer;
TLVType containerType;
EventEnvelopeContext context;
const bool recurse = false;
CHIP_ERROR err;
PriorityLevel imp = PriorityLevel::Invalid;

// pull out the delta time, pull out the priority
err = aReader.Next();
SuccessOrExit(err);
ReturnErrorOnFailure(aReader.Next());

err = aReader.EnterContainer(containerType);
SuccessOrExit(err);
TLVType containerType;
ReturnErrorOnFailure(aReader.EnterContainer(containerType));

err = TLV::Utilities::Iterate(aReader, FetchEventParameters, &context, recurse);
EventEnvelopeContext context;
constexpr bool recurse = false;
CHIP_ERROR err = TLV::Utilities::Iterate(aReader, FetchEventParameters, &context, recurse);
if (err == CHIP_END_OF_TLV)
{
err = CHIP_NO_ERROR;
}
SuccessOrExit(err);

err = aReader.ExitContainer(containerType);
ReturnErrorOnFailure(err);

SuccessOrExit(err);
ReturnErrorOnFailure(aReader.ExitContainer(containerType));

imp = static_cast<PriorityLevel>(context.mPriority);
const PriorityLevel imp = static_cast<PriorityLevel>(context.mPriority);

ReclaimEventCtx * const ctx = static_cast<ReclaimEventCtx *>(apAppData);
CircularEventBuffer * const eventBuffer = ctx->mpEventBuffer;
if (eventBuffer->IsFinalDestinationForPriority(imp))
{
// event is getting dropped. Increase the event number and first timestamp.
Expand All @@ -826,16 +816,12 @@ CHIP_ERROR EventManagement::EvictEvent(CHIPCircularTLVBuffer & apBuffer, void *
" };",
static_cast<unsigned>(eventBuffer->GetPriorityLevel()), static_cast<unsigned>(imp), ChipLogValueX64(numEventsToDrop));
ctx->mSpaceNeededForMovedEvent = 0;
}
else
{
// event is not getting dropped. Note how much space it requires, and return.
ctx->mSpaceNeededForMovedEvent = aReader.GetLengthRead();
err = CHIP_END_OF_TLV;
return CHIP_NO_ERROR;
}

exit:
return err;
// event is not getting dropped. Note how much space it requires, and return.
ctx->mSpaceNeededForMovedEvent = aReader.GetLengthRead();
return CHIP_END_OF_TLV;
}

CHIP_ERROR EventManagement::ScheduleFlushIfNeeded(EventOptions::Type aUrgent)
Expand Down
23 changes: 7 additions & 16 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,12 @@ InteractionModelEngine * InteractionModelEngine::GetInstance()

CHIP_ERROR InteractionModelEngine::Init(Messaging::ExchangeManager * apExchangeMgr, InteractionModelDelegate * apDelegate)
{
CHIP_ERROR err = CHIP_NO_ERROR;

mpExchangeMgr = apExchangeMgr;
mpDelegate = apDelegate;

err = mpExchangeMgr->RegisterUnsolicitedMessageHandlerForProtocol(Protocols::InteractionModel::Id, this);
SuccessOrExit(err);
ReturnErrorOnFailure(mpExchangeMgr->RegisterUnsolicitedMessageHandlerForProtocol(Protocols::InteractionModel::Id, this));

mReportingEngine.Init();
SuccessOrExit(err);

for (uint32_t index = 0; index < IM_SERVER_MAX_NUM_PATH_GROUPS - 1; index++)
{
Expand All @@ -60,8 +56,7 @@ CHIP_ERROR InteractionModelEngine::Init(Messaging::ExchangeManager * apExchangeM
mClusterInfoPool[IM_SERVER_MAX_NUM_PATH_GROUPS - 1].mpNext = nullptr;
mpNextAvailableClusterInfo = mClusterInfoPool;

exit:
return err;
return CHIP_NO_ERROR;
}

void InteractionModelEngine::Shutdown()
Expand Down Expand Up @@ -125,26 +120,22 @@ void InteractionModelEngine::Shutdown()

CHIP_ERROR InteractionModelEngine::NewCommandSender(CommandSender ** const apCommandSender)
{
CHIP_ERROR err = CHIP_ERROR_NO_MEMORY;
*apCommandSender = nullptr;

for (auto & commandSender : mCommandSenderObjs)
{
if (commandSender.IsFree())
{
*apCommandSender = &commandSender;
err = commandSender.Init(mpExchangeMgr, mpDelegate);
if (CHIP_NO_ERROR != err)
const CHIP_ERROR err = commandSender.Init(mpExchangeMgr, mpDelegate);
if (err == CHIP_NO_ERROR)
{
*apCommandSender = nullptr;
ExitNow();
*apCommandSender = &commandSender;
}
break;
return err;
}
}

exit:
return err;
return CHIP_ERROR_NO_MEMORY;
}

CHIP_ERROR InteractionModelEngine::NewReadClient(ReadClient ** const apReadClient)
Expand Down
Loading

0 comments on commit 66ce627

Please sign in to comment.