Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of DataModel::Provider in writes #34754

Merged
merged 90 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
197d02b
Implement DM::Provider::Write usage
andreilitvin Aug 2, 2024
826ba92
Fix compile
andy31415 Aug 2, 2024
260a17b
Merge branch 'master' into imdm/datamodel-writes
andy31415 Aug 2, 2024
6060937
Fix java builds
andy31415 Aug 2, 2024
567f658
Merge branch 'master' into imdm/datamodel-writes
andreilitvin Aug 6, 2024
0078f8d
Update src/app/InteractionModelEngine.cpp
andy31415 Aug 6, 2024
6998926
Make codegen data model call increasing the cluster data version
andreilitvin Aug 6, 2024
7788ad0
Restyle
andreilitvin Aug 6, 2024
9aeda71
Make sure that attribute changed information can be propagated out of…
andreilitvin Aug 6, 2024
d62dcc4
Optimize storage size of WriteHandler
andreilitvin Aug 6, 2024
921ed4c
Restyle
andreilitvin Aug 6, 2024
9606193
Make the code more obvious identical with what was there before
andreilitvin Aug 6, 2024
b4cd45c
Change Provider to not double-call the dirty and version increase
andy31415 Aug 6, 2024
df9f693
Update src/app/InteractionModelEngine.cpp
andy31415 Aug 8, 2024
81d9ca5
Cleaner usage: no need of a separate function that is used in one pla…
andreilitvin Sep 6, 2024
cbaba74
Attempt an API update
andreilitvin Sep 6, 2024
1182190
Fix typos in the Accessors src
andreilitvin Sep 6, 2024
011c793
Fix typo and regen
andreilitvin Sep 6, 2024
6470841
More fixes on accessors
andreilitvin Sep 6, 2024
9b0337c
Update signature for emAfWriteAttributeExternal
andreilitvin Sep 6, 2024
e4bece9
Add a comment about all the checks being vague
andreilitvin Sep 6, 2024
afc0b3f
Merge branch 'master' into ember_cluster_version_increase_decouple
andreilitvin Sep 6, 2024
322edf9
Update src/app/util/af-types.h
andy31415 Sep 9, 2024
4f0aed4
Update src/app/util/af-types.h
andy31415 Sep 9, 2024
71758d0
Update src/app/util/attribute-storage.cpp
andy31415 Sep 9, 2024
b83f33e
Update src/app/zap-templates/templates/app/attributes/Accessors-src.zapt
andy31415 Sep 9, 2024
b46930b
Update src/app/util/mock/CodegenEmberMocks.cpp
andy31415 Sep 9, 2024
24ecf40
Update src/app/zap-templates/templates/app/attributes/Accessors-src.zapt
andy31415 Sep 9, 2024
116e220
Update src/app/zap-templates/templates/app/attributes/Accessors-src.zapt
andy31415 Sep 9, 2024
65018ad
zap regen and restyle
andy31415 Sep 9, 2024
8407b63
Update src/app/zap-templates/templates/app/attributes/Accessors-src.zapt
andy31415 Sep 9, 2024
5397a81
Update src/app/util/attribute-table.cpp
andy31415 Sep 9, 2024
c6a843a
Update src/app/util/attribute-storage.cpp
andy31415 Sep 9, 2024
36a7a9e
Update src/app/util/attribute-storage.cpp
andy31415 Sep 9, 2024
fb03193
Update src/app/util/attribute-table.cpp
andy31415 Sep 9, 2024
21053a5
Update src/app/util/attribute-table.cpp
andy31415 Sep 9, 2024
5a841a2
Update src/app/util/attribute-storage.cpp
andy31415 Sep 9, 2024
25184e6
Update src/app/util/attribute-table.h
andy31415 Sep 9, 2024
0a64bf5
Rename ChangedPathListener to AttributesChangedListener
andy31415 Sep 9, 2024
acc5890
Remove chip:: and chip::app
andy31415 Sep 9, 2024
fbd1f13
Update constructors of AttributePathParams and add nodiscard accordin…
andy31415 Sep 9, 2024
5b1404f
Restyled by clang-format
restyled-commits Sep 9, 2024
b2b7353
Remove auto-inserted include
andy31415 Sep 9, 2024
39e9015
Update again and zap regen: removed extra namespace prefixes in acces…
andy31415 Sep 9, 2024
f448211
Add comment about uint8_t non-const usage...
andy31415 Sep 9, 2024
bb00408
Another rename given that the listener is now an attributes and not a…
andy31415 Sep 9, 2024
3ebc3be
Merge branch 'master' into ember_cluster_version_increase_decouple
andy31415 Sep 9, 2024
228f0fb
Merge branch 'ember_cluster_version_increase_decouple' into imdm/data…
andy31415 Sep 9, 2024
c2e80c2
Update src/app/util/attribute-table.h
andy31415 Sep 9, 2024
54312b3
Update after merge to have more things compile
andy31415 Sep 9, 2024
a124f5c
Everything compiles now
andy31415 Sep 9, 2024
9014d34
Restyle
andy31415 Sep 9, 2024
3ec8c51
Make unit tests pass: mocks also have to call the change listeners
andy31415 Sep 9, 2024
dc58006
Merge branch 'imdm/datamodel-writes' of github.com:andy31415/connecte…
andy31415 Sep 9, 2024
e87d063
Comment update to talk more about AttributesChangedListener
andy31415 Sep 9, 2024
574edce
Merge branch 'ember_cluster_version_increase_decouple' of github.com:…
andy31415 Sep 9, 2024
6969378
Restyle
andy31415 Sep 9, 2024
7890cc5
Merge branch 'ember_cluster_version_increase_decouple' into imdm/data…
andy31415 Sep 9, 2024
e4aee5e
Merge branch 'master' into ember_cluster_version_increase_decouple
andy31415 Sep 10, 2024
8cdb2f8
Merge branch 'ember_cluster_version_increase_decouple' into imdm/data…
andy31415 Sep 10, 2024
25286e8
Add support for a previous path write ... this is similar to what ACL…
andreilitvin Sep 10, 2024
3af3f70
Remove some extra added includes
andreilitvin Sep 10, 2024
b527233
Another include fix
andreilitvin Sep 10, 2024
3d4ee0a
Follow the comment and do not restrict the cache to ACL cluster, sinc…
andreilitvin Sep 10, 2024
5d1424d
More self code review changes
andreilitvin Sep 10, 2024
de5f4ff
Make tests pass, more code cleanup
andreilitvin Sep 10, 2024
6e73f47
Match ordering to ember-compatibility functions. This is ODD because …
andreilitvin Sep 10, 2024
4ed1703
Adjust test ordering and add a large note that we are probably doing …
andreilitvin Sep 10, 2024
5f900a7
Fix unit test
andreilitvin Sep 10, 2024
9ea2469
Merge branch 'master' into imdm/datamodel-writes
andy31415 Sep 11, 2024
bba9db8
Remove odd comment
andy31415 Sep 13, 2024
b170f1a
Add a few ending endifs
andy31415 Sep 13, 2024
096bae4
Renamed ScopedExchangeContext
andy31415 Sep 13, 2024
cfbaf2e
Update src/app/InteractionModelEngine.h
andy31415 Sep 16, 2024
98013f9
Update src/app/WriteHandler.h
andy31415 Sep 16, 2024
6d6a822
Update src/app/WriteHandler.h
andy31415 Sep 16, 2024
37e3d92
Update src/app/data-model-provider/OperationTypes.h
andy31415 Sep 16, 2024
5e6b47c
Update src/app/data-model-provider/OperationTypes.h
andy31415 Sep 16, 2024
bf754e7
Update src/app/data-model-provider/OperationTypes.h
andy31415 Sep 16, 2024
029f628
Update src/app/codegen-data-model-provider/CodegenDataModelProvider_W…
andy31415 Sep 16, 2024
da0df8d
Merge branch 'master' into imdm/datamodel-writes
andy31415 Sep 16, 2024
dda3881
Restyle to reorder includes
andy31415 Sep 16, 2024
a61e9a5
Add issue link
andy31415 Sep 16, 2024
15b7ee0
Update equality logic
andy31415 Sep 16, 2024
1be9fad
Rename member to mLastSuccessfullyWrittenPath
andy31415 Sep 16, 2024
5cb8128
Update argument logic
andy31415 Sep 16, 2024
646c2a9
Make ActionContext private in IME so it is not such a public API
andy31415 Sep 16, 2024
92254ba
Clean up comments
andy31415 Sep 16, 2024
0b794c4
fix up compares
andreilitvin Sep 17, 2024
3229704
Restyle
andreilitvin Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/AttributeValueDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class AttributeValueDecoder
const Access::SubjectDescriptor & GetSubjectDescriptor() const { return mSubjectDescriptor; }

