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

Remove now-unused old-style subscribe/report functionality. #13041

Merged
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
1 change: 0 additions & 1 deletion examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ executable("chip-tool") {
"commands/pairing/PairingCommand.cpp",
"commands/payload/AdditionalDataParseCommand.cpp",
"commands/payload/SetupPayloadParseCommand.cpp",
"commands/reporting/ReportingCommand.cpp",
"commands/tests/TestCommand.cpp",
"config/PersistentStorage.cpp",
"main.cpp",
Expand Down
65 changes: 0 additions & 65 deletions examples/chip-tool/commands/reporting/ReportingCommand.cpp

This file was deleted.

50 changes: 0 additions & 50 deletions examples/chip-tool/commands/reporting/ReportingCommand.h

This file was deleted.

2 changes: 0 additions & 2 deletions examples/chip-tool/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "commands/payload/Commands.h"

#include <zap-generated/cluster/Commands.h>
#include <zap-generated/reporting/Commands.h>
#include <zap-generated/test/Commands.h>

// ================================================================================
Expand All @@ -35,7 +34,6 @@ int main(int argc, char * argv[])
registerCommandsDiscover(commands);
registerCommandsPayload(commands);
registerCommandsPairing(commands);
registerCommandsReporting(commands);
registerCommandsTests(commands);
registerClusters(commands);

Expand Down
71 changes: 0 additions & 71 deletions examples/chip-tool/templates/reporting-commands.zapt

This file was deleted.

5 changes: 0 additions & 5 deletions examples/chip-tool/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@
"name": "Cluster Commands header",
"output": "cluster/Commands.h"
},
{
"path": "reporting-commands.zapt",
"name": "Reporting Commands header",
"output": "reporting/Commands.h"
},
{
"path": "tests-commands.zapt",
"name": "Tests Commands header",
Expand Down
84 changes: 2 additions & 82 deletions src/app/DeviceControllerInteractionModelDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ namespace Controller {
*
* TODO:(#8967) Implementation of CommandSender::Callback should be removed after switching to ClusterObjects.
*/
class DeviceControllerInteractionModelDelegate : public chip::app::ReadClient::Callback,
public chip::app::CommandSender::Callback,
class DeviceControllerInteractionModelDelegate : public chip::app::CommandSender::Callback,
public chip::app::WriteClient::Callback,
public chip::app::InteractionModelDelegate
{
public:
DeviceControllerInteractionModelDelegate() : mBufferedReadAdapter(*this) {}

app::BufferedReadCallback & GetBufferedCallback() { return mBufferedReadAdapter; }
DeviceControllerInteractionModelDelegate() {}

void OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aPath,
const chip::app::StatusIB & aStatus, TLV::TLVReader * aData) override
Expand Down Expand Up @@ -72,83 +69,6 @@ class DeviceControllerInteractionModelDelegate : public chip::app::ReadClient::C
}

void OnDone(app::WriteClient * apWriteClient) override {}

void OnEventData(const app::ReadClient * apReadClient, const app::EventHeader & aEventHeader, TLV::TLVReader * apData,
const app::StatusIB * apStatus) override
{}

void OnAttributeData(const app::ReadClient * apReadClient, const app::ConcreteDataAttributePath & aPath,
TLV::TLVReader * apData, const app::StatusIB & aStatus) override
{
//
// We shouldn't be getting list item operations in the provided path since that should be handled by the buffered read
// callback. If we do, that's a bug.
//
VerifyOrDie(!aPath.IsListItemOperation());

IMReadReportAttributesResponseCallback(apReadClient, &aPath, apData, aStatus.mStatus);
}

void OnSubscriptionEstablished(const app::ReadClient * apReadClient) override
{
IMSubscribeResponseCallback(apReadClient, EMBER_ZCL_STATUS_SUCCESS);
}

void OnError(const app::ReadClient * apReadClient, CHIP_ERROR aError) override
{
app::ClusterInfo path;
path.mNodeId = apReadClient->GetPeerNodeId();
IMReadReportAttributesResponseCallback(apReadClient, nullptr, nullptr, Protocols::InteractionModel::Status::Failure);
}

void OnDone(app::ReadClient * apReadClient) override
{
if (apReadClient->IsSubscriptionType())
{
this->FreeAttributePathParam(reinterpret_cast<uint64_t>(apReadClient));
}
}

// TODO: FreeAttributePathParam and AllocateAttributePathParam are used by CHIPDevice.cpp for getting a long-live attribute path
// object.
void FreeAttributePathParam(uint64_t applicationId)
{
for (auto & item : mAttributePathTransactionMapPool)
{
if (item.ApplicationId == applicationId)
{
item.ApplicationId = UINT64_MAX;
}
}
}

// TODO: We only support allocating one path, should support multiple path later.
app::AttributePathParams * AllocateAttributePathParam(size_t n, uint64_t applicationId)
{
if (n > 1)
{
return nullptr;
}
for (auto & item : mAttributePathTransactionMapPool)
{
if (item.ApplicationId == UINT64_MAX)
{
item.ApplicationId = applicationId;
return &item.Params;
}
}
return nullptr;
}

private:
struct AttributePathTransactionMap
{
uint64_t ApplicationId = UINT64_MAX;
app::AttributePathParams Params;
};

app::BufferedReadCallback mBufferedReadAdapter;
AttributePathTransactionMap mAttributePathTransactionMapPool[CHIP_DEVICE_CONTROLLER_SUBSCRIPTION_ATTRIBUTE_PATH_POOL_SIZE];
};

} // namespace Controller
Expand Down
49 changes: 0 additions & 49 deletions src/app/DeviceProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,55 +68,6 @@ void DeviceProxy::CancelIMResponseHandler(void * commandObj)
mCallbacksMgr.CancelResponseCallback(transactionId, 0 /* seqNum, always 0 for IM before #6559 */);
}

