Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and erwinpan1 committed May 17, 2024
1 parent 80fd884 commit addca91
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 39 deletions.
55 changes: 27 additions & 28 deletions examples/chef/common/chef-rpc-actions-worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,35 +92,34 @@ void ChefRpcActionsWorker::ProcessActionQueue()
return;
}

ActionType type = static_cast<ActionType>(task.type);

switch (type)
{
case ActionType::WRITE_ATTRIBUTE: {
ChipLogProgress(NotSpecified, "Writing Attribute: endpointId=%d, clusterId=%04lx, attributeId=%04lx, args.size=%lu",
task.endpointId, static_cast<unsigned long>(task.clusterId), static_cast<unsigned long>(task.actionId),
static_cast<unsigned long>(task.args.size()));
delegate->AttributeWriteHandler(task.endpointId, static_cast<chip::AttributeId>(task.actionId), task.args);
}
break;
case ActionType::RUN_COMMAND: {
ChipLogProgress(NotSpecified, "Running Command: endpointId=%d, clusterId=%04lx, commandId=%04lx, args.size=%lu",
task.endpointId, static_cast<unsigned long>(task.clusterId), static_cast<unsigned long>(task.actionId),
static_cast<unsigned long>(task.args.size()));
delegate->CommandHandler(task.endpointId, static_cast<chip::CommandId>(task.actionId), task.args);
}
break;
case ActionType::EMIT_EVENT: {
ChipLogProgress(NotSpecified, "Emitting Event: endpointId=%d, clusterId=%04lx, eventIdId=%04lx, args.size=%lu",
task.endpointId, static_cast<unsigned long>(task.clusterId), static_cast<unsigned long>(task.actionId),
static_cast<unsigned long>(task.args.size()));
delegate->EventHandler(task.endpointId, static_cast<chip::EventId>(task.actionId), task.args);
}
break;
default:
break;
}
ActionType type = static_cast<ActionType>(task.type);

switch (type)
{
case ActionType::WRITE_ATTRIBUTE: {
ChipLogProgress(NotSpecified, "Writing Attribute: endpointId=%d, clusterId=%04lx, attributeId=%04lx, args.size=%lu",
task.endpointId, static_cast<unsigned long>(task.clusterId), static_cast<unsigned long>(task.actionId),
static_cast<unsigned long>(task.args.size()));
delegate->AttributeWriteHandler(task.endpointId, static_cast<chip::AttributeId>(task.actionId), task.args);
}
break;
case ActionType::RUN_COMMAND: {
ChipLogProgress(NotSpecified, "Running Command: endpointId=%d, clusterId=%04lx, commandId=%04lx, args.size=%lu",
task.endpointId, static_cast<unsigned long>(task.clusterId), static_cast<unsigned long>(task.actionId),
static_cast<unsigned long>(task.args.size()));
delegate->CommandHandler(task.endpointId, static_cast<chip::CommandId>(task.actionId), task.args);
}
break;
case ActionType::EMIT_EVENT: {
ChipLogProgress(NotSpecified, "Emitting Event: endpointId=%d, clusterId=%04lx, eventIdId=%04lx, args.size=%lu",
task.endpointId, static_cast<unsigned long>(task.clusterId), static_cast<unsigned long>(task.actionId),
static_cast<unsigned long>(task.args.size()));
delegate->EventHandler(task.endpointId, static_cast<chip::EventId>(task.actionId), task.args);
}
break;
default:
break;
}

if (queue.empty())
{
Expand Down
10 changes: 6 additions & 4 deletions examples/chef/common/chef-rpc-actions-worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class ActionsDelegate
virtual ~ActionsDelegate() = default;

virtual void AttributeWriteHandler(chip::EndpointId endpointId, chip::AttributeId attributeId, std::vector<uint32_t> args) = 0;
virtual void CommandHandler(chip::EndpointId endpointId, chip::CommandId commandId, std::vector<uint32_t> args) = 0;
virtual void EventHandler(chip::EndpointId endpointId, chip::EventId eventId, std::vector<uint32_t> args) = 0;
virtual void CommandHandler(chip::EndpointId endpointId, chip::CommandId commandId, std::vector<uint32_t> args) = 0;
virtual void EventHandler(chip::EndpointId endpointId, chip::EventId eventId, std::vector<uint32_t> args) = 0;

protected:
ClusterId mClusterId;
Expand All @@ -53,8 +53,10 @@ struct ActionTask
uint32_t delayMs;
uint32_t actionId;
std::vector<uint32_t> args;
ActionTask(chip::EndpointId endpoint, chip::ClusterId cluster, chip::rpc::ActionType actionType, uint32_t delay, uint32_t id, std::vector<uint32_t> arg) :
endpointId(endpoint), clusterId(cluster), type(actionType), delayMs(delay), actionId(id), args(arg){};
ActionTask(chip::EndpointId endpoint, chip::ClusterId cluster, chip::rpc::ActionType actionType, uint32_t delay, uint32_t id,
std::vector<uint32_t> arg) :
endpointId(endpoint),
clusterId(cluster), type(actionType), delayMs(delay), actionId(id), args(arg){};
~ActionTask(){};
};