private:
friend class TestOnlyAttributeValueDecoderAccessor;

TLV::TLVReader & mReader;
bool mTriedDecode = false;
const Access::SubjectDescriptor mSubjectDescriptor;
Expand Down
7 changes: 7 additions & 0 deletions src/app/EventManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,12 @@ void EventManagement::SetScheduledEventInfo(EventNumber & aEventNumber, uint32_t
aInitialWrittenEventBytes = mBytesWritten;
}

CHIP_ERROR EventManagement::GenerateEvent(EventLoggingDelegate * eventPayloadWriter, const EventOptions & options,
EventNumber & generatedEventNumber)
{
return LogEvent(eventPayloadWriter, options, generatedEventNumber);
}

void CircularEventBuffer::Init(uint8_t * apBuffer, uint32_t aBufferLength, CircularEventBuffer * apPrev,
CircularEventBuffer * apNext, PriorityLevel aPriorityLevel)
{
Expand Down Expand Up @@ -914,5 +920,6 @@ CHIP_ERROR CircularEventBufferWrapper::GetNextBuffer(TLVReader & aReader, const
exit:
return err;
}

} // namespace app
} // namespace chip
8 changes: 7 additions & 1 deletion src/app/EventManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <app/EventLoggingTypes.h>
#include <app/MessageDef/EventDataIB.h>
#include <app/MessageDef/StatusIB.h>
#include <app/data-model-provider/EventsGenerator.h>
#include <app/util/basic-types.h>
#include <lib/core/TLVCircularBuffer.h>
#include <lib/support/CHIPCounter.h>
Expand Down Expand Up @@ -196,7 +197,7 @@ struct LogStorageResources
* more space for new events.
*/

