Skip to content

Commit da47564

Browse files
committed
Remove unused code and fix error when disable RPC
1 parent 2128dec commit da47564

File tree

5 files changed

+8
-72
lines changed

5 files changed

+8
-72
lines changed

examples/chef/common/chef-binding-handler.cpp

+5-59
Original file line numberDiff line numberDiff line change
@@ -327,59 +327,12 @@ void ChefBindingHandler::SwitchWorkerHandler(intptr_t context)
327327
BindingManager::GetInstance().NotifyBoundClusterChanged(data->EndpointId, data->ClusterId, static_cast<void *>(data));
328328
}
329329

330-
/*
331-
static void ChefBoundDeviceChangedHandler(const EmberBindingTableEntry & binding, chip::OperationalDeviceProxy * peer_device,
332-
void * context)
333-
{
334-
using namespace chip;
335-
using namespace chip::app;
336-
337-
if (binding.type == EMBER_MULTICAST_BINDING)
338-
{
339-
ChipLogError(NotSpecified, "Group binding is not supported now");
340-
return;
341-
}
342-
343-
printf("\033[41m %s, %d \033[0m \n", __func__, __LINE__);
344-
345-
if (binding.type == EMBER_UNICAST_BINDING && binding.local == 1 &&
346-
(!binding.clusterId.HasValue() || binding.clusterId.Value() == Clusters::OnOff::Id))
347-
{
348-
auto onSuccess = [](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) {
349-
ChipLogProgress(NotSpecified, "OnOff command succeeds");
350-
};
351-
auto onFailure = [](CHIP_ERROR ret) {
352-
ChipLogError(NotSpecified, "OnOff command failed: %" CHIP_ERROR_FORMAT, ret.Format());
353-
};
354-
355-
VerifyOrDie(peer_device != nullptr && peer_device->ConnectionReady());
356-
if (sSwitchOnOffState)
357-
{
358-
Clusters::OnOff::Commands::On::Type onCommand;
359-
Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(),
360-
binding.remote, onCommand, onSuccess, onFailure);
361-
}
362-
else
363-
{
364-
Clusters::OnOff::Commands::Off::Type offCommand;
365-
Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(),
366-
binding.remote, offCommand, onSuccess, onFailure);
367-
}
368-
}
369-
}
370-
*/
371-
372-
/*
373-
static void ChefBoundDeviceContextReleaseHandler(void * context)
374-
{
375-
(void) context;
376-
}
377-
*/
378330
void ChefBindingHandler::Init(chip::EndpointId endpoint)
379331
{
380332
DeviceLayer::PlatformMgr().ScheduleWork(InitInternal, endpoint);
381333
}
382334

335+
#if CONFIG_ENABLE_PW_RPC == 1
383336
#include "Rpc.h"
384337

385338
void ChefBindingCommandHandler(intptr_t ctx, chip::rpc::BindingCommandRequest * command)
@@ -395,26 +348,19 @@ printf("\033[41 %s, %d, endpoint=%d, clusterId=%d, commandId=%d \033[0m \n", __f
395348
data->IsGroup = ChefBindingHandler::GetInstance().IsGroupBound();
396349

397350
ChefBindingHandler::SwitchWorkerHandler(reinterpret_cast<intptr_t>(data));
398-
// DeviceLayer::PlatformMgr().ScheduleWork(ChefBindingHandler::SwitchWorkerHandler, reinterpret_cast<intptr_t>(data));
399351
// TODO: Platform::Delete(data);
400352
}
401353
}
402-
403-
#include "Rpc.h"
354+
#endif // CONFIG_ENABLE_PW_RPC
404355

405356
void emberAfBindingClusterInitCallback(EndpointId endpoint)
406357
{
407-
intptr_t ctx = 1;
408358
printf("\033[41m %s, %d \033[0m \n", __func__, __LINE__);
409359

410360
ChefBindingHandler::GetInstance().Init(endpoint);
361+
#if CONFIG_ENABLE_PW_RPC == 1
362+
intptr_t ctx = 1;
411363
chip::rpc::RpcRegisterAppBindingCommandHander(ChefBindingCommandHandler, ctx);
412-
/*
413-
auto & server = chip::Server::GetInstance();
414-
chip::BindingManager::GetInstance().Init(
415-
{ &server.GetFabricTable(), server.GetCASESessionManager(), &server.GetPersistentStorage() });
416-
chip::BindingManager::GetInstance().RegisterBoundDeviceChangedHandler(ChefBoundDeviceChangedHandler);
417-
chip::BindingManager::GetInstance().RegisterBoundDeviceContextReleaseHandler(ChefBoundDeviceContextReleaseHandler);
418-
*/
364+
#endif // CONFIG_ENABLE_PW_RPC
419365
}
420366

examples/chef/common/stubs.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,6 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI
6161
return EMBER_ZCL_STATUS_SUCCESS;
6262
}
6363

64-
/*
65-
*
66-
Thread 3 "rootnode_airqua" hit Breakpoint 1, emberAfExternalAttributeWriteCallback (endpoint=1, clusterId=91,
67-
attributeMetadata=0x555555791f30 <(anonymous namespace)::generatedAttributes+1904>, buffer=0x7ffff68464ac "\001")
68-
at /home/erwinpan/matter/erwinpan1/master_1124_airqualitysensor/examples/chef/common/stubs.cpp:22
69-
(gdb) p *attributeMetadata
70-
$1 = {defaultValue = {ptrToDefaultValue = 0x0, defaultValue = 0, ptrToMinMaxValue = 0x0}, attributeId = 0, size = 1, attributeType =
71-
48 '0', mask = 16 '\020'} (gdb)
72-
*/
73-
7464
EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
7565
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
7666
{

examples/common/pigweed/rpc_services/Device.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ class Device : public pw_rpc::nanopb::Device::Service<Device>
480480
return pw::OkStatus();
481481
}
482482

483-
using BindingCommandHandler = void (*)(uint32_t endpoint, uint32_t clusterId, uint32_t commandId, uint32_t value);
483+
using BindingCommandHandler = void (*)(uint16_t endpoint, uint32_t clusterId, uint32_t commandId, uint32_t value);
484484

485485
void RegisterBindingCommandHandler(BindingCommandHandler handler) { mBindingCommandHandler = handler; }
486486

examples/platform/linux/Rpc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ printf("\033[41m %s , %d, endpoint=%d, clusterId=%d, commandId=%d \033[0m \n", _
8787
delete data;
8888
}
8989

90-
void RpcBindingCommandHandler(uint32_t endpoint, uint32_t clusterId, uint32_t commandId, uint32_t value)
90+
void RpcBindingCommandHandler(uint16_t endpoint, uint32_t clusterId, uint32_t commandId, uint32_t value)
9191
{
9292
struct BindingCommandRequest * data = new BindingCommandRequest{endpoint, clusterId, commandId};
9393
printf("\033[41m %s , %d \033[0m \n", __func__, __LINE__);

examples/platform/linux/Rpc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace chip {
2222
namespace rpc {
2323

2424
struct BindingCommandRequest {
25-
uint32_t endpoint;
25+
uint16_t endpoint;
2626
uint32_t clusterId;
2727
uint32_t commandId;
2828
uint32_t value;

0 commit comments

Comments
 (0)