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

[Group] Enable Write Group msg test case #11933

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions src/app/AttributePathParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ struct AttributePathParams
AttributePathParams(aEndpointId, aClusterId, aAttributeId, ClusterInfo::kInvalidListIndex)
{}

AttributePathParams(ClusterId aClusterId, AttributeId aAttributeId) :
AttributePathParams(kInvalidEndpointId, aClusterId, aAttributeId, ClusterInfo::kInvalidListIndex)
{}

AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aAttributeId, ListIndex aListIndex) :
mEndpointId(aEndpointId), mClusterId(aClusterId), mAttributeId(aAttributeId), mListIndex(aListIndex)
{}
Expand All @@ -52,6 +56,7 @@ struct AttributePathParams
bool HasWildcard() const { return HasWildcardEndpointId() || HasWildcardClusterId() || HasWildcardAttributeId(); }

/**
* SPEC 8.9.2.2
* Check that the path meets some basic constraints of an attribute path: If list index is not wildcard, then field id must not
* be wildcard. This does not verify that the attribute being targeted is actually of list type when the list index is not
* wildcard.
Expand Down
8 changes: 4 additions & 4 deletions src/app/WriteClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ TLV::TLVWriter * WriteClient::GetAttributeDataIBTLVWriter()
CHIP_ERROR WriteClient::ConstructAttributePath(const AttributePathParams & aAttributePathParams,
AttributeDataIB::Builder aAttributeDataIB)
{
// We do not support wildcard write now, reject them on client side.
VerifyOrReturnError(!aAttributePathParams.HasWildcard() && aAttributePathParams.IsValidAttributePath(),
CHIP_ERROR_INVALID_PATH_LIST);
VerifyOrReturnError(aAttributePathParams.IsValidAttributePath(), CHIP_ERROR_INVALID_PATH_LIST);
return aAttributePathParams.BuildAttributePath(aAttributeDataIB.CreatePath());
}

Expand Down Expand Up @@ -257,13 +255,15 @@ CHIP_ERROR WriteClient::SendWriteRequest(SessionHandle session, System::Clock::T
exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(DataManagement, "Write client failed to SendWriteRequest");
ClearExistingExchangeContext();
}

if (session.IsGroupSession())
{
// Always shutdown on Group communication
Shutdown();
ChipLogDetail(DataManagement, "Closing on group Communication ");
ShutdownInternal();
}

return err;
Expand Down
1 change: 0 additions & 1 deletion src/app/tests/suites/TestGroupMessaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ tests:
- label: "Group Write Attribute"
command: "writeAttribute"
attribute: "location"
disabled: true
groupId: "1234"
arguments:
value: "us"
Expand Down
15 changes: 11 additions & 4 deletions src/controller/WriteInteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,26 @@ CHIP_ERROR WriteAttribute(SessionHandle sessionHandle, chip::EndpointId endpoint
ReturnErrorOnFailure(app::InteractionModelEngine::GetInstance()->NewWriteClient(handle, callback.get()));
if (sessionHandle.IsGroupSession())
{
// TODO : Issue #11604
return CHIP_ERROR_NOT_IMPLEMENTED;
// ReturnErrorOnFailure(
// handle.EncodeAttributeWritePayload(chip::app::AttributePathParams(clusterId, attributeId), requestData));
ReturnErrorOnFailure(
handle.EncodeAttributeWritePayload(chip::app::AttributePathParams(clusterId, attributeId), requestData));
}
else
{
ReturnErrorOnFailure(
handle.EncodeAttributeWritePayload(chip::app::AttributePathParams(endpointId, clusterId, attributeId), requestData));
}

ReturnErrorOnFailure(handle.SendWriteRequest(sessionHandle));

callback.release();

if (sessionHandle.IsGroupSession())
{
// Manually call success callback since OnReponse won't be called in WriteClient for group
app::ConcreteAttributePath aPath;
onSuccessCb(aPath);
}

return CHIP_NO_ERROR;
}

Expand Down
23 changes: 23 additions & 0 deletions src/darwin/Framework/CHIPTests/CHIPClustersTests.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/transport/SessionHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class SessionHandle

NodeId GetPeerNodeId() const { return mPeerNodeId; }
bool IsGroupSession() const { return mGroupId.HasValue(); }
const Optional<GroupId> & GetGroupId() const { return mGroupId; }
const Optional<uint16_t> & GetPeerSessionId() const { return mPeerSessionId; }
const Optional<uint16_t> & GetLocalSessionId() const { return mLocalSessionId; }

Expand Down
35 changes: 28 additions & 7 deletions src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,39 @@ CHIP_ERROR SessionManager::PrepareMessage(SessionHandle sessionHandle, PayloadHe
#endif // CHIP_PROGRESS_LOGGING
if (sessionHandle.IsSecure())
{
SecureSession * session = GetSecureSession(sessionHandle);
if (session == nullptr)
if (sessionHandle.IsGroupSession())
{
return CHIP_ERROR_NOT_CONNECTED;
}
// TODO : #11911
// For now, just set the packetHeader with the correct data.
packetHeader.SetDestinationGroupId(sessionHandle.GetGroupId());
packetHeader.SetFlags(Header::SecFlagValues::kPrivacyFlag);
packetHeader.SetSessionType(Header::SessionType::kGroupSession);
// TODO : Replace the PeerNodeId with Our nodeId
packetHeader.SetSourceNodeId(sessionHandle.GetPeerNodeId());

if (!packetHeader.IsValidGroupMsg())
{
return CHIP_ERROR_INTERNAL;
}

MessageCounter & counter = GetSendCounterForPacket(payloadHeader, *session);
ReturnErrorOnFailure(SecureMessageCodec::Encrypt(session, payloadHeader, packetHeader, message, counter));
#if CHIP_PROGRESS_LOGGING
destination = sessionHandle.GetPeerNodeId();
#endif // CHIP_PROGRESS_LOGGING
}
else
{
SecureSession * session = GetSecureSession(sessionHandle);
if (session == nullptr)
{
return CHIP_ERROR_NOT_CONNECTED;
}
MessageCounter & counter = GetSendCounterForPacket(payloadHeader, *session);
ReturnErrorOnFailure(SecureMessageCodec::Encrypt(session, payloadHeader, packetHeader, message, counter));

#if CHIP_PROGRESS_LOGGING
destination = session->GetPeerNodeId();
destination = session->GetPeerNodeId();
#endif // CHIP_PROGRESS_LOGGING
}
}
else
{
Expand Down
30 changes: 29 additions & 1 deletion zzz_generated/chip-tool/zap-generated/test/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.