class EventManagement
class EventManagement : public DataModel::EventsGenerator
{
public:
/**
Expand Down Expand Up @@ -387,6 +388,10 @@ class EventManagement
*/
void SetScheduledEventInfo(EventNumber & aEventNumber, uint32_t & aInitialWrittenEventBytes) const;

/* EventsGenerator implementation */
CHIP_ERROR GenerateEvent(EventLoggingDelegate * eventPayloadWriter, const EventOptions & options,
EventNumber & generatedEventNumber) override;

private:
/**
* @brief
Expand Down Expand Up @@ -559,5 +564,6 @@ class EventManagement

System::Clock::Milliseconds64 mMonotonicStartupTime;
};

} // namespace app
} // namespace chip
43 changes: 37 additions & 6 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ Protocols::InteractionModel::Status InteractionModelEngine::OnWriteRequest(Messa
{
if (writeHandler.IsFree())
{
VerifyOrReturnError(writeHandler.Init(this) == CHIP_NO_ERROR, Status::Busy);
VerifyOrReturnError(writeHandler.Init(GetDataModelProvider(), this) == CHIP_NO_ERROR, Status::Busy);
return writeHandler.OnWriteRequest(apExchangeContext, std::move(aPayload), aIsTimedWrite);
}
}
Expand Down Expand Up @@ -992,6 +992,9 @@ CHIP_ERROR InteractionModelEngine::OnMessageReceived(Messaging::ExchangeContext

Protocols::InteractionModel::Status status = Status::Failure;

// Ensure that DataModel::Provider has access to the exchange the message was received on.
CurrentExchangeValueScope scopedExchangeContext(*this, apExchangeContext);

// Group Message can only be an InvokeCommandRequest or WriteRequest
if (apExchangeContext->IsGroupExchangeContext() &&
!aPayloadHeader.HasMessageType(Protocols::InteractionModel::MsgType::InvokeCommandRequest) &&
Expand Down Expand Up @@ -1729,16 +1732,44 @@ DataModel::Provider * InteractionModelEngine::SetDataModelProvider(DataModel::Pr
// Alternting data model should not be done while IM is actively handling requests.
VerifyOrDie(mReadHandlers.begin() == mReadHandlers.end());

DataModel::Provider * oldModel = GetDataModelProvider();
mDataModelProvider = model;
DataModel::Provider * oldModel = mDataModelProvider;
if (oldModel != nullptr)
{
CHIP_ERROR err = oldModel->Shutdown();
if (err != CHIP_NO_ERROR)
{
ChipLogError(InteractionModel, "Failure on interaction model shutdown: %" CHIP_ERROR_FORMAT, err.Format());
}
}

mDataModelProvider = model;
if (mDataModelProvider != nullptr)
{
DataModel::InteractionModelContext context;

context.eventsGenerator = &EventManagement::GetInstance();
context.dataModelChangeListener = &mReportingEngine;
context.actionContext = this;

CHIP_ERROR err = mDataModelProvider->Startup(context);
if (err != CHIP_NO_ERROR)
{
ChipLogError(InteractionModel, "Failure on interaction model startup: %" CHIP_ERROR_FORMAT, err.Format());
}
}

return oldModel;
}

DataModel::Provider * InteractionModelEngine::GetDataModelProvider() const
DataModel::Provider * InteractionModelEngine::GetDataModelProvider()
{
#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
// TODO: this should be temporary, we should fully inject the data model
VerifyOrReturnValue(mDataModelProvider != nullptr, CodegenDataModelProviderInstance());
if (mDataModelProvider == nullptr)
{
// These should be called within the CHIP processing loop.
assertChipStackLockedByCurrentThread();
SetDataModelProvider(CodegenDataModelProviderInstance());
}
#endif
return mDataModelProvider;
}
Expand Down
27 changes: 25 additions & 2 deletions src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ namespace app {
*/
class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
public Messaging::ExchangeDelegate,
private DataModel::ActionContext,
public CommandResponseSender::Callback,
public CommandHandlerImpl::Callback,
public ReadHandler::ManagementCallback,
Expand Down Expand Up @@ -402,7 +403,10 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
}
#endif