Expand Down
4 changes: 2 additions & 2 deletions examples/chef/common/clusters/switch/SwitchManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SwitchActionsDelegate : public chip::app::ActionsDelegate
~SwitchActionsDelegate() override{};

void AttributeWriteHandler(chip::EndpointId endpointId, chip::AttributeId attributeId, std::vector<uint32_t> args) override;
void CommandHandler(chip::EndpointId endpointId, chip::AttributeId attributeId, std::vector<uint32_t> args) override {};
void CommandHandler(chip::EndpointId endpointId, chip::AttributeId attributeId, std::vector<uint32_t> args) override{};
void EventHandler(chip::EndpointId endpointId, chip::EventId eventId, std::vector<uint32_t> args) override;

private:
Expand Down Expand Up @@ -158,7 +158,7 @@ const Clusters::Descriptor::Structs::SemanticTagStruct::Type gLatchingSwitch[] =
{ chip::app::DataModel::MakeNullable(chip::CharSpan("High", 4)) }) }
};

static SwitchEventHandler * gSwitchEventHandler = new SwitchEventHandler();
static SwitchEventHandler * gSwitchEventHandler = new SwitchEventHandler();
static SwitchActionsDelegate * gSwitchActionsDelegate = new SwitchActionsDelegate(Clusters::Switch::Id, gSwitchEventHandler);

void emberAfSwitchClusterInitCallback(EndpointId endpointId)
Expand Down
15 changes: 10 additions & 5 deletions examples/common/pigweed/rpc_services/Actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,24 @@ class Actions final : public pw_rpc::nanopb::Actions::Service<Actions>
* In [1]: request=protos.chip.rpc.ActionsWrite(endpoint_id=1, cluster_id=int("0x003B", 16))
*
* # Add an action to write attribute id 0x1 (CurrentPosition) with data 2 after 1000 ms (meaning right away)
* In [2]: request.actions.append(protos.chip.rpc.Action(type=protos.chip.rpc.ActionType.WRITE_ATTRIBUTE, delayMs=1000, actionId=1, arg1=2))
* In [2]: request.actions.append(protos.chip.rpc.Action(type=protos.chip.rpc.ActionType.WRITE_ATTRIBUTE, delayMs=1000,
* actionId=1, arg1=2))
*
* # Define the follow action to emit an event id 0x1 (InitialPress) with data 2 (NewPosition) after 1000 ms
* In [3]: message.actions.append(protos.chip.rpc.Action(type=protos.chip.rpc.ActionType.EMIT_EVENT, delayMs=1000, actionId=1, arg1=2))
* In [3]: message.actions.append(protos.chip.rpc.Action(type=protos.chip.rpc.ActionType.EMIT_EVENT, delayMs=1000,
* actionId=1, arg1=2))
*
* # Define the follow action to emit an event id 0x2 (LongPress) with data 2 (NewPosition) after 2000 ms
* In [4]: message.actions.append(protos.chip.rpc.Action(type=protos.chip.rpc.ActionType.EMIT_EVENT, delayMs=2000, actionId=2, arg1=2))
* In [4]: message.actions.append(protos.chip.rpc.Action(type=protos.chip.rpc.ActionType.EMIT_EVENT, delayMs=2000,
* actionId=2, arg1=2))
*
* # Define an action to write attribute id 0x1 (CurrentPosition) with data 0 after 2000 ms (meaning button bouncing back)
* In [5]: message.actions.append(protos.chip.rpc.Action(type=protos.chip.rpc.ActionType.WRITE_ATTRIBUTE, delayMs=2000, actionId=1, arg1=0))
* In [5]: message.actions.append(protos.chip.rpc.Action(type=protos.chip.rpc.ActionType.WRITE_ATTRIBUTE, delayMs=2000,
* actionId=1, arg1=0))
*
* # Define the follow action to emit an event id 0x4 (LongRelease) with data 2 (PreviousPosition) after 1000 ms
* In [6]: message.actions.append(protos.chip.rpc.Action(type=protos.chip.rpc.ActionType.EMIT_EVENT, delayMs=1000, actionId=4, arg1=2))
* In [6]: message.actions.append(protos.chip.rpc.Action(type=protos.chip.rpc.ActionType.EMIT_EVENT, delayMs=1000,
* actionId=4, arg1=2))
*
* # Set the actions to device
* In [7]: rpcs.chip.rpc.Actions.Set(message, pw_rpc_timeout_s=10000)
Expand Down

0 comments on commit addca91

Please sign in to comment.