Skip to content

Commit

Permalink
Manual changes to remove emberAfSendImmediateDefaultResponse.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Feb 14, 2023
1 parent 1efc319 commit 01f9682
Show file tree
Hide file tree
Showing 28 changed files with 430 additions and 422 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class StaticSupportedModesManager : public chip::app::Clusters::ModeSelect::Supp

SupportedModesManager::ModeOptionsProvider getModeOptionsProvider(EndpointId endpointId) const override;

EmberAfStatus getModeOptionByMode(EndpointId endpointId, uint8_t mode, const ModeOptionStructType ** dataPtr) const override;
Protocols::InteractionModel::Status getModeOptionByMode(EndpointId endpointId, uint8_t mode,
const ModeOptionStructType ** dataPtr) const override;

~StaticSupportedModesManager(){};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using namespace std;
using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ModeSelect;
using chip::Protocols::InteractionModel::Status;

using ModeOptionStructType = Structs::ModeOptionStruct::Type;
using SemanticTag = Structs::SemanticTagStruct::Type;
Expand Down Expand Up @@ -51,13 +52,13 @@ SupportedModesManager::ModeOptionsProvider StaticSupportedModesManager::getModeO
return ModeOptionsProvider(nullptr, nullptr);
}

EmberAfStatus StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointId, unsigned char mode,
const ModeOptionStructType ** dataPtr) const
Status StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointId, unsigned char mode,
const ModeOptionStructType ** dataPtr) const
{
auto modeOptionsProvider = this->getModeOptionsProvider(endpointId);
if (modeOptionsProvider.begin() == nullptr)
{
return EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER;
return Status::UnsupportedCluster;
}
auto * begin = this->getModeOptionsProvider(endpointId).begin();
auto * end = this->getModeOptionsProvider(endpointId).end();
Expand All @@ -68,11 +69,11 @@ EmberAfStatus StaticSupportedModesManager::getModeOptionByMode(unsigned short en
if (modeOption.mode == mode)
{
*dataPtr = &modeOption;
return EMBER_ZCL_STATUS_SUCCESS;
return Status::Success;
}
}
emberAfPrintln(EMBER_AF_PRINT_DEBUG, "Cannot find the mode %u", mode);
return EMBER_ZCL_STATUS_INVALID_COMMAND;
return Status::InvalidCommand;
}

const ModeSelect::SupportedModesManager * ModeSelect::getSupportedModesManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class StaticSupportedModesManager : public chip::app::Clusters::ModeSelect::Supp

SupportedModesManager::ModeOptionsProvider getModeOptionsProvider(EndpointId endpointId) const override;

EmberAfStatus getModeOptionByMode(EndpointId endpointId, uint8_t mode, const ModeOptionStructType ** dataPtr) const override;
Protocols::InteractionModel::Status getModeOptionByMode(EndpointId endpointId, uint8_t mode,
const ModeOptionStructType ** dataPtr) const override;

~StaticSupportedModesManager(){};

Expand Down
11 changes: 6 additions & 5 deletions examples/placeholder/linux/static-supported-modes-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using namespace std;
using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ModeSelect;
using chip::Protocols::InteractionModel::Status;

using ModeOptionStructType = Structs::ModeOptionStruct::Type;
using SemanticTag = Structs::SemanticTagStruct::Type;
Expand Down Expand Up @@ -51,13 +52,13 @@ SupportedModesManager::ModeOptionsProvider StaticSupportedModesManager::getModeO
return ModeOptionsProvider(nullptr, nullptr);
}