void DeviceProxy::AddReportHandler(EndpointId endpoint, ClusterId cluster, AttributeId attribute,
Callback::Cancelable * onReportCallback, app::TLVDataFilter tlvDataFilter)
{
mCallbacksMgr.AddReportCallback(GetDeviceId(), endpoint, cluster, attribute, onReportCallback, tlvDataFilter);
}

CHIP_ERROR DeviceProxy::SendSubscribeAttributeRequest(app::AttributePathParams aPath, uint16_t mMinIntervalFloorSeconds,
uint16_t mMaxIntervalCeilingSeconds, Callback::Cancelable * onSuccessCallback,
Callback::Cancelable * onFailureCallback)
{
VerifyOrReturnLogError(IsSecureConnected(), CHIP_ERROR_INCORRECT_STATE);

uint8_t seqNum = GetNextSequenceNumber();

app::AttributePathParams * path = GetInteractionModelDelegate()->AllocateAttributePathParam(1, seqNum);

VerifyOrReturnError(path != nullptr, CHIP_ERROR_NO_MEMORY);

*path = aPath;

app::ReadClient * readClient = nullptr;
ReturnErrorOnFailure(chip::app::InteractionModelEngine::GetInstance()->NewReadClient(
&readClient, app::ReadClient::InteractionType::Subscribe, &GetInteractionModelDelegate()->GetBufferedCallback()));

// The application context is used to identify different requests from client application the type of it is intptr_t, here we
// use the seqNum.
VerifyOrReturnError(GetSecureSession().HasValue(), CHIP_ERROR_INCORRECT_STATE);
app::ReadPrepareParams params(GetSecureSession().Value());
params.mpAttributePathParamsList = path;
params.mAttributePathParamsListSize = 1;
params.mMinIntervalFloorSeconds = mMinIntervalFloorSeconds;
params.mMaxIntervalCeilingSeconds = mMaxIntervalCeilingSeconds;
params.mKeepSubscriptions = false;

CHIP_ERROR err = readClient->SendRequest(params);
if (err != CHIP_NO_ERROR)
{
GetInteractionModelDelegate()->FreeAttributePathParam(reinterpret_cast<uint64_t>(readClient));
readClient->Shutdown();
return err;
}

if (onSuccessCallback != nullptr || onFailureCallback != nullptr)
{
AddIMResponseHandler(readClient, onSuccessCallback, onFailureCallback);
}
return CHIP_NO_ERROR;
}

CHIP_ERROR DeviceProxy::SendWriteAttributeRequest(app::WriteClientHandle aHandle, Callback::Cancelable * onSuccessCallback,
Callback::Cancelable * onFailureCallback)
{
Expand Down
Loading