Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3830693

Browse files
jepenven-silabspull[bot]
authored andcommittedFeb 15, 2023
Enable Write Group msg test (#11933)
1 parent 8f90675 commit 3830693

File tree

8 files changed

+101
-17
lines changed

8 files changed

+101
-17
lines changed
 

‎src/app/AttributePathParams.h

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ struct AttributePathParams
4141
AttributePathParams(aEndpointId, aClusterId, aAttributeId, ClusterInfo::kInvalidListIndex)
4242
{}
4343

44+
AttributePathParams(ClusterId aClusterId, AttributeId aAttributeId) :
45+
AttributePathParams(kInvalidEndpointId, aClusterId, aAttributeId, ClusterInfo::kInvalidListIndex)
46+
{}
47+
4448
AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aAttributeId, ListIndex aListIndex) :
4549
mEndpointId(aEndpointId), mClusterId(aClusterId), mAttributeId(aAttributeId), mListIndex(aListIndex)
4650
{}
@@ -52,6 +56,7 @@ struct AttributePathParams
5256
bool HasWildcard() const { return HasWildcardEndpointId() || HasWildcardClusterId() || HasWildcardAttributeId(); }
5357

5458
/**
59+
* SPEC 8.9.2.2
5560
* Check that the path meets some basic constraints of an attribute path: If list index is not wildcard, then field id must not
5661
* be wildcard. This does not verify that the attribute being targeted is actually of list type when the list index is not
5762
* wildcard.

‎src/app/WriteClient.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,7 @@ TLV::TLVWriter * WriteClient::GetAttributeDataIBTLVWriter()
170170
CHIP_ERROR WriteClient::ConstructAttributePath(const AttributePathParams & aAttributePathParams,
171171
AttributeDataIB::Builder aAttributeDataIB)
172172
{
173-
// We do not support wildcard write now, reject them on client side.
174-
VerifyOrReturnError(!aAttributePathParams.HasWildcard() && aAttributePathParams.IsValidAttributePath(),
175-
CHIP_ERROR_INVALID_PATH_LIST);
173+
VerifyOrReturnError(aAttributePathParams.IsValidAttributePath(), CHIP_ERROR_INVALID_PATH_LIST);
176174
return aAttributePathParams.BuildAttributePath(aAttributeDataIB.CreatePath());
177175
}
178176

@@ -258,13 +256,15 @@ CHIP_ERROR WriteClient::SendWriteRequest(SessionHandle session, System::Clock::T
258256
exit:
259257
if (err != CHIP_NO_ERROR)
260258
{
259+
ChipLogError(DataManagement, "Write client failed to SendWriteRequest");
261260
ClearExistingExchangeContext();
262261
}
263262

264263
if (session.IsGroupSession())
265264
{
266265
// Always shutdown on Group communication
267-
Shutdown();
266+
ChipLogDetail(DataManagement, "Closing on group Communication ");
267+
ShutdownInternal();
268268
}
269269

270270
return err;

‎src/app/tests/suites/TestGroupMessaging.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ tests:
2626
- label: "Group Write Attribute"
2727
command: "writeAttribute"
2828
attribute: "location"
29-
disabled: true
3029
groupId: "1234"
3130
arguments:
3231
value: "us"

‎src/controller/WriteInteraction.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,26 @@ CHIP_ERROR WriteAttribute(SessionHandle sessionHandle, chip::EndpointId endpoint
9999
ReturnErrorOnFailure(app::InteractionModelEngine::GetInstance()->NewWriteClient(handle, callback.get()));
100100
if (sessionHandle.IsGroupSession())
101101
{
102-
// TODO : Issue #11604
103-
return CHIP_ERROR_NOT_IMPLEMENTED;
104-
// ReturnErrorOnFailure(
105-
// handle.EncodeAttributeWritePayload(chip::app::AttributePathParams(clusterId, attributeId), requestData));
102+
ReturnErrorOnFailure(
103+
handle.EncodeAttributeWritePayload(chip::app::AttributePathParams(clusterId, attributeId), requestData));
106104
}
107105
else
108106
{
109107
ReturnErrorOnFailure(
110108
handle.EncodeAttributeWritePayload(chip::app::AttributePathParams(endpointId, clusterId, attributeId), requestData));
111109
}
110+
112111
ReturnErrorOnFailure(handle.SendWriteRequest(sessionHandle));
113112

114113
callback.release();
114+
115+
if (sessionHandle.IsGroupSession())
116+
{
117+
// Manually call success callback since OnReponse won't be called in WriteClient for group
118+
app::ConcreteAttributePath aPath;
119+
onSuccessCb(aPath);
120+
}
121+
115122
return CHIP_NO_ERROR;
116123
}
117124

‎src/darwin/Framework/CHIPTests/CHIPClustersTests.m

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/transport/SessionHandle.h

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class SessionHandle
7575

7676
NodeId GetPeerNodeId() const { return mPeerNodeId; }
7777
bool IsGroupSession() const { return mGroupId.HasValue(); }
78+
const Optional<GroupId> & GetGroupId() const { return mGroupId; }
7879
const Optional<uint16_t> & GetPeerSessionId() const { return mPeerSessionId; }
7980
const Optional<uint16_t> & GetLocalSessionId() const { return mLocalSessionId; }
8081

‎src/transport/SessionManager.cpp

+28-7
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,39 @@ CHIP_ERROR SessionManager::PrepareMessage(SessionHandle sessionHandle, PayloadHe
117117
#endif // CHIP_PROGRESS_LOGGING
118118
if (sessionHandle.IsSecure())
119119
{
120-
SecureSession * session = GetSecureSession(sessionHandle);
121-
if (session == nullptr)
120+
if (sessionHandle.IsGroupSession())
122121
{
123-
return CHIP_ERROR_NOT_CONNECTED;
124-
}
122+
// TODO : #11911
123+
// For now, just set the packetHeader with the correct data.
124+
packetHeader.SetDestinationGroupId(sessionHandle.GetGroupId());
125+
packetHeader.SetFlags(Header::SecFlagValues::kPrivacyFlag);
126+
packetHeader.SetSessionType(Header::SessionType::kGroupSession);
127+
// TODO : Replace the PeerNodeId with Our nodeId
128+
packetHeader.SetSourceNodeId(sessionHandle.GetPeerNodeId());
129+
130+
if (!packetHeader.IsValidGroupMsg())
131+
{
132+
return CHIP_ERROR_INTERNAL;
133+
}
125134

126-
MessageCounter & counter = GetSendCounterForPacket(payloadHeader, *session);
127-
ReturnErrorOnFailure(SecureMessageCodec::Encrypt(session, payloadHeader, packetHeader, message, counter));
135+
#if CHIP_PROGRESS_LOGGING
136+
destination = sessionHandle.GetPeerNodeId();
137+
#endif // CHIP_PROGRESS_LOGGING
138+
}
139+
else
140+
{
141+
SecureSession * session = GetSecureSession(sessionHandle);
142+
if (session == nullptr)
143+
{
144+
return CHIP_ERROR_NOT_CONNECTED;
145+
}
146+
MessageCounter & counter = GetSendCounterForPacket(payloadHeader, *session);
147+
ReturnErrorOnFailure(SecureMessageCodec::Encrypt(session, payloadHeader, packetHeader, message, counter));
128148

129149
#if CHIP_PROGRESS_LOGGING
130-
destination = session->GetPeerNodeId();
150+
destination = session->GetPeerNodeId();
131151
#endif // CHIP_PROGRESS_LOGGING
152+
}
132153
}
133154
else
134155
{

‎zzz_generated/chip-tool/zap-generated/test/Commands.h

+29-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.