Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jadhavrohit924 committed Aug 8, 2024
1 parent efd2e07 commit 9e886cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace chip::DeviceLayer;
using chip::Protocols::InteractionModel::Status;

static std::unique_ptr<OccupancySensingAttrAccess>
gAttrAccess[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT + 1];
gAttrAccess[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT];

void emberAfOccupancySensingClusterInitCallback(EndpointId endpointId)
{
Expand Down
26 changes: 22 additions & 4 deletions src/app/clusters/mode-select-server/mode-select-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using BootReasonType = GeneralDiagnostics::BootReasonEnum;

static InteractionModel::Status verifyModeValue(const EndpointId endpointId, const uint8_t newMode);

ModeSelect::SupportedModesManager * sSupportedModesManager = nullptr;
static ModeSelect::SupportedModesManager * sSupportedModesManager = nullptr;

const SupportedModesManager * ModeSelect::getSupportedModesManager()
{
Expand Down Expand Up @@ -82,6 +82,12 @@ CHIP_ERROR ModeSelectAttrAccess::Read(const ConcreteReadAttributePath & aPath, A

if (ModeSelect::Attributes::SupportedModes::Id == aPath.mAttributeId)
{
if (gSupportedModeManager == nullptr)
{
ChipLogError(Zcl, "ModeSelect: SupportedModesManager is NULL");
aEncoder.EncodeEmptyList();
return CHIP_NO_ERROR;
}
const ModeSelect::SupportedModesManager::ModeOptionsProvider modeOptionsProvider =
gSupportedModeManager->getModeOptionsProvider(aPath.mEndpointId);
if (modeOptionsProvider.begin() == nullptr)
Expand Down Expand Up @@ -115,8 +121,14 @@ bool emberAfModeSelectClusterChangeToModeCallback(CommandHandler * commandHandle
uint8_t newMode = commandData.newMode;
// Check that the newMode matches one of the supported options
const ModeSelect::Structs::ModeOptionStruct::Type * modeOptionPtr;
Status checkSupportedModeStatus =
ModeSelect::getSupportedModesManager()->getModeOptionByMode(endpointId, newMode, &modeOptionPtr);
const ModeSelect::SupportedModesManager * gSupportedModeManager = ModeSelect::getSupportedModesManager();
if (gSupportedModeManager == nullptr)
{
ChipLogError(Zcl, "ModeSelect: SupportedModesManager is NULL");
commandHandler->AddStatus(commandPath, Status::Failure);
return true;
}
Status checkSupportedModeStatus = gSupportedModeManager->getModeOptionByMode(endpointId, newMode, &modeOptionPtr);
if (Status::Success != checkSupportedModeStatus)
{
ChipLogProgress(Zcl, "ModeSelect: Failed to find the option with mode %u", newMode);
Expand Down Expand Up @@ -276,5 +288,11 @@ static InteractionModel::Status verifyModeValue(const EndpointId endpointId, con
return InteractionModel::Status::Success;
}
const ModeSelect::Structs::ModeOptionStruct::Type * modeOptionPtr;
return ModeSelect::getSupportedModesManager()->getModeOptionByMode(endpointId, newMode, &modeOptionPtr);
const ModeSelect::SupportedModesManager * gSupportedModeManager = ModeSelect::getSupportedModesManager();
if (gSupportedModeManager == nullptr)
{
ChipLogError(Zcl, "ModeSelect: SupportedModesManager is NULL");
return Status::Failure;
}
return gSupportedModeManager->getModeOptionByMode(endpointId, newMode, &modeOptionPtr);
}

0 comments on commit 9e886cc

Please sign in to comment.