DataModel::Provider * GetDataModelProvider() const;
// Temporarily NOT const because the data model provider will be auto-set
// to codegen on first usage. This behaviour will be changed once each
// application must explicitly set the data model provider.
DataModel::Provider * GetDataModelProvider();
andy31415 marked this conversation as resolved.
Show resolved Hide resolved

// MUST NOT be used while the interaction model engine is running as interaction
// model functionality (e.g. active reads/writes/subscriptions) rely on data model
Expand All @@ -412,6 +416,9 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
DataModel::Provider * SetDataModelProvider(DataModel::Provider * model);

private:
/* DataModel::ActionContext implementation */
Messaging::ExchangeContext * CurrentExchange() override { return mCurrentExchange; }
andy31415 marked this conversation as resolved.
Show resolved Hide resolved

friend class reporting::Engine;
friend class TestCommandInteraction;
friend class TestInteractionModelEngine;
Expand Down Expand Up @@ -698,7 +705,23 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,

SubscriptionResumptionStorage * mpSubscriptionResumptionStorage = nullptr;

DataModel::Provider * mDataModelProvider = nullptr;
DataModel::Provider * mDataModelProvider = nullptr;
Messaging::ExchangeContext * mCurrentExchange = nullptr;

// Changes the current exchange context of a InteractionModelEngine to a given context
bzbarsky-apple marked this conversation as resolved.
Show resolved Hide resolved
class CurrentExchangeValueScope
{
public:
CurrentExchangeValueScope(InteractionModelEngine & engine, Messaging::ExchangeContext * context) : mEngine(engine)
{
mEngine.mCurrentExchange = context;
}

~CurrentExchangeValueScope() { mEngine.mCurrentExchange = nullptr; }

private:
InteractionModelEngine & mEngine;
};
};

} // namespace app
Expand Down
52 changes: 48 additions & 4 deletions src/app/WriteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,40 @@

