Skip to content

Commit

Permalink
Convert ApplicationBasicStatus to an enum class. (#12500)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Apr 7, 2022
1 parent fc8627f commit 9099989
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 41 deletions.
17 changes: 9 additions & 8 deletions examples/tv-app/android/include/application-basic/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@

#pragma once

#include <app-common/zap-generated/enums.h>
#include <app-common/zap-generated/cluster-objects.h>

struct Application
{
char vendorName[32] = "";
char name[32] = "";
char id[32] = "";
uint16_t vendorId = 0;
uint16_t productId = 0;
uint16_t catalogVendorId = 0;
EmberAfApplicationBasicStatus status = EMBER_ZCL_APPLICATION_BASIC_STATUS_STOPPED;
using ApplicationBasicStatus = chip::app::Clusters::ApplicationBasic::ApplicationBasicStatus;
char vendorName[32] = "";
char name[32] = "";
char id[32] = "";
uint16_t vendorId = 0;
uint16_t productId = 0;
uint16_t catalogVendorId = 0;
ApplicationBasicStatus status = ApplicationBasicStatus::kStopped;
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/command-id.h>
#include <app-common/zap-generated/enums.h>
#include <app/Command.h>
#include <app/util/af.h>
#include <app/util/basic-types.h>
#include <lib/support/TypeTraits.h>
#include <lib/support/ZclString.h>

#include <inipp/inipp.h>
Expand Down Expand Up @@ -153,9 +154,10 @@ Application ApplicationBasicManager::getApplicationForEndpoint(chip::EndpointId
return app;
}

bool applicationBasicClusterChangeApplicationStatus(EmberAfApplicationBasicStatus status, chip::EndpointId endpoint)
bool applicationBasicClusterChangeApplicationStatus(app::Clusters::ApplicationBasic::ApplicationBasicStatus status,
chip::EndpointId endpoint)
{
// TODO: Insert code here
ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", status, endpoint);
ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", to_underlying(status), endpoint);
return true;
}
18 changes: 10 additions & 8 deletions examples/tv-app/linux/include/application-basic/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@

#pragma once

#include <app-common/zap-generated/enums.h>
#include <app-common/zap-generated/cluster-objects.h>

struct Application
{
char vendorName[32] = "";
char name[32] = "";
char id[32] = "";
uint16_t vendorId = 0;
uint16_t productId = 0;
uint16_t catalogVendorId = 0;
EmberAfApplicationBasicStatus status = EMBER_ZCL_APPLICATION_BASIC_STATUS_STOPPED;
using ApplicationBasicStatus = chip::app::Clusters::ApplicationBasic::ApplicationBasicStatus;

char vendorName[32] = "";
char name[32] = "";
char id[32] = "";
uint16_t vendorId = 0;
uint16_t productId = 0;
uint16_t catalogVendorId = 0;
ApplicationBasicStatus status = ApplicationBasicStatus::kStopped;
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/command-id.h>
#include <app-common/zap-generated/enums.h>
#include <app/Command.h>
#include <app/util/af.h>
#include <app/util/basic-types.h>
#include <lib/support/TypeTraits.h>
#include <lib/support/ZclString.h>

#include <inipp/inipp.h>
Expand Down Expand Up @@ -153,9 +154,10 @@ Application ApplicationBasicManager::getApplicationForEndpoint(chip::EndpointId
return app;
}

bool applicationBasicClusterChangeApplicationStatus(EmberAfApplicationBasicStatus status, chip::EndpointId endpoint)
bool applicationBasicClusterChangeApplicationStatus(app::Clusters::ApplicationBasic::ApplicationBasicStatus status,
chip::EndpointId endpoint)
{
// TODO: Insert code here
ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", status, endpoint);
ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", to_underlying(status), endpoint);
return true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@
using namespace chip;
using namespace chip::app::Clusters::ApplicationBasic;

bool applicationBasicClusterChangeApplicationStatus(EmberAfApplicationBasicStatus status, EndpointId endpoint);
bool applicationBasicClusterChangeApplicationStatus(ApplicationBasicStatus status, EndpointId endpoint);

bool emberAfApplicationBasicClusterChangeStatusCallback(app::CommandHandler * commandObj,
const app::ConcreteCommandPath & commandPath,
const Commands::ChangeStatus::DecodableType & commandData)
{
auto & newApplicationStatus = commandData.status;

bool success = applicationBasicClusterChangeApplicationStatus(static_cast<EmberAfApplicationBasicStatus>(newApplicationStatus),
emberAfCurrentEndpoint());
bool success = applicationBasicClusterChangeApplicationStatus(newApplicationStatus, emberAfCurrentEndpoint());
EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE;
emberAfSendImmediateDefaultResponse(status);
return true;
Expand Down
1 change: 0 additions & 1 deletion src/app/zap-templates/templates/app/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ async function getResponseCommandName(responseRef, options)
function isWeaklyTypedEnum(label)
{
return [
"ApplicationBasicStatus",
"ApplicationLauncherStatus",
"AttributeWritePermission",
"AudioOutputType",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions zzz_generated/app-common/app-common/zap-generated/enums.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9099989

Please sign in to comment.