EmberAfStatus StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointId, unsigned char mode,
const ModeOptionStructType ** dataPtr) const
Status StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointId, unsigned char mode,
const ModeOptionStructType ** dataPtr) const
{
auto modeOptionsProvider = this->getModeOptionsProvider(endpointId);
if (modeOptionsProvider.begin() == nullptr)
{
return EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER;
return Status::UnsupportedCluster;
}
auto * begin = this->getModeOptionsProvider(endpointId).begin();
auto * end = this->getModeOptionsProvider(endpointId).end();
Expand All @@ -68,11 +69,11 @@ EmberAfStatus StaticSupportedModesManager::getModeOptionByMode(unsigned short en
if (modeOption.mode == mode)
{
*dataPtr = &modeOption;
return EMBER_ZCL_STATUS_SUCCESS;
return Status::Success;
}
}
emberAfPrintln(EMBER_AF_PRINT_DEBUG, "Cannot find the mode %u", mode);
return EMBER_ZCL_STATUS_INVALID_COMMAND;
return Status::InvalidCommand;
}

const ModeSelect::SupportedModesManager * ModeSelect::getSupportedModesManager()
Expand Down
20 changes: 10 additions & 10 deletions src/app/clusters/account-login-server/account-login-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ bool emberAfAccountLoginClusterLoginCallback(app::CommandHandler * command, cons
{
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
Status status = Status::Success;
auto & tempAccountIdentifier = commandData.tempAccountIdentifier;
auto & setupPin = commandData.setupPIN;

Expand All @@ -146,42 +146,42 @@ bool emberAfAccountLoginClusterLoginCallback(app::CommandHandler * command, cons

if (!delegate->HandleLogin(tempAccountIdentifier, setupPin))
{
status = EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS;
status = Status::UnsupportedAccess;
}

exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "emberAfAccountLoginClusterLoginCallback error: %s", err.AsString());
status = EMBER_ZCL_STATUS_FAILURE;
status = Status::Failure;
}
emberAfSendImmediateDefaultResponse(status);
command->AddStatus(commandPath, status);
return true;
}

bool emberAfAccountLoginClusterLogoutCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
const Commands::Logout::DecodableType & commandData)
{
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
Status status = Status::Success;

Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);

if (!delegate->HandleLogout())
{
status = EMBER_ZCL_STATUS_FAILURE;
status = Status::Failure;
}

exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "emberAfAccountLoginClusterLogoutCallback error: %s", err.AsString());
status = EMBER_ZCL_STATUS_FAILURE;
status = Status::Failure;
}

emberAfSendImmediateDefaultResponse(status);
commandObj->AddStatus(commandPath, status);
return true;
}

Expand Down
15 changes: 8 additions & 7 deletions src/app/clusters/audio-output-server/audio-output-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

using namespace chip;
using namespace chip::app::Clusters::AudioOutput;
using chip::Protocols::InteractionModel::Status;

static constexpr size_t kAudioOutputDelegateTableSize =
EMBER_AF_AUDIO_OUTPUT_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT;
Expand Down Expand Up @@ -212,27 +213,27 @@ bool emberAfAudioOutputClusterRenameOutputCallback(app::CommandHandler * command
bool emberAfAudioOutputClusterSelectOutputCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath,
const Commands::SelectOutput::DecodableType & commandData)
{
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
auto & index = commandData.index;
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
Status status = Status::Success;
auto & index = commandData.index;

Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);

if (!delegate->HandleSelectOutput(index))
{
status = EMBER_ZCL_STATUS_FAILURE;
status = Status::Failure;
}

exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "emberAfAudioOutputClusterSelectOutputCallback error: %s", err.AsString());
status = EMBER_ZCL_STATUS_FAILURE;
status = Status::Failure;
}

emberAfSendImmediateDefaultResponse(status);
command->AddStatus(commandPath, status);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::BarrierControl;
using chip::Protocols::InteractionModel::Status;