#include <app/AppConfig.h>
#include <app/AttributeAccessInterfaceRegistry.h>
#include <app/AttributeValueDecoder.h>
#include <app/InteractionModelEngine.h>
#include <app/MessageDef/EventPathIB.h>
#include <app/MessageDef/StatusIB.h>
#include <app/StatusResponse.h>
#include <app/WriteHandler.h>
#include <app/data-model-provider/OperationTypes.h>
#include <app/reporting/Engine.h>
#include <app/util/MatterCallbacks.h>
#include <app/util/ember-compatibility-functions.h>
#include <credentials/GroupDataProvider.h>
#include <lib/core/CHIPError.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/TypeTraits.h>
#include <messaging/ExchangeContext.h>
#include <protocols/interaction_model/StatusCode.h>

#include <optional>

namespace chip {
namespace app {

using namespace Protocols::InteractionModel;
using Status = Protocols::InteractionModel::Status;
constexpr uint8_t kListAttributeType = 0x48;

CHIP_ERROR WriteHandler::Init(WriteHandlerDelegate * apWriteHandlerDelegate)
CHIP_ERROR WriteHandler::Init(DataModel::Provider * apProvider, WriteHandlerDelegate * apWriteHandlerDelegate)
{
VerifyOrReturnError(!mExchangeCtx, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(apWriteHandlerDelegate, CHIP_ERROR_INVALID_ARGUMENT);
#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
VerifyOrReturnError(apProvider, CHIP_ERROR_INVALID_ARGUMENT);
mDataModelProvider = apProvider;
#endif // CHIP_CONFIG_USE_DATA_MODEL_INTERFACE

mDelegate = apWriteHandlerDelegate;
MoveToState(State::Initialized);
Expand All @@ -63,6 +73,9 @@ void WriteHandler::Close()
DeliverFinalListWriteEnd(false /* wasSuccessful */);
mExchangeCtx.Release();
mStateFlags.Clear(StateBits::kSuppressResponse);
#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
mDataModelProvider = nullptr;
#endif // CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
MoveToState(State::Uninitialized);
}

Expand Down Expand Up @@ -354,7 +367,7 @@ CHIP_ERROR WriteHandler::ProcessAttributeDataIBs(TLV::TLVReader & aAttributeData
err = CHIP_NO_ERROR;
}
SuccessOrExit(err);
err = WriteSingleClusterData(subjectDescriptor, dataAttributePath, dataReader, this);
err = WriteClusterData(subjectDescriptor, dataAttributePath, dataReader);
if (err != CHIP_NO_ERROR)
{
mWriteResponseBuilder.GetWriteResponses().Rollback(backup);
Expand Down Expand Up @@ -501,7 +514,7 @@ CHIP_ERROR WriteHandler::ProcessGroupAttributeDataIBs(TLV::TLVReader & aAttribut

DataModelCallbacks::GetInstance()->AttributeOperation(DataModelCallbacks::OperationType::Write,
DataModelCallbacks::OperationOrder::Pre, dataAttributePath);
err = WriteSingleClusterData(subjectDescriptor, dataAttributePath, tmpDataReader, this);
err = WriteClusterData(subjectDescriptor, dataAttributePath, tmpDataReader);
if (err != CHIP_NO_ERROR)
{
ChipLogError(DataManagement,
Expand Down Expand Up @@ -552,14 +565,18 @@ Status WriteHandler::ProcessWriteRequest(System::PacketBufferHandle && aPayload,
// our callees hand out Status as well.
Status status = Status::InvalidAction;

#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
mLastSuccessfullyWrittenPath = std::nullopt;
#endif // CHIP_CONFIG_USE_DATA_MODEL_INTERFACE

reader.Init(std::move(aPayload));

err = writeRequestParser.Init(reader);
SuccessOrExit(err);

#if CHIP_CONFIG_IM_PRETTY_PRINT
writeRequestParser.PrettyPrint();
#endif
#endif // CHIP_CONFIG_IM_PRETTY_PRINT
bool boolValue;

boolValue = mStateFlags.Has(StateBits::kSuppressResponse);
Expand Down Expand Up @@ -703,5 +720,32 @@ void WriteHandler::MoveToState(const State aTargetState)
ChipLogDetail(DataManagement, "IM WH moving to [%s]", GetStateStr());
}

CHIP_ERROR WriteHandler::WriteClusterData(const Access::SubjectDescriptor & aSubject, const ConcreteDataAttributePath & aPath,
TLV::TLVReader & aData)
{
// Writes do not have a checked-path. If data model interface is enabled (both checked and only version)
// the write is done via the DataModel interface
#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
VerifyOrReturnError(mDataModelProvider != nullptr, CHIP_ERROR_INCORRECT_STATE);

DataModel::WriteAttributeRequest request;

request.path = aPath;
request.subjectDescriptor = aSubject;
request.previousSuccessPath = mLastSuccessfullyWrittenPath;
request.writeFlags.Set(DataModel::WriteFlags::kTimed, IsTimedWrite());

AttributeValueDecoder decoder(aData, aSubject);

DataModel::ActionReturnStatus status = mDataModelProvider->WriteAttribute(request, decoder);

mLastSuccessfullyWrittenPath = status.IsSuccess() ? std::make_optional(aPath) : std::nullopt;

return AddStatusInternal(aPath, StatusIB(status.GetStatusCode()));
#else
return WriteSingleClusterData(aSubject, aPath, aData, this);
#endif // CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
}

} // namespace app
} // namespace chip
14 changes: 13 additions & 1 deletion src/app/WriteHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
#include <app/AppConfig.h>
#include <app/AttributeAccessToken.h>
#include <app/AttributePathParams.h>
#include <app/ConcreteAttributePath.h>
#include <app/InteractionModelDelegatePointers.h>
#include <app/MessageDef/WriteResponseMessage.h>
#include <app/data-model-provider/Provider.h>
#include <lib/core/CHIPCore.h>
#include <lib/core/TLVDebug.h>
#include <lib/support/BitFlags.h>
Expand Down Expand Up @@ -69,6 +71,7 @@ class WriteHandler : public Messaging::ExchangeDelegate
* construction until a call to Close is made to terminate the
* instance.
*
* @param[in] apProvider A valid pointer to the model used to forward writes towards
* @param[in] apWriteHandlerDelegate A Valid pointer to the WriteHandlerDelegate.
*
* @retval #CHIP_ERROR_INVALID_ARGUMENT on invalid pointers
Expand All @@ -77,7 +80,7 @@ class WriteHandler : public Messaging::ExchangeDelegate
* @retval #CHIP_NO_ERROR On success.
*
*/
CHIP_ERROR Init(WriteHandlerDelegate * apWriteHandlerDelegate);
CHIP_ERROR Init(DataModel::Provider * apProvider, WriteHandlerDelegate * apWriteHandlerDelegate);

/**
* Process a write request. Parts of the processing may end up being asynchronous, but the WriteHandler
Expand Down Expand Up @@ -182,11 +185,20 @@ class WriteHandler : public Messaging::ExchangeDelegate
System::PacketBufferHandle && aPayload) override;
void OnResponseTimeout(Messaging::ExchangeContext * apExchangeContext) override;

// Write the given data to the given path
CHIP_ERROR WriteClusterData(const Access::SubjectDescriptor & aSubject, const ConcreteDataAttributePath & aPath,
TLV::TLVReader & aData);

Messaging::ExchangeHolder mExchangeCtx;
WriteResponseMessage::Builder mWriteResponseBuilder;
Optional<ConcreteAttributePath> mProcessingAttributePath;
Optional<AttributeAccessToken> mACLCheckCache = NullOptional;

#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
DataModel::Provider * mDataModelProvider = nullptr;
bzbarsky-apple marked this conversation as resolved.
Show resolved Hide resolved
std::optional<ConcreteAttributePath> mLastSuccessfullyWrittenPath;
#endif

// This may be a "fake" pointer or a real delegate pointer, depending
// on CHIP_CONFIG_STATIC_GLOBAL_INTERACTION_MODEL_ENGINE setting.
//
Expand Down
Loading
Loading