typedef struct
{
Expand Down Expand Up @@ -258,9 +259,9 @@ void emberAfBarrierControlClusterServerTickCallback(EndpointId endpoint)
// -----------------------------------------------------------------------------
// Handling commands

static void sendDefaultResponse(EmberAfStatus status)
static void sendDefaultResponse(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, Status status)
{
if (emberAfSendImmediateDefaultResponse(status) != EMBER_SUCCESS)
if (commandObj->AddStatus(commandPath, status) != CHIP_NO_ERROR)
{
emberAfBarrierControlClusterPrintln("Failed to send default response");
}
Expand All @@ -272,21 +273,21 @@ bool emberAfBarrierControlClusterBarrierControlGoToPercentCallback(
{
auto & percentOpen = commandData.percentOpen;

EndpointId endpoint = commandPath.mEndpointId;
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
EndpointId endpoint = commandPath.mEndpointId;
Status status = Status::Success;

emberAfBarrierControlClusterPrintln("RX: GoToPercentCallback p=%d", percentOpen);

if (isRemoteLockoutOn(endpoint))
{
status = EMBER_ZCL_STATUS_FAILURE;
status = Status::Failure;
}
else if (percentOpen > 100 // "100" means "100%", so greater than that is invalid
|| (!emAfPluginBarrierControlServerIsPartialBarrierSupported(endpoint) &&
percentOpen != EMBER_ZCL_BARRIER_CONTROL_BARRIER_POSITION_CLOSED &&
percentOpen != EMBER_ZCL_BARRIER_CONTROL_BARRIER_POSITION_OPEN))
{
status = EMBER_ZCL_STATUS_CONSTRAINT_ERROR;
status = Status::ConstraintError;
}
else
{
Expand All @@ -307,7 +308,7 @@ bool emberAfBarrierControlClusterBarrierControlGoToPercentCallback(
}
}

sendDefaultResponse(status);
sendDefaultResponse(commandObj, commandPath, status);

return true;
}
Expand All @@ -319,7 +320,7 @@ bool emberAfBarrierControlClusterBarrierControlStopCallback(app::CommandHandler
EndpointId endpoint = commandPath.mEndpointId;
emberAfDeactivateServerTick(endpoint, BarrierControl::Id);
setMovingState(endpoint, EMBER_ZCL_BARRIER_CONTROL_MOVING_STATE_STOPPED);
sendDefaultResponse(EMBER_ZCL_STATUS_SUCCESS);
sendDefaultResponse(commandObj, commandPath, Status::Success);
return true;
}

Expand Down
30 changes: 15 additions & 15 deletions src/app/clusters/channel-server/channel-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,55 +233,55 @@ bool emberAfChannelClusterChangeChannelCallback(app::CommandHandler * command, c
bool emberAfChannelClusterChangeChannelByNumberCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath,
const Commands::ChangeChannelByNumber::DecodableType & commandData)
{
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
auto & majorNumber = commandData.majorNumber;
auto & minorNumber = commandData.minorNumber;
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
Status status = Status::Success;
auto & majorNumber = commandData.majorNumber;
auto & minorNumber = commandData.minorNumber;

Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);

if (!delegate->HandleChangeChannelByNumber(majorNumber, minorNumber))
{
status = EMBER_ZCL_STATUS_FAILURE;
status = Status::Failure;
}

exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "emberAfChannelClusterChangeChannelByNumberCallback error: %s", err.AsString());
status = EMBER_ZCL_STATUS_FAILURE;
status = Status::Failure;
}

emberAfSendImmediateDefaultResponse(status);
command->AddStatus(commandPath, status);
return true;
}

bool emberAfChannelClusterSkipChannelCallback(app::CommandHandler * command, const app::ConcreteCommandPath & commandPath,
const Commands::SkipChannel::DecodableType & commandData)
{
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
auto & count = commandData.count;
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;
Status status = Status::Success;
auto & count = commandData.count;

Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);

if (!delegate->HandleSkipChannel(count))
{
status = EMBER_ZCL_STATUS_FAILURE;
status = Status::Failure;
}

exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl, "emberAfChannelClusterSkipChannelCallback error: %s", err.AsString());
status = EMBER_ZCL_STATUS_FAILURE;
status = Status::Failure;
}

emberAfSendImmediateDefaultResponse(status);
command->AddStatus(commandPath, status);
return true;
}

Expand Down
Loading

0 comments on commit 01f9682

Please sign in to comment.